a Code for the Combination of Indirect and Direct Constraints on High Energy Physics Models Logo
Observable2D Class Reference

A class for analyzing observables pairwise. More...

#include <Observable2D.h>

+ Inheritance diagram for Observable2D:

Detailed Description

A class for analyzing observables pairwise.

Author
HEPfit Collaboration

The class for building a pair of observables and storing their different parameters read from the SomeModel.conf file or specified by the user. The names (thname) of the observables have to correspond to the allowed names of observables listed in the ThFactory class.

Definition at line 24 of file Observable2D.h.

Public Member Functions

double computeTheoryValue2 ()
 A method to access the computed theory value of the second observable. More...
 
virtual double computeWeight ()
 A method to compute the weight associated with the observable. More...
 
virtual double computeWeight (double th1, double th2)
 A method to compute the weight associated with the observable. More...
 
double getAve2 () const
 A get method to access the average value of the second observable. More...
 
double getErrf2 () const
 A get method to access the flat error of the second observable. More...
 
double getErrg2 () const
 A get method to access the Gaussian error of the second observble. More...
 
std::string getLabel2 () const
 A get method to access the label for the second observable. More...
 
double getMax2 () const
 A get method to access the maximum value of the second observable. More...
 
double getMin2 () const
 A get method to access the minimum value of the second observable. More...
 
std::string getObsType2 () const
 
std::string getThname2 () const
 A get method to access the thname of the second observable as defined in ThFactory class. More...
 
ThObservablegetTho2 () const
 A get method to access the pointer to the object of the ThObservable class for the second observable. More...
 
bool isEOF ()
 A method to check if the end of file has been reached. More...
 
 Observable2D ()
 The default constructor. More...
 
 Observable2D (const Observable &o1d)
 A conversion constructor. Constructs Observable2D with just one observable. More...
 
 Observable2D (const Observable2D &orig)
 The copy constructor. More...
 
 Observable2D (const std::string name_i, const std::string thname_i, const std::string thname2_i, const std::string label_i, const std::string label2_i, const bool tMCMC_i, const double min_i, const double max_i, const double min2_i, const double max2_i, ThObservable *tho_i, ThObservable *tho2_i)
 Constructor. More...
 
int ParseObservable2D (std::string &type, boost::tokenizer< boost::char_separator< char > > *tok, boost::tokenizer< boost::char_separator< char > >::iterator &beg, std::string &infilename, std::ifstream &ifile, int lineNo, int rank)
 
void setAve2 (double ave2)
 A set method to fix the average value of the second observable. More...
 
void setErrf2 (double errf2)
 A set method to fix the flat error of the second observable. More...
 
void setErrg2 (double errg2)
 A set method to fix the gaussian error of the observable. More...
 
void setLabel2 (std::string label2)
 A set method to fix the label for the second observable. More...
 
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 read. More...
 
void setMax2 (double max2)
 A set method to fix the maximum value for the second observable. More...
 
void setMin2 (double min2)
 A set method to fix the minimum value for the second observable. More...
 
void setObsType2 (std::string &obsType2_i)
 
void setThname2 (std::string thname2)
 A set method to fix the name of the second observable as listed in ThFactory class. More...
 
void setTho1Tho2 (ThObservable *tho1_i, ThObservable *tho2_i)
 A set method to fix the pointer to object of type ThObservable class for the second observable. More...
 
void setTho2 (ThObservable *tho2_i)
 A set method to fix the pointer to object of type ThObservable class for the second observable. More...
 
virtual ~Observable2D ()
 The default destructor. More...
 
- Public Member Functions inherited from Observable
double computeTheoryValue ()
 A method to access the computed theory value of the observable. More...
 
virtual double computeWeight (double th)
 A method to compute the weight associated with the observable. More...
 
virtual double computeWeight (double th, double ave_i, double errg_i, double errf_i)
 A method to compute the weight associated with the observable. More...
 
double getAve () const
 A get method to access the average value of the observable. More...
 
std::string getDistr () const
 A get method to access the name of the distribution of the observable. More...
 
double getErrf () const
 A get method to access the flat error of the observable. More...
 
double getErrg () const
 A get method to access the Gaussian error of the observble. More...
 
std::string getFilename () const
 A get method to access the filename of the observables experimental likelihood file. More...
 
std::string getHistoname () const
 A get method to access the name for the histogram of the observable. More...
 
std::string getLabel () const
 A get method to access the label for the observable. More...
 
double getMax () const
 A get method to access the maximum value of the observable. More...
 
double getMin () const
 A get method to access the minimum value of the observable. More...
 
std::string getName () const
 A get method to access the name of the observable. More...
 
virtual int getNChannels ()
 
virtual int getNTheoryValues ()
 
std::string getObsType () const
 A get method to get the Observable type. More...
 
virtual void getTheoryValues (std::vector< double > &theoryValues_i)
 
std::string getThname () const
 A get method to access the thname of the observable as defined in ThFactory class. More...
 
