GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
EfficiencyHelper.hh
Go to the documentation of this file.
1#ifndef EFFICIENCYHELPER_HH
2#define EFFICIENCYHELPER_HH
3
4#include "TGRSIHelper.h"
5
6#include "TGriffin.h"
7#include "TGriffinBgo.h"
8
9// This is a custom action which respects a well defined interface. It supports parallelism,
10// in the sense that it behaves correctly if implicit multi threading is enabled.
11// Note the plural: in presence of a MT execution, internally more than a single TList is created.
12// The detector types in the specifcation of Book must match those in the call to it as well as those in the Exec function (and be in the same order)!
13
14class EfficiencyHelper : public TGRSIHelper, public ROOT::Detail::RDF::RActionImpl<EfficiencyHelper> {
15public:
16 // constructor sets the prefix (which is used for the output file as well)
17 // and calls Setup which in turn also calls CreateHistograms
18 explicit EfficiencyHelper(TList* list)
19 : TGRSIHelper(list)
20 {
21 if(fUserSettings != nullptr) {
23 try {
24 fPileUpRejection = fUserSettings->GetBool("PileUpRejection", true);
25 } catch(std::exception&) {}
27 fGgLow = fUserSettings->GetDouble("Timing.GriffinGriffin.Coincident.Low", fGgLow);
28 fGgHigh = fUserSettings->GetDouble("Timing.GriffinGriffin.Coincident.High", fGgHigh);
29 fMaxCfd = fUserSettings->GetDouble("MaximumCfd", fMaxCfd);
30 fEnergyBins1D = fUserSettings->GetInt("Energy.Bins.1D", fEnergyBins1D);
31 fEnergyBins2D = fUserSettings->GetInt("Energy.Bins.2D", fEnergyBins2D);
34 }
35 Prefix("EfficiencyHelper");
36 Setup();
37 }
38
39 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
40 {
41 return d->Book<TGriffin, TGriffinBgo>(std::move(*this), {"TGriffin", "TGriffinBgo"});
42 }
43 // this function creates and books all histograms
44 void CreateHistograms(unsigned int slot) override;
45 // this function gets called for every single event and fills the histograms
46 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo);
47 // this function is optional and is called after the output lists off all slots/workers have been merged
48 void EndOfSort(std::shared_ptr<std::map<std::string, TList>>& list) override {}
49
50private:
51 // any constants that are set in the CreateHistograms function and used in the Exec function can be stored here
52 // or any other settings
53 // some variables to easily change range and binning for multiple histograms at once
54 int fEnergyBins1D{10000};
55 int fEnergyBins2D{2000};
56 double fLowEnergy{0.};
57 double fHighEnergy{2000.};
58
59 // Pile-up Rejection - default k-values for not piled-up hits
61 bool fPileUpRejection{true}; // If true, pile-up is rejected
62 double fMinimumGriffinEnergy{0.}; // reject hits below this energy
63
64 // Coincidences Gates
65 double fGgLow{-250.};
66 double fGgHigh{250.};
67 double fMaxCfd{20.};
68
69 // ========== functions for timing conditions ==========
70 // Griffin-Griffin
72 {
73 return fGgLow < h1->GetTime() - h2->GetTime() && h1->GetTime() - h2->GetTime() < fGgHigh;
74 }
75
76 // general check for good CFD
78 {
79 return h1->GetTime() - h1->GetTimeStampNs() < fMaxCfd;
80 }
81
82 // ========== functions for pileup rejection, and minimum energy ==========
84 {
86 }
87};
88
89// These are needed functions used by TDataFrameLibrary to create and destroy the instance of this helper
90extern "C" EfficiencyHelper* CreateHelper(TList* list) { return new EfficiencyHelper(list); }
91
92extern "C" void DestroyHelper(TGRSIHelper* helper) { delete helper; }
93
94#endif
void DestroyHelper(TGRSIHelper *helper)
EfficiencyHelper * CreateHelper(TList *list)
bool GoodCfd(TDetectorHit *h1)
void EndOfSort(std::shared_ptr< std::map< std::string, TList > > &list) override
This method gets called at the end of Finalize()
ROOT::RDF::RResultPtr< std::map< std::string, TList > > Book(ROOT::RDataFrame *d) override
This method will call the Book action on the provided dataframe.
void CreateHistograms(unsigned int slot) override
Virtual helper function that the user uses to create their histograms.
EfficiencyHelper(TList *list)
bool PromptCoincidence(TGriffinHit *h1, TGriffinHit *h2)
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo)
bool Reject(TGriffinHit *hit)
virtual Long64_t GetTimeStampNs(Option_t *opt="") const
virtual double GetEnergy(Option_t *opt="") const
virtual Short_t GetKValue() 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
int GetInt(const std::string &parameter, bool quiet=false) const
double GetDouble(const std::string &parameter, bool quiet=false) const