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

A class for observables. More...

#include <Observable.h>

+ Inheritance diagram for Observable:

Detailed Description

A class for observables.

Author
HEPfit Collaboration

The class for building an observable and storing its different parameters read from the SomeModel.conf file or specified by the user. The name (thname) of the observable has to correspond to the allowed name of observables listed in the ThFactory class.

Definition at line 28 of file Observable.h.

Public Member Functions

double computeTheoryValue ()
 A method to access the computed theory value of the observable. More...
 
virtual double computeWeight ()
 A method to compute the weight associated with 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...
 
virtual double computeWeight (double th1, double th2)
 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...
 
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 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...
 

Protected Attributes

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...
 

Friends

std::ostream & operator<< (std::ostream &output, const Observable &o)
 Befriending of the std::ostream operator << to generate an output stream for printing the observables details. More...
 

Constructor & Destructor Documentation

◆ Observable() [1/3]

Observable::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.

Parameters
[in]name_ia given name for the observable
[in]thname_ithe thname for the observable fixed in ThFactory()
[in]label_ithe label assigned to the observable
[in]tMCMC_iboolean flag to indicate inclusion in MCMC
[in]min_iminimum value for the observable
[in]max_imaximum value for the observable
[in]tho_ia pointer to an object of type ThObservable

Definition at line 18 of file Observable.cpp.

25{
26 name = name_i;
27 thname = thname_i;
28 label = label_i;
29 min = min_i;
30 max = max_i;
31 tMCMC = tMCMC_i;
32 tho = tho_i;
33 distr = "";
34 filename = "";
35 histoname = "";
36 ave = 0.;
37 errg = 0.;
38 errf = 0.;
39 errgl = 0.;
40 errgr = 0.;
41 obsType = "";
42 bin_min = 0.;
43 bin_max = 0.;
44 iterationNo = std::numeric_limits<int>::max();
45 writeChain = false;
47}
bool tMCMC
The flag to include or exclude the observable from the MCMC run.
Definition: Observable.h:492
int iterationNo
A counter for the interation that helps with the observable caching.
Definition: Observable.h:498
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
std::string obsType
Type of the Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable...
Definition: Observable.h:495
bool writeChain
The flag to write the chain for the observable from the MCMC run.
Definition: Observable.h:493
double ave
The average value of the observable.
Definition: Observable.h:485
double bin_min
The minimum value of the observable bin.
Definition: Observable.h:496
bool hasInverseCovariance
Definition: Observable.h:500
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
double bin_max
The maximum valus of the observable bin.
Definition: Observable.h:497

◆ Observable() [2/3]

Observable::Observable ( const Observable orig)

The copy constructor.

Definition at line 49 of file Observable.cpp.

50{
51 name = orig.name;
52 thname = orig.thname;
53 label = orig.label;
54 min = orig.min;
55 max = orig.max;
56 tMCMC = orig.tMCMC;
57 tho = orig.tho;
58 distr = orig.distr;
59 filename = orig.filename;
60 histoname = orig.histoname;
61 ave = orig.ave;
62 errg = orig.errg;
63 errf = orig.errf;
64 errgl = orig.errgl;
65 errgr = orig.errgr;
66 obsType = orig.obsType;
67 bin_min = orig.bin_min;
68 bin_min = orig.bin_max;
70 inhisto = orig.inhisto;
73}
TH1D * inhisto
1D Histogram containing the experimental likelihood for the observable
Definition: Observable.h:494

◆ Observable() [3/3]

Observable::Observable ( )

The default constructor.

Definition at line 75 of file Observable.cpp.

76{
77 name = "";
78 thname = "";
79 label = "";
80 min = 0.;
81 max = 0.;
82 tMCMC = false;
83 tho = NULL;
84 distr = "";
85 filename = "";
86 histoname = "";
87 ave = 0.;
88 errg = 0.;
89 errf = 0.;
90 errgl = 0.;
91 errgr = 0.;
92 obsType = "";
93 bin_min = 0.;
94 bin_max = 0.;
95 iterationNo = std::numeric_limits<int>::max();
96 writeChain = false;
98}

◆ ~Observable()