ThObservablegetTho () const
 A get method to access the pointer to the object of the ThObservable class. More...
 
virtual bool isNew ()
 
bool isTMCMC () const
 A method to check if the observable is listed for MCMC. More...
 
bool isWriteChain () const
 A method to check if the observable is listed for writing chains. More...
 
double LogGaussian (double x, double ave, double sigma)
 
double LogSplitGaussian (double x, double ave, double errl, double errr)
 
 Observable ()
 The default constructor. More...
 
 Observable (const Observable &orig)
 The copy constructor. More...
 
 Observable (const std::string name_i, const std::string thname_i, const std::string label_i, const bool tMCMC_i, const double min_i, const double max_i, ThObservable *tho_i)
 Constructor. More...
 
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. More...
 
void setAve (double ave)
 A set method to fix the average value of the observable. More...
 
void setDistr (std::string distr)
 A set method to fix the name of the distribution of the observable. More...
 
void setErrf (double errf)
 A set method to fix the flat error of the observable. More...
 
void setErrg (double errg)
 A set method to fix the gaussian error of the observable. More...
 
void setErrgl (double errgl)
 A set method to fix the left Gaussian error of the observable. More...
 
void setErrgr (double errgr)
 A set method to fix the right Gaussian error of the observable. More...
 
void setFilename (std::string filename_i)
 
void setHasInverseCovariance (bool hasInverseCovariance)
 A set method to state that the Observable is a part of ObservablesWithInverseCovariance. More...
 
void setHistoname (std::string histoname_i)
 A set method to set the name of the histogram containing the likelihood. More...
 
void setLabel (std::string label)
 A set method to fix the label for the observable. More...
 
void setMax (double max)
 A set method to fix the maximum value for the observable. More...
 
void setMin (double min)
 A set method to fix the minimum value for the observable. More...
 
void setName (std::string name)
 A set method to fix the name for the observable. More...
 
void setObsType (std::string &obsType_s)
 A set method to set the Observable type. More...
 
virtual void setParametricLikelihood (std::string filename)
 A set method to set a parametric likelihood reading parameters from a file. More...
 
virtual void setParametricLikelihood (std::string filename, std::vector< ThObservable * > thObsV)
 
void setThname (std::string thname)
 A set method to fix the name of the observable as listed in ThFactory class. More...
 
void setTho (ThObservable *tho_i)
 A set method to fix the pointer to object of type ThObservable. More...
 
void setTho (ThObservable *tho_i, double bmin, double bmax)
 A set method to fix the pointer to object of type ThObservable. More...
 
void setTMCMC (bool tMCMC)
 A set method to fix the observable's inclusion in the MCMC listing. More...
 
virtual ~Observable ()
 The default destructor. More...
 

Private Attributes

double ave2
 The average value of the second observable. More...
 
std::vector< double > bin_max
 The maximum value of the bin. More...
 
std::vector< double > bin_min
 The minimum value of the bin. More...
 
double errf2
 the flat error of the second observable. More...
 
double errg2
 The Gaussian error of the second observable. More...
 
double errgl2
 The left Gaussian error of the second observable. More...
 
double errgr2
 The right Gaussian error of the second observable. More...
 
std::string filepath
 The path to the file being parsed. More...
 
TH2D * inhisto2d
 2D Histogram containing the experimental likelihood for the observable. More...
 
bool IsEOF
 A bolean that is true if the end of file is reached. More...
 
int iterationNo2
 Counts the iteration to help with caching. More...
 
std::string label2
 A label for the second observable. More...
 
double max2
 The maximum valus of the second observable. More...
 
double min2
 The minimum value of the second observable. More...
 
std::string obsType2
 Type of the second Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable. More...
 
std::string thname2
 The name for the second observable as fixed in the ThObservable() class. More...
 
ThObservabletho2
 A pointer to an object of the ThObservable class. More...
 
double thValue2
 The theory value of the second observable. More...
 

Additional Inherited Members

- Protected Attributes inherited from Observable
double ave
 The average value of the observable. More...
 
double bin_max
 The maximum valus of the observable bin. More...
 
double bin_min
 The minimum value of the observable bin. More...
 
std::string distr
 The name of the distribution of the the observable. More...
 
double errf
 The flat error of the observable. More...
 
double errg
 The gaussian error of the observable. More...
 
double errgl
 The lower gaussian error of the observable. More...
 
double errgr
 The upper gaussian error of the observable. More...
 
std::string filename
 The name of the file containing the experimental likelihood for the observable. More...
 
bool hasInverseCovariance
 
std::string histoname
 The name of the histogram for the observable. More...
 
TH1D * inhisto
 1D Histogram containing the experimental likelihood for the observable More...
 
int iterationNo
 A counter for the interation that helps with the observable caching. More...
 
std::string label
 A label for the observable. More...
 
double max
 The maximum valus of the observable. More...
 
double min
 The minimum value of the observable. More...
 
std::string name
 A name for the observable. More...
 
