GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
ExampleEventHelper.hh
Go to the documentation of this file.
1// TODO: Replace all EXAMPLEVENT and ExampleEvent with the name you want to use for this helper action
2#ifndef EXAMPLEEVENTHELPER_HH
3#define EXAMPLEEVENTHELPER_HH
4
5#include "TGRSIHelper.h"
6
7// TODO: edit these include statments to match the detectors you want to use!
8#include "TGriffin.h"
9#include "TGriffinBgo.h"
10#include "TZeroDegree.h"
11
12// This is a custom action which respects a well defined interface. It supports parallelism,
13// in the sense that it behaves correctly if implicit multi threading is enabled.
14// Note the plural: in presence of a MT execution, internally more than a single TList is created.
15// 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)!
16
17class ExampleEventHelper : public TGRSIHelper, public ROOT::Detail::RDF::RActionImpl<ExampleEventHelper> {
18public:
19 // constructor sets the prefix (which is used for the output file as well)
20 // and calls Setup which in turn also calls CreateHistograms
21 explicit ExampleEventHelper(TList* list)
22 : TGRSIHelper(list)
23 {
24 Prefix("ExampleEventHelper");
25 Setup();
26 }
27
28 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
29 {
30 // TODO: edit the template specification and branch names to match the detectors you want to use!
31 return d->Book<TGriffin, TGriffinBgo, TZeroDegree>(std::move(*this), {"TGriffin", "TGriffinBgo", "TZeroDegree"});
32 }
33 // this function creates and books all histograms
34 void CreateHistograms(unsigned int slot) override;
35 // this function gets called for every single event and fills the histograms
36 // TODO: edit the function arguments to match the detectors you want to use!
37 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo, TZeroDegree& zds);
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 Long64_t fCycleLength{0};
45};
46
47// These are needed functions used by TDataFrameLibrary to create and destroy the instance of this helper
48extern "C" ExampleEventHelper* CreateHelper(TList* list) { return new ExampleEventHelper(list); }
49
50extern "C" void DestroyHelper(TGRSIHelper* helper) { delete helper; }
51
52#endif
void DestroyHelper(TGRSIHelper *helper)
ExampleEventHelper * CreateHelper(TList *list)
void EndOfSort(std::shared_ptr< std::map< std::string, TList > > &list) override
This method gets called at the end of Finalize()
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo, TZeroDegree &zds)
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.
ExampleEventHelper(TList *list)
std::string & Prefix()
Definition TGRSIHelper.h:40
virtual void Setup()