9 #include "RooArgList.h"
13 using namespace RooFit;
70 pathToCards_=
"../data/CombinationInputs/SM_inputs_8TeV/";
114 if (
verbose_)
MELAout <<
"SuperMELA::SetDecayChannel: Switching from " <<
strChan_ <<
" to " << myChan << endl;
118 if (
verbose_)
MELAout <<
"Setting decay channel of SuperMELA to " <<
strChan_.c_str() <<
" , re-initializing..." << endl;
128 MELAout <<
"Error from SuperMELA::GetSigShapeSystematic, unrecognized input: " << parName.c_str() << endl;
133 if (e==40)
MELAout <<
"Exception " << e <<
" in SuperMELA::GetSigShapeSystematic! Unrecognized type of parameter requested: " << parName.c_str() <<
" . Valid options are meanCB ; sigmaCB" << endl;
141 if (parName==
"meanCB")
return meanTOT_CB_->getVal();
142 else if (parName==
"sigmaCB")
return sigma_CB_->getVal();
143 else if (parName==
"alphaCB")
return alpha_CB_->getVal();
144 else if (parName==
"nCB")
return n_CB_->getVal();
150 if (e==40)
MELAout <<
"Exception " << e <<
" in SuperMELA::GetSigShapeParameter! Unrecognized type of parameter requested: " << parName.c_str() <<
" . Valid options are meanCB ; sigmaCB ; alphaCB ; nCB" << endl;
169 double str_mean_CB_err_e;
170 double str_mean_CB_err_m;
171 double str_sigma_CB_err_e;
172 double str_sigma_CB_err_m;
173 readSigSystFromFile(str_mean_CB_err_e, str_mean_CB_err_m, str_sigma_CB_err_e, str_sigma_CB_err_m);
175 MELAout <<
"mean_CB systematics (ele and mu): " << str_mean_CB_err_e <<
" / " << str_mean_CB_err_m << endl;
176 MELAout <<
"sigma_CB systematics (ele and mu): " << str_sigma_CB_err_e <<
" / " << str_sigma_CB_err_m << endl;
183 mean_CB_err_=
new RooRealVar(
"mean_CB_err",
"mean_CB_err", str_mean_CB_err_m);
184 sigma_CB_err_=
new RooRealVar(
"sigma_CB_err",
"sigma_CB_err", str_sigma_CB_err_m);
187 mean_CB_err_=
new RooRealVar(
"mean_CB_err",
"mean_CB_err", str_mean_CB_err_e);
188 sigma_CB_err_=
new RooRealVar(
"sigma_CB_err",
"sigma_CB_err", str_sigma_CB_err_e);
191 mean_CB_err_=
new RooRealVar(
"mean_CB_err",
"mean_CB_err", (str_mean_CB_err_m + str_mean_CB_err_e));
192 sigma_CB_err_=
new RooRealVar(
"sigma_CB_err",
"sigma_CB_err", sqrt(pow(str_sigma_CB_err_m, 2) + pow(str_sigma_CB_err_e, 2)));
202 string str_alpha2_CB;
206 readSigParsFromFile(str_mean_CB, str_sigma_CB, str_n_CB, str_alpha_CB, str_n2_CB, str_alpha2_CB);
208 MELAout <<
"Read from input card the following formulas: " << endl;
209 MELAout <<
"Mean RooFormula (string): " << str_mean_CB.c_str() << endl;
210 MELAout <<
"Sigma RooFormula (string): " << str_sigma_CB.c_str() << endl;
218 sprintf(rrvName,
"CMS_zz4l_n_sig_%s_%d",
strChan_.c_str(),
int(
sqrts_));
219 if (
verbose_)
MELAout <<
"SuperMELA::init: Constructing n_CB_ from formula " << str_n_CB.c_str() << endl;
220 n_CB_=
new RooFormulaVar(rrvName, str_n_CB.c_str(), RooArgList(*
mH_rrv_));
221 sprintf(rrvName,
"CMS_zz4l_alpha_sig_%s_%d",
strChan_.c_str(),
int(
sqrts_));
222 if (
verbose_)
MELAout <<
"SuperMELA::init: Constructing alpha_CB_ from formula " << str_alpha_CB.c_str() << endl;
223 alpha_CB_=
new RooFormulaVar(rrvName, str_alpha_CB.c_str(), RooArgList(*
mH_rrv_));
224 sprintf(rrvName,
"CMS_zz4l_n2_sig_%s_%d",
strChan_.c_str(),
int(
sqrts_));
225 if (
verbose_)
MELAout <<
"SuperMELA::init: Constructing n2_CB_ from formula " << str_n2_CB.c_str() << endl;
226 n2_CB_=
new RooFormulaVar(rrvName, str_n2_CB.c_str(), RooArgList(*
mH_rrv_));
227 sprintf(rrvName,
"CMS_zz4l_alpha2_sig_%s_%d",
strChan_.c_str(),
int(
sqrts_));
228 if (
verbose_)
MELAout <<
"SuperMELA::init: Constructing alpha2_CB_ from formula " << str_alpha2_CB.c_str() << endl;
229 alpha2_CB_=
new RooFormulaVar(rrvName, str_alpha2_CB.c_str(), RooArgList(*
mH_rrv_));
231 corr_mean_sig =
new RooRealVar(
"CMS_zz4l_mean_sig_corrMH",
"CMS_zz4l_mean_sig_corrMH", 0., -10., 10.);
232 corr_sigma_sig =
new RooRealVar(
"CMS_zz4l_sigma_sig_corrMH",
"CMS_zz4l_sigma_sig_corrMH", 0., -10., 10.);
247 sprintf(rrvName,
"CMS_zz4l_mean_BW_sig_%s_%d",
strChan_.c_str(),
int(
sqrts_));
248 mean_BW_=
new RooRealVar(rrvName,
"CMS_zz4l_mean_BW",
mHVal_, 100., 1000.);
249 sprintf(rrvName,
"CMS_zz4l_width_BW_sig_%s_%d",
strChan_.c_str(),
int(
sqrts_));
250 width_BW_=
new RooRealVar(rrvName,
"CMS_zz4l_width_BW", 1.);
256 MELAout <<
"Signal shape parameter values: " << endl;
259 MELAout <<
"n (formula value) = " <<
n_CB_->getVal() << endl;
261 MELAout <<
"n2 (formula value) = " <<
n2_CB_->getVal() << endl;
275 MELAout <<
"Value of signal m4l CB shape is " <<
sig_CB_->getVal() << endl;
276 MELAout <<
"Value of signal m4l BW shape is " <<
sig_BW_->getVal() << endl;
283 tmpint =
sig_CB_->createIntegral(RooArgSet(*
m4l_rrv_), RooFit::Range(
"shape"));
289 tmpint =
sig_BW_->createIntegral(RooArgSet(*
m4l_rrv_), RooFit::Range(
"shape"));
290 double norm_sig_BW_ =tmpint->getVal();
292 if (
verbose_)
MELAout <<
"Normalization of signal m4l BW shape is " << norm_sig_BW_ << endl;
303 vector<double> v_apars;
307 MELAout <<
"Size of vector with bkg shape pars is " << v_apars.size() << endl;
308 MELAout <<
"Param [0]=" << v_apars.at(0) <<
" [13]=" << v_apars.at(13) << endl;
311 delete a0_qqZZ_;
a0_qqZZ_=
new RooRealVar(
"CMS_zz4l_a0_qqZZ",
"CMS_zz4l_a0_qqZZ", v_apars.at(0), 0., 200.);
312 delete a1_qqZZ_;
a1_qqZZ_=
new RooRealVar(
"CMS_zz4l_a1_qqZZ",
"CMS_zz4l_a1_qqZZ", v_apars.at(1), 0., 200.);
313 delete a2_qqZZ_;
a2_qqZZ_=
new RooRealVar(
"CMS_zz4l_a2_qqZZ",
"CMS_zz4l_a2_qqZZ", v_apars.at(2), 0., 200.);
314 delete a3_qqZZ_;
a3_qqZZ_=
new RooRealVar(
"CMS_zz4l_a3_qqZZ",
"CMS_zz4l_a3_qqZZ", v_apars.at(3), 0., 1.);
315 delete a4_qqZZ_;
a4_qqZZ_=
new RooRealVar(
"CMS_zz4l_a4_qqZZ",
"CMS_zz4l_a4_qqZZ", v_apars.at(4), 0., 200.);
316 delete a5_qqZZ_;
a5_qqZZ_=
new RooRealVar(
"CMS_zz4l_a5_qqZZ",
"CMS_zz4l_a5_qqZZ", v_apars.at(5), 0., 200.);
317 delete a6_qqZZ_;
a6_qqZZ_=
new RooRealVar(
"CMS_zz4l_a6_qqZZ",
"CMS_zz4l_a6_qqZZ", v_apars.at(6), 0., 100.);
318 delete a7_qqZZ_;
a7_qqZZ_=
new RooRealVar(
"CMS_zz4l_a7_qqZZ",
"CMS_zz4l_a7_qqZZ", v_apars.at(7), 0., 1.);
319 delete a8_qqZZ_;
a8_qqZZ_=
new RooRealVar(
"CMS_zz4l_a8_qqZZ",
"CMS_zz4l_a8_qqZZ", v_apars.at(8), 0., 200.);
320 delete a9_qqZZ_;
a9_qqZZ_=
new RooRealVar(
"CMS_zz4l_a9_qqZZ",
"CMS_zz4l_a9_qqZZ", v_apars.at(9), 0., 1.);
321 delete a10_qqZZ_;
a10_qqZZ_=
new RooRealVar(
"CMS_zz4l_a10_qqZZ",
"CMS_zz4l_a10_qqZZ", v_apars.at(10), 0., 200.);
322 delete a11_qqZZ_;
a11_qqZZ_=
new RooRealVar(
"CMS_zz4l_a11_qqZZ",
"CMS_zz4l_a11_qqZZ", v_apars.at(11), -100., 100.);
323 delete a12_qqZZ_;
a12_qqZZ_=
new RooRealVar(
"CMS_zz4l_a12_qqZZ",
"CMS_zz4l_a12_qqZZ", v_apars.at(12), 0., 10000.);
324 delete a13_qqZZ_;
a13_qqZZ_=
new RooRealVar(
"CMS_zz4l_a13_qqZZ",
"CMS_zz4l_a13_qqZZ", v_apars.at(13), 0., 1.);
346 tmpint =
qqZZ_pdf_->createIntegral(RooArgSet(*
m4l_rrv_), RooFit::Range(
"shape"));
364 string suboption=rawoption, result=rawoption;
367 size_t posEq = suboption.find(delimiter);
368 if (posEq!=string::npos){
370 remnant=suboption.substr(posEq+1);
371 result.erase(result.begin()+posEq, result.end());
377 if (result!=
"") splitoptions.push_back(result);
380 if (remnant!=
"") splitoptions.push_back(remnant);
384 double& str_mean_CB_err_e,
385 double& str_mean_CB_err_m,
386 double& str_sigma_CB_err_e,
387 double& str_sigma_CB_err_m
389 bool mean_e_OK=
false, sigma_e_OK=
false;
390 bool mean_m_OK=
false, sigma_m_OK=
false;
394 if (
verbose_)
MELAout <<
"SuperMELA::readSigSystFromFile: Parsing signal shape systematics from input card " << fCardName.c_str() << endl;
395 ifstream card(fCardName.c_str(), ios::in);
397 MELAerr <<
"SuperMELA::readSigSystFromFile: Input card " << fCardName <<
" is not good!" << endl;
400 else if (
verbose_)
MELAout <<
"SuperMELA::readSigSystFromFile: Input card " << fCardName <<
" can be read!" << endl;
405 vector<string> fields;
408 if (fields.size()<2 || !(fields[0]==
"systematic"&&fields[1]==
"param"))
continue;
410 if (fields.size()!=4){
411 MELAerr <<
"Error in SuperMELA::readSigSystFromFile! Incorrect format of line " << line.c_str() << endl;
415 if (fields[2]==
"CMS_zz4l_mean_m_sig"){
416 str_mean_CB_err_m = atof(fields.at(3).c_str());
419 if (fields[2]==
"CMS_zz4l_mean_e_sig"){
420 str_mean_CB_err_e = atof(fields.at(3).c_str());
423 if (fields[2]==
"CMS_zz4l_sigma_m_sig"){
424 str_sigma_CB_err_m = atof(fields.at(3).c_str());
427 if (fields[2]==
"CMS_zz4l_sigma_e_sig"){
428 str_sigma_CB_err_e = atof(fields.at(3).c_str());
432 if (mean_e_OK && sigma_e_OK && mean_m_OK && sigma_m_OK)
break;
436 if ((!(mean_e_OK&&sigma_e_OK))&&(!(mean_m_OK&&sigma_m_OK)))
throw 20;
440 <<
"Exception " << e <<
" in SuperMELA::readSigSystFromFile! Not all signal shape formulas were read " << mean_e_OK <<
" " << sigma_e_OK <<
" " << mean_m_OK <<
" " << sigma_m_OK
449 string& str_sigma_CB,
451 string& str_alpha_CB,
453 string& str_alpha2_CB
455 bool meanOK=
false, sigmaOK=
false, nOK=
false, alphaOK=
false, n2OK=
false, alpha2OK=
false;
458 if (
verbose_)
MELAout <<
"Parsing input card " << fCardName.c_str() << endl;
459 ifstream card(fCardName.c_str(), ios::in);
463 vector<string> fields;
465 if (fields.size()==0 || fields[0]!=
"signalShape")
continue;
467 if (fields.size()<3){
468 MELAout <<
"Error in SuperMELA::readSigParsFromFile! Incorrect format of line " << line.c_str() <<
" There should be at least three fields, I could find only " << fields.size() <<
" fields." << endl;
471 if (fields.at(1)==
"n_CB"){ str_n_CB=fields.at(2); nOK=
true; }
472 if (fields.at(1)==
"alpha_CB"){ str_alpha_CB=fields.at(2); alphaOK=
true; }
473 if (fields.at(1)==
"n2_CB"){ str_n2_CB=fields.at(2); n2OK=
true; }
474 if (fields.at(1)==
"alpha2_CB"){ str_alpha2_CB=fields.at(2); alpha2OK=
true; }
475 if (fields.at(1)==
"mean_CB"){ str_mean_CB=fields.at(2); meanOK=
true; }
476 if (fields.at(1)==
"sigma_CB"){ str_sigma_CB=fields.at(2); sigmaOK=
true; }
477 if (
verbose_)
MELAout << fields.at(1) <<
" == " << fields.at(2) << endl;
479 if (meanOK && sigmaOK && alphaOK && nOK && alpha2OK && n2OK)
break;
482 if (!(meanOK && sigmaOK && alphaOK && nOK && alpha2OK && n2OK)){
483 MELAout <<
"Exception in SuperMELA::readSigParsFromFile! Not all signal shape formulas were read " << meanOK <<
" " << sigmaOK <<
" " << alphaOK <<
" " << nOK <<
" " << alpha2OK <<
" " << n2OK << endl;
495 if (
verbose_)
MELAout <<
"Parsing input card " << fCardName.c_str() << endl;
496 ifstream card(fCardName.c_str(), ios::in);
501 vector<string> fields;
503 if (fields.size()==0 || fields[0]!=
"qqZZshape")
continue;
505 if (fields.size()<3){
506 MELAout <<
"Error in SuperMELA::readSigParsFromFile! Incorrect format of line \'" << line.c_str() <<
"\' . It contains " << fields.size() <<
"fields (it should be 3)" << endl;
512 if (fields[1]==
"a"+ssip.str()+
"_bkgd"){
513 apars[nFound]=atof(fields[2].c_str());
525 MELAerr <<
"Exception from void SuperMELA::readBkgParsFromFile(vector<double> apars ). Mismatched number of params of qqZZ shape read from card file " << fCardName.c_str() <<
" ---> " << nFound <<
" (it should be " << nPars << endl;
526 for (
unsigned int j=0; j<apars.size(); j++){
MELAerr << apars[j] <<
" " << flush; }
538 string path = MELAPKGPATH +
"data/HiggsTotalWidth_YR3.txt";
540 path.erase((find(path.rbegin(), path.rend(),
'/').base()), path.end());
543 double windowVal = max(widthHVal, 1.);
544 double lowside = 100.;
545 if (mHVal >= 275){ lowside = 180.; }
546 else { lowside = 100.; }
548 low_M = int(max((mHVal - 20.*windowVal), lowside)+0.5);
549 high_M = int(min((mHVal + 15.*windowVal),
sqrts_*1000.)+0.5);
555 if (m4l<lowMH_ || m4l>
highMH_){
556 if (
verbose_)
MELAerr <<
"SuperMELA::M4lProb: m4l = " << m4l <<
" outside range [" <<
lowMH_ <<
", " <<
highMH_ <<
"]. Setting SuperMELA to dummy values." << endl;
563 MELAout <<
"SuperMELA::M4lProb: m4l = " << m4l
564 <<
", m4lPsig = " << Psig
565 <<
", m4lPbkg = " << Pbkg
569 return make_pair(Psig, Pbkg);
581 if (
verbose_)
MELAerr <<
"SuperMELA::M4lProb: m4l pairs " << m4lPair.first <<
" - " << m4lPair.second <<
" outside range [" <<
lowMH_ <<
", " <<
highMH_ <<
"]. Setting SuperMELA to dummy values." << endl;
589 MELAout <<
"SuperMELA::M4lProb: "
590 <<
"m4lPsig(" << m4lPair.first <<
") = " << Psig
591 <<
", m4lPbkg(" << m4lPair.second <<
") = " << Pbkg
595 return make_pair(Psig, Pbkg);
605 MELAerr <<
"Exception " << e <<
" from SuperMELA::SetDecayChannel(string myChan). Unrecognized string for decay channel: " <<
strChan_.c_str() << endl;