a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
Observable.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 HEPfit Collaboration
3  *
4  *
5  * For the licensing terms see doc/COPYING.
6  */
7 
8 #ifndef OBSERVABLE_H
9 #define OBSERVABLE_H
10 
11 #include "ThObservable.h"
12 #include <string>
13 #include <iostream>
14 #include <boost/tokenizer.hpp>
15 
16 class TH1D;
17 
28 class Observable {
29 public:
40  Observable(const std::string name_i,
41  const std::string thname_i,
42  const std::string label_i,
43  const bool tMCMC_i,
44  const double min_i,
45  const double max_i,
46  ThObservable * tho_i);
47 
51  Observable(const Observable& orig);
52 
56  Observable();
57 
68  boost::tokenizer<boost::char_separator<char> >::iterator & ParseObservable(std::string& type,
69  boost::tokenizer<boost::char_separator<char> >* tok,
70  boost::tokenizer<boost::char_separator<char> >::iterator & beg,
71  std::string& filepath,
72  std::string& infilename,
73  int rank);
74 
78  virtual ~Observable();
79 
83  double computeTheoryValue();
84 
89  virtual double computeWeight(double th);
90 
98  virtual double computeWeight(double th, double ave_i, double errg_i, double errf_i);
99 
105  virtual double computeWeight(double th1, double th2)
106  {
107  return 0.0;
108  };
109 
113  virtual double computeWeight()
114  {
116  }
117 
122  double getAve() const
123  {
124  return ave;
125  }
126 
131  void setAve(double ave)
132  {
133  this->ave = ave;
134  }
135 
140  std::string getDistr() const
141  {
142  return distr;
143  }
144 
149  void setDistr(std::string distr)
150  {
151  this->distr = distr;
152  }
153 
158  double getErrf() const
159  {
160  return errf;
161  }
162 
167  void setErrf(double errf)
168  {
169  this->errf = errf;
170  }
171 
176  double getErrg() const
177  {
178  return errg;
179  }
180 
185  void setErrg(double errg)
186  {
187  this->errg = errg;
188  }
189 
194  void setErrgl(double errgl)
195  {
196  this->errgl = errgl;
197  }
198 
203  void setErrgr(double errgr)
204  {
205  this->errgr = errgr;
206  }
207 
212  std::string getFilename() const
213  {
214  return filename;
215  }
216 
217  void setFilename(std::string filename_i)
218  {
219  filename = filename_i;
220  }
221 
228  virtual void setLikelihoodFromHisto(std::string filename, std::string histoname);
229 
234  virtual void setParametricLikelihood(std::string filename)
235  {
236  this->filename=filename; //real implementation will be done in extension
237  }
238 
244  virtual void setParametricLikelihood(std::string filename, std::vector<ThObservable*> thObsV)
245  {};
246 
251  std::string getHistoname() const
252  {
253  return histoname;
254  }
255 
260  void setHistoname(std::string histoname_i)
261  {
262  histoname = histoname_i;
263  }
264 
269  std::string getLabel() const
270  {
271  return label;
272  }
273 
278  void setLabel(std::string label)
279  {
280  this->label = label;
281  }
282 
287  double getMax() const
288  {
289  return max;
290  }
291 
296  void setMax(double max)
297  {
298  this->max = max;
299  }
300 
305  double getMin() const
306  {
307  return min;
308  }
309 
314  void setMin(double min)
315  {
316  this->min = min;
317  }
318 
323  std::string getName() const
324  {
325  return name;
326  }
327 
332  void setName(std::string name)
333  {
334  this->name = name;
335  }
336 
341  bool isTMCMC() const
342  {
343  return tMCMC;
344  }
345 
350  bool isWriteChain() const
351  {
352  return writeChain;
353  }
354 
359  void setTMCMC(bool tMCMC)
360  {
361  this->tMCMC = tMCMC;
362  }
363 
368  std::string getThname() const
369  {
370  return thname;
371  }
372 
377  void setThname(std::string thname)
378  {
379  this->thname = thname;
380  }
381 
387  {
388  return tho;
389  }
390 
395  void setObsType(std::string& obsType_s)
396  {
397  obsType = obsType_s;
398  }
399 
404  std::string getObsType() const
405  {
406  return obsType;
407  }
408 
413  void setTho(ThObservable* tho_i)
414  {
415  tho = tho_i;
418  }
419 
426  void setTho(ThObservable* tho_i, double bmin, double bmax)
427  {
428  tho = tho_i;
429  tho->setBinMin(bmin);
430  tho->setBinMax(bmax);
431  }
432 
441  double LogSplitGaussian(double x, double ave, double errl, double errr);
442 
450  double LogGaussian(double x, double ave, double sigma);
451 
452  virtual void getTheoryValues(std::vector<double>& theoryValues_i) {};
453 
454  virtual int getNTheoryValues() { return 0; };
455 
456  virtual int getNChannels() { return 0; };
457 
458  virtual bool isNew() { return false; };
459 
465  {
466  this->hasInverseCovariance = hasInverseCovariance;
467  }
468 
475  friend std::ostream& operator<<(std::ostream& output, const Observable& o);
476 
477 protected:
479  std::string name;
480  std::string thname;
481  std::string label;
482  std::string distr;
483  std::string filename;
484  std::string histoname;
485  double ave;
486  double errg;
487  double errf;
488  double errgl;
489  double errgr;
490  double min;
491  double max;
492  bool tMCMC;
493  bool writeChain;
494  TH1D * inhisto;
495  std::string obsType;
496  double bin_min;
497  double bin_max;
499  double thValue;
501 };
502 
503 
504 #endif /* OBSERVABLE_H */
505 
Observable::tho
ThObservable * tho
A pointer of to the object of the ThObservables class.
Definition: Observable.h:478
Observable::computeTheoryValue
double computeTheoryValue()
A method to access the computed theory value of the observable.
Definition: Observable.cpp:130
Observable::getMin
double getMin() const
A get method to access the minimum value of the observable.
Definition: Observable.h:305
Observable::isWriteChain
bool isWriteChain() const
A method to check if the observable is listed for writing chains.
Definition: Observable.h:350
Observable::isNew
virtual bool isNew()
Definition: Observable.h:458
Observable::getAve
double getAve() const
A get method to access the average value of the observable.
Definition: Observable.h:122
Observable::histoname
std::string histoname
The name of the histogram for the observable.
Definition: Observable.h:484
Observable::setMin
void setMin(double min)
A set method to fix the minimum value for the observable.
Definition: Observable.h:314
Observable::getDistr
std::string getDistr() const
A get method to access the name of the distribution of the observable.
Definition: Observable.h:140
Observable::max
double max
The maximum valus of the observable.
Definition: Observable.h:491
Observable::tMCMC
bool tMCMC
The flag to include or exclude the observable from the MCMC run.
Definition: Observable.h:492
Observable::getTho
ThObservable * getTho() const
A get method to access the pointer to the object of the ThObservable class.
Definition: Observable.h:386
Observable::setErrgl
void setErrgl(double errgl)
A set method to fix the left Gaussian error of the observable.
Definition: Observable.h:194
Observable::setTho
void setTho(ThObservable *tho_i)
A set method to fix the pointer to object of type ThObservable.
Definition: Observable.h:413
Observable::computeWeight
virtual double computeWeight()
A method to compute the weight associated with the observable.
Definition: Observable.h:113
Observable::obsType
std::string obsType
Type of the Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable...
Definition: Observable.h:495
ThObservable::setBinMin
void setBinMin(double min)
A set method to set the minimum value of the bin.
Definition: ThObservable.h:64
Observable::setLikelihoodFromHisto
virtual void setLikelihoodFromHisto(std::string filename, std::string histoname)
A set method to set the likelihood from which the experimental likelihood of the observable will be r...
Definition: Observable.cpp:111
ThObservable.h
Observable::setParametricLikelihood
virtual void setParametricLikelihood(std::string filename)
A set method to set a parametric likelihood reading parameters from a file.
Definition: Observable.h:234
Observable::ParseObservable
boost::tokenizer< boost::char_separator< char > >::iterator & ParseObservable(std::string &type, boost::tokenizer< boost::char_separator< char > > *tok, boost::tokenizer< boost::char_separator< char > >::iterator &beg, std::string &filepath, std::string &infilename, int rank)
The parser for Observables.
Definition: Observable.cpp:202
Observable::setErrf
void setErrf(double errf)
A set method to fix the flat error of the observable.
Definition: Observable.h:167
Observable::setErrg
void setErrg(double errg)
A set method to fix the gaussian error of the observable.
Definition: Observable.h:185
Observable::getLabel
std::string getLabel() const
A get method to access the label for the observable.
Definition: Observable.h:269
Observable::min
double min
The minimum value of the observable.
Definition: Observable.h:490
Observable::ave
double ave
The average value of the observable.
Definition: Observable.h:485
Observable::operator<<
friend std::ostream & operator<<(std::ostream &output, const Observable &o)
Befriending of the std::ostream operator << to generate an output stream for printing the observables...
Definition: Observable.cpp:102
Observable::getTheoryValues
virtual void getTheoryValues(std::vector< double > &theoryValues_i)
Definition: Observable.h:452
Observable::errgr
double errgr
The upper gaussian error of the observable.
Definition: Observable.h:489
Observable::setThname
void setThname(std::string thname)
A set method to fix the name of the observable as listed in ThFactory class.
Definition: Observable.h:377
Observable::getThname
std::string getThname() const
A get method to access the thname of the observable as defined in ThFactory class.
Definition: Observable.h:368
Observable::isTMCMC
bool isTMCMC() const
A method to check if the observable is listed for MCMC.
Definition: Observable.h:341
Observable::getErrg
double getErrg() const
A get method to access the Gaussian error of the observble.
Definition: Observable.h:176
Observable::setParametricLikelihood
virtual void setParametricLikelihood(std::string filename, std::vector< ThObservable * > thObsV)
Definition: Observable.h:244
Observable::thValue
double thValue
The theory value of the first observable.
Definition: Observable.h:499
Observable::getNTheoryValues
virtual int getNTheoryValues()
Definition: Observable.h:454
Observable::writeChain
bool writeChain
The flag to write the chain for the observable from the MCMC run.
Definition: Observable.h:493
Observable::getFilename
std::string getFilename() const
A get method to access the filename of the observables experimental likelihood file.
Definition: Observable.h:212
Observable::setName
void setName(std::string name)
A set method to fix the name for the observable.
Definition: Observable.h:332
Observable::computeWeight
virtual double computeWeight(double th1, double th2)
A method to compute the weight associated with the observable.
Definition: Observable.h:105
ThObservable::setBinMax
void setBinMax(double max)
A set method to set the maximum value of the bin.
Definition: ThObservable.h:73
Observable::getHistoname
std::string getHistoname() const
A get method to access the name for the histogram of the observable.
Definition: Observable.h:251
Observable::getObsType
std::string getObsType() const
A get method to get the Observable type.
Definition: Observable.h:404
Observable::LogSplitGaussian
double LogSplitGaussian(double x, double ave, double errl, double errr)
Definition: Observable.cpp:141
Observable::setAve
void setAve(double ave)
A set method to fix the average value of the observable.
Definition: Observable.h:131
Observable::errg
double errg
The gaussian error of the observable.
Definition: Observable.h:486
Observable::errf
double errf
The flat error of the observable.
Definition: Observable.h:487
Observable::getErrf
double getErrf() const
A get method to access the flat error of the observable.
Definition: Observable.h:158
Observable::thname
std::string thname
The name for the observable as fixed in the ThObservable class.
Definition: Observable.h:480
Observable::setDistr
void setDistr(std::string distr)
A set method to fix the name of the distribution of the observable.
Definition: Observable.h:149
Observable
A class for observables.
Definition: Observable.h:28
Observable::setErrgr
void setErrgr(double errgr)
A set method to fix the right Gaussian error of the observable.
Definition: Observable.h:203
Observable::getNChannels
virtual int getNChannels()
Definition: Observable.h:456
Observable::~Observable
virtual ~Observable()
The default destructor.
Definition: Observable.cpp:100
Observable::hasInverseCovariance
bool hasInverseCovariance
Definition: Observable.h:500
Observable::name
std::string name
A name for the observable.
Definition: Observable.h:479
Observable::label
std::string label
A label for the observable.
Definition: Observable.h:481
Observable::iterationNo
int iterationNo
A counter for the interation that helps with the observable caching.
Definition: Observable.h:498
Observable::Observable
Observable()
The default constructor.
Definition: Observable.cpp:75
ThObservable
A class for a model prediction of an observable.
Definition: ThObservable.h:25
Observable::setHasInverseCovariance
void setHasInverseCovariance(bool hasInverseCovariance)
A set method to state that the Observable is a part of ObservablesWithInverseCovariance.
Definition: Observable.h:464
Observable::errgl
double errgl
The lower gaussian error of the observable.
Definition: Observable.h:488
Observable::setFilename
void setFilename(std::string filename_i)
Definition: Observable.h:217
Observable::filename
std::string filename
The name of the file containing the experimental likelihood for the observable.
Definition: Observable.h:483
Observable::bin_max
double bin_max
The maximum valus of the observable bin.
Definition: Observable.h:497
Observable::setLabel
void setLabel(std::string label)
A set method to fix the label for the observable.
Definition: Observable.h:278
Observable::setObsType
void setObsType(std::string &obsType_s)
A set method to set the Observable type.
Definition: Observable.h:395
Observable::distr
std::string distr
The name of the distribution of the the observable.
Definition: Observable.h:482
Observable::getName
std::string getName() const
A get method to access the name of the observable.
Definition: Observable.h:323
Observable::setTMCMC
void setTMCMC(bool tMCMC)
A set method to fix the observable's inclusion in the MCMC listing.
Definition: Observable.h:359
Observable::setMax
void setMax(double max)
A set method to fix the maximum value for the observable.
Definition: Observable.h:296
Observable::LogGaussian
double LogGaussian(double x, double ave, double sigma)
Definition: Observable.cpp:147
Observable::getMax
double getMax() const
A get method to access the maximum value of the observable.
Definition: Observable.h:287
Observable::setHistoname
void setHistoname(std::string histoname_i)
A set method to set the name of the histogram containing the likelihood.
Definition: Observable.h:260
Observable::inhisto
TH1D * inhisto
1D Histogram containing the experimental likelihood for the observable
Definition: Observable.h:494
Observable::bin_min
double bin_min
The minimum value of the observable bin.
Definition: Observable.h:496
Observable::setTho
void setTho(ThObservable *tho_i, double bmin, double bmax)
A set method to fix the pointer to object of type ThObservable.
Definition: Observable.h:426