83#define NoHistConst_Low "0"
84#define NoHistConst_High "2000"
97 fNomLumi(1.0), fLumiError(0),
98 fLowBin(0), fHighBin(0)
105 fSystToFix( measurement.GetConstantParams() ),
106 fParamValues( measurement.GetParamValues() ),
107 fNomLumi( measurement.GetLumi() ),
108 fLumiError( measurement.GetLumi()*measurement.GetLumiRelErr() ),
109 fLowBin( measurement.GetBinLow() ),
110 fHighBin( measurement.GetBinHigh() ) {
125 if( proto_config == NULL ) {
126 std::cout <<
"Error: Did not find 'ModelConfig' object in file: " << ws_single->
GetName()
131 std::vector<std::string> poi_list = measurement.
GetPOIList();
132 if( poi_list.size()==0 ) {
133 std::cout <<
"Warining: No Parametetrs of interest are set" << std::endl;
136 cout <<
"Setting Parameter(s) of Interest as: ";
137 for(
unsigned int i = 0; i < poi_list.size(); ++i) {
138 cout << poi_list.at(i) <<
" ";
143 for(
unsigned int i = 0; i < poi_list.size(); ++i ) {
144 std::string poi_name = poi_list.at(i);
150 std::cout <<
"WARNING: Can't find parameter of interest: " << poi_name
151 <<
" in Workspace. Not setting in ModelConfig." << std::endl;
158 std::string NewModelName =
"newSimPdf";
172 proto_config->
SetPdf( *ws_single->
pdf(
"newSimPdf" ) );
179 std::cout <<
"Error: Failed to find dataset: " << expData
180 <<
" in workspace" << std::endl;
183 if(poi_list.size()!=0){
195 if( !pdf ) pdf = ws_single->
pdf( ModelName.c_str() );
196 const RooArgSet* observables = ws_single->
set(
"observables");
199 std::string SnapShotName =
"NominalParamValues";
206 std::string AsimovName = asimov.
GetName();
208 std::cout <<
"Generating additional Asimov Dataset: " << AsimovName << std::endl;
213 std::cout <<
"Importing Asimov dataset" << std::endl;
214 bool failure = ws_single->
import(*asimov_dataset,
Rename(AsimovName.c_str()));
216 std::cout <<
"Error: Failed to import Asimov dataset: " << AsimovName
218 delete asimov_dataset;
227 delete asimov_dataset;
249 string ch_name = channel.
GetName();
253 if( ws_single == NULL ) {
254 std::cout <<
"Error: Failed to make Single-Channel workspace for channel: " << ch_name
255 <<
" and measurement: " << measurement.
GetName() << std::endl;
283 vector<RooWorkspace*> channel_workspaces;
284 vector<string> channel_names;
286 for(
unsigned int chanItr = 0; chanItr < measurement.
GetChannels().size(); ++chanItr ) {
291 std::cout <<
"MakeModelAndMeasurementsFast: Channel: " << channel.
GetName()
292 <<
" has uninitialized histogram pointers" << std::endl;
296 string ch_name = channel.
GetName();
297 channel_names.push_back(ch_name);
302 channel_workspaces.push_back(ws_single);
316 for (vector<RooWorkspace*>::iterator iter = channel_workspaces.begin() ; iter != channel_workspaces.end() ; ++iter) {
326 string prefix,
string productPrefix,
329 cout <<
"processing hist " << hist->
GetName() << endl;
331 cout <<
"hist is empty" << endl;
341 unsigned int histndim(1);
342 std::string classname = hist->
ClassName();
343 if (classname.find(
"TH1")==0) { histndim=1; }
344 else if (classname.find(
"TH2")==0) { histndim=2; }
345 else if (classname.find(
"TH3")==0) { histndim=3; }
350 std::vector<std::string>::iterator itr =
fObsNameVec.begin();
351 for (
int idx=0; itr!=
fObsNameVec.end(); ++itr, ++idx ) {
352 if ( !
proto->var(itr->c_str()) ) {
354 if (idx==0) { axis = hist->
GetXaxis(); }
355 if (idx==1) { axis = hist->
GetYaxis(); }
356 if (idx==2) { axis = hist->
GetZaxis(); }
362 proto->var(itr->c_str())->setBins(nbins);
364 observables.
add( *
proto->var(itr->c_str()) );
370 proto->import(*histFunc);
373 proto->factory((
"prod:"+productPrefix+
"("+prefix+
"_nominal,"+systTerm+
")").c_str() );
386 for(
Int_t i=lowBin; i<highBin; ++i){
387 std::stringstream str;
394 for(
int i=lowBin; i<highBin; ++i){
395 for(
int j=0; j<highBin-lowBin; ++j){
396 if(i==j) { Cov(i,j) =
sqrt(mean(i)); }
397 else { Cov(i,j) = 0; }
404 floating, mean, Cov);
406 proto->import(constraint);
408 constraintTermNames.push_back(constraint.
GetName());
412 std::vector<HistoSys> histoSysList,
413 string prefix,
string productPrefix,
415 vector<string>& constraintTermNames){
425 unsigned int histndim(1);
426 std::string classname = nominal->
ClassName();
427 if (classname.find(
"TH1")==0) { histndim=1; }
428 else if (classname.find(
"TH2")==0) { histndim=2; }
429 else if (classname.find(
"TH3")==0) { histndim=3; }
435 std::vector<std::string>::iterator itr =
fObsNameVec.begin();
436 for (
int idx=0; itr!=
fObsNameVec.end(); ++itr, ++idx ) {
437 if ( !
proto->var(itr->c_str()) ) {
439 if (idx==0) { axis = nominal->
GetXaxis(); }
440 else if (idx==1) { axis = nominal->
GetYaxis(); }
441 else if (idx==2) { axis = nominal->
GetZaxis(); }
443 std::cout <<
"Error: Too many observables. "
444 <<
"HistFactory only accepts up to 3 observables (3d) "
453 proto->var(itr->c_str())->setBins(nbins);
455 observables.
add( *
proto->var(itr->c_str()) );
467 for(
unsigned int j=0; j<histoSysList.size(); ++j){
468 std::stringstream str;
471 HistoSys& histoSys = histoSysList.at(j);
472 string histoSysName = histoSys.
GetName();
477 temp = (
RooRealVar*)
proto->factory((
"alpha_" + histoSysName + range).c_str());
480 string command=(
"Gaussian::alpha_"+histoSysName+
"Constraint(alpha_"+histoSysName+
",nom_alpha_"+histoSysName+
"[0.,-10,10],1.)");
481 cout << command << endl;
482 constraintTermNames.push_back(
proto->factory( command.c_str() )->
GetName() );
483 proto->var((
"nom_alpha_"+histoSysName).c_str())->setConstant();
484 const_cast<RooArgSet*
>(
proto->set(
"globalObservables"))->add(*
proto->var((
"nom_alpha_"+histoSysName).c_str()));
491 vector<double> low, high;
494 for(
unsigned int j=0; j<histoSysList.size(); ++j){
495 std::stringstream str;
498 HistoSys& histoSys = histoSysList.at(j);
503 lowSet.
add(*lowFunc);
504 highSet.
add(*highFunc);
516 proto->import(interp);
519 proto->factory((
"prod:"+productPrefix+
"("+prefix+
","+systTerm+
")").c_str() );
525 string overallNorm_times_sigmaEpsilon ;
529 vector<string> normFactorNames, rangeNames;
531 if(normList.size() > 0){
533 for(vector<NormFactor>::iterator itr = normList.begin(); itr != normList.end(); ++itr){
538 if(!prodNames.empty()) prodNames +=
",";
540 varname = norm.
GetName() +
"_" + channel;
549 std::stringstream range;
552 if(
proto->obj(varname.c_str()) == NULL) {
553 cout <<
"making normFactor: " << norm.
GetName() << endl;
555 proto->factory((varname + range.str()).c_str());
561 cout <<
"WARNING: Const attribute to <NormFactor> tag is deprecated, will ignore." <<
562 " Instead, add \n\t<ParamSetting Const=\"True\">" << varname <<
"</ParamSetting>\n" <<
563 " to your top-level XML's <Measurment> entry" << endl;
566 rangeNames.push_back(range.str());
567 normFactorNames.push_back(varname);
570 overallNorm_times_sigmaEpsilon = sample.
GetName() +
"_" + channel +
"_overallNorm_x_sigma_epsilon";
571 proto->factory((
"prod::" + overallNorm_times_sigmaEpsilon +
"(" + prodNames +
"," + sigmaEpsilon +
")").c_str());
574 unsigned int rangeIndex=0;
575 for( vector<string>::iterator nit = normFactorNames.begin(); nit!=normFactorNames.end(); ++nit){
576 if( count (normFactorNames.begin(), normFactorNames.end(), *nit) > 1 ){
577 cout <<
"WARNING: <NormFactor Name =\""<<*nit<<
"\"> is duplicated for <Sample Name=\""
578 << sample.
GetName() <<
"\">, but only one factor will be included. \n Instead, define something like"
579 <<
"\n\t<Function Name=\""<<*nit<<
"Squared\" Expresion=\""<<*nit<<
"*"<<*nit<<
"\" Var=\""<<*nit<<rangeNames.at(rangeIndex)
580 <<
"\"> \nin your top-level XML's <Measurment> entry and use <NormFactor Name=\""<<*nit<<
"Squared\" in your channel XML file."<< endl;
585 if(!overallNorm_times_sigmaEpsilon.empty())
586 return overallNorm_times_sigmaEpsilon;
593 std::vector<OverallSys>& systList,
594 vector<string>& constraintTermNames,
595 vector<string>& totSystTermNames) {
601 totSystTermNames.push_back(prefix);
604 vector<double> lowVec, highVec;
606 std::map<std::string, double>::iterator itconstr;
607 for(
unsigned int i = 0; i < systList.size(); ++i) {
610 std::string strname = sys.
GetName();
611 const char *
name = strname.c_str();
615 std::cout <<
"HistoToWorkspaceFast::AddConstraintTerm - skip systematic " << sys.
GetName() << std::endl;
622 std::cout <<
"HistoToWorkspaceFast::AddConstraintTerm - zero uncertainty assigned - skip systematic " << sys.
GetName() << std::endl;
625 double tauVal = 1./(relerr*relerr);
626 double sqtau = 1./relerr;
639 alphaOfBeta->
Print(
"t");
641 constraintTermNames.push_back(
gamma->GetName());
645 const_cast<RooArgSet*
>(
proto->set(
"globalObservables"))->add(*yvar);
648 params.
add(*alphaOfBeta);
649 std::cout <<
"Added a gamma constraint for " <<
name << std::endl;
658 double gaussSigma = 1;
661 std::cout <<
"Added a uniform constraint for " <<
name <<
" as a gaussian constraint with a very large sigma " << std::endl;
672 constraintTermNames.push_back( gausConstraint->
GetName() );
673 proto->var((
"nom_" + prefix + sys.
GetName()).c_str())->setConstant();
674 const_cast<RooArgSet*
>(
proto->set(
"globalObservables"))->add(*nomAlpha);
690 double tauVal = 1./relerr;
691 std::string tauName =
"tau_" + sys.
GetName();
693 double kappaVal = 1. + relerr;
694 std::string kappaName =
"kappa_" + sys.
GetName();
696 const char * alphaName = alpha->
GetName();
698 std::string alphaOfBetaName =
"alphaOfBeta_" + sys.
GetName();
700 tauName.c_str(),kappaName.c_str(),alphaName,
701 tauName.c_str(),kappaName.c_str(),alphaName ) );
703 std::cout <<
"Added a log-normal constraint for " <<
name << std::endl;
704 alphaOfBeta->
Print(
"t");
705 params.
add(*alphaOfBeta);
710 double low = sys.
GetLow();
712 lowVec.push_back(low);
713 highVec.push_back(high);
717 if(systList.size() > 0){
722 assert(
int(lowVec.size()) == params.
getSize() );
724 FlexibleInterpVar interp( (interpName).c_str(),
"", params, 1., lowVec, highVec);
727 proto->import(interp);
732 proto->import(interp);
742 vector<string>& syst_x_expectedPrefixNames,
743 vector<string>& normByNames){
753 double binWidth(1.0);
754 std::string obsNameVecStr;
755 std::vector<std::string>::iterator itr =
fObsNameVec.begin();
757 std::string obsName = *itr;
758 binWidth *=
proto->var(obsName.c_str())->numBins()/(
proto->var(obsName.c_str())->getMax() -
proto->var(obsName.c_str())->getMin()) ;
759 if (obsNameVecStr.size()>0) { obsNameVecStr +=
"_"; }
760 obsNameVecStr += obsName;
764 for(
unsigned int j=0; j<syst_x_expectedPrefixNames.size();++j){
765 std::stringstream str;
769 command=string(
Form(
"binWidth_%s_%d[%e]",obsNameVecStr.c_str(),j,binWidth));
770 proto->factory(command.c_str());
771 proto->var(
Form(
"binWidth_%s_%d",obsNameVecStr.c_str(),j))->setConstant();
772 coeffList+=prepend+
"binWidth_"+obsNameVecStr+str.str();
774 command=
"prod::L_x_"+syst_x_expectedPrefixNames.at(j)+
"("+normByNames.at(j)+
","+syst_x_expectedPrefixNames.at(j)+
")";
776 proto->factory(command.c_str());
777 shapeList+=prepend+
"L_x_"+syst_x_expectedPrefixNames.at(j);
786 proto->defineSet(
"coefList",coeffList.c_str());
787 proto->defineSet(
"shapeList",shapeList.c_str());
821 vector<string>& likelihoodTermNames){
826 for(
Int_t i=lowBin; i<highBin; ++i){
827 std::stringstream str;
830 string command(
"Poisson::"+prefix+str.str()+
"("+obsPrefix+str.str()+
","+expPrefix+str.str()+
",1)");
834 cout <<
"Poisson Term " << command << endl;
838 likelihoodTermNames.push_back( temp->
GetName() );
841 proto->defineSet(prefix.c_str(),Pois);
847 TTree*
tree =
new TTree();
851 for(
Int_t i=lowBin; i<highBin; ++i){
852 std::stringstream str;
855 cout <<
"expected number of events called: " << expPrefix << endl;
861 cout <<
"setting obs"+str.str()+
" to expected = " <<
exp->getVal() <<
" check: " << obs->
getVal() << endl;
864 obsForTree[i] =
exp->getVal();
865 tree->Branch((obsPrefix+str.str()).c_str(), obsForTree+i ,(obsPrefix+str.str()+
"/D").c_str());
868 cout <<
"problem retrieving obs or exp " << obsPrefix+str.str() << obs <<
" " << expPrefix+str.str() <<
exp << endl;
875 delete [] obsForTree;
886 map<string,double> gammaSyst,
887 map<string,double> uniformSyst,
888 map<string,double> logNormSyst,
889 map<string,double> noSyst) {
890 string pdfName(pdfNameChar);
893 if( combined_config==NULL ) {
894 std::cout <<
"Error: Failed to find object 'ModelConfig' in workspace: "
895 <<
proto->GetName() << std::endl;
900 string edit=
"EDIT::newSimPdf("+pdfName+
",";
902 string lastPdf=pdfName;
904 unsigned int numReplacements = 0;
905 unsigned int nskipped = 0;
906 map<string,double>::iterator it;
910 for(it=gammaSyst.begin(); it!=gammaSyst.end(); ++it) {
912 if(!
proto->var((
"alpha_"+it->first).c_str())){
919 double relativeUncertainty = it->second;
920 double scale = 1/
sqrt((1+1/
pow(relativeUncertainty,2)));
923 proto->factory(
Form(
"beta_%s[1,0,10]",it->first.c_str()));
924 proto->factory(
Form(
"y_%s[%f]",it->first.c_str(),1./
pow(relativeUncertainty,2))) ;
925 proto->factory(
Form(
"theta_%s[%f]",it->first.c_str(),
pow(relativeUncertainty,2))) ;
926 proto->factory(
Form(
"Gamma::beta_%sConstraint(beta_%s,sum::k_%s(y_%s,one[1]),theta_%s,zero[0])",
931 it->first.c_str())) ;
947 proto->factory(
Form(
"PolyVar::alphaOfBeta_%s(beta_%s,{%f,%f})",it->first.c_str(),it->first.c_str(),-1./scale,1./scale));
950 if(
proto->var(
Form(
"alpha_%s",it->first.c_str()))->isConstant()) {
951 proto->var(
Form(
"beta_%s",it->first.c_str()))->setConstant(
true);
954 proto->var(
Form(
"beta_%s",it->first.c_str()))->setConstant(
false);
960 editList+=precede +
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint";
962 editList+=precede +
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first;
972 if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
973 edit=
"EDIT::"+lastPdf+
"_("+lastPdf+
","+editList+
")";
977 cout <<
"Going to issue this edit command\n" << edit<< endl;
978 proto->factory( edit.c_str() );
981 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
987 for(it=uniformSyst.begin(); it!=uniformSyst.end(); ++it) {
988 cout <<
"edit for " << it->first <<
"with rel uncert = " << it->second << endl;
989 if(!
proto->var((
"alpha_"+it->first).c_str())){
990 cout <<
"systematic not there" << endl;
997 proto->factory(
Form(
"beta_%s[1,0,10]",it->first.c_str()));
998 proto->factory(
Form(
"Uniform::beta_%sConstraint(beta_%s)",it->first.c_str(),it->first.c_str()));
999 proto->factory(
Form(
"PolyVar::alphaOfBeta_%s(beta_%s,{-1,1})",it->first.c_str(),it->first.c_str()));
1002 if(
proto->var(
Form(
"alpha_%s",it->first.c_str()))->isConstant())
1003 proto->var(
Form(
"beta_%s",it->first.c_str()))->setConstant(
true);
1005 proto->var(
Form(
"beta_%s",it->first.c_str()))->setConstant(
false);
1010 cout <<
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint" << endl;
1011 editList+=precede +
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint";
1013 cout <<
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first << endl;
1014 editList+=precede +
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first;
1016 if(
proto->pdf((
"alpha_"+it->first+
"Constraint").c_str()) &&
proto->var((
"alpha_"+it->first).c_str()) )
1017 cout <<
" checked they are there" <<
proto->pdf((
"alpha_"+it->first+
"Constraint").c_str()) <<
" " <<
proto->var((
"alpha_"+it->first).c_str()) << endl;
1019 cout <<
"NOT THERE" << endl;
1022 if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
1023 edit=
"EDIT::"+lastPdf+
"_("+lastPdf+
","+editList+
")";
1027 cout << edit<< endl;
1028 proto->factory( edit.c_str() );
1031 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
1041 for(it=logNormSyst.begin(); it!=logNormSyst.end(); ++it) {
1042 cout <<
"edit for " << it->first <<
"with rel uncert = " << it->second << endl;
1043 if(!
proto->var((
"alpha_"+it->first).c_str())){
1044 cout <<
"systematic not there" << endl;
1050 double relativeUncertainty = it->second;
1051 double kappa = 1+relativeUncertainty;
1055 double scale = relativeUncertainty;
1058 const char * cname = it->first.c_str();
1065 cname, cname, cname, cname)) ;
1066 proto->factory(
TString::Format(
"PolyVar::alphaOfBeta_%s(beta_%s,{%f,%f})",cname,cname,-1./scale,1./scale));
1078 cout <<
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint" << endl;
1079 editList+=precede +
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint";
1081 cout <<
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first << endl;
1082 editList+=precede +
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first;
1084 if(
proto->pdf((
"alpha_"+it->first+
"Constraint").c_str()) &&
proto->var((
"alpha_"+it->first).c_str()) )
1085 cout <<
" checked they are there" <<
proto->pdf((
"alpha_"+it->first+
"Constraint").c_str()) <<
" " <<
proto->var((
"alpha_"+it->first).c_str()) << endl;
1087 cout <<
"NOT THERE" << endl;
1090 if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
1091 edit=
"EDIT::"+lastPdf+
"_("+lastPdf+
","+editList+
")";
1095 cout << edit<< endl;
1096 proto->factory( edit.c_str() );
1099 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
1106 proto->removeSet(
"globalObservables");
1107 proto->defineSet(
"globalObservables",gobsNew);
1115 for(it=noSyst.begin(); it!=noSyst.end(); ++it) {
1117 cout <<
"remove constraint for parameter" << it->first << endl;
1118 if(!
proto->var((
"alpha_"+it->first).c_str()) || !
proto->pdf((
"alpha_"+it->first+
"Constraint").c_str()) ) {
1119 cout <<
"systematic not there" << endl;
1126 if ( !
proto->var(
"one") ) {
proto->factory(
"one[1.0]"); }
1127 proto->var(
"one")->setConstant();
1130 cout <<
"alpha_"+it->first+
"Constraint=one" << endl;
1131 editList+=precede +
"alpha_"+it->first+
"Constraint=one";
1135 if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
1136 edit=
"EDIT::"+lastPdf+
"_("+lastPdf+
","+editList+
")";
1140 cout << edit << endl;
1141 proto->factory( edit.c_str() );
1143 if(!newOne) { cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl; }
1150 edit=
"EDIT::newSimPdf("+lastPdf+
","+editList+
")";
1151 cout << edit<< endl;
1152 proto->factory( edit.c_str() );
1157 combined_config->
SetPdf(*newOne);
1160 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
1167 FILE* covFile = fopen ((filename).c_str(),
"w");
1172 fprintf(covFile,
" ") ;
1175 fprintf(covFile,
" & %s", myargi->
GetName());
1177 fprintf(covFile,
"\\\\ \\hline \n" );
1181 fprintf(covFile,
"%s", myargi->
GetName());
1186 fprintf(covFile,
" & %.2f", result->
correlation(*myargi, *myargj));
1189 fprintf(covFile,
" \\\\\n");
1202 Error(
"MakeSingleChannelWorkspace",
"The input Channel does not contain any sample - return a nullptr");
1214 string channel_name = channel.
GetName();
1222 TH1* channel_hist_template = channel.
GetSamples().at(0).GetHisto();
1225 for (
unsigned int idx=0; idx<
fObsNameVec.size(); ++idx ) {
1236 cout <<
"\n\n-------------------\nStarting to process " << channel_name <<
" channel with " <<
fObsNameVec.size() <<
" observables" << endl;
1242 auto proto_config = make_unique<ModelConfig>(
"ModelConfig",
proto);
1243 proto_config->SetWorkspace(*
proto);
1248 cout <<
"will preprocess this line: " << *funcIter <<endl;
1249 proto->factory(funcIter->c_str());
1253 RooArgSet likelihoodTerms(
"likelihoodTerms"), constraintTerms(
"constraintTerms");
1254 vector<string> likelihoodTermNames, constraintTermNames, totSystTermNames, syst_x_expectedPrefixNames, normalizationNames;
1256 vector< pair<string,string> > statNamePairs;
1257 vector< pair<TH1*,TH1*> > statHistPairs;
1258 std::string statFuncName;
1259 std::string statNodeName;
1263 string prefix, range;
1268 std::stringstream lumiStr;
1271 proto->factory((
"Lumi"+lumiStr.str()).c_str());
1272 cout <<
"lumi str = " << lumiStr.str() << endl;
1274 std::stringstream lumiErrorStr;
1276 proto->factory((
"Gaussian::lumiConstraint(Lumi,"+lumiErrorStr.str()+
")").c_str());
1277 proto->var(
"nominalLumi")->setConstant();
1278 proto->defineSet(
"globalObservables",
"nominalLumi");
1280 constraintTermNames.push_back(
"lumiConstraint");
1281 cout <<
"lumi Error str = " << lumiErrorStr.str() << endl;
1288 vector<Sample>::iterator it = channel.
GetSamples().begin();
1289 for(; it!=channel.
GetSamples().end(); ++it) {
1293 string overallSystName = sample.
GetName() +
"_" + channel_name +
"_epsilon";
1295 string systSourcePrefix =
"alpha_";
1303 overallSystName =
AddNormFactor(
proto, channel_name, overallSystName, sample, doRatio);
1308 string syst_x_expectedPrefix =
"";
1328 cout << sample.
GetName() +
"_" + channel_name +
" has no variation histograms " << endl;
1329 string expPrefix = sample.
GetName() +
"_" + channel_name;
1330 syst_x_expectedPrefix = sample.
GetName() +
"_" + channel_name +
"_overallSyst_x_Exp";
1338 string constraintPrefix = sample.
GetName() +
"_" + channel_name +
"_Hist_alpha";
1339 syst_x_expectedPrefix = sample.
GetName() +
"_" + channel_name +
"_overallSyst_x_HistSyst";
1344 constraintPrefix, syst_x_expectedPrefix, overallSystName,
1345 constraintTermNames);
1355 std::cout <<
"Cannot include Stat Error for histograms of more than 3 dimensions."
1364 std::cout <<
"Sample: " << sample.
GetName() <<
" to be included in Stat Error "
1365 <<
"for channel " << channel_name
1395 string UncertName = syst_x_expectedPrefix +
"_StatAbsolUncert";
1396 TH1* statErrorHist = NULL;
1400 std::cout <<
"Making Statistical Uncertainty Hist for "
1401 <<
" Channel: " << channel_name
1402 <<
" Sample: " << sample.
GetName()
1413 std::cout <<
"Using external histogram for Stat Errors for "
1414 <<
" Channel: " << channel_name
1415 <<
" Sample: " << sample.
GetName()
1417 std::cout <<
"Error Histogram: " << statErrorHist->
GetName() << std::endl;
1420 statErrorHist->
Multiply( nominal );
1421 statErrorHist->
SetName( UncertName.c_str() );
1426 statHistPairs.push_back( pair<TH1*,TH1*>(nominal, statErrorHist) );
1443 statFuncName =
"mc_stat_" + channel_name;
1445 if( paramHist == NULL ) {
1450 std::vector<std::string>::iterator itr =
fObsNameVec.begin();
1451 for (
int idx=0; itr!=
fObsNameVec.end(); ++itr, ++idx ) {
1452 observables.
add( *
proto->var(itr->c_str()) );
1457 std::string ParamSetPrefix =
"gamma_stat_" + channel_name;
1461 ParamSetPrefix.c_str(),
1463 gammaMin, gammaMax);
1465 ParamHistFunc statUncertFunc(statFuncName.c_str(), statFuncName.c_str(),
1466 observables, statFactorParams );
1477 statNodeName = sample.
GetName() +
"_" + channel_name +
"_overallSyst_x_StatUncert";
1480 RooProduct nodeWithMcStat(statNodeName.c_str(), statNodeName.c_str(),
1488 syst_x_expectedPrefix = nodeWithMcStat.
GetName();
1501 std::cout <<
"Cannot include Stat Error for histograms of more than 3 dimensions."
1506 std::cout <<
"Sample: " << sample.
GetName() <<
" in channel: " << channel_name
1507 <<
" to be include a ShapeFactor."
1510 std::vector<ParamHistFunc*> paramHistFuncList;
1511 std::vector<std::string> shapeFactorNameList;
1517 std::string funcName = channel_name +
"_" + shapeFactor.
GetName() +
"_shapeFactor";
1519 if( paramHist == NULL ) {
1522 std::vector<std::string>::iterator itr =
fObsNameVec.begin();
1523 for (
int idx=0; itr!=
fObsNameVec.end(); ++itr, ++idx ) {
1524 observables.
add( *
proto->var(itr->c_str()) );
1528 std::string funcParams =
"gamma_" + shapeFactor.
GetName();
1534 observables, 0, 1000);
1537 ParamHistFunc shapeFactorFunc( funcName.c_str(), funcName.c_str(),
1538 observables, shapeFactorParams );
1543 std::cout <<
"Setting Shape Factor: " << shapeFactor.
GetName()
1544 <<
" to have initial shape from hist: "
1547 shapeFactorFunc.
setShape( initialShape );
1552 std::cout <<
"Setting Shape Factor: " << shapeFactor.
GetName()
1553 <<
" to be constant" << std::endl;
1562 paramHistFuncList.push_back(paramHist);
1563 shapeFactorNameList.push_back(funcName);
1572 std::string shapeFactorNodeName = syst_x_expectedPrefix;
1573 for(
unsigned int i=0; i < shapeFactorNameList.size(); ++i) {
1574 shapeFactorNodeName +=
"_x_" + shapeFactorNameList.at(i);
1579 for(
unsigned int i=0; i < paramHistFuncList.size(); ++i) {
1580 nodesForProduct.
add( *paramHistFuncList.at(i) );
1585 RooProduct nodeWithShapeFactor(shapeFactorNodeName.c_str(),
1586 shapeFactorNodeName.c_str(),
1594 syst_x_expectedPrefix = nodeWithShapeFactor.
GetName();
1607 std::cout <<
"Cannot include Stat Error for histograms of more than 3 dimensions."
1613 std::vector<string> ShapeSysNames;
1628 std::cout <<
"Sample: " << sample.
GetName() <<
" in channel: " << channel_name
1629 <<
" to include a ShapeSys." << std::endl;
1631 std::string funcName = channel_name +
"_" + shapeSys.
GetName() +
"_ShapeSys";
1632 ShapeSysNames.push_back( funcName );
1634 if( paramHist == NULL ) {
1640 std::vector<std::string>::iterator itr =
fObsNameVec.begin();
1642 observables.
add( *
proto->var(itr->c_str()) );
1646 std::string funcParams =
"gamma_" + shapeSys.
GetName();
1649 observables, 0, 10);
1652 ParamHistFunc shapeFactorFunc( funcName.c_str(), funcName.c_str(),
1653 observables, shapeFactorParams );
1676 Double_t minShapeUncertainty = 0.0;
1678 *paramHist, shapeErrorHist,
1680 minShapeUncertainty);
1688 std::string NodeName = syst_x_expectedPrefix;
1691 ShapeSysForNode.
add( *expFunc );
1692 for(
unsigned int i = 0; i < ShapeSysNames.size(); ++i ) {
1693 std::string ShapeSysName = ShapeSysNames.at(i);
1694 ShapeSysForNode.
add( *
proto->function(ShapeSysName.c_str()) );
1695 NodeName = NodeName +
"_x_" + ShapeSysName;
1699 RooProduct nodeWithShapeFactor(NodeName.c_str(), NodeName.c_str(), ShapeSysForNode );
1705 syst_x_expectedPrefix = nodeWithShapeFactor.
GetName();
1714 syst_x_expectedPrefixNames.push_back(syst_x_expectedPrefix);
1720 normalizationNames.push_back(
"Lumi" );
1723 TString lumiParamString;
1724 lumiParamString += measurement.
GetLumi();
1725 lumiParamString.ReplaceAll(
' ', TString());
1726 normalizationNames.push_back(lumiParamString.Data());
1734 if( statHistPairs.size() > 0 ) {
1739 if( fracStatError == NULL ) {
1740 std::cout <<
"Error: Failed to make ScaledUncertaintyHist for: "
1741 << statNodeName << std::endl;
1748 std::cout <<
"About to create Constraint Terms from: "
1749 << chanStatUncertFunc->
GetName()
1750 <<
" params: " << chanStatUncertFunc->
paramList()
1761 std::cout <<
"Using Gaussian StatErrors in channel: " << channel.
GetName() << std::endl;
1764 std::cout <<
"Using Poisson StatErrors in channel: " << channel.
GetName() << std::endl;
1769 *chanStatUncertFunc, fracStatError,
1771 statRelErrorThreshold);
1775 for (
unsigned int i = 0; i < statHistPairs.size() ; ++i )
1776 delete statHistPairs[i].
second;
1778 statHistPairs.clear();
1780 delete fracStatError;
1790 syst_x_expectedPrefixNames, normalizationNames);
1791 likelihoodTermNames.push_back(channel_name+
"_model");
1795 for(
unsigned int i=0; i<systToFix.size(); ++i){
1803 if(systToFix.at(i)==
"Lumi"){
1804 auxMeas =
proto->var(
"nominalLumi");
1810 const_cast<RooArgSet*
>(
proto->set(
"globalObservables"))->remove(*auxMeas);
1812 cout <<
"could not corresponding auxiliary measurement "
1816 cout <<
"could not find variable " << systToFix.at(i)
1817 <<
" could not set it to constant" << endl;
1823 for(
unsigned int i=0; i<constraintTermNames.size(); ++i){
1824 RooAbsArg* proto_arg = (
proto->arg(constraintTermNames[i].c_str()));
1825 if( proto_arg==NULL ) {
1826 std::cout <<
"Error: Cannot find arg set: " << constraintTermNames.at(i)
1827 <<
" in workspace: " <<
proto->GetName() << std::endl;
1830 constraintTerms.
add( *proto_arg );
1833 for(
unsigned int i=0; i<likelihoodTermNames.size(); ++i){
1834 RooAbsArg* proto_arg = (
proto->arg(likelihoodTermNames[i].c_str()));
1835 if( proto_arg==NULL ) {
1836 std::cout <<
"Error: Cannot find arg set: " << likelihoodTermNames.at(i)
1837 <<
" in workspace: " <<
proto->GetName() << std::endl;
1840 likelihoodTerms.add( *proto_arg );
1842 proto->defineSet(
"constraintTerms",constraintTerms);
1843 proto->defineSet(
"likelihoodTerms",likelihoodTerms);
1848 std::string observablesStr;
1850 std::vector<std::string>::iterator itr =
fObsNameVec.begin();
1852 observables.
add( *
proto->var(itr->c_str()) );
1853 if (!observablesStr.empty()) { observablesStr +=
","; }
1854 observablesStr += *itr;
1865 cout <<
"-----------------------------------------"<<endl;
1866 cout <<
"import model into workspace" << endl;
1868 auto model = make_unique<RooProdPdf>(
1869 (
"model_"+channel_name).c_str(),
1870 "product of Poissons accross bins for a single channel",
1871 constraintTerms,
Conditional(likelihoodTerms,observables));
1874 proto_config->SetPdf(*
model);
1875 proto_config->SetObservables(observables);
1876 proto_config->SetGlobalObservables(*
proto->set(
"globalObservables"));
1880 proto->import(*proto_config,proto_config->GetName());
1881 proto->importClassCode();
1886 const char* weightName=
"weightVar";
1896 RooDataSet* asimovDataUnbinned = new RooDataSet("asimovData","",*proto->set("obsAndWeight"),weightName);
1897 for(int i=0; i<asimov_data->numEntries(); ++i){
1898 asimov_data->get(i)->Print("v");
1899 //cout << "GREPME : " << i << " " << data->weight() <<endl;
1900 asimovDataUnbinned->add( *asimov_data->get(i), asimov_data->weight() );
1902 proto->import(*asimovDataUnbinned);
1914 TH1* mnominal =
data.GetHisto();
1916 std::cout <<
"Error: Data histogram for channel: " << channel.
GetName()
1917 <<
" is NULL" << std::endl;
1922 auto obsDataUnbinned = make_unique<RooDataSet>(
"obsData",
"",*
proto->set(
"obsAndWeight"),weightName);
1961 proto->import(*obsDataUnbinned);
1968 std::string dataName =
data.GetName();
1969 TH1* mnominal =
data.GetHisto();
1971 std::cout <<
"Error: Additional Data histogram for channel: " << channel.
GetName()
1972 <<
" with name: " << dataName <<
" is NULL" << std::endl;
1977 auto obsDataUnbinned = make_unique<RooDataSet>(dataName.c_str(), dataName.c_str(),
1978 *
proto->set(
"obsAndWeight"), weightName);
2016 proto->import(*obsDataUnbinned);
2028 std::vector<std::string> ObsNameVec) {
2034 if (ObsNameVec.empty() ) {
2035 Error(
"ConfigureHistFactoryDataset",
"Invalid input - return");
2045 for (
int i=1; i<=ax->
GetNbins(); ++i) {
2048 proto->var( ObsNameVec[0].c_str() )->setVal( xval );
2050 if(ObsNameVec.size()==1) {
2052 obsDataUnbinned->
add( *
proto->set(
"obsAndWeight"), fval );
2055 for(
int j=1; j<=ay->
GetNbins(); ++j) {
2057 proto->var( ObsNameVec[1].c_str() )->setVal( yval );
2059 if(ObsNameVec.size()==2) {
2061 obsDataUnbinned->
add( *
proto->set(
"obsAndWeight"), fval );
2064 for(
int k=1; k<=az->
GetNbins(); ++k) {
2066 proto->var( ObsNameVec[2].c_str() )->setVal( zval );
2068 obsDataUnbinned->
add( *
proto->set(
"obsAndWeight"), fval );
2081 unsigned int histndim(1);
2082 std::string classname = hist->
ClassName();
2083 if (classname.find(
"TH1")==0) { histndim=1; }
2084 else if (classname.find(
"TH2")==0) { histndim=2; }
2085 else if (classname.find(
"TH3")==0) { histndim=3; }
2087 for (
unsigned int idx=0; idx<histndim; ++idx ) {
2100 if (ch_names.empty() || chs.empty() ) {
2101 Error(
"MakeCombinedModel",
"Input vectors are empty - return a nullptr");
2104 if (chs.size() < ch_names.size() ) {
2105 Error(
"MakeCombinedModel",
"Input vector of workspace has an invalid size - return a nullptr");
2113 map<string, RooAbsPdf*> pdfMap;
2114 vector<RooAbsPdf*> models;
2118 for(
unsigned int i = 0; i< ch_names.size(); ++i){
2122 cout <<
"full list of observables:"<<endl;
2126 for(
unsigned int i = 0; i< ch_names.size(); ++i){
2127 string channel_name=ch_names[i];
2129 if (ss.str().empty()) ss << channel_name ;
2130 else ss <<
',' << channel_name ;
2134 if(!
model) cout <<
"failed to find model for channel"<<endl;
2136 models.push_back(
model);
2137 globalObs.
add(*ch->
set(
"globalObservables"));
2140 pdfMap[channel_name]=
model;
2144 cout <<
"\n\n------------------\n Entering combination" << endl;
2155 combined->
import(globalObs);
2156 combined->
defineSet(
"globalObservables",globalObs);
2162 cout <<
"-----------------------------------------"<<endl;
2163 cout <<
"create toy data for " << ss.str() << endl;
2169 combined->
factory(
"weightVar[0,-1e10,1e10]");
2170 obsList.
add(*combined->
var(
"weightVar"));
2191 if( asimov_combined ) {
2192 combined->
import( *asimov_combined,
Rename(
"asimovData"));
2195 std::cout <<
"Error: Failed to create combined asimov dataset" << std::endl;
2198 delete asimov_combined;
2201 if(chs[0]->
data(
"obsData") != NULL) {
2202 MergeDataSets(combined, chs, ch_names,
"obsData", obsList, channelCat);
2250 obsList.
add(*channelCat);
2251 combined->
defineSet(
"observables",obsList);
2256 cout <<
"\n\n----------------\n Importing combined model" << endl;
2262 std::map< std::string, double>::iterator param_itr =
fParamValues.begin();
2265 std::string paramName = param_itr->first;
2266 double paramVal = param_itr->second;
2270 temp->
setVal( paramVal );
2271 cout <<
"setting " << paramName <<
" to the value: " << paramVal << endl;
2273 cout <<
"could not find variable " << paramName <<
" could not set its value" << endl;
2277 for(
unsigned int i=0; i<
fSystToFix.size(); ++i){
2282 cout <<
"setting " <<
fSystToFix.at(i) <<
" constant" << endl;
2284 cout <<
"could not find variable " <<
fSystToFix.at(i) <<
" could not set it to constant" << endl;
2292 combined_config->
SetPdf(*simPdf);
2295 combined->
import(*combined_config,combined_config->
GetName());
2300 delete combined_config;
2308 std::vector<RooWorkspace*> wspace_vec,
2309 std::vector<std::string> channel_names,
2310 std::string dataSetName,
2319 for(
unsigned int i = 0; i< channel_names.size(); ++i){
2322 std::cout <<
"Merging data for channel " << channel_names[i].c_str() << std::endl;
2324 if( !obsDataInChannel ) {
2325 std::cout <<
"Error: Can't find DataSet: " << dataSetName
2326 <<
" in channel: " << channel_names.at(i)
2333 obsList,
Index(*channelCat),
2335 Import(channel_names[i].c_str(),*obsDataInChannel));
2337 simData->
append(*tempData);
2348 combined->
import(*simData,
Rename(dataSetName.c_str()));
2353 std::cout <<
"Error: Unable to merge observable datasets" << std::endl;
2372 Int_t binNumber = 0;
2375 for(
Int_t i_bin = 0; i_bin < numBins; ++i_bin) {
2386 if( histError != histError ) {
2387 std::cout <<
"Warning: In histogram " << Nominal->
GetName()
2388 <<
" bin error for bin " << i_bin
2389 <<
" is NAN. Not using Error!!!"
2397 if( histError < 0 ) {
2398 std::cout <<
"Warning: In histogram " << Nominal->
GetName()
2399 <<
" bin error for bin " << binNumber
2400 <<
" is < 0. Setting Error to 0"
2426 unsigned int numHists = HistVec.size();
2428 if( numHists == 0 ) {
2429 std::cout <<
"Warning: Empty Hist Vector, cannot create total uncertainty" << std::endl;
2433 TH1* HistTemplate = HistVec.at(0).first;
2438 for(
unsigned int i = 0; i < HistVec.size(); ++i ) {
2440 TH1* nominal = HistVec.at(i).first;
2441 TH1* error = HistVec.at(i).second;
2444 std::cout <<
"Error: Provided hists have unequal bins" << std::endl;
2448 std::cout <<
"Error: Provided hists have unequal bins" << std::endl;
2453 std::vector<double> TotalBinContent( numBins, 0.0);
2454 std::vector<double> HistErrorsSqr( numBins, 0.0);
2456 Int_t binNumber = 0;
2459 for(
Int_t i_bins = 0; i_bins < numBins; ++i_bins) {
2466 for(
unsigned int i_hist = 0; i_hist < numHists; ++i_hist ) {
2468 TH1* nominal = HistVec.at(i_hist).first;
2469 TH1* error = HistVec.at(i_hist).second;
2484 if( histError != histError ) {
2485 std::cout <<
"Warning: In histogram " << error->
GetName()
2486 <<
" bin error for bin " << binNumber
2487 <<
" is NAN. Not using error!!"
2493 TotalBinContent.at(i_bins) += histValue;
2494 HistErrorsSqr.at(i_bins) += histError*histError;
2506 for(
Int_t i = 0; i < numBins; ++i) {
2514 Double_t ErrorsSqr = HistErrorsSqr.at(i);
2515 Double_t TotalVal = TotalBinContent.at(i);
2517 if( TotalVal <= 0 ) {
2518 std::cout <<
"Warning: Sum of histograms for bin: " << binNumber
2519 <<
" is <= 0. Setting error to 0"
2530 if( RelativeError != RelativeError ) {
2531 std::cout <<
"Error: bin " << i <<
" error is NAN" << std::endl;
2532 std::cout <<
" HistErrorsSqr: " << ErrorsSqr
2533 <<
" TotalVal: " << TotalVal
2544 std::cout <<
"Making Total Uncertainty for bin " << binNumber
2545 <<
" Error = " <<
sqrt(ErrorsSqr)
2546 <<
" Val = " << TotalVal
2547 <<
" RelativeError = " << RelativeError
2589 if( numBins != numParams ) {
2590 std::cout <<
"Error: In createStatConstraintTerms, encountered bad number of bins" << std::endl;
2591 std::cout <<
"Given histogram with " << numBins <<
" bins,"
2592 <<
" but require exactly " << numParams << std::endl;
2596 Int_t TH1BinNumber = 0;
2607 std::cout <<
"Creating constraint for: " <<
gamma.GetName()
2608 <<
". Type of constraint: " <<
type << std::endl;
2617 std::cout <<
"Not creating constraint term for "
2619 <<
" because sigma = " <<
sigma
2621 <<
" (TH1 bin number = " << TH1BinNumber <<
")"
2633 std::string constrName = string(
gamma.GetName()) +
"_constraint";
2634 std::string nomName = string(
"nom_") +
gamma.GetName();
2635 std::string sigmaName = string(
gamma.GetName()) +
"_sigma";
2636 std::string poisMeanName = string(
gamma.GetName()) +
"_poisMean";
2649 RooRealVar constrNom(nomName.c_str(), nomName.c_str(), 1.0,0,10);
2654 constrNom,
gamma, constrSigma );
2664 RooRealVar constrNom(nomName.c_str(), nomName.c_str(), tau);
2669 std::string scalingName = string(
gamma.GetName()) +
"_tau";
2670 RooConstVar poissonScaling( scalingName.c_str(), scalingName.c_str(), tau);
2678 RooPoisson pois(constrName.c_str(), constrName.c_str(), constrNom, constrMean);
2684 std::cout <<
"Error: Did not recognize Stat Error constraint term type: "
2685 <<
type <<
" for : " << paramHist.
GetName() << std::endl;
2692 if(
sigma < minSigma ) {
2693 std::cout <<
"Warning: Bin " << i <<
" = " <<
sigma
2694 <<
" and is < " << minSigma
2695 <<
". Setting: " <<
gamma.GetName() <<
" to constant"
2700 constraintTermNames.push_back( constrName );
2701 ConstraintTerms.
add( *
proto->pdf(constrName.c_str()) );
2708 if( ! globalSet->
contains(*nomVarInWorkspace) ) {
2709 globalSet->
add( *nomVarInWorkspace );
2714 return ConstraintTerms;
double pow(double, double)
char * Form(const char *fmt,...)
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
void setConstant(bool constant)
const RooArgList & paramList() const
static RooArgList createParamSet(RooWorkspace &w, const std::string &, const RooArgList &Vars)
Create the list of RooRealVar parameters which represent the height of the histogram bins.
void setShape(TH1 *shape)
Bool_t setBinIntegrator(RooArgSet &allVars)
void setAllInterpCodes(int code)
void setPositiveDefinite(bool flag=true)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
void setAttribute(const Text_t *name, Bool_t value=kTRUE)
Set (default) or clear a named boolean attribute of this object.
Bool_t isConstant() const
Bool_t contains(const RooAbsArg &var) const
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
virtual void Print(Option_t *options=0) const
This method must be overridden when a class wants to print itself.
TIterator * createIterator(Bool_t dir=kIterForward) const
RooAbsData is the common abstract base class for binned and unbinned datasets.
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
void setConstant(Bool_t value=kTRUE)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Double_t getVal(const RooArgSet *set=0) const
Evaluate object. Returns either cached value or triggers a recalculation.
RooNumIntConfig * specialIntegratorConfig() const
Returns the specialized integrator configuration for this RooAbsReal.
virtual void forceNumInt(Bool_t flag=kTRUE)
RooArgSet is a container object that can hold multiple RooAbsArg objects.
virtual Bool_t add(const RooAbsCollection &col, Bool_t silent=kFALSE)
Add a collection of arguments to this collection by calling add() for each element in the source coll...
RooCategory represents a fundamental (non-derived) discrete value object.
virtual Bool_t setLabel(const char *label, Bool_t printError=kTRUE)
Set value by specifying the name of the desired state If printError is set, a message will be printed...
RooConstVar represent a constant real-valued object.
RooDataSet is a container class to hold N-dimensional binned data.
RooDataSet is a container class to hold unbinned data.
virtual void add(const RooArgSet &row, Double_t weight=1.0, Double_t weightError=0)
Add a data point, with its coordinates specified in the 'data' argset, to the data set.
void append(RooDataSet &data)
Add all data points of given data set to this data set.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Double_t correlation(const RooAbsArg &par1, const RooAbsArg &par2) const
RooHistFunc implements a real-valued function sampled from a multidimensional histogram.
Multivariate Gaussian p.d.f.
void setNoRounding(bool flag=kTRUE)
RooProduct a RooAbsReal implementation that represent the product of a given set of other RooAbsReal ...
Class RooRealSumPdf implements a PDF constructed from a sum of functions:
RooRealVar represents a fundamental (non-derived) real valued object.
void setMin(const char *name, Double_t value)
Set minimum of name range to given value.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
static RooAbsData * GenerateAsimovData(const RooAbsPdf &pdf, const RooArgSet &observables)
generate the asimov data for the observables (not the global ones) need to deal with the case of a si...
TODO Here, we are missing some documentation.
void ConfigureWorkspace(RooWorkspace *)
This class encapsulates all information for the statistical interpretation of one experiment.
std::vector< RooStats::HistFactory::Data > & GetAdditionalData()
retrieve vector of additional data objects
HistFactory::StatErrorConfig & GetStatErrorConfig()
get information about threshold for statistical uncertainties and constraint term
RooStats::HistFactory::Data & GetData()
get data object
std::string GetName()
get name of channel
std::vector< RooStats::HistFactory::Sample > & GetSamples()
get vector of samples for this channel
void setAllInterpCodes(int code)
Configuration for a constrained, coherent shape variation of affected samples.
void ConfigureHistFactoryDataset(RooDataSet *obsData, TH1 *nominal, RooWorkspace *proto, std::vector< std::string > obsNameVec)
static void EditSyst(RooWorkspace *proto, const char *pdfNameChar, std::map< std::string, double > gammaSyst, std::map< std::string, double > uniformSyst, std::map< std::string, double > logNormSyst, std::map< std::string, double > noSyst)
RooWorkspace * MakeSingleChannelModel(Measurement &measurement, Channel &channel)
RooWorkspace * MakeSingleChannelWorkspace(Measurement &measurement, Channel &channel)
void ProcessExpectedHisto(TH1 *hist, RooWorkspace *proto, std::string prefix, std::string productPrefix, std::string systTerm)
void SetObsToExpected(RooWorkspace *proto, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin)
void LinInterpWithConstraint(RooWorkspace *proto, TH1 *nominal, std::vector< HistoSys >, std::string prefix, std::string productPrefix, std::string systTerm, std::vector< std::string > &likelihoodTermNames)
std::vector< std::string > fPreprocessFunctions
void SetFunctionsToPreprocess(std::vector< std::string > lines)
std::vector< std::string > fObsNameVec
RooDataSet * MergeDataSets(RooWorkspace *combined, std::vector< RooWorkspace * > wspace_vec, std::vector< std::string > channel_names, std::string dataSetName, RooArgList obsList, RooCategory *channelCat)
virtual ~HistoToWorkspaceFactoryFast()
TH1 * MakeAbsolUncertaintyHist(const std::string &Name, const TH1 *Hist)
std::map< std::string, double > fParamValues
static void ConfigureWorkspaceForMeasurement(const std::string &ModelName, RooWorkspace *ws_single, Measurement &measurement)
void GuessObsNameVec(TH1 *hist)
TH1 * MakeScaledUncertaintyHist(const std::string &Name, std::vector< std::pair< TH1 *, TH1 * > > HistVec)
void AddPoissonTerms(RooWorkspace *proto, std::string prefix, std::string obsPrefix, std::string expPrefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
static void PrintCovarianceMatrix(RooFitResult *result, RooArgSet *params, std::string filename)
std::vector< std::string > fSystToFix
void MakeTotalExpected(RooWorkspace *proto, std::string totName, std::vector< std::string > &syst_x_expectedPrefixNames, std::vector< std::string > &normByNames)
void AddMultiVarGaussConstraint(RooWorkspace *proto, std::string prefix, int lowBin, int highBin, std::vector< std::string > &likelihoodTermNames)
std::string AddNormFactor(RooWorkspace *proto, std::string &channel, std::string &sigmaEpsilon, Sample &sample, bool doRatio)
void AddConstraintTerms(RooWorkspace *proto, Measurement &measurement, std::string prefix, std::string interpName, std::vector< OverallSys > &systList, std::vector< std::string > &likelihoodTermNames, std::vector< std::string > &totSystTermNames)
HistoToWorkspaceFactoryFast()
RooWorkspace * MakeCombinedModel(std::vector< std::string >, std::vector< RooWorkspace * >)
RooArgList createStatConstraintTerms(RooWorkspace *proto, std::vector< std::string > &constraintTerms, ParamHistFunc ¶mHist, TH1 *uncertHist, Constraint::Type type, Double_t minSigma)
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
std::map< std::string, double > & GetGammaSyst()
std::map< std::string, double > & GetLogNormSyst()
std::map< std::string, double > & GetNoSyst()
std::vector< std::string > & GetPOIList()
get vector of PoI names
std::map< std::string, double > & GetUniformSyst()
std::vector< std::string > & GetConstantParams()
get vector of all constant parameters
std::vector< RooStats::HistFactory::Channel > & GetChannels()
std::vector< RooStats::HistFactory::Asimov > & GetAsimovDatasets()
get vector of defined Asimov Datasets
double GetLumi()
retrieve integrated luminosity
std::vector< std::string > GetPreprocessFunctions()
Configuration for an un- constrained overall systematic to scale sample normalisations.
Configuration for a constrained overall systematic to scale sample normalisations.
std::vector< RooStats::HistFactory::OverallSys > & GetOverallSysList()
std::string GetName()
get name of sample
RooStats::HistFactory::StatError & GetStatError()
std::vector< RooStats::HistFactory::ShapeFactor > & GetShapeFactorList()
std::vector< RooStats::HistFactory::NormFactor > & GetNormFactorList()
std::vector< RooStats::HistFactory::HistoSys > & GetHistoSysList()
bool GetNormalizeByTheory()
does the normalization scale with luminosity
std::vector< RooStats::HistFactory::ShapeSys > & GetShapeSysList()
Unconstrained bin-by-bin variation of affected histogram.
Constrained bin-by-bin variation of affected histogram.
Constraint::Type GetConstraintType()
double GetRelErrorThreshold()
Constraint::Type GetConstraintType()
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
virtual void SetObservables(const RooArgSet &set)
specify the observables
virtual void SetWorkspace(RooWorkspace &ws)
virtual void SetParametersOfInterest(const RooArgSet &set)
virtual void SetGlobalObservables(const RooArgSet &set)
specify the global observables
const RooArgSet * GetObservables() const
get RooArgSet for observables (return NULL if not existing)
void GuessObsAndNuisance(const RooAbsData &data)
guesses Observables and ParametersOfInterest if not already set
virtual void SetPdf(const RooAbsPdf &pdf)
Set the Pdf, add to the the workspace if not already there.
The RooWorkspace is a persistable container for RooFit projects.
RooAbsData * data(const char *name) const
Retrieve dataset (binned or unbinned) with given name. A null pointer is returned if not found.
RooArgSet allVars() const
Return set with all variable objects.
Bool_t importClassCode(const char *pat="*", Bool_t doReplace=kFALSE)
Inport code of all classes in the workspace that have a class name that matches pattern 'pat' and whi...
void Print(Option_t *opts=0) const
Print contents of the workspace.
Bool_t defineSet(const char *name, const RooArgSet &aset, Bool_t importMissing=kFALSE)
Define a named RooArgSet with given constituents.
Bool_t saveSnapshot(const char *name, const char *paramNames)
Save snapshot of values and attributes (including "Constant") of parameters 'params' If importValues ...
Bool_t loadSnapshot(const char *name)
Load the values and attributes of the parameters in the snapshot saved with the given name.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found.
Bool_t import(const RooAbsArg &arg, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg())
Import a RooAbsArg object, e.g.
RooFactoryWSTool & factory()
Return instance to factory tool.
const RooArgSet * set(const char *name)
Return pointer to previously defined named set with given nmame If no such set is found a null pointe...
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name)
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
Class to manage histogram axis.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
virtual Bool_t Multiply(TF1 *f1, Double_t c1=1)
Performs the operation:
virtual Int_t GetNbinsY() const
virtual Double_t GetBinError(Int_t bin) const
Return value of error associated to bin number bin.
virtual Int_t GetNbinsZ() const
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
TAxis * GetXaxis()
Get the behaviour adopted by the object about the statoverflows. See EStatOverflows for more informat...
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
virtual Int_t GetNbinsX() const
Bool_t IsBinUnderflow(Int_t bin, Int_t axis=0) const
Return true if the bin is underflow.
Bool_t IsBinOverflow(Int_t bin, Int_t axis=0) const
Return true if the bin is overflow.
virtual void SetBinContent(Int_t bin, Double_t content)
Set bin content see convention for numbering bins in TH1::GetBin In case the bin number is greater th...
virtual void SetName(const char *name)
Change the name of this histogram.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual const char * GetName() const
Returns name of object.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
double beta(double x, double y)
Calculates the beta function.
RooCmdArg WeightVar(const char *name, Bool_t reinterpretAsWeight=kFALSE)
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
RooCmdArg Index(RooCategory &icat)
RooCmdArg Rename(const char *suffix)
RooCmdArg Import(const char *state, TH1 &histo)
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, Bool_t depsAreCond=kFALSE)
@(#)root/roostats:$Id$ Author: George Lewis, Kyle Cranmer
static constexpr double second
static constexpr double gauss