GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
ComptonPolarimetryHelper.hh
Go to the documentation of this file.
1#ifndef ComptonPolarimetryHelper_h
2#define ComptonPolarimetryHelper_h
3
4#include "TGriffin.h"
5#include "TGriffinBgo.h"
6#include "TGRSIHelper.h"
7
8class ComptonPolarimetryHelper : public TGRSIHelper, public ROOT::Detail::RDF::RActionImpl<ComptonPolarimetryHelper> {
9private:
10 double fGriffinDistance{145.};
11 std::vector<int> fExcludedDetectors;
12 std::vector<int> fExcludedCrystals;
13
14 bool fUseTimestamps{false}; // Whether to use timestamps of CFD corrected time for prompt gate
15 double fPrompt{200.}; // Maximum absolute time difference for prompt gamma-gamma
16
17 int fBins{3000};
18 double fMinEnergy{0.};
19 double fMaxEnergy{3000.};
20 int fXiBins{180};
21 int fThetaBins{180};
22
23 // not using vectors here because we need to ensure anyway that there are exactly two gates
24 std::array<double, 2> fGammaGateLow = {1170., 1329.};
25 std::array<double, 2> fGammaGateHigh = {1176., 1335.};
26
27 std::map<unsigned int, std::deque<TGriffin*>> fGriffinDeque;
28
29 bool ExcludeDetector(int detector) const
30 {
31 return std::binary_search(fExcludedDetectors.begin(), fExcludedDetectors.end(), detector);
32 }
33 bool ExcludeCrystal(int arraynumber) const
34 {
35 return std::binary_search(fExcludedCrystals.begin(), fExcludedCrystals.end(), arraynumber);
36 }
37
38 double TimeDiff(TGriffinHit* grif1, TGriffinHit* grif2) const
39 {
40 if(fUseTimestamps) {
41 return TMath::Abs(static_cast<double>(grif1->GetTimeStampNs() - grif2->GetTimeStampNs()));
42 }
43 return TMath::Abs(grif1->GetTime() - grif2->GetTime());
44 }
45
46 bool Coincident(TGriffinHit* grif1, TGriffinHit* grif2) const
47 {
48 if(fUseTimestamps) {
49 return TMath::Abs(static_cast<double>(grif1->GetTimeStampNs() - grif2->GetTimeStampNs())) < fPrompt;
50 }
51 return TMath::Abs(grif1->GetTime() - grif2->GetTime()) < fPrompt;
52 }
53
54 int CheckEnergy(double energy, int index = -1) const
55 {
56 // if index is -1 return index of gamma gate this energy falls into or return -1
57 if(index < 0 || index > 1) {
58 for(index = 0; index < 2; ++index) {
59 if(fGammaGateLow[index] < energy && energy < fGammaGateHigh[index]) { return index; }
60 }
61 // we only reach here if the energy doesn't fall in either gate
62 return -1;
63 }
64 // else check if energy falls in gamma gate indicated by the index (or return -1)
65 if(fGammaGateLow[index] < energy && energy < fGammaGateHigh[index]) { return index; }
66 return -1;
67 }
68
69public:
70 explicit ComptonPolarimetryHelper(TList* list)
71 : TGRSIHelper(list)
72 {
73 Prefix("ComptonPolarimetry");
74
75 if(fUserSettings != nullptr) {
76 fGriffinDistance = fUserSettings->GetDouble("GriffinDistance", 145.);
77 fExcludedDetectors = fUserSettings->GetIntVector("ExcludedDetector", true); // be quiet if we don't find this
78 fExcludedCrystals = fUserSettings->GetIntVector("ExcludedCrystal", true); // be quiet if we don't find this
79
80 fUseTimestamps = fUserSettings->GetBool("UseTimestamps", false);
81 fPrompt = fUserSettings->GetDouble("MaxPromptTime", 200.);
82
83 fBins = fUserSettings->GetInt("NumberOfBins", 3000);
84 fMinEnergy = fUserSettings->GetDouble("MinimumEnergy", 0.);
85 fMaxEnergy = fUserSettings->GetDouble("MaximumEnergy", 3000.);
86 fXiBins = fUserSettings->GetInt("NumberOfXiBins", 181);
87 fThetaBins = fUserSettings->GetInt("NumberOfThetaBins", 181);
88 fGammaGateLow[0] = fUserSettings->GetDouble("GammaGate.0.Low", 1170.);
89 fGammaGateHigh[0] = fUserSettings->GetDouble("GammaGate.0.High", 1176.);
90 fGammaGateLow[1] = fUserSettings->GetDouble("GammaGate.1.Low", 1329.);
91 fGammaGateHigh[1] = fUserSettings->GetDouble("GammaGate.1.High", 1335.);
92 } else {
93 std::cout << "No user settings provided, using default settings: ";
94 }
95 std::cout << std::boolalpha << "distance " << fGriffinDistance << " mm, using " << (fUseTimestamps ? "timestamps" : "CFD corrected time") << ", gamma gate " << fGammaGateLow[0] << " - " << fGammaGateHigh[0] << " and " << fGammaGateLow[1] << " - " << fGammaGateHigh[1] << std::endl;
96
97 // Setup calls CreateHistograms, which uses the stored angle combinations, so we need those set before
98 Setup();
99 }
100
101 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
102 {
103 return d->Book<TGriffin, TGriffinBgo>(std::move(*this), {"TGriffin", "TGriffinBgo"});
104 }
105
106 void CreateHistograms(unsigned int slot) override;
107 void Exec(unsigned int slot, TGriffin& fGriffin, TGriffinBgo& fGriffinBgo);
108};
109
110#endif
111
112extern "C" ComptonPolarimetryHelper* CreateHelper(TList* list) { return new ComptonPolarimetryHelper(list); }
113
114extern "C" void DestroyHelper(TGRSIHelper* helper) { delete helper; }
void DestroyHelper(TGRSIHelper *helper)
ComptonPolarimetryHelper * CreateHelper(TList *list)
ROOT::RDF::RResultPtr< std::map< std::string, TList > > Book(ROOT::RDataFrame *d) override
This method will call the Book action on the provided dataframe.
std::array< double, 2 > fGammaGateLow
double TimeDiff(TGriffinHit *grif1, TGriffinHit *grif2) const
bool Coincident(TGriffinHit *grif1, TGriffinHit *grif2) const
std::array< double, 2 > fGammaGateHigh
void Exec(unsigned int slot, TGriffin &fGriffin, TGriffinBgo &fGriffinBgo)
void CreateHistograms(unsigned int slot) override
Virtual helper function that the user uses to create their histograms.
bool ExcludeCrystal(int arraynumber) const
bool ExcludeDetector(int detector) const
std::map< unsigned int, std::deque< TGriffin * > > fGriffinDeque
int CheckEnergy(double energy, int index=-1) const
virtual Long64_t GetTimeStampNs(Option_t *opt="") const
virtual Double_t GetTime(const ETimeFlag &correct_flag=ETimeFlag::kAll, Option_t *opt="") const
Returns a time value to the nearest nanosecond!
TUserSettings * fUserSettings
Definition TGRSIHelper.h:54
std::string & Prefix()
Definition TGRSIHelper.h:36
virtual void Setup()
bool GetBool(const std::string &parameter, bool quiet=false) const
std::vector< int > GetIntVector(const std::string &parameter, bool quiet=false) const
int GetInt(const std::string &parameter, bool quiet=false) const
double GetDouble(const std::string &parameter, bool quiet=false) const