std::string obsType
 Type of the Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable. More...
 
std::string thname
 The name for the observable as fixed in the ThObservable class. More...
 
ThObservabletho
 A pointer of to the object of the ThObservables class. More...
 
double thValue
 The theory value of the first observable. More...
 
bool tMCMC
 The flag to include or exclude the observable from the MCMC run. More...
 
bool writeChain
 The flag to write the chain for the observable from the MCMC run. More...
 

Constructor & Destructor Documentation

◆ Observable2D() [1/4]

Observable2D::Observable2D ( const std::string  name_i,
const std::string  thname_i,
const std::string  thname2_i,
const std::string  label_i,
const std::string  label2_i,
const bool  tMCMC_i,
const double  min_i,
const double  max_i,
const double  min2_i,
const double  max2_i,
ThObservable tho_i,
ThObservable tho2_i 
)

Constructor.

Parameters
[in]name_ia given name for the observable pair
[in]thname_ithe thname for the first observable fixed in ThFactory
[in]thname2_ithe thname for the second observable fixed in ThFactory
[in]label_ithe label assigned to the first observable
[in]label2_ithe label assigned to the second observable
[in]tMCMC_iboolean flag to indicate inclusion in MCMC
[in]min_iminimum value for the first observable
[in]max_imaximum value for the first observable
[in]min2_iminimum value for the second observable
[in]max2_imaximum value for the second observable
[in]tho_ia pointer to an object of type ThObservable for the first observable
[in]tho2_ia pointer to an object of type ThObservable for the second observable

Definition at line 15 of file Observable2D.cpp.

27: Observable(name_i, thname_i, label_i, tMCMC_i, min_i, max_i, tho_i),
28 bin_min(2, 0.),
29 bin_max(2, 0.)
30{
31 thname2 = thname2_i;
32 label2 = label2_i;
33 min2 = min2_i;
34 max2 = max2_i;
35 tho2 = tho2_i;
36 obsType2 = "";
37 filepath = "";
38 iterationNo2 = std::numeric_limits<int>::max();
39 IsEOF = false;
40}
double max2
The maximum valus of the second observable.
Definition: Observable2D.h:294
std::string filepath
The path to the file being parsed.
Definition: Observable2D.h:305
std::string thname2
The name for the second observable as fixed in the ThObservable() class.
Definition: Observable2D.h:291
std::string label2
A label for the second observable.
Definition: Observable2D.h:292
bool IsEOF
A bolean that is true if the end of file is reached.
Definition: Observable2D.h:308
int iterationNo2
Counts the iteration to help with caching.
Definition: Observable2D.h:306
ThObservable * tho2
A pointer to an object of the ThObservable class.
Definition: Observable2D.h:301
std::vector< double > bin_max
The maximum value of the bin.
Definition: Observable2D.h:304
double min2
The minimum value of the second observable.
Definition: Observable2D.h:293
std::string obsType2
Type of the second Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable,...
Definition: Observable2D.h:300
std::vector< double > bin_min
The minimum value of the bin.
Definition: Observable2D.h:303
Observable()
The default constructor.
Definition: Observable.cpp:75

◆ Observable2D() [2/4]

Observable2D::Observable2D ( )

The default constructor.

Definition at line 58 of file Observable2D.cpp.

59: Observable(),
60 bin_min(2, 0.),
61 bin_max(2, 0.)
62{
63 thname2 = "";
64 label2 = "";
65 min2 = 0.;
66 max2 = 0.;
67 tho2 = NULL;
68 obsType2 = "";
69 filepath = "";
70 iterationNo2 = std::numeric_limits<int>::max();
71 IsEOF = false;
72}

◆ Observable2D() [3/4]

Observable2D::Observable2D ( const Observable o1d)

A conversion constructor. Constructs Observable2D with just one observable.

Definition at line 42 of file Observable2D.cpp.

43: Observable(o1d),
44 bin_min(2, 0.),
45 bin_max(2, 0.)
46{
47 thname2 = "";
48 label2 = "";
49 min2 = 0.;
50 max2 = 0.;
51 tho2 = NULL;
52 obsType2 = "";
53 filepath = "";
54 iterationNo2 = std::numeric_limits<int>::max();
55 IsEOF = false;
56}

◆ Observable2D() [4/4]

Observable2D::Observable2D ( const Observable2D orig)

The copy constructor.

Definition at line 74 of file Observable2D.cpp.