Observable::~Observable ( )
virtual

The default destructor.

Definition at line 100 of file Observable.cpp.

100{}

Member Function Documentation

◆ computeTheoryValue()

double Observable::computeTheoryValue ( )

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

Definition at line 130 of file Observable.cpp.

131{
133 return thValue;
134 } else {
137 return thValue;
138 }
139}
double thValue
The theory value of the first observable.
Definition: Observable.h:499
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/4]

virtual double Observable::computeWeight ( )
inlinevirtual

A method to compute the weight associated with the observable.

Reimplemented in HiggsObservable, and Observable2D.

Definition at line 113 of file Observable.h.

114 {
116 }
virtual double computeWeight()
A method to compute the weight associated with the observable.
Definition: Observable.h:113
double computeTheoryValue()
A method to access the computed theory value of the observable.
Definition: Observable.cpp:130

◆ computeWeight() [2/4]

double Observable::computeWeight ( double  th)
virtual

A method to compute the weight associated with the observable.

Parameters
[in]ththe theoretical value of the observable

Definition at line 152 of file Observable.cpp.

153{
154 double logprob;
155 if (distr.compare("weight") == 0) {
156 if (getObsType().compare("AsyGausObservable") == 0) logprob = LogSplitGaussian(th, ave, errgl, errgr);
157 else {
158 if (errf == 0.)
159 logprob = LogGaussian(th, ave, errg);
160 else if (errg == 0.) {
161 if (th < ave + errf && th > ave - errf)
162 logprob = 1.;
163 else
164 logprob = log(0.);
165 } else
166 logprob = log(TMath::Erf((th - ave + errf) / sqrt(2.) / errg)
167 - TMath::Erf((th - ave - errf) / sqrt(2.) / errg));
168 }
169 } else if (distr.compare("file") == 0) {
170 int i = inhisto->FindBin(th);
171 if (inhisto->IsBinOverflow(i) || inhisto->IsBinUnderflow(i))
172 logprob = log(0.);
173 else
174 logprob = log(inhisto->GetBinContent(i));
175 //logprob = log(h->GetBinContent(h->FindBin(th)));
176 } else
177 throw std::runtime_error("ERROR: MonteCarloEngine::Weight() called without weight for "
178 + name);
179 return (logprob);
180}
double LogGaussian(double x, double ave, double sigma)
Definition: Observable.cpp:147
std::string getObsType() const
A get method to get the Observable type.
Definition: Observable.h:404
double LogSplitGaussian(double x, double ave, double errl, double errr)
Definition: Observable.cpp:141

◆ computeWeight() [3/4]

double Observable::computeWeight ( double  th,
double  ave_i,
double  errg_i,
double  errf_i 
)
virtual

A method to compute the weight associated with the observable.

Parameters
[in]ththe theoretical value of the observable
[in]ave_ithe average value of the observable
[in]errg_ithe Gaussian error of the observable
[in]errf_ithe flat error of the observable

Definition at line 182 of file Observable.cpp.

183{
184 double logprob;
185 if (distr.compare("weight") == 0) {
186 if (errf_i == 0.)
187 logprob = LogGaussian(th, ave_i, errg_i);
188 else if (errg_i == 0.) {
189 if (th < ave_i + errf_i && th > ave_i - errf_i)
190 logprob = 1.;
191 else
192 logprob = log(0.);
193 } else
194 logprob = log(TMath::Erf((th - ave_i + errf_i) / sqrt(2.) / errg_i)
195 - TMath::Erf((th - ave_i - errf_i) / sqrt(2.) / errg_i));
196 } else
197 throw std::runtime_error("ERROR: MonteCarloEngine::Weight() called without weight for "
198 + name);
199 return (logprob);
200}

◆ computeWeight() [4/4]

virtual double Observable::computeWeight ( double  th1,
double  th2 
)
inlinevirtual

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 in Observable2D.

Definition at line 105 of file Observable.h.

106 {
107 return 0.0;
108 };

◆ getAve()

double Observable::getAve ( ) const
inline

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

Returns
the average value of the observable

Definition at line 122 of file Observable.h.

123 {
124 return ave;
125 }

