GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
AngularCorrelationHelper.hh
Go to the documentation of this file.
1#ifndef AngularCorrelationHelper_h
2#define AngularCorrelationHelper_h
3
4#include "TGriffin.h"
5#include "TGriffinBgo.h"
6#include "TGriffinAngles.h"
7#include "TGRSIHelper.h"
8
9class AngularCorrelationHelper : public TGRSIHelper, public ROOT::Detail::RDF::RActionImpl<AngularCorrelationHelper> {
10private:
12 double fGriffinDistance{145.};
13 bool fFolding{false};
14 bool fGrouping{false};
15 bool fAddback{true};
16 bool fSingleCrystal{false};
17 std::vector<int> fExcludedDetectors;
18 std::vector<int> fExcludedCrystals;
19
20 double fPrompt{200.}; // Maximum absolute time difference for prompt gamma-gamma
21 double fTimeRandomLow{400.}; // Minimum time difference for gamma-gamma time random background
22 double fTimeRandomHigh{600.}; // Maximum time difference for gamma-gamma time random background
23
24 Long64_t fCycleLength{0};
25 double fCycleTimeLow{-1.}; // Minimum time in the cycle in s (if both are -1 we ignore it)
26 double fCycleTimeHigh{-1.}; // Maximum time in the cycle in s (if both are -1 we ignore it)
27
28 int fBins{3000};
29 double fMinEnergy{0.};
30 double fMaxEnergy{3000.};
31
33
34 std::map<unsigned int, std::deque<TGriffin*>> fGriffinDeque;
35 std::map<unsigned int, std::deque<TGriffinBgo*>> fBgoDeque;
36
37 bool ExcludeDetector(int detector)
38 {
39 return std::binary_search(fExcludedDetectors.begin(), fExcludedDetectors.end(), detector);
40 }
41 bool ExcludeCrystal(int arraynumber)
42 {
43 return std::binary_search(fExcludedCrystals.begin(), fExcludedCrystals.end(), arraynumber);
44 }
45
46 bool GoodCycleTime(double timeInCycle)
47 {
48 // check if the timeInCycle (in microseconds!) falls within the limits
49 // this could be done much smarter, but this might be easier to read
50 // if no limits are set we always are within the limits
51 if(fCycleTimeLow == -1. && fCycleTimeHigh == -1.) {
52 return true;
53 }
54 if(fCycleTimeLow == -1. && timeInCycle / 1e6 < fCycleTimeHigh) {
55 return true;
56 }
57 if(fCycleTimeLow < timeInCycle / 1e6 && fCycleTimeHigh == -1.) {
58 return true;
59 }
60 if(fCycleTimeLow < timeInCycle / 1e6 && timeInCycle / 1e6 < fCycleTimeHigh) {
61 return true;
62 }
63 return false;
64 }
65
66public:
67 explicit AngularCorrelationHelper(TList* list)
68 : TGRSIHelper(list)
69 {
70 Prefix("AngularCorrelation");
71
72 if(fUserSettings != nullptr) {
73 fNofMixedEvents = fUserSettings->GetInt("NumberOfMixedEvents", 10);
74 fGriffinDistance = fUserSettings->GetDouble("GriffinDistance", 145.);
75 fAddback = fUserSettings->GetBool("Addback", true);
76 fSingleCrystal = fUserSettings->GetBool("SingleCrystal", true);
77 fFolding = fUserSettings->GetBool("Folding", false);
78 fGrouping = fUserSettings->GetBool("Grouping", false);
79
80 try {
81 fExcludedDetectors = fUserSettings->GetIntVector("ExcludedDetector", true); // be quiet if we don't find this
82 } catch(std::out_of_range&) {
83 // do nothing, we simply don't have any detectors to exclude
84 }
85 try {
86 fExcludedCrystals = fUserSettings->GetIntVector("ExcludedCrystal", true); // be quiet if we don't find this
87 } catch(std::out_of_range&) {
88 // do nothing, we simply don't have any crystals to exclude
89 }
90
91 fPrompt = fUserSettings->GetDouble("MaxPromptTime", 200.);
92 fTimeRandomLow = fUserSettings->GetDouble("TimeRandom.Low", 400.);
93 fTimeRandomHigh = fUserSettings->GetDouble("TimeRandom.High", 600.);
94
95 fCycleTimeLow = fUserSettings->GetDouble("CycleTime.Low", -1.);
96 fCycleTimeHigh = fUserSettings->GetDouble("CycleTime.High", -1.);
97
98 fBins = fUserSettings->GetInt("NumberOfBins", 3000);
99 fMinEnergy = fUserSettings->GetDouble("MinimumEnergy", 0.);
100 fMaxEnergy = fUserSettings->GetDouble("MaximumEnergy", 3000.);
101 } else {
102 std::cout << "No user settings provided, using default settings: ";
103 }
104 if(fSingleCrystal && !fAddback) {
105 std::cerr << "Error, can't use single crystal method if not using addback! Setting addback to true!" << std::endl;
106 fAddback = true;
107 }
108 std::cout << std::boolalpha << "# of mixed events " << fNofMixedEvents << ", distance " << fGriffinDistance << " mm, single crystal " << fSingleCrystal << ", addback " << fAddback << ", folding " << fFolding << ", and grouping " << fGrouping << std::endl;
109
111 fAngles->Print();
112
113 // Setup calls CreateHistograms, which uses the stored angle combinations, so we need those set before
114 Setup();
115 }
116
117 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
118 {
119 return d->Book<TGriffin, TGriffinBgo>(std::move(*this), {"TGriffin", "TGriffinBgo"});
120 }
121
122 void CreateHistograms(unsigned int slot) override;
123 void Exec(unsigned int slot, TGriffin& fGriffin, TGriffinBgo& fGriffinBgo);
124};
125
126#endif
127
128extern "C" AngularCorrelationHelper* CreateHelper(TList* list) { return new AngularCorrelationHelper(list); }
129
130extern "C" void DestroyHelper(TGRSIHelper* helper) { delete helper; }
void DestroyHelper(TGRSIHelper *helper)
AngularCorrelationHelper * CreateHelper(TList *list)
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 GoodCycleTime(double timeInCycle)
bool ExcludeCrystal(int arraynumber)
std::map< unsigned int, std::deque< TGriffin * > > fGriffinDeque
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::map< unsigned int, std::deque< TGriffinBgo * > > fBgoDeque
TUserSettings * fUserSettings
Definition TGRSIHelper.h:58
std::string & Prefix()
Definition TGRSIHelper.h:40
virtual void Setup()
void Print(Option_t *="") const override
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