75: Observable(orig.name, orig.thname, orig.label, orig.tMCMC, orig.min, orig.max, orig.tho),
76 bin_min(orig.bin_min),
77 bin_max(orig.bin_max)
78{
79
80 distr = orig.distr;
81 filename = orig.filename;
82 histoname = orig.histoname;
83 ave = orig.ave;
84 errg = orig.errg;
85 errg2 = orig.errg2;
86 errf = orig.errf;
87 errf2 = orig.errf2;
88 errgl = orig.errgl;
89 errgl2 = orig.errgl2;
90 errgr = orig.errgr;
91 errgr2 = orig.errgr2;
92
93 thname2 = orig.thname2;
94 label2 = orig.label2;
95 min2 = orig.min2;
96 max2 = orig.max2;
97 tho2 = orig.tho2;
98 filepath = orig.filepath;
100 IsEOF = orig.IsEOF;
101 inhisto2d = orig.inhisto2d;
102}
double errf2
the flat error of the second observable.
Definition: Observable2D.h:297
double errgr2
The right Gaussian error of the second observable.
Definition: Observable2D.h:299
double errgl2
The left Gaussian error of the second observable.
Definition: Observable2D.h:298
double errg2
The Gaussian error of the second observable.
Definition: Observable2D.h:296
TH2D * inhisto2d
2D Histogram containing the experimental likelihood for the observable.
Definition: Observable2D.h:302
bool tMCMC
The flag to include or exclude the observable from the MCMC run.
Definition: Observable.h:492
std::string thname
The name for the observable as fixed in the ThObservable class.
Definition: Observable.h:480
std::string distr
The name of the distribution of the the observable.
Definition: Observable.h:482
double errf
The flat error of the observable.
Definition: Observable.h:487
double max
The maximum valus of the observable.
Definition: Observable.h:491
double ave
The average value of the observable.
Definition: Observable.h:485
std::string label
A label for the observable.
Definition: Observable.h:481
double min
The minimum value of the observable.
Definition: Observable.h:490
double errgr
The upper gaussian error of the observable.
Definition: Observable.h:489
double errg
The gaussian error of the observable.
Definition: Observable.h:486
std::string histoname
The name of the histogram for the observable.
Definition: Observable.h:484
std::string filename
The name of the file containing the experimental likelihood for the observable.
Definition: Observable.h:483
ThObservable * tho
A pointer of to the object of the ThObservables class.
Definition: Observable.h:478
double errgl
The lower gaussian error of the observable.
Definition: Observable.h:488
std::string name
A name for the observable.
Definition: Observable.h:479

◆ ~Observable2D()

Observable2D::~Observable2D ( )
virtual

The default destructor.

Definition at line 104 of file Observable2D.cpp.

105{}

Member Function Documentation

◆ computeTheoryValue2()

double Observable2D::computeTheoryValue2 ( )

A method to access the computed theory value of the second observable.

Definition at line 107 of file Observable2D.cpp.

108{
110 return thValue2;
111 } else {
114 return thValue2;
115 }
116}
double thValue2
The theory value of the second observable.
Definition: Observable2D.h:307
const int getIterationNo() const
const StandardModel & getModel()
A get method to get the model.
Definition: ThObservable.h:100
virtual double computeThValue()=0
A member to be overloaded by the respective theory observable. class that calculates the value of the...

◆ computeWeight() [1/2]

virtual double Observable2D::computeWeight ( )
inlinevirtual

A method to compute the weight associated with the observable.

Reimplemented from Observable.

Definition at line 212 of file Observable2D.h.

213 {
215 }
double computeTheoryValue2()
A method to access the computed theory value of the second observable.
virtual double computeWeight()
A method to compute the weight associated with the observable.
Definition: Observable2D.h:212
double computeTheoryValue()
A method to access the computed theory value of the observable.
Definition: Observable.cpp:130

◆ computeWeight() [2/2]

double Observable2D::computeWeight ( double  th1,
double  th2 
)
virtual

A method to compute the weight associated with the observable.

Parameters
[in]th1the theoretical value of the first observable
[in]th2the theoretical value of the second observable

Reimplemented from Observable.

Definition at line 139 of file Observable2D.cpp.

140{
141 double logprob;
142 if (distr.compare("file") == 0) {
143 int i = inhisto2d->FindBin(th1, th2);
144 if (inhisto2d->IsBinOverflow(i) || inhisto2d->IsBinUnderflow(i))
145 logprob = log(0.);
146 else
147 logprob = log(inhisto2d->GetBinContent(i));
148 //logprob = log(h->GetBinContent(h->GetXaxis()->FindBin(th1),h->GetYaxis()->FindBin(th2)));
149 } else if (distr.compare("weight") == 0) {
150 double wt2;
151 if (obsType2.compare("AsyGausObservable") == 0) wt2 = Observable::LogSplitGaussian(th2, ave2, errgl, errgr);
152 else wt2 = Observable::computeWeight(th2, ave2, errg2, errf2);
153 logprob = Observable::computeWeight(th1) + wt2;
154 } else
155 throw std::runtime_error("ERROR: 2D MonteCarloEngine::Weight() called without file for "
156 + name);
157 return (logprob);
158}
double ave2
The average value of the second observable.
Definition: Observable2D.h:295
virtual double computeWeight()
A method to compute the weight associated with the observable.
Definition: Observable.h:113
double LogSplitGaussian(double x, double ave, double errl, double errr)
Definition: Observable.cpp:141

◆ getAve2()