◆ getDistr()

std::string Observable::getDistr ( ) const
inline

A get method to access the name of the distribution of the observable.

Returns
the name of the distribution of the observable

Definition at line 140 of file Observable.h.

141 {
142 return distr;
143 }

◆ getErrf()

double Observable::getErrf ( ) const
inline

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

Returns
the flat error of the observable

Definition at line 158 of file Observable.h.

159 {
160 return errf;
161 }

◆ getErrg()

double Observable::getErrg ( ) const
inline

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

Returns
the Gauissian error of the observable

Definition at line 176 of file Observable.h.

177 {
178 return errg;
179 }

◆ getFilename()

std::string Observable::getFilename ( ) const
inline

A get method to access the filename of the observables experimental likelihood file.

Returns
the name of the file

Definition at line 212 of file Observable.h.

213 {
214 return filename;
215 }

◆ getHistoname()

std::string Observable::getHistoname ( ) const
inline

A get method to access the name for the histogram of the observable.

Returns
the name of the histogram for the observable

Definition at line 251 of file Observable.h.

252 {
253 return histoname;
254 }

◆ getLabel()

std::string Observable::getLabel ( ) const
inline

A get method to access the label for the observable.

Returns
the label for the observable

Definition at line 269 of file Observable.h.

270 {
271 return label;
272 }

◆ getMax()

double Observable::getMax ( ) const
inline

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

Returns
the maximum value of the observable

Definition at line 287 of file Observable.h.

288 {
289 return max;
290 }

◆ getMin()

double Observable::getMin ( ) const
inline

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

Returns
the minimum value of the observable

Definition at line 305 of file Observable.h.

306 {
307 return min;
308 }

◆ getName()

std::string Observable::getName ( ) const
inline

A get method to access the name of the observable.

Returns
the name of the observable

Definition at line 323 of file Observable.h.

324 {
325 return name;
326 }

◆ getNChannels()

virtual int Observable::getNChannels ( )
inlinevirtual

Reimplemented in HiggsObservable.

Definition at line 456 of file Observable.h.

456{ return 0; };

◆ getNTheoryValues()

virtual int Observable::getNTheoryValues ( )
inlinevirtual

Reimplemented in HiggsObservable.

Definition at line 454 of file Observable.h.

454{ return 0; };

◆ getObsType()

std::string Observable::getObsType ( ) const
inline

A get method to get the Observable type.

Returns
a string containing the observable type

Definition at line 404 of file Observable.h.

405 {
406 return obsType;
407 }

◆ getTheoryValues()

virtual void Observable::getTheoryValues ( std::vector< double > &  theoryValues_i)
inlinevirtual

Reimplemented in HiggsObservable.

Definition at line 452 of file Observable.h.

452{};

◆ getThname()

std::string Observable::getThname ( ) const
inline

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

Returns
thname the name of the observable as listed in ThFactory class

Definition at line 368 of file Observable.h.

369 {
370 return thname;
371 }

◆ getTho()

ThObservable * Observable::getTho ( ) const
inline

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

Returns
pointer to the object of type ThObservable

Definition at line 386 of file Observable.h.

387 {
388 return tho;
389 }

◆ isNew()

virtual bool Observable::isNew ( )
inlinevirtual

Reimplemented in HiggsObservable.

Definition at line 458 of file Observable.h.

458{ return false; };

◆ isTMCMC()

bool Observable::isTMCMC ( ) const
inline

A method to check if the observable is listed for MCMC.

Returns
true or false

Definition at line 341 of file Observable.h.

342 {
343 return tMCMC;
344 }

◆ isWriteChain()

bool Observable::isWriteChain ( ) const
inline

A method to check if the observable is listed for writing chains.

Returns
true or false

Definition at line 350 of file Observable.h.

351 {
352 return writeChain;
353 }

◆ LogGaussian()

double Observable::LogGaussian ( double  x,
double  ave,
double  sigma 
)

A method to compute the log of a Gaussian likelihood

Parameters
[in]xthe value of the Gaussian distributed variable
[in]avethe average value
[in]sigmathe error
Returns
the log likelihood at point x

