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