19 const std::string thname_i,
20 const std::string label_i,
104 output <<
"Observable name, tMCMC, min, max, distribution, distribution parameters" << std::endl;
105 output << o.
name <<
" " << o.
tMCMC <<
" " << o.
min <<
" " << o.
max <<
" "
107 <<
" " << o.
errg <<
" " << o.
errf << std::endl;
115 TFile *lik =
new TFile((
filename +
".root").c_str(),
"read");
116 TH1D *htmp = (TH1D*) (lik->Get(
histoname.c_str()));
118 throw std::runtime_error(
"ERROR: nonexistent histogram called "
143 double sigma = (x >
ave ? errr : errl);
144 return -0.5 * (x-
ave) * (x-
ave) / sigma / sigma;
149 return -0.5 * (x-
ave) * (x-
ave) / sigma / sigma;
155 if (
distr.compare(
"weight") == 0) {
160 else if (
errg == 0.) {
161 if (th < ave + errf && th >
ave -
errf)
166 logprob = log(TMath::Erf((th -
ave +
errf) / sqrt(2.) /
errg)
167 - TMath::Erf((th -
ave -
errf) / sqrt(2.) /
errg));
169 }
else if (
distr.compare(
"file") == 0) {
174 logprob = log(
inhisto->GetBinContent(i));
177 throw std::runtime_error(
"ERROR: MonteCarloEngine::Weight() called without weight for "
185 if (
distr.compare(
"weight") == 0) {
188 else if (errg_i == 0.) {
189 if (th < ave_i + errf_i && th > ave_i - errf_i)
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));
197 throw std::runtime_error(
"ERROR: MonteCarloEngine::Weight() called without weight for "
203 boost::tokenizer<boost::char_separator<char> >* tok,
204 boost::tokenizer<boost::char_separator<char> >::iterator & beg,
205 std::string& filepath,
206 std::string& infilename,
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);
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);
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);
226 while ((pos =
label.find(
"~", pos)) != std::string::npos)
227 label.replace(pos++, 1,
" ");
229 min = atof((*beg).c_str());
231 max = atof((*beg).c_str());
233 std::string toMCMC = *beg;
234 if (toMCMC.compare(
"MCMC") == 0)
236 else if (toMCMC.compare(
"noMCMC") == 0)
239 if (rank == 0)
throw std::runtime_error(
"ERROR: wrong MCMC flag in " +
name +
".\n");
243 if (
obsType.compare(
"Observable") == 0 ||
obsType.compare(
"BinnedObservable") == 0 ||
obsType.compare(
"FunctionObservable") == 0 || type.compare(
"AsyGausObservable") == 0) {
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");
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");
257 if (rank == 0) std::cout <<
"added input histogram " <<
filename <<
"/" <<
histoname << std::endl;
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");
265 ave = atof((*beg).c_str());
267 if (type.compare(
"AsyGausObservable") == 0)
errgl = atof((*beg).c_str());
268 else errg = atof((*beg).c_str());
270 if (type.compare(
"AsyGausObservable") == 0)
errgr = atof((*beg).c_str());
271 else errf = atof((*beg).c_str());
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");
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");
280 }
else if (
distr.compare(
"noweight") == 0 ||
distr.compare(
"writeChain") == 0) {
283 if (rank == 0)
throw std::runtime_error(
"ERROR: writeChains cannot be requested since " +
name +
" is set to MCMC in " + infilename +
" .\n");
286 if (
obsType.compare(
"BinnedObservable") == 0 ||
obsType.compare(
"FunctionObservable") == 0) {
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");
296 if (
obsType.compare(
"BinnedObservable") == 0) {
297 bin_min = atof((*beg).c_str());
299 bin_max = atof((*beg).c_str());
301 }
else if (
obsType.compare(
"FunctionObservable") == 0) {
302 bin_min = atof((*beg).c_str());
305 if (beg != tok->end() && rank == 0) std::cout <<
"WARNING: unread information in observable " <<
name << std::endl;
std::ostream & operator<<(std::ostream &output, const Observable &o)
bool tMCMC
The flag to include or exclude the observable from the MCMC run.
int iterationNo
A counter for the interation that helps with the observable caching.
std::string thname
The name for the observable as fixed in the ThObservable class.
std::string distr
The name of the distribution of the the observable.
double LogGaussian(double x, double ave, double sigma)
std::string getObsType() const
A get method to get the Observable type.
TH1D * inhisto
1D Histogram containing the experimental likelihood for the observable
double errf
The flat error of the observable.
double max
The maximum valus of the observable.
std::string obsType
Type of the Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable...
bool writeChain
The flag to write the chain for the observable from the MCMC run.
double ave
The average value of the observable.
double bin_min
The minimum value of the observable bin.
virtual double computeWeight()
A method to compute the weight associated with the observable.
bool hasInverseCovariance
std::string label
A label for the observable.
double min
The minimum value of the observable.
virtual ~Observable()
The default destructor.
double thValue
The theory value of the first observable.
void setMax(double max)
A set method to fix the maximum value for 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.
double LogSplitGaussian(double x, double ave, double errl, double errr)
double errgr
The upper gaussian error of the observable.
double errg
The gaussian error of the observable.
std::string histoname
The name of the histogram 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 errgl
The lower gaussian error of the observable.
std::string name
A name for the observable.
double computeTheoryValue()
A method to access the computed theory value of the observable.
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...
double bin_max
The maximum valus of the observable bin.
Observable()
The default constructor.
void setMin(double min)
A set method to fix the minimum value for the observable.
const int getIterationNo() const
A class for a model prediction of an observable.
const StandardModel & getModel()
A get method to get the model.
virtual double computeThValue()=0
A member to be overloaded by the respective theory observable. class that calculates the value of the...