Definition at line 147 of file Observable.cpp.

148{
149 return -0.5 * (x-ave) * (x-ave) / sigma / sigma;
150}

◆ LogSplitGaussian()

double Observable::LogSplitGaussian ( double  x,
double  ave,
double  errl,
double  errr 
)

A method to compute the log of a split Gaussian likelihood

Parameters
xthe value of the split-Gaussian distributed variable
[in]avethe average value
[in]errlthe left-side error
[in]errrthe right-side error
Returns
the log likelihood at point x

Definition at line 141 of file Observable.cpp.

142{
143 double sigma = (x > ave ? errr : errl);
144 return -0.5 * (x-ave) * (x-ave) / sigma / sigma;
145}

◆ ParseObservable()

boost::tokenizer< boost::char_separator< char > >::iterator & Observable::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.

Parameters
[in]typethe string specifying the type of the observable
[in]tokthe tokenizer containing the line being parsed
[in]begthe iterator that parses a line in the config file
[in]filepaththe path to the config file being parsed
[in]infilenamethe name of the config file being parsed
[in]rankthe MPI rank of the process accessing the code
Returns
the line number (integer) after the parsing is done

Definition at line 202 of file Observable.cpp.

208{
209 if ((type.compare("Observable") == 0 || type.compare("HiggsObservable")) && std::distance(tok->begin(), tok->end()) < 8) {
210 if(rank == 0) throw std::runtime_error("ERROR: lack of information on " + *beg + " in " + infilename);
211 else sleep (2);
212 } else if (type.compare("BinnedObservable") == 0 && std::distance(tok->begin(), tok->end()) < 12) {
213 if(rank == 0) throw std::runtime_error("ERROR: lack of information on " + *beg + " in " + infilename);
214 else sleep (2);
215 } else if (type.compare("FunctionObservable") == 0 && std::distance(tok->begin(), tok->end()) < 11) {
216 if(rank == 0) throw std::runtime_error("ERROR: lack of information on " + *beg + " in " + infilename);
217 else sleep (2);
218 } else {
219 obsType = type;
220 name = *beg;
221 ++beg;
222 thname = *beg;
223 ++beg;
224 label = *beg;
225 size_t pos = 0;
226 while ((pos = label.find("~", pos)) != std::string::npos)
227 label.replace(pos++, 1, " ");
228 ++beg;
229 min = atof((*beg).c_str());
230 ++beg;
231 max = atof((*beg).c_str());
232 ++beg;
233 std::string toMCMC = *beg;
234 if (toMCMC.compare("MCMC") == 0)
235 tMCMC = true;
236 else if (toMCMC.compare("noMCMC") == 0)
237 tMCMC = false;
238 else {
239 if (rank == 0) throw std::runtime_error("ERROR: wrong MCMC flag in " + name + ".\n");
240 else sleep (2);
241 }
242
243 if (obsType.compare("Observable") == 0 || obsType.compare("BinnedObservable") == 0 || obsType.compare("FunctionObservable") == 0 || type.compare("AsyGausObservable") == 0) {
244 ++beg;
245 distr = *beg;
246 if (distr.compare("file") == 0) {
247 if (std::distance(tok->begin(), tok->end()) < 10) {
248 if (rank == 0) throw std::runtime_error("ERROR: lack of information on " + *beg + " in " + infilename + ".\n");
249 else sleep(2);
250 } else if (type.compare("AsyGausObservable") == 0) {
251 if (rank == 0) throw std::runtime_error("ERROR: AsyGausObservable cannot be specified with a input histogram, use Observable keyword instead.\n");
252 else sleep(2);
253 } else {
254 filename = filepath + *(++beg);
255 histoname = *(++beg);
257 if (rank == 0) std::cout << "added input histogram " << filename << "/" << histoname << std::endl;
258 }
259 } else if (distr.compare("weight") == 0) {
260 if (std::distance(tok->begin(), tok->end()) < 11) {
261 if(rank == 0) throw std::runtime_error("ERROR: lack of information on " + *beg + " in " + infilename + ".\n");
262 else sleep (2);
263 }
264 ++beg;
265 ave = atof((*beg).c_str());
266 ++beg;
267 if (type.compare("AsyGausObservable") == 0) errgl = atof((*beg).c_str());
268 else errg = atof((*beg).c_str());
269 ++beg;
270 if (type.compare("AsyGausObservable") == 0) errgr = atof((*beg).c_str());
271 else errf = atof((*beg).c_str());
272 if (type.compare("AsyGausObservable") != 0 && errf == 0. && errg == 0. && !hasInverseCovariance) {
273 if (rank == 0) throw std::runtime_error("ERROR: The Gaussian and flat error in weight for " + name + " cannot both be 0. in the " + infilename + " .\n");
274 else sleep(2);
275 }
276 if (type.compare("AsyGausObservable") == 0 && errgl == 0. && errgr == 0. && !hasInverseCovariance) {
277 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 + " .\n");
278 else sleep(2);
279 }
280 } else if (distr.compare("noweight") == 0 || distr.compare("writeChain") == 0) {
281 if (!tMCMC) writeChain = (distr.compare("writeChain") == 0);
282 else {
283 if (rank == 0) throw std::runtime_error("ERROR: writeChains cannot be requested since " + name + " is set to MCMC in " + infilename + " .\n");
284 else sleep(2);
285 }
286 if (obsType.compare("BinnedObservable") == 0 || obsType.compare("FunctionObservable") == 0) {
287 ++beg;
288 ++beg;
289 ++beg;
290 }
291 } else {
292 if (rank == 0) throw std::runtime_error("ERROR: wrong distribution flag in " + name + " in file " + infilename + ": can be only weight, noweight or writeChain.\n");
293 else sleep(2);
294 }
295 ++beg;
296 if (obsType.compare("BinnedObservable") == 0) {
297 bin_min = atof((*beg).c_str());
298 ++beg;
299 bin_max = atof((*beg).c_str());
300 ++beg;
301 } else if (obsType.compare("FunctionObservable") == 0) {
302 bin_min = atof((*beg).c_str());
303 ++beg;
304 }
305 if (beg != tok->end() && rank == 0) std::cout << "WARNING: unread information in observable " << name << std::endl;
306 }
307 }
308 return beg;
309}
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

