GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
DirectoryHelper.hh
Go to the documentation of this file.
1#ifndef TESTHELPER_HH
2#define TESTHELPER_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 DirectoryHelper : public TGRSIHelper, public ROOT::Detail::RDF::RActionImpl<DirectoryHelper> {
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 DirectoryHelper(TList* list)
19 : TGRSIHelper(list)
20 {
21 if(fUserSettings != nullptr) {
22 fEnergyBins = fUserSettings->GetInt("LaBr3.Threshold", fEnergyBins);
23 fEnergyLow = fUserSettings->GetDouble("LaBr3.Threshold", fEnergyLow);
24 fEnergyHigh = fUserSettings->GetDouble("LaBr3.Threshold", fEnergyHigh);
25 }
26 Prefix("DirectoryHelper");
27 Setup();
28 }
29
30 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
31 {
32 return d->Book<TGriffin, TGriffinBgo>(std::move(*this), {"TGriffin", "TGriffinBgo"});
33 }
34 // this function creates and books all histograms
35 void CreateHistograms(unsigned int slot) override;
36 // this function gets called for every single event and fills the histograms
37 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo);
38 // this function is optional and is called after the output lists off all slots/workers have been merged
39 void EndOfSort(std::shared_ptr<std::map<std::string, TList>>& list) override;
40
41private:
42 // any constants that are set in the CreateHistograms function and used in the Exec function can be stored here
43 // or any other settings
44 std::map<uint16_t, std::vector<int64_t>> fLastTS;
45 std::map<uint16_t, std::vector<int64_t>> fLastSuppressedTS;
46 std::map<uint16_t, std::vector<double>> fLastTime;
47 std::map<uint16_t, std::vector<double>> fLastSuppressedTime;
48 std::map<uint16_t, std::vector<int64_t>> fLastTSNoPileup;
49 std::map<uint16_t, std::vector<int64_t>> fLastSuppressedTSNoPileup;
50 std::map<uint16_t, std::vector<double>> fLastTimeNoPileup;
51 std::map<uint16_t, std::vector<double>> fLastSuppressedTimeNoPileup;
52
53 // some variables to easily change range and binning for multiple histograms at once
54 int fEnergyBins = 10000;
55 double fEnergyLow = 0.;
56 double fEnergyHigh = 2000.;
57};
58
59// These are needed functions used by TDataFrameLibrary to create and destroy the instance of this helper
60extern "C" DirectoryHelper* CreateHelper(TList* list) { return new DirectoryHelper(list); }
61
62extern "C" void DestroyHelper(TGRSIHelper* helper) { delete helper; }
63
64#endif
void DestroyHelper(TGRSIHelper *helper)
DirectoryHelper * CreateHelper(TList *list)
std::map< uint16_t, std::vector< double > > fLastSuppressedTime
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo)
std::map< uint16_t, std::vector< int64_t > > fLastTS
std::map< uint16_t, std::vector< int64_t > > fLastSuppressedTS
void EndOfSort(std::shared_ptr< std::map< std::string, TList > > &list) override
This method gets called at the end of Finalize()
std::map< uint16_t, std::vector< double > > fLastSuppressedTimeNoPileup
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< uint16_t, std::vector< int64_t > > fLastTSNoPileup
std::map< uint16_t, std::vector< int64_t > > fLastSuppressedTSNoPileup
void CreateHistograms(unsigned int slot) override
Virtual helper function that the user uses to create their histograms.
DirectoryHelper(TList *list)
std::map< uint16_t, std::vector< double > > fLastTimeNoPileup
std::map< uint16_t, std::vector< double > > fLastTime
TUserSettings * fUserSettings
Definition TGRSIHelper.h:54
std::string & Prefix()
Definition TGRSIHelper.h:36
virtual void Setup()
int GetInt(const std::string &parameter, bool quiet=false) const
double GetDouble(const std::string &parameter, bool quiet=false) const