17 const std::string thname_i,
18 const std::string label_i,
89 output <<
"Observable name, tMCMC, min, max, distribution, distribution parameters" << std::endl;
90 output << o.
name <<
" " << o.
tMCMC <<
" " << o.
min <<
" " << o.
max <<
" "
92 <<
" " << o.
errg <<
" " << o.
errf << std::endl;
100 TFile *lik =
new TFile((filename +
".root").c_str(),
"read");
101 TH1D *htmp = (TH1D*) (lik->Get(histoname.c_str()));
103 throw std::runtime_error(
"ERROR: nonexistent histogram called "
105 + filename +
".root");
106 inhisto = (TH1D *) htmp->Clone((filename +
"/" + histoname).c_str());
128 double sigma = (x > ave ? errr : errl);
129 return -0.5 * (x-
ave) * (x-ave) / sigma / sigma;
134 return -0.5 * (x-
ave) * (x-ave) / sigma / sigma;
140 if (
distr.compare(
"weight") == 0) {
143 else if (
errg == 0.) {
144 if (th < ave + errf && th >
ave -
errf)
151 }
else if (
distr.compare(
"file") == 0) {
159 throw std::runtime_error(
"ERROR: MonteCarloEngine::Weight() called without weight for "
167 if (
distr.compare(
"weight") == 0) {
170 else if (errg_i == 0.) {
171 if (th < ave_i + errf_i && th > ave_i - errf_i)
176 logprob =
log(TMath::Erf((th - ave_i + errf_i) /
sqrt(2.) / errg_i)
177 - TMath::Erf((th - ave_i - errf_i) /
sqrt(2.) / errg_i));
179 throw std::runtime_error(
"ERROR: MonteCarloEngine::Weight() called without weight for "
185 boost::tokenizer<boost::char_separator<char> >* tok,
186 boost::tokenizer<boost::char_separator<char> >::iterator & beg,
187 std::string& filepath,
188 std::string& infilename,
191 if ((type.compare(
"Observable") == 0 || type.compare(
"HiggsObservable")) && std::distance(tok->begin(), tok->end()) < 8) {
192 if(rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " + infilename);
194 }
else if (type.compare(
"BinnedObservable") == 0 && std::distance(tok->begin(), tok->end()) < 10) {
195 if(rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " + infilename);
197 }
else if (type.compare(
"FunctionObservable") == 0 && std::distance(tok->begin(), tok->end()) < 9) {
198 if(rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " + infilename);
208 while ((pos =
label.find(
"~", pos)) != std::string::npos)
209 label.replace(pos++, 1,
" ");
211 min = atof((*beg).c_str());
213 max = atof((*beg).c_str());
215 std::string toMCMC = *beg;
216 if (toMCMC.compare(
"MCMC") == 0)
218 else if (toMCMC.compare(
"noMCMC") == 0)
221 if (rank == 0)
throw std::runtime_error(
"ERROR: wrong MCMC flag in " +
name +
".\n");
225 if (
obsType.compare(
"Observable") == 0 ||
obsType.compare(
"BinnedObservable") == 0 ||
obsType.compare(
"FunctionObservable") == 0) {
228 if (
distr.compare(
"file") == 0) {
229 if (std::distance(tok->begin(), tok->end()) < 10) {
230 if (rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " + infilename +
".\n");
236 if (rank == 0) std::cout <<
"added input histogram " <<
filename <<
"/" << histoname << std::endl;
238 }
else if (
distr.compare(
"weight") == 0) {
239 if (std::distance(tok->begin(), tok->end()) < 11) {
240 if(rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " + infilename +
".\n");
244 ave = atof((*beg).c_str());
246 errg = atof((*beg).c_str());
248 errf = atof((*beg).c_str());
250 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");
253 }
else if (
distr.compare(
"noweight") == 0) {
254 if (
obsType.compare(
"BinnedObservable") == 0 ||
obsType.compare(
"FunctionObservable") == 0) {
260 if (rank == 0)
throw std::runtime_error(
"ERROR: wrong distribution flag in " +
name +
" in file " + infilename +
".\n");
264 if (
obsType.compare(
"BinnedObservable") == 0) {
265 bin_min = atof((*beg).c_str());
267 bin_max = atof((*beg).c_str());
269 }
else if (
obsType.compare(
"FunctionObservable") == 0) {
270 bin_min = atof((*beg).c_str());
274 if (beg != tok->end() && rank == 0) std::cout <<
"WARNING: unread information in observable " <<
name << std::endl;
double bin_min
The minimum value of the observable bin.
virtual double computeThValue()=0
A member to be overloaded by the respective theory observable. class that calculates the value of the...
std::string obsType
Type of the Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable...
double min
The minimum value of the observable.
double max
The maximum valus of the observable.
virtual double computeWeight()
A method to compute the weight associated with the observable.
std::string histoname
The name of the histogram for the observable.
void setMin(double min)
A set method to fix the minimum value for the observable.
bool tMCMC
The flag to include or exclude the observable from the MCMC run.
A class for a model prediction of an observable.
double ave
The average value of the observable.
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.
int getIterationNo() const
double errg
The gaussian error of the observable.
virtual ~Observable()
The default destructor.
double thValue
The theory value of the first observable.
double errf
the flat error of the observable.
std::string label
A label for the observable.
double LogSplitGaussian(double x, double ave, double errl, double errr)
int iterationNo
A counter for the interation that helps with the observable caching.
std::string thname
The name for the oservable as fixed in the ThObservable class.
double LogGaussian(double x, double ave, double sigma)
complex log(const complex &z)
Observable()
The default constructor.
void setMax(double max)
A set method to fix the maximum value for the observable.
std::string name
A name for the observable.
std::string filename
The name of the file containing the experimental likelihood for the observable.
ThObservable * tho
A pointer of to the object of the ThObservables class.
double computeTheoryValue()
A method to access the computed theory value of the observable.
const StandardModel & getModel()
A get method to get the model.
std::ostream & operator<<(std::ostream &output, const Observable &o)
TH1D * inhisto
1D Histogram containing the experimental likelihood for the observable
std::string distr
The name of the distribution of the the observable.
double bin_max
The maximum valus of the observable bin.
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...
complex sqrt(const complex &z)