15 const std::string thname_i,
16 const std::string thname2_i,
17 const std::string label_i,
18 const std::string label2_i,
26 :
Observable(name_i, thname_i, label_i, tMCMC_i, min_i, max_i, tho_i),
71 :
Observable(orig.name, orig.thname, orig.label, orig.tMCMC, orig.min, orig.max, orig.tho),
72 bin_min(orig.bin_min),
110 TFile *lik2 =
new TFile((filename +
".root").c_str(),
"read");
111 TH2D *htmp2 = (TH2D*) (lik2->Get(histoname.c_str()));
113 throw std::runtime_error(
"ERROR: nonexistent histogram called "
115 +
" in " + filename +
".root");
116 inhisto2d = (TH2D *) htmp2->Clone((filename +
"/" + histoname).c_str());
118 std::cout <<
"added 2D input histogram " <<
name << std::endl;
130 if (
distr.compare(
"file") == 0) {
137 }
else if (
distr.compare(
"weight") == 0) {
140 throw std::runtime_error(
"ERROR: 2D MonteCarloEngine::Weight() called without file for "
146 boost::tokenizer<boost::char_separator<char> >* tok,
147 boost::tokenizer<boost::char_separator<char> >::iterator& beg,
148 std::string& infilename,
149 std::ifstream& ifile,
153 if (infilename.find(
"\\/") == std::string::npos)
filepath = infilename.substr(0, infilename.find_last_of(
"\\/") + 1);
154 if (std::distance(tok->begin(), tok->end()) < 12) {
157 if (std::distance(tok->begin(), tok->end()) < 4) {
158 if(rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " +
name +
" in " + infilename +
" at line number" + boost::lexical_cast<std::string>(lineNo));
161 std::string toMCMC = *beg;
162 if (toMCMC.compare(
"MCMC") == 0)
164 else if (toMCMC.compare(
"noMCMC") == 0)
167 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");
173 if (
distr.compare(
"file") == 0) {
174 if (std::distance(tok->begin(), tok->end()) < 6) {
175 if(rank == 0)
throw std::runtime_error(
"ERROR: lack of information on "+ *beg +
" in " + infilename);
182 std::vector<double>
min(2, 0.);
183 std::vector<double>
max(2, 0.);
184 std::vector<double>
ave(2, 0.);
185 std::vector<double>
errg(2, 0.);
186 std::vector<double>
errf(2, 0.);
187 std::vector<std::string>
thname(2,
"");
188 std::vector<std::string>
label(2,
"");
189 std::vector<std::string> type2D(2,
"");
192 boost::char_separator<char> sep(
" \t");
193 for (
int i = 0; i < 2; i++) {
194 IsEOF = getline(ifile, line).eof();
195 if (line.empty() || line.at(0) ==
'#') {
196 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");
200 boost::tokenizer<boost::char_separator<char> > mytok(line, sep);
203 if (type2D[i].compare(
"Observable") != 0 && type2D[i].compare(
"BinnedObservable") != 0 && type2D[i].compare(
"FunctionObservable") != 0) {
204 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");
211 while ((pos = label[i].find(
"~", pos)) != std::string::npos)
212 label[i].replace(pos++, 1,
" ");
214 min[i] = atof((*beg).c_str());
216 max[i] = atof((*beg).c_str());
217 if (
distr.compare(
"weight") == 0) {
219 ave[i] = atof((*beg).c_str());
221 errg[i] = atof((*beg).c_str());
223 errf[i] = atof((*beg).c_str());
224 if (errg[i] == 0. && errg[i] == 0.) {
225 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");
228 }
else if (
distr.compare(
"noweight") == 0 ||
distr.compare(
"file") == 0) {
229 if (type2D[i].compare(
"BinnedObservable") == 0 || type2D[i].compare(
"FunctionObservable") == 0) {
235 if (rank == 0)
throw std::runtime_error(
"ERROR: wrong distribution flag in " +
name +
" in file " + infilename +
".\n");
238 if (type2D[i].compare(
"BinnedObservable") == 0) {
240 bin_min[i] = atof((*beg).c_str());
242 bin_max[i] = atof((*beg).c_str());
243 }
else if (type2D[i].compare(
"FunctionObservable") == 0) {
245 bin_min[i] = atof((*beg).c_str());
265 if (
distr.compare(
"file") == 0) {
267 if (rank == 0) std::cout <<
"added input histogram " <<
filename <<
"/" <<
histoname << std::endl;
273 std::string
distr = *beg;
274 if (distr.compare(
"file") == 0) {
275 if (std::distance(tok->begin(), tok->end()) < 14) {
276 if (rank == 0)
throw std::runtime_error(
"ERROR: lack of information on " + *beg +
" in " + infilename +
".\n");
282 if (rank == 0) std::cout <<
"added input histogram " <<
filename <<
"/" <<
histoname << std::endl;
283 }
else if (distr.compare(
"noweight") == 0) {
285 if (rank == 0)
throw std::runtime_error(
"ERROR: wrong distribution flag in " +
name);
292 std::string
label = *beg;
294 while ((pos = label.find(
"~", pos)) != std::string::npos)
295 label.replace(pos, 1,
" ");
298 min2 = atof((*beg).c_str());
300 max2 = atof((*beg).c_str());
302 if (beg != tok->end())
303 if (rank == 0) std::cout <<
"WARNING: unread information in observable2D " <<
name << std::endl;
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...
std::string label2
A label for the second observable.
void setErrf(double errf)
A set method to fix the flat error of the observable.
void setErrg(double errg)
A set method to fix the gaussian error of the 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 ave2
The average value of the second observable.
virtual double computeThValue()=0
A member to be overloaded by the respective theory observable. class that calculates the value of the...
std::string obsType2
Type of the second Observable. 0: Observable, 1: HiggsObservable, 2: BinnedObservable, 3: FunctionObservable.
ThObservable * tho2
A pointer to an object of the ThObservable class.
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.
double min2
The minimum value of the second 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.
A class for analyzing observables pairwise.
A class for a model prediction of an observable.
double errf2
the flat error of the second 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
std::vector< double > bin_min
The minimum value of the bin.
void setThname(std::string thname)
A set method to fix the name of the observable as listed in ThFactory class.
double errg
The gaussian error of the observable.
double errg2
The gaussian error of the second observable.
void setAve(double ave)
A set method to fix the average value of the observable.
double thValue2
The theory value of the second observable.
Observable2D()
The default constructor.
double errf
the flat error of the observable.
void setMax2(double max2)
A set method to fix the maximum value for the second observable.
void setName(std::string name)
A set method to fix the name for the observable.
int iterationNo2
Counts the iteration to help with caching.
std::string label
A label for the observable.
std::string thname2
The name for the second oservable as fixed in the ThObservable() class.
void setMin2(double min2)
A set method to fix the minimum value for the second observable.
std::string thname
The name for the oservable as fixed in the ThObservable class.
void setFilename(std::string filename_i)
void setDistr(std::string distr)
A set method to fix the name of the distribution of the observable.
bool IsEOF
A bolean that is true if the end of file is reached.
double max2
The maximum valus of the second observable.
double computeTheoryValue2()
A method to access the computed theory value of the second observable.
complex log(const complex &z)
void setMax(double max)
A set method to fix the maximum value for the observable.
void setTMCMC(bool tMCMC)
A set method to fix the observable's inclusion in the MCMC listing.
std::string name
A name for the observable.
std::string filename
The name of the file containing the experimental likelihood for the observable.
void setLabel(std::string label)
A set method to fix the label for the observable.
std::vector< double > bin_max
The maximum value of the bin.
const StandardModel & getModel()
A get method to get the model.
TH2D * inhisto2d
2D Histogram containing the experimental likelihood for the observable.
void setHistoname(std::string histoname_i)
A set method to set the name of the histogram containing the likelihood.
std::string distr
The name of the distribution of the the observable.
virtual ~Observable2D()
The default destructor.
void setObsType(std::string &obsType_s)
A set method to set the Observable type.
std::string filepath
The path to the file being parsed.