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 Prefix("DirectoryHelper");
22 Setup();
23 }
24
25 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
26 {
27 return d->Book<TGriffin, TGriffinBgo>(std::move(*this), {"TGriffin", "TGriffinBgo"});
28 }
29 // this function creates and books all histograms
30 void CreateHistograms(unsigned int slot) override;
31 // this function gets called for every single event and fills the histograms
32 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo);
33 // this function is optional and is called after the output lists off all slots/workers have been merged
34 void EndOfSort(std::shared_ptr<std::map<std::string, TList>>& list) override;
35
36private:
37 // any constants that are set in the CreateHistograms function and used in the Exec function can be stored here
38 // or any other settings
39 std::map<std::vector<double>> fLastTS;
40 std::map<std::vector<double>> fLastSuppressedTS;
41 std::map<std::vector<double>> fLastTime;
42 std::map<std::vector<double>> fLastSuppressedTime;
43 std::map<std::vector<double>> fLastTSNoPileup;
44 std::map<std::vector<double>> fLastSuppressedTSNoPileup;
45 std::map<std::vector<double>> fLastTimeNoPileup;
46 std::map<std::vector<double>> fLastSuppressedTimeNoPileup;
47};
48
49// These are needed functions used by TDataFrameLibrary to create and destroy the instance of this helper
50extern "C" DirectoryHelper* CreateHelper(TList* list) { return new DirectoryHelper(list); }
51
52extern "C" void DestroyHelper(TGRSIHelper* helper) { delete helper; }
53
54#endif
void DestroyHelper(TGRSIHelper *helper)
DirectoryHelper * CreateHelper(TList *list)
std::map< std::vector< double > > fLastSuppressedTime
std::map< std::vector< double > > fLastSuppressedTS
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo)
std::map< std::vector< double > > fLastTime
void EndOfSort(std::shared_ptr< std::map< std::string, TList > > &list) override
This method gets called at the end of Finalize()
std::map< std::vector< double > > fLastTSNoPileup
std::map< 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.
void CreateHistograms(unsigned int slot) override
Virtual helper function that the user uses to create their histograms.
DirectoryHelper(TList *list)
std::map< std::vector< double > > fLastTimeNoPileup
std::map< std::vector< double > > fLastTS
std::map< std::vector< double > > fLastSuppressedTSNoPileup
std::string & Prefix()
Definition TGRSIHelper.h:40
virtual void Setup()