HighLAND
SystematicBase.cxx
1 #include "SystematicBase.hxx"
2 #include "MultiThread.hxx"
3 
4 ClassImp(SystematicBase)
5 
6 //***********************************************************
8 //***********************************************************
9 
10  _nParameters = 1; // The number of systematic parameters
11  _name = "";
12  _type = kUnknown;
13  // _PDF = kUnknownPDF;
14  _PDF = kGaussian;
15  _enabled = false;
16  _systBoxes=NULL;
17 }
18 
19 //***********************************************************
21 //***********************************************************
22 
23  _nParameters = npar; // The number of systematic parameters
24  _name = "";
25  _type = kUnknown;
26  // _PDF = kUnknownPDF;
27  _PDF = kGaussian;
28  _enabled = false;
29  _systBoxes=NULL;
30 }
31 
32 //***********************************************************
34 //***********************************************************
35 
36  if (_type == kVariation)
37  return "variation";
38  else if (_type == kWeight)
39  return "weight";
40  else if (_type == kFlux)
41  return "flux";
42  else
43  return "unknown";
44 }
45 
46 //***********************************************************
48 //***********************************************************
49 
50  if (_PDF == kGaussian)
51  return "gaussian";
52  else if (_PDF == kUniform)
53  return "uniform";
54  else if (_PDF == kBinomial)
55  return "binomial";
56  else if (_PDF == kMultinomial)
57  return "multinomial";
58  else
59  return "unknown";
60 
61 }
62 
63 //********************************************************************
64 SystBoxB* SystematicBase::GetSystBox(const AnaEventC& event, Int_t isel, Int_t ibranch) const {
65 //********************************************************************
66 
67  Int_t uniqueID = 0;
68 
69 #ifdef MULTITHREAD
70  uniqueID = event.UniqueID;
71 #else
72  (void)event;
73 #endif
74 
75  return _systBoxes[isel][ibranch][uniqueID];
76 }
77 
78 //********************************************************************
79 void SystematicBase::Initialize(Int_t nsel, Int_t isel, Int_t nbranches, Int_t nevents){
80 //********************************************************************
81 
82 #ifndef MULTITHREAD
83  nevents=1;
84 #endif
85 
86  // Create the array of SystBox for nsel selections the first time this is called
87  if (!_systBoxes){
88  _systBoxes = new SystBoxB***[nsel];
89  _systBoxesNSel=nsel;
90  for (Int_t i=0;i<nsel;i++){
91  _systBoxes[i]=NULL;
92  _systBoxesNBranches[i]=0;
93  }
94  }
95 
96  //Create the subarray of SystBox for the specified selection, with nbranches and for a given number of events
97  // Only the first time it is called for a given selection
98  if (_systBoxes[isel]) return;
99 
100  _systBoxes[isel] = new SystBoxB**[nbranches];
101  _systBoxesNBranches[isel]=nbranches;
102  for (Int_t j=0;j<nbranches;j++){
103  _systBoxes[isel][j] = new SystBoxB*[nevents];
104  _systBoxesNEvents[isel][j]=nevents;
105  for (Int_t k= 0;k<nevents;k++)
106  _systBoxes[isel][j][k]=NULL;
107  }
108 }
109 
110 //********************************************************************
112 //********************************************************************
113 
114  Int_t uniqueID = 0;
115 
116 #ifdef MULTITHREAD
117  uniqueID = event.UniqueID;
118 #else
119  (void)event;
120 #endif
121 
122  // Delete the SystBox when it exists and create a new one.
123  // TODO: It is probably faster to just reset the arrays
124 
125  if(!_systBoxes) return;
126  for (Int_t isel=0;isel<_systBoxesNSel;isel++){
127  if(!_systBoxes[isel]) continue;
128  for (Int_t ibranch=0;ibranch<_systBoxesNBranches[isel];ibranch++){
129  if(!_systBoxes[isel][ibranch]) continue;
130  if(_systBoxes[isel][ibranch][uniqueID]) delete _systBoxes[isel][ibranch][uniqueID];
131  _systBoxes[isel][ibranch][uniqueID]=NULL;
132  }
133  }
134 }
135 
UInt_t _nParameters
the number of systematic parameters
SystBoxB * GetSystBox(const AnaEventC &event, Int_t isel=0, Int_t ibranch=0) const
Get the SystBox corresponding to a selection, branch and event.
virtual void Initialize(Int_t nsel, Int_t isel, Int_t nbranch, Int_t nevents)
Create the array of SystBox.
PDFEnum _PDF
The PDF use for the systematic parameter scan.
virtual void FinalizeEvent(const AnaEventC &event)
Delete the SystBox for this event.
TypeEnum _type
The type of this systematic (variation, weight or flux)
bool _enabled
Is this systematic enabled ?
std::string ConvertType()
Return the type of this systematic.
std::string _name
The name of this systematic.
SystBoxB **** _systBoxes
----—— Relevant objects for this systematic ------------——
SystematicBase()
Create the systematic, with one parameter.
std::string ConvertPDF()
Return the PDF of this systematic.