◆ setAve()

void Observable::setAve ( double  ave)
inline

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

Parameters
[in]avethe average value of the observable

Definition at line 131 of file Observable.h.

132 {
133 this->ave = ave;
134 }

◆ setDistr()

void Observable::setDistr ( std::string  distr)
inline

A set method to fix the name of the distribution of the observable.

Parameters
[in]distrthe name of the distribution of the observable

Definition at line 149 of file Observable.h.

150 {
151 this->distr = distr;
152 }

◆ setErrf()

void Observable::setErrf ( double  errf)
inline

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

Parameters
[in]errfthe flat error of the observable

Definition at line 167 of file Observable.h.

168 {
169 this->errf = errf;
170 }

◆ setErrg()

void Observable::setErrg ( double  errg)
inline

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

Parameters
[in]errgthe Gaussian error of the observable

Definition at line 185 of file Observable.h.

186 {
187 this->errg = errg;
188 }

◆ setErrgl()

void Observable::setErrgl ( double  errgl)
inline

A set method to fix the left Gaussian error of the observable.

Parameters
[in]errglthe left Gaussian error of the observable

Definition at line 194 of file Observable.h.

195 {
196 this->errgl = errgl;
197 }

◆ setErrgr()

void Observable::setErrgr ( double  errgr)
inline

A set method to fix the right Gaussian error of the observable.

Parameters
[in]errgrthe right Gaussian error of the observable

Definition at line 203 of file Observable.h.

204 {
205 this->errgr = errgr;
206 }

◆ setFilename()

void Observable::setFilename ( std::string  filename_i)
inline

Definition at line 217 of file Observable.h.

218 {
219 filename = filename_i;
220 }

◆ setHasInverseCovariance()

void Observable::setHasInverseCovariance ( bool  hasInverseCovariance)
inline

A set method to state that the Observable is a part of ObservablesWithInverseCovariance.

Parameters
[in]hasInverseCovariancea boolean which is true for ObservablesWithInverseCovariance

