GamR  0.0.0
GammaROOT
Loading...
Searching...
No Matches
DetDefn.hh
Go to the documentation of this file.
1#ifndef GAMROOT_TREE_DETDEFN_HH
2#define GAMROOT_TREE_DETDEFN_HH
3
4/* STD */
5#include <array>
6#include <memory>
7#include <string>
8#include <tuple>
9#include <vector>
10
11/* ROOT */
12#include <TFormula.h>
13#include <TH1D.h>
14#include <TObject.h>
15#include <TRandom3.h>
16
17/* GAMR */
18#include <utils/Tuples.hh>
19
20namespace GamR {
21namespace Tree {
22
23template <class... Ts>
24class TDetDefn : public TObject {
25private:
26 TRandom3 fRnd;
27 // std::tuple<std::shared_ptr<Ts>...> fRawDatum;
28 std::tuple<Ts *...> fRawDatum;
29 std::tuple<std::pair<Ts, Double_t>...> fDatum;
30 std::tuple<std::vector<Ts>...> fRunning;
31 std::vector<std::shared_ptr<TFormula>> fCalFunc;
32 std::vector<std::shared_ptr<TFormula>> fPollGate;
33 // std::vector<std::shared_ptr<TH1D> > fRawHists;
34 Int_t fMeasCount;
35 Int_t fAtleast;
36 TFormula fEffFunc;
37
38 std::array<std::pair<Double_t, Double_t>, sizeof...(Ts)> fMean; // Means first X, last X
39 std::array<std::pair<Double_t, Double_t>, sizeof...(Ts)> fStdDev; // Stdev, first X, last X
40
41 std::string fType;
42 std::string fName;
43 Int_t fID;
44 std::array<Int_t, sizeof...(Ts)> fRunningIndex;
45 std::array<Double_t, sizeof...(Ts)> fRunningSquared; // sum(x^2)/size
46 Int_t fPollFreq;
47
48private:
49 struct UpdateGoodness; // IsGood()
50 struct InterpretPointers; // SetPtrs()
51 struct DereferencePointers; // Calibrate(...)
52 // struct FillHistogram; // Calibrate(...)
53 struct CalFunctor; // Calibrate(...)
54
55public:
56 TDetDefn(std::string t = "", int id = -1, std::string n = "", int I = 50000)
57 : fDatum(), fType(t), fName(n), fID(id), fPollFreq(I)
58 {
59 fRawDatum = std::make_tuple(new Ts...);
60 fRunning = std::make_tuple(std::vector<Ts>(I)...);
61 fRnd.SetSeed(std::rand());
62 fRunningIndex.fill(0);
63 fRunningSquared.fill(0);
64 }
66 {
67 fCalFunc.resize(0);
68 fPollGate.resize(0);
69 }
70
71 template <int N>
72 auto GetDatum(ULong64_t eventNum) -> decltype(std::get<N>(fDatum)) &
73 {
74 Calibrate(eventNum);
75 return std::get<N>(fDatum);
76 }
77 auto GetAllDatums(ULong64_t eventNum) -> decltype(fDatum) &
78 {
79 Calibrate(eventNum);
80 return fDatum;
81 }
82 size_t GetNumMeasurements() const { return sizeof...(Ts); }
83
84 Int_t GetID() { return fID; }
85 Double_t GetEfficiency() { return fEffFunc.Eval(0); }
86
87 Bool_t IsGood();
88 void SetPtrs(std::map<std::string, void *> &branchmap, std::string branches);
89 void SetRequired(Int_t n) { fAtleast = n; };
90 void SetCalFuncs(std::string funcstrs);
91 void SetPollGates(std::string pollstrs);
92 void SetEffFunc(std::string function);
93 void Calibrate(ULong64_t eventNum=0);
94
96};
97
98} // namespace Tree
99} // namespace GamR
100
101#include "DetDefn.tt"
102
103#endif
TDetDefn(std::string t="", int id=-1, std::string n="", int I=50000)
Definition DetDefn.hh:56
void SetEffFunc(std::string function)
Definition DetDefn.tt:268
void SetRequired(Int_t n)
Definition DetDefn.hh:89
auto GetAllDatums(ULong64_t eventNum) -> decltype(fDatum) &
Definition DetDefn.hh:77
Double_t GetEfficiency()
Definition DetDefn.hh:85
void Calibrate(ULong64_t eventNum=0)
Definition DetDefn.tt:277
void SetPtrs(std::map< std::string, void * > &branchmap, std::string branches)
Definition DetDefn.tt:180
void SetCalFuncs(std::string funcstrs)
Definition DetDefn.tt:210
auto GetDatum(ULong64_t eventNum) -> decltype(std::get< N >(fDatum)) &
Definition DetDefn.hh:72
ClassDef(TDetDefn, 1)
void SetPollGates(std::string pollstrs)
Definition DetDefn.tt:237
size_t GetNumMeasurements() const
Definition DetDefn.hh:82
Definition Gain.cc:19