GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TGRSIHelper.h
Go to the documentation of this file.
1#ifndef TGRSIHELPER_H
2#define TGRSIHELPER_H
3#include "RVersion.h"
4#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 14, 0)
5#include "ROOT/RDataFrame.hxx"
6#include "TObject.h"
7#include "TList.h"
8#include "TH1.h"
9#include "TH2.h"
10#include "TH3.h"
11#include "TTree.h"
12#include "TCutG.h"
13#include "TBufferFile.h"
14
15#include "TGRSIOptions.h"
16#include "TAnalysisOptions.h"
17#include "GHSym.h"
18#include "GCube.h"
19#include "GValue.h"
20#include "TPPG.h"
21#include "TRunInfo.h"
22#include "TGRSIMap.h"
23#include "TChannel.h"
24#include "TUserSettings.h"
25
26////////////////////////////////////////////////////////////////////////////////
27///
28/// \class TGRSIHelper
29///
30/// Base class for all helpers used in grsiframe.
31/// It provides some general members that are set from the input list, like
32/// TPPG, run info, and user settings. It also loads settings from the input
33/// list into general GRSISort variables, like the analysis options, g-value
34/// files, cut files, or calibration files.
35///
36////////////////////////////////////////////////////////////////////////////////
37
38class TGRSIHelper : public TObject {
39public:
40 std::string& Prefix() { return fPrefix; }
41
42protected:
43 TPPG* Ppg() { return fPpg; }
44 TRunInfo* RunInfo() { return fRunInfo; }
46
47 std::vector<std::shared_ptr<std::map<std::string, TList>>> fLists; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map of lists and directories per data processing slot to hold all output objects
48 std::vector<TGRSIMap<std::string, TH1*>> fH1; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map per data processing slot for 1D histograms
49 std::vector<TGRSIMap<std::string, TH2*>> fH2; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map per data processing slot for 2D histograms
50 std::vector<TGRSIMap<std::string, TH3*>> fH3; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map per data processing slot for 3D histograms
51 std::vector<TGRSIMap<std::string, GHSym*>> fSym; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map per data processing slot for GRSISort's symmectric 2D histograms
52 std::vector<TGRSIMap<std::string, GCube*>> fCube; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map per data processing slot for GRSISort's 3D histograms
53 std::vector<TGRSIMap<std::string, TTree*>> fTree; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map per data processing slot for trees
54 std::vector<TGRSIMap<std::string, TObject*>> fObject; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! one map per data processing slot for any TObjects
55 std::map<std::string, TCutG*> fCuts; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! map of cuts
56 TPPG* fPpg{nullptr}; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! pointer to the PPG
57 TRunInfo* fRunInfo{nullptr}; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! pointer to the run info
58 TUserSettings* fUserSettings{nullptr}; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! pointer to the user settings
59 std::string fPrefix{"TGRSIHelper"}; // NOLINT(cppcoreguidelines-non-private-member-variables-in-classes) //!<! name of this action (used as prefix)
60
61private:
62 static constexpr int fSizeLimit = 1073741822; //!<! 1 GiB size limit for objects in ROOT
63 void CheckSizes(unsigned int slot, const char* usage);
64
65public:
66 /// This type is a requirement for every helper.
67 using Result_t = std::map<std::string, TList>;
68
69 explicit TGRSIHelper(TList* input);
70
71 /// This function builds the vectors of TLists and maps for 1D- and 2D-histograms.
72 /// It calls the overloaded CreateHistograms functions in which the user can define
73 /// their histograms. Then it adds all those histograms to the list of the corresponding slot.
74 virtual void Setup();
75 /// Virtual helper function that the user uses to create their histograms
76 virtual void CreateHistograms(unsigned int)
77 {
78 std::cout << this << " - " << __PRETTY_FUNCTION__ << ", " << Prefix() << ": This function should not get called, the user's code should replace it. Not creating any histograms!" << std::endl; // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
79 }
80 /// This method will call the Book action on the provided dataframe
81 virtual ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame*)
82 {
83 std::cout << this << " - " << __PRETTY_FUNCTION__ << ", " << Prefix() << ": This function should not get called, the user's code should replace it. Returning empty list!" << std::endl; // NOLINT(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
84 return {};
85 }
86
87 TGRSIHelper(const TGRSIHelper&) = delete;
91 ~TGRSIHelper() = default;
92 std::shared_ptr<std::map<std::string, TList>> GetResultPtr() const { return fLists[0]; }
93 void InitTask(TTreeReader*, unsigned int) {}
94 void Initialize() {} // required method, gets called once before starting the event loop
95 /// This required method is called at the end of the event loop. It is used to merge all the internal TLists which
96 /// were used in each of the data processing slots.
97 void Finalize();
98
99 /// This method gets called at the end of Finalize()
100 virtual void EndOfSort(std::shared_ptr<std::map<std::string, TList>>&) {}
101
102 std::string Prefix() const { return fPrefix; }
103 void Prefix(const std::string& val) { fPrefix = val; }
104 std::string GetActionName() const { return Prefix(); } // apparently a required function (not documented but doesn't compile w/o it)
105};
106
107#endif
108#endif
TUserSettings * UserSettings()
Definition TGRSIHelper.h:45
std::vector< TGRSIMap< std::string, TTree * > > fTree
Definition TGRSIHelper.h:53
std::map< std::string, TCutG * > fCuts
Definition TGRSIHelper.h:55
std::vector< TGRSIMap< std::string, GCube * > > fCube
Definition TGRSIHelper.h:52
std::vector< TGRSIMap< std::string, GHSym * > > fSym
Definition TGRSIHelper.h:51
std::shared_ptr< std::map< std::string, TList > > GetResultPtr() const
Definition TGRSIHelper.h:92
std::vector< TGRSIMap< std::string, TH2 * > > fH2
Definition TGRSIHelper.h:49
void Prefix(const std::string &val)
std::string Prefix() const
void CheckSizes(unsigned int slot, const char *usage)
TGRSIHelper & operator=(TGRSIHelper &&)=default
std::vector< TGRSIMap< std::string, TObject * > > fObject
Definition TGRSIHelper.h:54
TUserSettings * fUserSettings
Definition TGRSIHelper.h:58
std::map< std::string, TList > Result_t
This type is a requirement for every helper.
Definition TGRSIHelper.h:67
std::string fPrefix
Definition TGRSIHelper.h:59
void Initialize()
Definition TGRSIHelper.h:94
TRunInfo * RunInfo()
Definition TGRSIHelper.h:44
virtual ROOT::RDF::RResultPtr< std::map< std::string, TList > > Book(ROOT::RDataFrame *)
This method will call the Book action on the provided dataframe.
Definition TGRSIHelper.h:81
std::vector< TGRSIMap< std::string, TH1 * > > fH1
Definition TGRSIHelper.h:48
virtual void CreateHistograms(unsigned int)
Virtual helper function that the user uses to create their histograms.
Definition TGRSIHelper.h:76
virtual void EndOfSort(std::shared_ptr< std::map< std::string, TList > > &)
This method gets called at the end of Finalize()
std::string & Prefix()
Definition TGRSIHelper.h:40
std::vector< std::shared_ptr< std::map< std::string, TList > > > fLists
Definition TGRSIHelper.h:47
TGRSIHelper(const TGRSIHelper &)=delete
TPPG * fPpg
Definition TGRSIHelper.h:56
void InitTask(TTreeReader *, unsigned int)
Definition TGRSIHelper.h:93
TGRSIHelper(TGRSIHelper &&)=default
TGRSIHelper(TList *input)
static constexpr int fSizeLimit
! 1 GiB size limit for objects in ROOT
Definition TGRSIHelper.h:62
std::string GetActionName() const
TPPG * Ppg()
Definition TGRSIHelper.h:43
virtual void Setup()
TRunInfo * fRunInfo
Definition TGRSIHelper.h:57
~TGRSIHelper()=default
std::vector< TGRSIMap< std::string, TH3 * > > fH3
Definition TGRSIHelper.h:50
TGRSIHelper & operator=(const TGRSIHelper &)=delete
Definition TPPG.h:132