double Observable2D::getAve2 ( ) const
inline

A get method to access the average value of the second observable.

Returns
the average value of the observable

Definition at line 231 of file Observable2D.h.

232 {
233 return ave2;
234 }

◆ getErrf2()

double Observable2D::getErrf2 ( ) const
inline

A get method to access the flat error of the second observable.

Returns
the flat error of the observable

Definition at line 249 of file Observable2D.h.

250 {
251 return errf2;
252 }

◆ getErrg2()

double Observable2D::getErrg2 ( ) const
inline

A get method to access the Gaussian error of the second observble.

Returns
the Gauissian error of the observable

Definition at line 267 of file Observable2D.h.

268 {
269 return errg2;
270 }

◆ getLabel2()

std::string Observable2D::getLabel2 ( ) const
inline

A get method to access the label for the second observable.

Returns
the label for the second observable

Definition at line 101 of file Observable2D.h.

102 {
103 return label2;
104 }

◆ getMax2()

double Observable2D::getMax2 ( ) const
inline

A get method to access the maximum value of the second observable.

Returns
the maximum value of the second observable

Definition at line 119 of file Observable2D.h.

120 {
121 return max2;
122 }

◆ getMin2()

double Observable2D::getMin2 ( ) const
inline

A get method to access the minimum value of the second observable.

Returns
the minimum value of the second observable

Definition at line 137 of file Observable2D.h.

138 {
139 return min2;
140 }

◆ getObsType2()

std::string Observable2D::getObsType2 ( ) const
inline

Definition at line 222 of file Observable2D.h.

223 {
224 return obsType2;
225 }

◆ getThname2()

std::string Observable2D::getThname2 ( ) const
inline

A get method to access the thname of the second observable as defined in ThFactory class.

Returns
thname the name of the second observable as listed in ThFactory() class

Definition at line 155 of file Observable2D.h.

156 {
157 return thname2;
158 }

◆ getTho2()

ThObservable * Observable2D::getTho2 ( ) const
inline

A get method to access the pointer to the object of the ThObservable class for the second observable.

Returns
pointer to the object of type ThObservable() for the second observable

Definition at line 174 of file Observable2D.h.

175 {
176 return tho2;
177 }

◆ isEOF()

bool Observable2D::isEOF ( )
inline

A method to check if the end of file has been reached.

Returns
a boolean which is true if the end of file has been reached

Definition at line 285 of file Observable2D.h.

286 {
287 return IsEOF;
288 }

◆ ParseObservable2D()

int Observable2D::ParseObservable2D ( std::string &  type,
boost::tokenizer< boost::char_separator< char > > *  tok,
boost::tokenizer< boost::char_separator< char > >::iterator &  beg,
std::string &  infilename,
std::ifstream &  ifile,
int  lineNo,
int  rank 
)

Definition at line 160 of file Observable2D.cpp.