Definition at line 464 of file Observable.h.

465 {
467 }

◆ setHistoname()

void Observable::setHistoname ( std::string  histoname_i)
inline

A set method to set the name of the histogram containing the likelihood.

Parameters
[in]histoname_ia string that contains the name of the histogram

Definition at line 260 of file Observable.h.

261 {
262 histoname = histoname_i;
263 }

◆ setLabel()

void Observable::setLabel ( std::string  label)
inline

A set method to fix the label for the observable.

Parameters
[in]labelthe label for the observable

Definition at line 278 of file Observable.h.

279 {
280 this->label = label;
281 }

◆ setLikelihoodFromHisto()

void Observable::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 in Observable2D.

Definition at line 111 of file Observable.cpp.

112 {
113 this->filename = filename;
114 this->histoname = histoname;
115 TFile *lik = new TFile((filename + ".root").c_str(), "read");
116 TH1D *htmp = (TH1D*) (lik->Get(histoname.c_str()));
117 if (htmp == NULL)
118 throw std::runtime_error("ERROR: nonexistent histogram called "
119 + histoname + " in "
120 + filename + ".root");
121 inhisto = (TH1D *) htmp->Clone((filename + "/" + histoname).c_str());
122 inhisto->SetDirectory(gROOT);
123 setMin(inhisto->GetXaxis()->GetXmin());
124 setMax(inhisto->GetXaxis()->GetXmax());
125 lik->Close();
126 delete lik;
127 }
void setMax(double max)
A set method to fix the maximum value for the observable.
Definition: Observable.h:296
void setMin(double min)
A set method to fix the minimum value for the observable.
Definition: Observable.h:314

◆ setMax()

void Observable::setMax ( double  max)
inline

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

Parameters
[in]maxthe maximum value for the observable

Definition at line 296 of file Observable.h.

297 {
298 this->max = max;
299 }

◆ setMin()

void Observable::setMin ( double  min)
inline

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

Parameters
[in]minthe minimum value for the observable

Definition at line 314 of file Observable.h.

315 {
316 this->min = min;
317 }

◆ setName()

void Observable::setName ( std::string  name)
inline

A set method to fix the name for the observable.

Parameters
namefor the observable

Definition at line 332 of file Observable.h.

333 {
334 this->name = name;
335 }

◆ setObsType()

void Observable::setObsType ( std::string &  obsType_s)
inline

A set method to set the Observable type.

Parameters
[in]obsType_sa string that contains the parameter name

Definition at line 395 of file Observable.h.

396 {
397 obsType = obsType_s;
398 }

◆ setParametricLikelihood() [1/2]

virtual void Observable::setParametricLikelihood ( std::string  filename)
inlinevirtual

A set method to set a parametric likelihood reading parameters from a file.

Parameters
filenamethe name of the file

Definition at line 234 of file Observable.h.

235 {
236 this->filename=filename; //real implementation will be done in extension
237 }

◆ setParametricLikelihood() [2/2]

virtual void Observable::setParametricLikelihood ( std::string  filename,
std::vector< ThObservable * >  thObsV 
)
inlinevirtual

Set the parametric likelihood to be overloaded by HiggsObservable.

Parameters
filenamethe name of the config file
thObsVa vector of ThObservables

Reimplemented in HiggsObservable.

Definition at line 244 of file Observable.h.

245 {};

◆ setThname()

void Observable::setThname ( std::string  thname)
inline

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

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

Definition at line 377 of file Observable.h.

378 {
379 this->thname = thname;
380 }

◆ setTho() [1/2]

void Observable::setTho ( ThObservable tho_i)
inline

A set method to fix the pointer to object of type ThObservable.

Parameters
[in]tho_ipointer to the object of type ThObservable

Definition at line 413 of file Observable.h.

414 {
415 tho = tho_i;
418 }
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

◆ setTho() [2/2]

void Observable::setTho ( ThObservable tho_i,
double  bmin,
double  bmax 
)
inline

A set method to fix the pointer to object of type ThObservable.

Parameters
[in]tho_ipointer to the object of type ThObservable
[in]bminthe lower limit of the bin
[in]bmaxthe upper limit of the bin

