GRSISort "v4.1.1.0"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
ExampleTreeHelper.hh
Go to the documentation of this file.
1#ifndef ExampleTreeHelper_h
2#define ExampleTreeHelper_h
3
4/** \addtogroup Helpers
5 * @{
6 */
7
8////////////////////////////////////////////////////////////////////////////////
9/// \class ExampleTreeHelper
10///
11/// This selector shows how to create a tree with selected events (beta-tagged
12/// with gamma multiplicities of at least three), and selected information
13/// (suppressed addback energies, and beta-gamma timing differences).
14///
15////////////////////////////////////////////////////////////////////////////////
16
17// Header file for the classes stored in the TTree if any.
18#include "TGRSIHelper.h"
19#include "TGriffin.h"
20#include "TGriffinBgo.h"
21#include "TSceptar.h"
22#include "TZeroDegree.h"
23
24// Fixed size dimensions of array or collections stored in the TTree if any.
25
26class ExampleTreeHelper : public TGRSIHelper, public ROOT::Detail::RDF::RActionImpl<ExampleTreeHelper> {
27public:
28 explicit ExampleTreeHelper(TList* list)
29 : TGRSIHelper(list)
30 {
31 Prefix("ExampleTree");
32 Setup();
33 }
34 // These functions are expected to exist
35 ROOT::RDF::RResultPtr<std::map<std::string, TList>> Book(ROOT::RDataFrame* d) override
36 {
37 auto columnNames = ColumnNames();
38 std::cout << "Using column names";
39 for(const auto& name : columnNames) {
40 std::cout << " \"" << name << "\"";
41 }
42 std::cout << " we get:" << std::endl;
43 if(std::none_of(columnNames.begin(), columnNames.end(), [](const std::string& name) { return name == "TGriffin"; }) ||
44 std::none_of(columnNames.begin(), columnNames.end(), [](const std::string& name) { return name == "TGriffinBgo"; })) {
45 throw std::runtime_error("Missing either TGriffin or TGriffinBgo in list of column names?");
46 }
47 fZds = std::any_of(columnNames.begin(), columnNames.end(), [](const std::string& name) { return name == "TZeroDegree"; });
48 fSceptar = std::any_of(columnNames.begin(), columnNames.end(), [](const std::string& name) { return name == "TSceptar"; });
49 std::cout << "Zds " << (fZds ? "present" : "missing") << ", and Sceptar " << (fSceptar ? "present" : "missing") << std::endl;
50 if(fZds && fSceptar) {
51 return d->Book<TGriffin, TGriffinBgo, TZeroDegree, TSceptar>(std::move(*this), {"TGriffin", "TGriffinBgo", "TZeroDegree", "TSceptar"});
52 }
53 if(fZds) {
54 return d->Book<TGriffin, TGriffinBgo, TZeroDegree>(std::move(*this), {"TGriffin", "TGriffinBgo", "TZeroDegree"});
55 }
56 if(fSceptar) {
57 return d->Book<TGriffin, TGriffinBgo, TSceptar>(std::move(*this), {"TGriffin", "TGriffinBgo", "TSceptar"});
58 }
59 return d->Book<TGriffin, TGriffinBgo>(std::move(*this), {"TGriffin", "TGriffinBgo"});
60 }
61 void CreateHistograms(unsigned int slot) override;
62 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo, TZeroDegree& zds, TSceptar& scep);
63 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo, TZeroDegree& zds)
64 {
65 TSceptar scep;
66 Exec(slot, grif, grifBgo, zds, scep);
67 }
68 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo, TSceptar& scep)
69 {
70 TZeroDegree zds;
71 Exec(slot, grif, grifBgo, zds, scep);
72 }
73 void Exec(unsigned int slot, TGriffin& grif, TGriffinBgo& grifBgo)
74 {
75 TZeroDegree zds;
76 TSceptar scep;
77 Exec(slot, grif, grifBgo, zds, scep);
78 }
79
80private:
81 // branches of output trees
82 // all of these need to be maps for the different slots/workers, we're using maps as they don't need to be resized and once accessed
83 // the address of key stays the same (important to be able to create branches)
84 std::map<unsigned int, double*> fSuppressedAddback2; ///< vector of suppressed addback energies
85 std::map<unsigned int, std::vector<double>> fSuppressedAddback; ///< vector of suppressed addback energies
86 std::map<unsigned int, std::vector<double>> fBetaGammaTiming; ///< vector of beta-gamma timing
87 std::map<unsigned int, int> fGriffinMultiplicity; ///< multiplicity of suppressed addback energies
88 bool fZds{false}; ///< flag whether ZDS is present in the data
89 bool fSceptar{false}; ///< flag whether SCEPTAR is present in the data
90};
91
92extern "C" ExampleTreeHelper* CreateHelper(TList* list) { return new ExampleTreeHelper(list); }
93
94extern "C" void DestroyHelper(TGRSIHelper* helper) { delete helper; }
95
96/*! @} */
97#endif
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo)
ROOT::RDF::RResultPtr< std::map< std::string, TList > > Book(ROOT::RDataFrame *d) override
This method will call the Book action on the provided dataframe.
bool fZds
flag whether ZDS is present in the data
void CreateHistograms(unsigned int slot) override
Virtual helper function that the user uses to create their histograms.
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo, TZeroDegree &zds)
std::map< unsigned int, int > fGriffinMultiplicity
multiplicity of suppressed addback energies
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo, TSceptar &scep)
void Exec(unsigned int slot, TGriffin &grif, TGriffinBgo &grifBgo, TZeroDegree &zds, TSceptar &scep)
std::map< unsigned int, std::vector< double > > fBetaGammaTiming
vector of beta-gamma timing
std::map< unsigned int, std::vector< double > > fSuppressedAddback
vector of suppressed addback energies
ExampleTreeHelper(TList *list)
bool fSceptar
flag whether SCEPTAR is present in the data
std::map< unsigned int, double * > fSuppressedAddback2
vector of suppressed addback energies
std::string & Prefix()
Definition TGRSIHelper.h:38
ROOT::RDF::ColumnNames_t ColumnNames() const
Definition TGRSIHelper.h:40
virtual void Setup()
void DestroyHelper(TGRSIHelper *helper)
ExampleTreeHelper * CreateHelper(TList *list)