167{
168 if (infilename.find("\\/") == std::string::npos) filepath = infilename.substr(0, infilename.find_last_of("\\/") + 1);
169 if (std::distance(tok->begin(), tok->end()) < 12) {
170 setName(*beg);
171 ++beg;
172 if (std::distance(tok->begin(), tok->end()) < 4) {
173 if(rank == 0) throw std::runtime_error("ERROR: lack of information on " + name + " in " + infilename + " at line number" + boost::lexical_cast<std::string>(lineNo));
174 else sleep (2);
175 }
176 std::string toMCMC = *beg;
177 if (toMCMC.compare("MCMC") == 0)
178 setTMCMC(true);
179 else if (toMCMC.compare("noMCMC") == 0)
180 setTMCMC(false);
181 else {
182 if (rank == 0) throw std::runtime_error("ERROR: wrong MCMC flag in Observable2D" + name + " at line number:" + boost::lexical_cast<std::string>(lineNo) + " of file " + infilename + ".\n");
183 else sleep(2);
184 }
185
186 ++beg;
187 setDistr(*beg);
188 if (distr.compare("file") == 0) {
189 if (std::distance(tok->begin(), tok->end()) < 6) {
190 if(rank == 0) throw std::runtime_error("ERROR: lack of information on "+ *beg + " in " + infilename);
191 else sleep (2);
192 }
193 setFilename(filepath + *(++beg));
194 setHistoname(*(++beg));
195 }
196
197 std::vector<double> min(2, 0.);
198 std::vector<double> max(2, 0.);
199 std::vector<double> ave(2, 0.);
200 std::vector<double> errg(2, 0.);
201 std::vector<double> errf(2, 0.);
202 std::vector<double> errgl(2, 0.);
203 std::vector<double> errgr(2, 0.);
204 std::vector<std::string> thname(2, "");
205 std::vector<std::string> label(2, "");
206 std::vector<std::string> type2D(2, "");
207 std::string line;
208 size_t pos = 0;
209 boost::char_separator<char> sep(" \t");
210 for (int i = 0; i < 2; i++) {
211 IsEOF = getline(ifile, line).eof();
212 if (line.empty() || line.at(0) == '#') {
213 if (rank == 0) throw std::runtime_error("ERROR: no comments or empty lines in Observable2D please! In file " + infilename + " at line number:" + boost::lexical_cast<std::string>(lineNo) + ".\n");
214 else sleep(2);
215 }
216 lineNo++;
217 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
218 beg = mytok.begin();
219 type2D[i] = *beg;
220 if (type2D[i].compare("Observable") != 0 && type2D[i].compare("BinnedObservable") != 0 && type2D[i].compare("FunctionObservable") != 0 && type2D[i].compare("AsyGausObservable") != 0) {
221 if (rank == 0) throw std::runtime_error("ERROR: in line no." + boost::lexical_cast<std::string>(lineNo) + " of file " + infilename + ", expecting an Observable or BinnedObservable or FunctionObservable type here...\n");
222 else sleep(2);
223 }
224 ++beg;
225 thname[i] = *beg;
226 ++beg;
227 label[i] = *beg;
228 while ((pos = label[i].find("~", pos)) != std::string::npos)
229 label[i].replace(pos++, 1, " ");
230 ++beg;
231 min[i] = atof((*beg).c_str());
232 ++beg;
233 max[i] = atof((*beg).c_str());
234 if (distr.compare("weight") == 0) {
235 ++beg;
236 ave[i] = atof((*beg).c_str());
237 ++beg;
238 if (type.compare("AsyGausObservable") == 0) errgl[i] = atof((*beg).c_str());
239 else errg[i] = atof((*beg).c_str());
240 ++beg;
241 if (type.compare("AsyGausObservable") == 0) errgr[i] = atof((*beg).c_str());
242 else errf[i] = atof((*beg).c_str());
243 if (type.compare("AsyGausObservable") != 0 && errg[i] == 0. && errf[i] == 0.) {
244 if (rank == 0) throw std::runtime_error("ERROR: The Gaussian and flat error in weight for " + name + " cannot both be 0. in the " + infilename + " file, line number:" + boost::lexical_cast<std::string>(lineNo) + ".\n");
245 else sleep(2);
246 }
247 if (type.compare("AsyGausObservable") == 0 && errgl[i] == 0. && errgr[i] == 0.) {
248 if (rank == 0) throw std::runtime_error("ERROR: The left Gaussian and right Gaussian error in weight for " + name + " cannot both be 0. in the " + infilename + " file, line number:" + boost::lexical_cast<std::string>(lineNo) + ".\n");
249 else sleep(2);
250 }
251 } else if (distr.compare("noweight") == 0 || distr.compare("file") == 0) {
252 if (type2D[i].compare("BinnedObservable") == 0 || type2D[i].compare("FunctionObservable") == 0) {
253 ++beg;
254 ++beg;
255 ++beg;
256 }
257 } else {
258 if (rank == 0) throw std::runtime_error("ERROR: wrong distribution flag in " + name + " in file " + infilename + ".\n");
259 else sleep(2);
260 }
261 if (type2D[i].compare("BinnedObservable") == 0) {
262 ++beg;
263 bin_min[i] = atof((*beg).c_str());
264 ++beg;
265 bin_max[i] = atof((*beg).c_str());
266 } else if (type2D[i].compare("FunctionObservable") == 0) {
267 ++beg;
268 bin_min[i] = atof((*beg).c_str());
269 ++beg;
270 }
271 }
272 setObsType(type2D[0]);
273 obsType2 = type2D[1];
274 setThname(thname[0]);
275 thname2 = thname[1];
276 setLabel(label[0]);
277 label2 = label[1];
278 setMin(min[0]);
279 min2 = min[1];
280 setMax(max[0]);
281 max2= max[1];
282 setAve(ave[0]);
283 ave2 = ave[1];
284 setErrg(errg[0]);
285 errg2 = errg[1];
286 setErrf(errf[0]);
287 errf2 = errf[1];
288 setErrgl(errgl[0]);
289 errgl2 = errgl[1];
290 setErrgr(errgr[0]);
291 errgr2 = errgr[1];
292 if (distr.compare("file") == 0) {
294 if (rank == 0) std::cout << "added input histogram " << filename << "/" << histoname << std::endl;
295 }
296 return lineNo;
297 } else {
298 beg = ParseObservable(type, tok, beg, filepath, filename, rank);
299 ++beg;
300 std::string distr = *beg;
301 if (distr.compare("file") == 0) {
302 if (std::distance(tok->begin(), tok->end()) < 14) {
303 if (rank == 0) throw std::runtime_error("ERROR: lack of information on " + *beg + " in " + infilename + ".\n");
304 else sleep(2);
305 }
306 setFilename(filepath + *(++beg));
307 setHistoname(*(++beg));
309 if (rank == 0) std::cout << "added input histogram " << filename << "/" << histoname << std::endl;
310 } else if (distr.compare("noweight") == 0) {
311 } else {
312 if (rank == 0) throw std::runtime_error("ERROR: wrong distribution flag in " + name);
313 else sleep(2);
314 }
316 ++beg;
317 thname2 = *beg;
318 ++beg;
319 std::string label = *beg;
320 size_t pos = 0;
321 while ((pos = label.find("~", pos)) != std::string::npos)
322 label.replace(pos, 1, " ");
323 label2 = label;
324 ++beg;
325 min2 = atof((*beg).c_str());
326 ++beg;
327 max2 = atof((*beg).c_str());
328 ++beg;
329 if (beg != tok->end())
330 if (rank == 0) std::cout << "WARNING: unread information in observable2D " << name << std::endl;
331 return lineNo;
332 }
333}
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...
void setErrgl(double errgl)
A set method to fix the left Gaussian error of the observable.
Definition: Observable.h:194
void setErrgr(double errgr)
A set method to fix the right Gaussian error of the observable.
Definition: Observable.h:203
void setName(std::string name)
A set method to fix the name for the observable.
Definition: Observable.h:332
void setFilename(std::string filename_i)
Definition: Observable.h:217
void setAve(double ave)
A set method to fix the average value of the observable.
Definition: Observable.h:131
void setTMCMC(bool tMCMC)
A set method to fix the observable's inclusion in the MCMC listing.
Definition: Observable.h:359
void setMax(double max)
A set method to fix the maximum value for the observable.
Definition: Observable.h:296
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
void setThname(std::string thname)
A set method to fix the name of the observable as listed in ThFactory class.
Definition: Observable.h:377
void setLabel(std::string label)
A set method to fix the label for the observable.
Definition: Observable.h:278
void setErrg(double errg)
A set method to fix the gaussian error of the observable.
Definition: Observable.h:185
void setDistr(std::string distr)
A set method to fix the name of the distribution of the observable.
Definition: Observable.h:149
void setObsType(std::string &obsType_s)
A set method to set the Observable type.
Definition: Observable.h:395
void setHistoname(std::string histoname_i)
A set method to set the name of the histogram containing the likelihood.
Definition: Observable.h:260
void setErrf(double errf)
A set method to fix the flat error of the observable.
Definition: Observable.h:167
void setMin(double min)
A set method to fix the minimum value for the observable.
Definition: Observable.h:314