Definition at line 426 of file Observable.h.

427 {
428 tho = tho_i;
429 tho->setBinMin(bmin);
430 tho->setBinMax(bmax);
431 }

◆ setTMCMC()

void Observable::setTMCMC ( bool  tMCMC)
inline

A set method to fix the observable's inclusion in the MCMC listing.

Parameters
[in]tMCMCtrue or false

Definition at line 359 of file Observable.h.

360 {
361 this->tMCMC = tMCMC;
362 }

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  output,
const Observable o 
)
friend

Befriending of the std::ostream operator << to generate an output stream for printing the observables details.

Parameters
[out]outputthe formatted output stream to print the model parameters
[in]oa reference to an object of type Observable()

Definition at line 102 of file Observable.cpp.

103{
104 output << "Observable name, tMCMC, min, max, distribution, distribution parameters" << std::endl;
105 output << o.name << " " << o.tMCMC << " " << o.min << " " << o.max << " "
106 << o.distr << " " << o.filename << " " << o.histoname << " " << o.ave
107 << " " << o.errg << " " << o.errf << std::endl;
108 return output;
109}

Member Data Documentation

◆ ave

double Observable::ave
protected

The average value of the observable.

Definition at line 485 of file Observable.h.

◆ bin_max

double Observable::bin_max
protected

The maximum valus of the observable bin.

Definition at line 497 of file Observable.h.

◆ bin_min

double Observable::bin_min
protected

The minimum value of the observable bin.

Definition at line 496 of file Observable.h.

◆ distr

std::string Observable::distr
protected

The name of the distribution of the the observable.

Definition at line 482 of file Observable.h.

◆ errf

double Observable::errf
protected

The flat error of the observable.

Definition at line 487 of file Observable.h.

◆ errg

double Observable::errg
protected

The gaussian error of the observable.

Definition at line 486 of file Observable.h.

◆ errgl

double Observable::errgl
protected

The lower gaussian error of the observable.

Definition at line 488 of file Observable.h.

◆ errgr

double Observable::errgr
protected

The upper gaussian error of the observable.

Definition at line 489 of file Observable.h.

◆ filename

std::string Observable::filename
protected

The name of the file containing the experimental likelihood for the observable.

Definition at line 483 of file Observable.h.

◆ hasInverseCovariance

bool Observable::hasInverseCovariance
protected

Definition at line 500 of file Observable.h.

◆ histoname

std::string Observable::histoname
protected

The name of the histogram for the observable.

Definition at line 484 of file Observable.h.

◆ inhisto

TH1D* Observable::inhisto
protected

1D Histogram containing the experimental likelihood for the observable

Definition at line 494 of file Observable.h.

◆ iterationNo

int Observable::iterationNo
protected

A counter for the interation that helps with the observable caching.

Definition at line 498 of file Observable.h.

◆ label

std::string Observable::label
protected

A label for the observable.

Definition at line 481 of file Observable.h.

◆ max

double Observable::max
protected

The maximum valus of the observable.

Definition at line 491 of file Observable.h.

◆ min

double Observable::min
protected

The minimum value of the observable.

Definition at line 490 of file Observable.h.

◆ name

std::string Observable::name
protected

A name for the observable.

Definition at line 479 of file Observable.h.

◆ obsType

std::string Observable::obsType
protected

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

Definition at line 495 of file Observable.h.

◆ thname

std::string Observable::thname
protected

The name for the observable as fixed in the ThObservable class.

Definition at line 480 of file Observable.h.

◆ tho

ThObservable* Observable::tho
protected

A pointer of to the object of the ThObservables class.

Definition at line 478 of file Observable.h.

◆ thValue

double Observable::thValue
protected

The theory value of the first observable.

Definition at line 499 of file Observable.h.

◆ tMCMC

bool Observable::tMCMC
protected

The flag to include or exclude the observable from the MCMC run.

Definition at line 492 of file Observable.h.

◆ writeChain

bool Observable::writeChain
protected

The flag to write the chain for the observable from the MCMC run.

Definition at line 493 of file Observable.h.


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