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) const
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 try {
76 fAddback = fUserSettings->GetBool("Addback", true);
77 fSingleCrystal = fUserSettings->GetBool("SingleCrystal", true);
78 fFolding = fUserSettings->GetBool("Folding", true);
79 fGrouping = fUserSettings->GetBool("Grouping", true);
80 } catch(std::exception&) {}
81
82 try {
83 fExcludedDetectors = fUserSettings->GetIntVector("ExcludedDetector", true); // be quiet if we don't find this
84 } catch(std::out_of_range&) {
85 // do nothing, we simply don't have any detectors to exclude
86 }
87 try {
88 fExcludedCrystals = fUserSettings->GetIntVector("ExcludedCrystal", true); // be quiet if we don't find this
89 } catch(std::out_of_range&) {
90 // do nothing, we simply don't have any crystals to exclude
91 }
92
93 fPrompt = fUserSettings->GetDouble("MaxPromptTime", 200.);
94 fTimeRandomLow = fUserSettings->GetDouble("TimeRandom.Low", 400.);
95 fTimeRandomHigh = fUserSettings->GetDouble("TimeRandom.High", 600.);
96
97 fCycleTimeLow = fUserSettings->GetDouble("CycleTime.Low", -1.);
98 fCycleTimeHigh = fUserSettings->GetDouble("CycleTime.High", -1.);
99
100 fBins = fUserSettings->GetInt("NumberOfBins", 3000);
101 fMinEnergy = fUserSettings->GetDouble("MinimumEnergy", 0.);
102 fMaxEnergy = fUserSettings->GetDouble("MaximumEnergy", 3000.);
103 } else {
104 std::cout << "No user settings provided, using default settings: ";
105 }
106 if(fSingleCrystal && !fAddback) {
107 std::cerr << "Error, can't use single crystal method if not using addback! Setting addback to true!" << std::endl;
108 fAddback = true;
109 }
110 std::cout << std::boolalpha << "# of mixed events " << fNofMixedEvents << ", distance " << fGriffinDistance << " mm, single crystal " << fSingleCrystal << ", addback " << fAddback << ", folding " << fFolding << ", and grouping " << fGrouping << std::endl;
111
113 fAngles->Print();
114
115 // Setup calls CreateHistograms, which uses the stored angle combinations, so we need those set before
116 Setup();
117 }
118
119 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
120 {
121 return d->Book<TGriffin, TGriffinBgo>(std::move(*this), {"TGriffin", "TGriffinBgo"});
122 }
123
124 void CreateHistograms(unsigned int slot) override;
125 void Exec(unsigned int slot, TGriffin& fGriffin, TGriffinBgo& fGriffinBgo);
126};
127
128#endif
129
130extern "C" AngularCorrelationHelper* CreateHelper(TList* list) { return new AngularCorrelationHelper(list); }
131
132extern "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) const
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:54
std::string & Prefix()
Definition TGRSIHelper.h:36
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