◆ setAve2()

void Observable2D::setAve2 ( double  ave2)
inline

A set method to fix the average value of the second observable.

Parameters
[in]ave2the average value of the observable

Definition at line 240 of file Observable2D.h.

241 {
242 this->ave2 = ave2;
243 }

◆ setErrf2()

void Observable2D::setErrf2 ( double  errf2)
inline

A set method to fix the flat error of the second observable.

Parameters
[in]errf2the flat error of the observable

Definition at line 258 of file Observable2D.h.

259 {
260 this->errf2 = errf2;
261 }

◆ setErrg2()

void Observable2D::setErrg2 ( double  errg2)
inline

A set method to fix the gaussian error of the observable.

Parameters
[in]errg2the Gaussian error of the observable

Definition at line 276 of file Observable2D.h.

277 {
278 this->errg2 = errg2;
279 }

◆ setLabel2()

void Observable2D::setLabel2 ( std::string  label2)
inline

A set method to fix the label for the second observable.

Parameters
[in]label2the label for the second observable

Definition at line 110 of file Observable2D.h.

111 {
112 this->label2 = label2;
113 }

◆ setLikelihoodFromHisto()

void Observable2D::setLikelihoodFromHisto ( std::string  filename,
std::string  histoname 
)
virtual

A set method to set the likelihood from which the experimental likelihood of the observable will be read.

Parameters
filenamethe name of the file
histonamethe name of the histogram

Reimplemented from Observable.

Definition at line 118 of file Observable2D.cpp.

119{
120 this->filename = filename;
121 this->histoname = histoname;
122 TFile *lik2 = new TFile((filename + ".root").c_str(), "read");
123 TH2D *htmp2 = (TH2D*) (lik2->Get(histoname.c_str()));
124 if (htmp2 == NULL)
125 throw std::runtime_error("ERROR: nonexistent histogram called "
126 + histoname
127 + " in " + filename + ".root");
128 inhisto2d = (TH2D *) htmp2->Clone((filename + "/" + histoname).c_str());
129 inhisto2d->SetDirectory(gROOT);
130 std::cout << "added 2D input histogram " << name << std::endl;
131 setMin(inhisto2d->GetXaxis()->GetXmin());
132 setMax(inhisto2d->GetXaxis()->GetXmax());
133 setMin2(inhisto2d->GetYaxis()->GetXmin());
134 setMax2(inhisto2d->GetYaxis()->GetXmax());
135 lik2->Close();
136 delete lik2;
137}
void setMin2(double min2)
A set method to fix the minimum value for the second observable.
Definition: Observable2D.h:146
void setMax2(double max2)
A set method to fix the maximum value for the second observable.
Definition: Observable2D.h:128

