HighLAND
BinnedParams.hxx
1 #ifndef BinnedParams_h
2 #define BinnedParams_h
3 
4 #include "BaseDataClasses.hxx"
5 #include "TGraph.h"
6 
7 /// This class represents a systematic source.
8 /// It provides the functionality to read a file containing the systematic source values
9 /// and store the values in BinnedParamsBin's. It handles systematic parameters in 1D, 2D and 3D
10 
11 /*
12 //! [BinnedParamsTypes]
13 This are the type enums the BinnedParams class can have
14 
15 For standard weight systematics:
16 - k1D_SYMMETRIC: the systematic depends on a single observable (i.e. momentum) and its error is symmetric
17 - k2D_SYMMETRIC: the systematic depends on two observables (i.e. momentum and angle) and its error is symmetric
18 - k3D_SYMMETRIC: the systematic depends on three observables and its error is symmetric
19 - k1D_SYMMETRIC_NOMEAN: the systematic depends on a single observable (i.e. momentum) and its error is symmetric. The correction is not specified
20 - k2D_SYMMETRIC_NOMEAN: the systematic depends on two observables (i.e. momentum and angle) and its error is symmetric. The correction is not specified
21 - k3D_SYMMETRIC_NOMEAN: the systematic depends on three observables and its error is symmetric. The correction is not specified
22 
23 
24 For efficiency-like weight systematics:
25 - k1D_EFF_SYMMETRIC: the systematic depends on a single observable (i.e. momentum) and its error is symmetric
26 - k2D_EFF_SYMMETRIC, the systematic depends on two observables (i.e. momentum and angle) and its error is symmetric
27 - k3D_EFF_SYMMETRIC, the systematic depends on three observables and its error is symmetric
28 - k1D_EFF_ASSYMMETRIC: the systematic depends on a single observable (i.e. momentum) and its error is assymmetric
29 - k2D_EFF_ASSYMMETRIC: the systematic depends on two observables (i.e. momentum and angle) and its error is assymmetric
30 - k3D_EFF_ASSYMMETRIC, the systematic depends on three observables and its error is assymmetric
31 //! [BinnedParamsTypes]
32 */
33 
34 
35 const UInt_t NMAXSYSTSOURCEBINS = 50;
36 
38  public :
39 
40  BinnedParamsParams() {}
41  virtual ~BinnedParamsParams(){}
42 
43  /// The mean value for each of the systematic parameters of the control sample
44  Float_t meanDATA; //!
45 
46  /// The sigma value for each of the systematic parameters of the control sample /// with possibility of asymm errors l=low, h=high
47  // Float_t sigmaDATA; //!
48  Float_t sigmaDATAl; //!
49  Float_t sigmaDATAh; //!
50 
51  /// The mean value for each of the systematic parameters of the control sample
52  Float_t meanMC; //!
53 
54  /// The sigma value for each of the systematic parameters of the control sample
55  /// with possibility of asymm errors l=low, h=high
56  // Float_t sigmaMC; //!
57  Float_t sigmaMCl; //!
58  Float_t sigmaMCh; //!
59 
60  /// The mean value for each of the systematic parameters of the analysis sample
61  Float_t meanMCANA; //!
62 
63  /// The mean value for each of the systematic parameters of the control sample
64  Float_t mean; //!
65 
66  /// The sigma value for each of the systematic parameters of the control sample taking errors from data and mc
67  Float_t sigma; //!
68 
69 };
70 
71 
73 
74 public:
75 
76  enum BinEnum{
77  kMeanDATA = 0,
78  kSigmaDATAl,
79  kSigmaDATAh,
80  kMeanMC,
81  kSigmaMCl,
82  kSigmaMCh,
83  kMeanMCANA,
84  kMean,
85  kSigma,
86  kNGraph
87  };
88 
89  /// default constructor
91  Initialize();
92  }
93 
94  /// Constructor for 2D bin
95  BinnedParamsGraphBin(Float_t min, Float_t max)
96  {_min=min; _max=max; Initialize();}
97 
98  /// Constructor for 3D bin
99  BinnedParamsGraphBin(Float_t min, Float_t max, Float_t min2, Float_t max2)
100  {_min=min; _max=max; _min2=min2; _max2=max2; Initialize();}
101 
102  /// default destructor
104  for (int i = 0; i < kNGraph; i++){
105  if (_graphs[i]) delete _graphs[i];
106  _graphs[i] = NULL;
107  }
108  }
109 
110  /// Update
111  void Update(Float_t min, Float_t max,
112  Float_t meanREAL,
113  Float_t meanMC,
114  Float_t sigmaMCl,
115  Float_t sigmaMCh,
116  Float_t meanDATA,
117  Float_t sigmaDATAl,
118  Float_t sigmaDATAh){
119 
120  Float_t point = min + max;
121  point /= 2;
122 
123  if (_graphs[kMeanMCANA ] ) _graphs[kMeanMCANA ] -> SetPoint( _graphs[kMeanMCANA ] -> GetN(), point, meanREAL );
124  if (_graphs[kMeanMC ] ) _graphs[kMeanMC ] -> SetPoint( _graphs[kMeanMC ] -> GetN(), point, meanMC );
125  if (_graphs[kSigmaMCl ] ) _graphs[kSigmaMCh ] -> SetPoint( _graphs[kSigmaMCh ] -> GetN(), point, sigmaMCl );
126  if (_graphs[kSigmaMCh ] ) _graphs[kSigmaMCl ] -> SetPoint( _graphs[kSigmaMCl ] -> GetN(), point, sigmaMCh );
127  if (_graphs[kMeanDATA ] ) _graphs[kMeanDATA ] -> SetPoint( _graphs[kMeanDATA ] -> GetN(), point, meanDATA );
128  if (_graphs[kSigmaDATAl ] ) _graphs[kSigmaDATAl ] -> SetPoint( _graphs[kSigmaDATAl ] -> GetN(), point, sigmaDATAl );
129  if (_graphs[kSigmaDATAh ] ) _graphs[kSigmaDATAh ] -> SetPoint( _graphs[kSigmaDATAh ] -> GetN(), point, sigmaDATAh );
130 
131  }
132 
133  void Update(Float_t min, Float_t max,
134  Float_t mean,
135  Float_t sigma){
136 
137  Float_t point = min + max;
138  point /= 2;
139 
140  if (_graphs[kMean ] ) _graphs[kMean ] -> SetPoint( _graphs[kMean ] -> GetN(), point, mean);
141  if (_graphs[kSigma ] ) _graphs[kSigma ] -> SetPoint( _graphs[kSigma ] -> GetN(), point, sigma);
142  }
143 
144  bool GetValue(BinEnum type, Float_t value, Float_t& result){
145  if (type == kNGraph) return false;
146 
147  if (!_graphs[type] || _graphs[type]->GetN()<2)
148  return false;
149 
150  // this is a simple linear interpolation
151  result = (Float_t)(_graphs[type]->Eval(value));
152 
153  return true;
154  }
155 
156  /// Fill params given a value
157  bool GetParams(Float_t value, BinnedParamsParams& params);
158 
159  /// bin limits (for 2D)
160  Float_t _min;
161  Float_t _max;
162 
163  /// bin limits (for 3D)
164  Float_t _min2;
165  Float_t _max2;
166 
167  Int_t _index;
168 
169 protected:
170 
171  /// Internal graphs for interpolation
172  TGraph* _graphs[kNGraph];
173 
174 private:
175  /// Initialize
176  void Initialize(){
177  for (int i = 0; i < kNGraph; i++)
178  _graphs[i] = new TGraph();
179  }
180 };
181 
182 
184 
185 public:
186 
187  /// default constructor
189 
190  /// default destructor
192 
193  /// Constructor for 1D bin
194  BinnedParamsBin(Float_t min, Float_t max, Float_t meanREAL,Float_t meanMC, Float_t sigmaMCl,Float_t sigmaMCh,Float_t meanDATA, Float_t sigmaDATAl,Float_t sigmaDATAh)
195  {_min=min;_max=max;_meanREAL=meanREAL;_meanMC=meanMC;_sigmaMCl=sigmaMCl;_sigmaMCh=sigmaMCh;_meanDATA=meanDATA;_sigmaDATAl=sigmaDATAl;_sigmaDATAh=sigmaDATAh;}
196 
197 
198  BinnedParamsBin(Float_t min, Float_t max, Float_t mean,Float_t sigma)
199  {_min=min;_max=max;_mean=mean;_sigma=sigma;}
200 
201  /// Constructor for 2D bin
202  BinnedParamsBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl,Float_t sigmaMCh,Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
203  {_min=min;_max=max;_min2=min2;_max2=max2;_meanREAL=meanREAL;_meanMC=meanMC;_sigmaMCl=sigmaMCl;_sigmaMCh=sigmaMCh;_meanDATA=meanDATA;_sigmaDATAl=sigmaDATAl;_sigmaDATAh=sigmaDATAh;}
204 
205  BinnedParamsBin(Float_t min, Float_t max, Float_t min2, Float_t max2,Float_t mean,Float_t sigma)
206  {_min=min;_max=max;_min2=min2;_max2=max2;_mean=mean;_sigma=sigma;}
207 
208  /// Constructor for 3D bin
209  BinnedParamsBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3,
210  Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl,Float_t sigmaMCh,Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
211  {_min=min; _max=max; _min2=min2; _max2=max2; _min3=min3; _max3=max3; _meanMC=meanMC; _meanREAL=meanREAL; _sigmaMCl=sigmaMCl; _sigmaMCh=sigmaMCh;
212  _meanDATA=meanDATA; _sigmaDATAl=sigmaDATAl; _sigmaDATAh=sigmaDATAh;}
213 
214  BinnedParamsBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3, Float_t mean, Float_t sigma)
215  {_min=min; _max=max; _min2=min2; _max2=max2; _min3=min3; _max3=max3; _mean=mean; _sigma=sigma;}
216 
217 
218 public:
219 
220  /// bin limits (for 1D and 2D)
221  Float_t _min;
222  Float_t _max;
223 
224  /// bin limits (only for 2D)
225  Float_t _min2;
226  Float_t _max2;
227 
228  /// bin limits (only for 3D)
229  Float_t _min3;
230  Float_t _max3;
231 
232  /// mean and sigma for this bin
233  Float_t _mean;
234  Float_t _sigma;
235 
236  /// mean and sigma for this bin
237  Float_t _meanREAL; /// Efficiency of the MC analysis sample
238  Float_t _meanMC; /// Efficiency of the MC control sample
239  Float_t _sigmaMCl; /// Low error on Efficiency of the MC control sample
240  Float_t _sigmaMCh; /// high error on Efficiency of the MC control sample
241  Float_t _meanDATA; /// Efficiency of the DATA control sample
242  Float_t _sigmaDATAl; /// Low error on Efficiency of the DATA control sample
243  Float_t _sigmaDATAh; /// high error on Efficiency of the DATA control sample
244 
245  /// index for bin
246  Int_t _index;
247 
248 };
249 
251 
252 public:
253 
254  /// Enumerator describing the values that _type member can take
255  enum TypeEnum {
256  k1D_SYMMETRIC = 0,
257  k2D_SYMMETRIC,
258  k3D_SYMMETRIC,
259  k1D_SYMMETRIC_NOMEAN, // no mean
260  k2D_SYMMETRIC_NOMEAN, // no mean
261  k3D_SYMMETRIC_NOMEAN, // no mean
262  k1D_EFF_SYMMETRIC,
263  k2D_EFF_SYMMETRIC,
264  k3D_EFF_SYMMETRIC,
265  k1D_EFF_ASSYMMETRIC,
266  k2D_EFF_ASSYMMETRIC,
267  k3D_EFF_ASSYMMETRIC,
268  // Simple ones that store one value per bin
269  k1D_DATA,
270  k2D_DATA,
271  k3D_DATA,
272  kUnknown
273  }; //!
274 
275  //1D, 2D or 3D
276  enum TypeShortEnum {
277  k1D = 0,
278  k2D,
279  k3D,
280  kUnknownShort
281  };
282 
283 
284 public:
285 
286  BinnedParams();
287 
288  /// Constructor provided the folder name, name and the type
290  const std::string& folder_name,
291  const std::string& name,
292  TypeEnum type,
293  const std::string& extension="",
294  bool useInterpolation = false
295  ){
296  Initialize(
297  folder_name,
298  name,
299  type,
300  extension,
301  useInterpolation
302  );
303 
304  }
305 
306 
307  /// Constructor provided the name and the type, this is to make current psycheSystematics work, may remove it
308  BinnedParams(const std::string& name,
309  TypeEnum type,
310  const std::string& extension="",
311  bool useInterpolation = false){
312 
313  std::string folder_name = std::string(getenv("PSYCHESYSTEMATICSROOT")) + "/data";
314 
315  Initialize(
316  folder_name,
317  name,
318  type,
319  extension,
320  useInterpolation
321  );
322  }
323 
324  virtual ~BinnedParams(){
325 
326  //clear bins
327 
328  for (Int_t i = 0; i < _nBins; i++){
329  if (_bins[i]) delete _bins[i];
330  _bins[i] = NULL;
331  }
332 
333  for (Int_t i = 0; i < _nGraphBins; i++){
334  if (_graphBins[i]) delete _graphBins[i];
335  _graphBins[i] = NULL;
336  }
337  }
338 
339  /// Add a new bin for a 1D source
340  void AddBin(Float_t min, Float_t max,
341  Float_t meanREAL,
342  Float_t meanMC,
343  Float_t sigmaMCl,
344  Float_t sigmaMCh,
345  Float_t meanDATA,
346  Float_t sigmaDATAl,
347  Float_t sigmaDATAh){
348 
349  BinnedParamsBin* b = new BinnedParamsBin(min, max,
350  meanREAL,
351  meanMC,
352  sigmaMCl,
353  sigmaMCh,
354  meanDATA,
355  sigmaDATAl,
356  sigmaDATAh);
357 
358  _bins[_nBins++] = b;
359 
360  if (_useInterpolation)
361  AddGraphBin(min, max,
362  meanREAL,
363  meanMC,
364  sigmaMCl,
365  sigmaMCh,
366  meanDATA,
367  sigmaDATAl,
368  sigmaDATAh);
369 
370  }
371  void AddBin(Float_t min, Float_t max,
372  Float_t mean,
373  Float_t sigma){
374  BinnedParamsBin* b = new BinnedParamsBin(min, max,
375  mean,
376  sigma);
377 
378  _bins[_nBins++] = b;
379 
380  if (_useInterpolation)
381  AddGraphBin(min, max,
382  mean,
383  sigma);
384  }
385 
386  /// Add a new bin for a 2D source
387  void AddBin(Float_t min, Float_t max, Float_t min2, Float_t max2,
388  Float_t meanREAL,
389  Float_t meanMC,
390  Float_t sigmaMCl,
391  Float_t sigmaMCh,
392  Float_t meanDATA,
393  Float_t sigmaDATAl,
394  Float_t sigmaDATAh){
395 
396  BinnedParamsBin* b = new BinnedParamsBin(min, max, min2, max2,
397  meanREAL,
398  meanMC,
399  sigmaMCl,
400  sigmaMCh,
401  meanDATA,
402  sigmaDATAl,
403  sigmaDATAh);
404 
405  _bins[_nBins++] = b;
406 
407  if (_useInterpolation)
408  AddGraphBin(min, max, min2, max2,
409  meanREAL,
410  meanMC,
411  sigmaMCl,
412  sigmaMCh,
413  meanDATA,
414  sigmaDATAl,
415  sigmaDATAh);
416 
417  }
418 
419  void AddBin(Float_t min, Float_t max, Float_t min2, Float_t max2,
420  Float_t mean,
421  Float_t sigma){
422 
423  BinnedParamsBin* b = new BinnedParamsBin(min, max, min2, max2,
424  mean,
425  sigma);
426  _bins[_nBins++] = b;
427 
428  if (_useInterpolation)
429  AddGraphBin(min, max, min2, max2,
430  mean,
431  sigma);
432  }
433 
434  /// Add a new bin for a 3D source
435  void AddBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3,
436  Float_t meanREAL,
437  Float_t meanMC,
438  Float_t sigmaMCl,
439  Float_t sigmaMCh,
440  Float_t meanDATA,
441  Float_t sigmaDATAl,
442  Float_t sigmaDATAh){
443 
444  BinnedParamsBin* b = new BinnedParamsBin(min, max, min2, max2, min3, max3,
445  meanREAL,
446  meanMC,
447  sigmaMCl,
448  sigmaMCh,
449  meanDATA,
450  sigmaDATAl,
451  sigmaDATAh);
452  _bins[_nBins++] = b;
453 
454  if (_useInterpolation)
455  AddGraphBin(min, max, min2, max2, min3, max3,
456  meanREAL,
457  meanMC,
458  sigmaMCl,
459  sigmaMCh,
460  meanDATA,
461  sigmaDATAl,
462  sigmaDATAh);
463  }
464 
465  void AddBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3,
466  Float_t mean,
467  Float_t sigma){
468 
469  BinnedParamsBin* b = new BinnedParamsBin(min, max, min2, max2, min3, max3,
470  mean,
471  sigma);
472  _bins[_nBins++] = b;
473 
474  if (_useInterpolation)
475  AddGraphBin(min, max, min2, max2, min3, max3,
476  mean,
477  sigma);
478  }
479 
480  /// Add a new bin graph for a 1D source
481  void AddGraphBin(Float_t min, Float_t max,
482  Float_t meanREAL,
483  Float_t meanMC,
484  Float_t sigmaMCl,
485  Float_t sigmaMCh,
486  Float_t meanDATA,
487  Float_t sigmaDATAl,
488  Float_t sigmaDATAh);
489 
490  void AddGraphBin(Float_t min, Float_t max,
491  Float_t mean,
492  Float_t sigma);
493 
494 
495  /// Add a new bin graph for a 2D source
496  void AddGraphBin(Float_t min, Float_t max, Float_t min2, Float_t max2,
497  Float_t meanREAL,
498  Float_t meanMC,
499  Float_t sigmaMCl,
500  Float_t sigmaMCh,
501  Float_t meanDATA,
502  Float_t sigmaDATAl,
503  Float_t sigmaDATAh);
504 
505  void AddGraphBin(Float_t min, Float_t max, Float_t min2, Float_t max2,
506  Float_t mean,
507  Float_t sigma);
508 
509  /// Add a new bin graph for a 3D source
510  void AddGraphBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3,
511  Float_t meanREAL,
512  Float_t meanMC,
513  Float_t sigmaMCl,
514  Float_t sigmaMCh,
515  Float_t meanDATA,
516  Float_t sigmaDATAl,
517  Float_t sigmaDATAh);
518 
519  void AddGraphBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3,
520  Float_t mean,
521  Float_t sigma);
522 
523  /// Gets the bin for a 2D source
524  bool GetGraphBin(Float_t value, BinnedParamsGraphBin*& bin);
525 
526  /// Gets the bin for a 3D source
527  bool GetGraphBin(Float_t value1, Float_t value2, BinnedParamsGraphBin*& bin);
528 
529 
530  /// Gets the bin for a 1D source
531  bool GetBin(Float_t value, BinnedParamsBin*& bin);
532 
533  /// Gets the bin for a 2D source
534  bool GetBin(Float_t value1, Float_t value2, BinnedParamsBin*& bin);
535 
536  /// Gets the bin for a 3D source
537  bool GetBin(Float_t value1, Float_t value2, Float_t value3, BinnedParamsBin*& bin);
538 
539 
540  /// Gets the bin index for a 1D source
541  bool GetBinIndex(Float_t value, Int_t& index);
542 
543  /// Gets the bin values for a source provided the bin index
544  bool GetParametersForBin(Int_t index, Float_t& mean, Float_t& sigma);
545  bool GetParametersForBin(Int_t index, BinnedParamsParams& params);
546 
547  /// Get only mean or sigma
548  bool GetSigmaValueForBin(Int_t index, Float_t& sigma){
549  Float_t mean;
550  return GetParametersForBin(index, mean, sigma);
551  }
552  bool GetMeanValueForBin(Int_t index, Float_t& mean){
553  Float_t sigma;
554  return GetParametersForBin(index, mean, sigma);
555  }
556 
557 
558  /// Gets the bin values for a 1D source
559  bool GetBinValues(Float_t value, Float_t& mean, Float_t& sigma){
560  Int_t index;
561  return GetBinValues(value, mean, sigma, index);
562  }
563  bool GetBinValues(Float_t value, Float_t& mean, Float_t& sigma, Int_t& index);
564 
565  /// Get only sigma
566  bool GetBinSigmaValue(Float_t value, Float_t& sigma){
567  Float_t mean;
568  Int_t index;
569  return GetBinValues(value, mean, sigma, index);
570  }
571 
572  bool GetBinSigmaValue(Float_t value, Float_t& sigma, Int_t& index){
573  Float_t mean;
574  return GetBinValues(value, mean, sigma, index);
575  }
576 
577  // Get only mean
578  bool GetBinMeanValue(Float_t value, Float_t& mean){
579  Float_t sigma;
580  Int_t index;
581  return GetBinValues(value, mean, sigma, index);
582  }
583 
584  bool GetBinMeanValue(Float_t value, Float_t& mean, Int_t& index){
585  Float_t sigma;
586  return GetBinValues(value, mean, sigma, index);
587  }
588 
589 
590  bool GetBinValues(Float_t value, BinnedParamsParams& params){
591  Int_t index;
592  return GetBinValues(value, params, index);
593  }
594  bool GetBinValues(Float_t value, BinnedParamsParams& params, Int_t& index);
595 
596  /// Gets the bin values for a 2D source
597  bool GetBinValues(Float_t value1, Float_t value2, Float_t& mean, Float_t& sigma){
598  Int_t index;
599  return GetBinValues(value1, value2, mean, sigma, index);
600  }
601 
602  bool GetBinValues(Float_t value1, Float_t value2, Float_t& mean, Float_t& sigma, Int_t& index);
603 
604  /// Get only sigma
605  bool GetBinSigmaValue(Float_t value1, Float_t value2, Float_t& sigma){
606  Float_t mean;
607  Int_t index;
608  return GetBinValues(value1, value2, mean, sigma, index);
609  }
610 
611  bool GetBinSigmaValue(Float_t value1, Float_t value2, Float_t& sigma, Int_t& index){
612  Float_t mean;
613  return GetBinValues(value1, value2, mean, sigma, index);
614  }
615 
616  // Get only mean
617  bool GetBinMeanValue(Float_t value1, Float_t value2, Float_t& mean){
618  Float_t sigma;
619  Int_t index;
620  return GetBinValues(value1, value2, mean, sigma, index);
621  }
622 
623  bool GetBinMeanValue(Float_t value1, Float_t value2, Float_t& mean, Int_t& index){
624  Float_t sigma;
625  return GetBinValues(value1, value2, mean, sigma, index);
626  }
627 
628  bool GetBinValues(Float_t value1, Float_t value2, BinnedParamsParams& params){
629  Int_t index;
630  return GetBinValues(value1, value2, params, index);
631  }
632 
633  bool GetBinValues(Float_t value1, Float_t value2, BinnedParamsParams& params, Int_t& index);
634 
635  /// Gets the bin values for a 3D source
636  bool GetBinValues(Float_t value1, Float_t value2, Float_t value3, Float_t& mean, Float_t& sigma){
637  Int_t index;
638  return GetBinValues(value1, value2, value3, mean, sigma, index);
639  }
640 
641  bool GetBinValues(Float_t value1, Float_t value2, Float_t value3, Float_t& mean, Float_t& sigma, Int_t& index);
642 
643  /// Get only sigma
644  bool GetBinSigmaValue(Float_t value1, Float_t value2, Float_t value3, Float_t& sigma){
645  Float_t mean;
646  Int_t index;
647  return GetBinValues(value1, value2, value3, mean, sigma, index);
648  }
649 
650  bool GetBinSigmaValue(Float_t value1, Float_t value2, Float_t value3, Float_t& sigma, Int_t& index){
651  Float_t mean;
652  return GetBinValues(value1, value2, value3, mean, sigma, index);
653  }
654 
655  // Get only mean
656  bool GetBinMeanValue(Float_t value1, Float_t value2, Float_t value3, Float_t& mean){
657  Float_t sigma;
658  Int_t index;
659  return GetBinValues(value1, value2, value3, mean, sigma, index);
660  }
661 
662  bool GetBinMeanValue(Float_t value1, Float_t value2, Float_t value3, Float_t& mean, Int_t& index){
663  Float_t sigma;
664  return GetBinValues(value1, value2, value3, mean, sigma, index);
665  }
666 
667  bool GetBinValues(Float_t value1, Float_t value2, Float_t value3, BinnedParamsParams& params){
668  Int_t index;
669  return GetBinValues(value1, value2, value3, params, index);
670  }
671 
672  bool GetBinValues(Float_t value1, Float_t value2, Float_t value3, BinnedParamsParams& params, Int_t& index);
673 
674 
675  /// Get values using interpolation
676  bool GetInterBinValues(Float_t value1, BinnedParamsParams& params);
677 
678  /// Gets the bin values for a 2D source
679  bool GetInterBinValues(Float_t value1, Float_t value2, BinnedParamsParams& params);
680 
681  /// Gets the bin values for a 3D source
682  bool GetInterBinValues(Float_t value1, Float_t value2, Float_t value3, BinnedParamsParams& params);
683 
684  /// Set the type
685  void SetType(TypeEnum type);
686 
687  /// Set the name
688  void SetName(const std::string& name){_name = name;}
689 
690  /// Set the name
691  void SetInterpolationUsage(bool use){_useInterpolation = use;}
692 
693  /// Get the name of the source
694  const std::string& GetDataName(){return _name;}
695 
696  /// Returns the type of the data
697  TypeEnum GetDataType(){return _type;}
698 
699  /// Returns the type of the data
700  bool GetInterpolationStatus(){return _useInterpolation;}
701 
702  /// Dump into the screen the systematic source values
703  void Print();
704 
705  /// Read from a file the systematic source values
706  void Read(const std::string& inputDirName, const std::string& extension="");
707 
708  /// Get the number of bins
709  Int_t GetNBins() {return _nBins;}
710 
711  /// Update the efficiency variables _ncorrect and _nwrong
712  bool UpdateEfficiencyCounter(Int_t index, bool correct);
713 
714  /// Initialize counters
716  for( UInt_t i=0;i<NMAXSYSTSOURCEBINS;i++){
717  _ncorrect[i]=0;
718  _nwrong[i]=0;
719  }
720  }
721 
722  Int_t GetNCorrectAssoc(Int_t index){
723  if((UInt_t)index>=NMAXSYSTSOURCEBINS) {index=NMAXSYSTSOURCEBINS-1;std::cout<<" BinnedParams:: error index>" << NMAXSYSTSOURCEBINS <<std::endl;}
724  return _ncorrect[index];
725  }
726  Int_t GetNWrongAssoc(Int_t index){
727  if((UInt_t)index>=NMAXSYSTSOURCEBINS) {index=NMAXSYSTSOURCEBINS;std::cout<<" BinnedParams:: error index>"<< NMAXSYSTSOURCEBINS <<std::endl;}
728  return _nwrong[index];
729  }
730 
731 private:
732 
733  /// Prevent copying, will add Clone() method if needed
734  BinnedParams(const BinnedParams&); // no implementation
735  BinnedParams& operator=(const BinnedParams&); // no implementation
736 
737  /// Initialize the BinnedParams
738  void Initialize(
739  const std::string& folder_name,
740  const std::string& name,
741  TypeEnum type,
742  const std::string& extension,
743  bool useInterpolation
744  );
745 
746  /// number of correct associations
747  Int_t _ncorrect[NMAXSYSTSOURCEBINS]; //!
748 
749  /// number of wrong associations
750  Int_t _nwrong[NMAXSYSTSOURCEBINS]; //!
751 
752  /// The name of the systematic source
753  std::string _name;
754 
755  /// The type of the systematic source
756  TypeEnum _type;
757 
758  /// The vector of bins
759  BinnedParamsBin* _bins[NMAXSYSTSOURCEBINS];
760 
761  /// The vector of graphs used to interpolate the systematics
762  BinnedParamsGraphBin* _graphBins[NMAXSYSTSOURCEBINS];
763 
764  /// Number of bins for the BinnedParams
765  Int_t _nBins;
766 
767  /// Number of graph bins for the BinnedParams
768  Int_t _nGraphBins;
769 
770  /// The short principle type
771  TypeShortEnum _typeShort;
772 
773  /// A parameter to check whether to use interpolation
774  bool _useInterpolation;
775 
776  /// Set short type based on the current type
777  void SetShortType();
778  };
779 
780 #endif
void AddBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl, Float_t sigmaMCh, Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
Add a new bin for a 2D source.
Float_t _meanREAL
mean and sigma for this bin
BinnedParamsBin()
default constructor
bool GetBinValues(Float_t value1, Float_t value2, Float_t value3, Float_t &mean, Float_t &sigma)
Gets the bin values for a 3D source.
bool GetBinSigmaValue(Float_t value1, Float_t value2, Float_t &sigma)
Get only sigma.
bool GetInterpolationStatus()
Returns the type of the data.
const std::string & GetDataName()
Get the name of the source.
void SetName(const std::string &name)
Set the name.
Float_t sigma
The sigma value for each of the systematic parameters of the control sample taking errors from data a...
Float_t _min2
bin limits (for 3D)
Float_t _min
bin limits (for 1D and 2D)
Float_t _min2
bin limits (only for 2D)
void AddBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl, Float_t sigmaMCh, Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
Add a new bin for a 3D source.
bool GetBinValues(Float_t value, Float_t &mean, Float_t &sigma)
Gets the bin values for a 1D source.
BinnedParamsGraphBin(Float_t min, Float_t max)
Constructor for 2D bin.
Float_t meanDATA
The mean value for each of the systematic parameters of the control sample.
Float_t _sigmaDATAl
Efficiency of the DATA control sample.
Float_t _mean
mean and sigma for this bin
TypeEnum GetDataType()
Returns the type of the data.
BinnedParams(const std::string &name, TypeEnum type, const std::string &extension="", bool useInterpolation=false)
Constructor provided the name and the type, this is to make current psycheSystematics work...
BinnedParamsBin(Float_t min, Float_t max, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl, Float_t sigmaMCh, Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
Constructor for 1D bin.
Float_t meanMC
The mean value for each of the systematic parameters of the control sample.
BinnedParamsBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl, Float_t sigmaMCh, Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
Constructor for 2D bin.
void AddBin(Float_t min, Float_t max, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl, Float_t sigmaMCh, Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
Add a new bin for a 1D source.
Float_t _min3
bin limits (only for 3D)
Float_t _sigmaMCl
Efficiency of the MC control sample.
BinnedParams(const std::string &folder_name, const std::string &name, TypeEnum type, const std::string &extension="", bool useInterpolation=false)
Constructor provided the folder name, name and the type.
TypeEnum
Enumerator describing the values that _type member can take.
BinnedParamsGraphBin()
default constructor
Float_t mean
The mean value for each of the systematic parameters of the control sample.
void SetInterpolationUsage(bool use)
Set the name.
~BinnedParamsGraphBin()
default destructor
Float_t meanMCANA
The mean value for each of the systematic parameters of the analysis sample.
Float_t _min
bin limits (for 2D)
Float_t _sigmaMCh
Low error on Efficiency of the MC control sample.
BinnedParamsBin(Float_t min, Float_t max, Float_t min2, Float_t max2, Float_t min3, Float_t max3, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl, Float_t sigmaMCh, Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
Constructor for 3D bin.
Float_t _meanMC
Efficiency of the MC analysis sample.
Float_t sigmaDATAl
The sigma value for each of the systematic parameters of the control sample /// with possibility of a...
void InitializeEfficiencyCounter()
Initialize counters.
bool GetBinSigmaValue(Float_t value, Float_t &sigma)
Get only sigma.
Int_t _index
high error on Efficiency of the DATA control sample
bool GetBinSigmaValue(Float_t value1, Float_t value2, Float_t value3, Float_t &sigma)
Get only sigma.
Float_t _sigmaDATAh
Low error on Efficiency of the DATA control sample.
Int_t GetNBins()
Get the number of bins.
BinnedParamsGraphBin(Float_t min, Float_t max, Float_t min2, Float_t max2)
Constructor for 3D bin.
void Update(Float_t min, Float_t max, Float_t meanREAL, Float_t meanMC, Float_t sigmaMCl, Float_t sigmaMCh, Float_t meanDATA, Float_t sigmaDATAl, Float_t sigmaDATAh)
Update.
Float_t _meanDATA
high error on Efficiency of the MC control sample
~BinnedParamsBin()
default destructor
bool GetSigmaValueForBin(Int_t index, Float_t &sigma)
Get only mean or sigma.
bool GetBinValues(Float_t value1, Float_t value2, Float_t &mean, Float_t &sigma)
Gets the bin values for a 2D source.