16 const std::string thname_i,
17 const std::string thname2_i,
18 const std::string label_i,
19 const std::string label2_i,
27:
Observable(name_i, thname_i, label_i, tMCMC_i, min_i, max_i, tho_i),
75:
Observable(orig.name, orig.thname, orig.label, orig.tMCMC, orig.min, orig.max, orig.tho),
76 bin_min(orig.bin_min),
122 TFile *lik2 =
new TFile((
filename +
".root").c_str(),
"read");
123 TH2D *htmp2 = (TH2D*) (lik2->Get(
histoname.c_str()));
125 throw std::runtime_error(
"ERROR: nonexistent histogram called "
130 std::cout <<
"added 2D input histogram " <<
name << std::endl;
142 if (
distr.compare(
"file") == 0) {
147 logprob = log(
inhisto2d->GetBinContent(i));
149 }
else if (
distr.compare(
"weight") == 0) {
155 throw std::runtime_error(
"ERROR: 2D MonteCarloEngine::Weight() called without file for "
161 boost::tokenizer<boost::char_separator<char> >* tok,
162 boost::tokenizer<boost::char_separator<char> >::iterator& beg,
163 std::string& infilename,
164 std::ifstream& ifile,
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) {
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));
176 std::string toMCMC = *beg;
177 if (toMCMC.compare(
"MCMC") == 0)
179 else if (toMCMC.compare(
"noMCMC") == 0)
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");
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);
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,
"");
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");
217 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
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");
228 while ((pos =
label[i].find(
"~", pos)) != std::string::npos)
229 label[i].replace(pos++, 1,
" ");
231 min[i] = atof((*beg).c_str());
233 max[i] = atof((*beg).c_str());
234 if (
distr.compare(
"weight") == 0) {
236 ave[i] = atof((*beg).c_str());
238 if (type.compare(
"AsyGausObservable") == 0)
errgl[i] = atof((*beg).c_str());
239 else errg[i] = atof((*beg).c_str());
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");
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");
251 }
else if (
distr.compare(
"noweight") == 0 ||
distr.compare(
"file") == 0) {
252 if (type2D[i].compare(
"BinnedObservable") == 0 || type2D[i].compare(
"FunctionObservable") == 0) {
258 if (rank == 0)
throw std::runtime_error(
"ERROR: wrong distribution flag in " +
name +
" in file " + infilename +
".\n");
261 if (type2D[i].compare(
"BinnedObservable") == 0) {
263 bin_min[i] = atof((*beg).c_str());
265 bin_max[i] = atof((*beg).c_str());
266 }
else if (type2D[i].compare(
"FunctionObservable") == 0) {
268 bin_min[i] = atof((*beg).c_str());
292 if (
distr.compare(
"file") == 0) {
294 if (rank == 0) std::cout <<
"added input histogram " <<
filename <<
"/" <<
histoname << std::endl;
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");
309 if (rank == 0) std::cout <<
"added input histogram " <<
filename <<
"/" <<
histoname << std::endl;
310 }
else if (
distr.compare(
"noweight") == 0) {
312 if (rank == 0)
throw std::runtime_error(
"ERROR: wrong distribution flag in " +
name);
319 std::string
label = *beg;
321 while ((pos =
label.find(
"~", pos)) != std::string::npos)
322 label.replace(pos, 1,
" ");
325 min2 = atof((*beg).c_str());
327 max2 = atof((*beg).c_str());
329 if (beg != tok->end())
330 if (rank == 0) std::cout <<
"WARNING: unread information in observable2D " <<
name << std::endl;
A class for analyzing observables pairwise.
double computeTheoryValue2()
A method to access the computed theory value of the second 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 max2
The maximum valus of the second observable.
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)
double errf2
the flat error of the second observable.
std::string filepath
The path to the file being parsed.
std::string thname2
The name for the second observable as fixed in the ThObservable() class.
double errgr2
The right Gaussian error of the second observable.
std::string label2
A label for the second observable.
bool IsEOF
A bolean that is true if the end of file is reached.
double ave2
The average value of the second observable.
int iterationNo2
Counts the iteration to help with caching.
Observable2D()
The default constructor.
ThObservable * tho2
A pointer to an object of the ThObservable class.
std::vector< double > bin_max
The maximum value of the bin.
virtual ~Observable2D()
The default destructor.
double errgl2
The left Gaussian error of the second observable.
double min2
The minimum value of the second observable.
double thValue2
The theory value of the second observable.
virtual double computeWeight()
A method to compute the weight associated with the observable.
void setMin2(double min2)
A set method to fix the minimum value for the second observable.
double errg2
The Gaussian error of the second observable.
TH2D * inhisto2d
2D Histogram containing the experimental likelihood for the observable.
void setMax2(double max2)
A set method to fix the maximum value for the second observable.
std::string obsType2
Type of the second Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable,...
std::vector< double > bin_min
The minimum value of the bin.
std::string thname
The name for the observable as fixed in the ThObservable class.
void setErrgl(double errgl)
A set method to fix the left Gaussian error of the observable.
std::string distr
The name of the distribution of the the observable.
void setErrgr(double errgr)
A set method to fix the right Gaussian error of the observable.
double errf
The flat error of the observable.
void setName(std::string name)
A set method to fix the name for the observable.
void setFilename(std::string filename_i)
void setAve(double ave)
A set method to fix the average value of the observable.
double max
The maximum valus of the observable.
double ave
The average value of the observable.
virtual double computeWeight()
A method to compute the weight associated with the observable.
std::string label
A label for the observable.
double min
The minimum value of the observable.
void setTMCMC(bool tMCMC)
A set method to fix the observable's inclusion in the MCMC listing.
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)
void setThname(std::string thname)
A set method to fix the name of the observable as listed in ThFactory class.
double errgr
The upper gaussian error of the observable.
void setLabel(std::string label)
A set method to fix the label for the observable.
void setErrg(double errg)
A set method to fix the gaussian error of the observable.
void setDistr(std::string distr)
A set method to fix the name of the distribution 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.
void setObsType(std::string &obsType_s)
A set method to set the Observable type.
void setHistoname(std::string histoname_i)
A set method to set the name of the histogram containing the likelihood.
double errgl
The lower gaussian error of the observable.
std::string name
A name for the observable.
void setErrf(double errf)
A set method to fix the flat error of the observable.
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...