◆ setMax2()

void Observable2D::setMax2 ( double  max2)
inline

A set method to fix the maximum value for the second observable.

Parameters
[in]max2the maximum value for the second observable

Definition at line 128 of file Observable2D.h.

129 {
130 this->max2 = max2;
131 }

◆ setMin2()

void Observable2D::setMin2 ( double  min2)
inline

A set method to fix the minimum value for the second observable.

Parameters
[in]min2the minimum value for the second observable

Definition at line 146 of file Observable2D.h.

147 {
148 this->min2 = min2;
149 }

◆ setObsType2()

void Observable2D::setObsType2 ( std::string &  obsType2_i)
inline

Definition at line 217 of file Observable2D.h.

218 {
219 obsType2 = obsType2_i;
220 }

◆ setThname2()

void Observable2D::setThname2 ( std::string  thname2)
inline

A set method to fix the name of the second observable as listed in ThFactory class.

Parameters
[in]thname2the name of the second observable as listed in ThFactory class

Definition at line 164 of file Observable2D.h.

165 {
166 this->thname2 = thname2;
167 }

◆ setTho1Tho2()

void Observable2D::setTho1Tho2 ( ThObservable tho1_i,
ThObservable tho2_i 
)
inline

A set method to fix the pointer to object of type ThObservable class for the second observable.

Parameters
[in]tho2pointer to the object of type ThObservable() for the second observable

Definition at line 196 of file Observable2D.h.

197 {
198 setTho(tho1_i, bin_min[0], bin_max[0]);
199 setTho2(tho2_i);
200 }
void setTho2(ThObservable *tho2_i)
A set method to fix the pointer to object of type ThObservable class for the second observable.
Definition: Observable2D.h:184
void setTho(ThObservable *tho_i)
A set method to fix the pointer to object of type ThObservable.
Definition: Observable.h:413

◆ setTho2()

void Observable2D::setTho2 ( ThObservable tho2_i)
inline

A set method to fix the pointer to object of type ThObservable class for the second observable.

Parameters
[in]tho2pointer to the object of type ThObservable() for the second observable

Definition at line 184 of file Observable2D.h.

185 {
186 tho2 = tho2_i;
189 }
void setBinMax(double max)
A set method to set the maximum value of the bin.
Definition: ThObservable.h:73
void setBinMin(double min)
A set method to set the minimum value of the bin.
Definition: ThObservable.h:64

Member Data Documentation

◆ ave2

double Observable2D::ave2
private

The average value of the second observable.

Definition at line 295 of file Observable2D.h.

◆ bin_max

std::vector<double> Observable2D::bin_max
private

The maximum value of the bin.

Definition at line 304 of file Observable2D.h.

◆ bin_min

std::vector<double> Observable2D::bin_min
private

The minimum value of the bin.

Definition at line 303 of file Observable2D.h.

◆ errf2

double Observable2D::errf2
private

the flat error of the second observable.

Definition at line 297 of file Observable2D.h.

◆ errg2

double Observable2D::errg2
private

The Gaussian error of the second observable.

Definition at line 296 of file Observable2D.h.

◆ errgl2

double Observable2D::errgl2
private

The left Gaussian error of the second observable.

Definition at line 298 of file Observable2D.h.

◆ errgr2

double Observable2D::errgr2
private

The right Gaussian error of the second observable.

Definition at line 299 of file Observable2D.h.

◆ filepath

std::string Observable2D::filepath
private

The path to the file being parsed.

Definition at line 305 of file Observable2D.h.

◆ inhisto2d

TH2D* Observable2D::inhisto2d
private

2D Histogram containing the experimental likelihood for the observable.

Definition at line 302 of file Observable2D.h.

◆ IsEOF

bool Observable2D::IsEOF
private

A bolean that is true if the end of file is reached.

Definition at line 308 of file Observable2D.h.

◆ iterationNo2

int Observable2D::iterationNo2
private

Counts the iteration to help with caching.

Definition at line 306 of file Observable2D.h.

◆ label2

std::string Observable2D::label2
private

A label for the second observable.

Definition at line 292 of file Observable2D.h.

◆ max2

double Observable2D::max2
private

The maximum valus of the second observable.

Definition at line 294 of file Observable2D.h.

◆ min2

double Observable2D::min2
private

The minimum value of the second observable.

Definition at line 293 of file Observable2D.h.

◆ obsType2

std::string Observable2D::obsType2
private

Type of the second Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable.

Definition at line 300 of file Observable2D.h.

◆ thname2

std::string Observable2D::thname2
private

The name for the second observable as fixed in the ThObservable() class.

Definition at line 291 of file Observable2D.h.

◆ tho2

ThObservable* Observable2D::tho2
private

A pointer to an object of the ThObservable class.

Definition at line 301 of file Observable2D.h.

◆ thValue2

double Observable2D::thValue2
private

The theory value of the second observable.

Definition at line 307 of file Observable2D.h.


The documentation for this class was generated from the following files: