79 std::vector<double> out(numBins);
81 for (
int i = 0; i < numBins; ++i) {
93using std::string, std::vector;
107 fSystToFix( measurement.GetConstantParams() ),
108 fParamValues( measurement.GetParamValues() ),
109 fNomLumi( measurement.GetLumi() ),
110 fLumiError( measurement.GetLumi()*measurement.GetLumiRelErr() ),
111 fLowBin( measurement.GetBinLow() ),
112 fHighBin( measurement.GetBinHigh() ),
128 if( proto_config ==
nullptr ) {
129 cxcoutFHF <<
"Error: Did not find 'ModelConfig' object in file: " << ws_single->
GetName() << std::endl;
133 if( measurement.GetPOIList().empty() ) {
134 cxcoutWHF <<
"No Parametetrs of interest are set" << std::endl;
138 std::stringstream sstream;
139 sstream <<
"Setting Parameter(s) of Interest as: ";
140 for(
auto const& item : measurement.GetPOIList()) {
141 sstream << item <<
" ";
146 for(
auto const& poi_name : measurement.GetPOIList()) {
151 cxcoutWHF <<
"WARNING: Can't find parameter of interest: " << poi_name
152 <<
" in Workspace. Not setting in ModelConfig." << std::endl;
156 proto_config->SetParametersOfInterest(params);
159 std::string NewModelName =
"newSimPdf";
165 RooAbsPdf* pdf = ws_single->pdf(NewModelName);
166 if( !pdf ) pdf = ws_single->pdf( ModelName );
167 const RooArgSet* observables = ws_single->set(
"observables");
170 if(!measurement.GetPOIList().empty()){
178 std::string SnapShotName =
"NominalParamValues";
179 ws_single->saveSnapshot(SnapShotName, ws_single->allVars());
181 for(
unsigned int i=0; i<measurement.GetAsimovDatasets().size(); ++i) {
185 std::string AsimovName = asimov.
GetName();
187 cxcoutPHF <<
"Generating additional Asimov Dataset: " << AsimovName << std::endl;
191 cxcoutPHF <<
"Importing Asimov dataset" << std::endl;
192 bool failure = ws_single->import(*asimov_dataset,
RooFit::Rename(AsimovName.c_str()));
194 cxcoutFHF <<
"Error: Failed to import Asimov dataset: " << AsimovName << std::endl;
200 ws_single->loadSnapshot(SnapShotName.c_str());
221 string ch_name = channel.
GetName();
225 if( ws_single ==
nullptr ) {
226 cxcoutFHF <<
"Error: Failed to make Single-Channel workspace for channel: " << ch_name
227 <<
" and measurement: " << measurement.GetName() << std::endl;
274 std::vector<std::unique_ptr<RooWorkspace>> channel_workspaces;
275 std::vector<std::string> channel_names;
279 if( ! channel.CheckHistograms() ) {
280 cxcoutFHF <<
"MakeModelAndMeasurementsFast: Channel: " << channel.GetName()
281 <<
" has uninitialized histogram pointers" << std::endl;
285 string ch_name = channel.GetName();
286 channel_names.push_back(ch_name);
295 std::unique_ptr<RooWorkspace> ws{histFactory.
MakeCombinedModel( channel_names, channel_workspaces )};
308template <
class Arg_t,
typename... Args_t>
311 Arg_t arg{
name.c_str(),
name.c_str(), std::forward<Args_t>(args)...};
313 return *
dynamic_cast<Arg_t *
>(ws.
arg(
name));
332std::pair<bool, std::string> isChannelDataConsistent(std::vector<std::unique_ptr<RooWorkspace>>
const &chs,
333 std::vector<std::string>
const &ch_names,
334 std::set<std::string>
const &allowedInconsistent)
337 std::set<std::string> referenceDataNames;
339 referenceDataNames.insert(
data->GetName());
343 for (std::size_t i = 1; i < chs.size(); ++i) {
344 std::set<std::string> thisDataNames;
346 thisDataNames.insert(
data->GetName());
350 std::vector<std::string> missing;
351 std::vector<std::string> extra;
352 std::set_difference(referenceDataNames.begin(), referenceDataNames.end(), thisDataNames.begin(),
353 thisDataNames.end(), std::back_inserter(missing));
354 std::set_difference(thisDataNames.begin(), thisDataNames.end(), referenceDataNames.begin(),
355 referenceDataNames.end(), std::back_inserter(extra));
358 auto isAllowed = [&](std::string
const &
name) {
return allowedInconsistent.count(
name) != 0; };
360 missing.erase(std::remove_if(missing.begin(), missing.end(), isAllowed), missing.end());
361 extra.erase(std::remove_if(extra.begin(), extra.end(), isAllowed), extra.end());
363 if (!missing.empty() || !extra.empty()) {
364 std::stringstream errMsg;
365 errMsg <<
"ERROR: Inconsistent datasets across channel workspaces.\n"
366 <<
"Workspace for channel \"" << ch_names[i] <<
"\" does not match "
367 <<
"the datasets in channel \"" << ch_names[0] <<
"\".\n";
369 if (!missing.empty()) {
370 errMsg <<
" Missing datasets:\n";
371 for (
const auto &
name : missing) {
372 errMsg <<
" - " <<
name <<
"\n";
376 if (!extra.empty()) {
377 errMsg <<
" Extra datasets:\n";
378 for (
const auto &
name : extra) {
379 errMsg <<
" - " <<
name <<
"\n";
383 errMsg <<
"All channel workspaces must contain exactly the same datasets.\n";
384 return {
false, errMsg.str()};
396 for (
unsigned int idx=0; idx <
fObsNameVec.size(); ++idx) {
420 cxcoutI(HistFactory) <<
"processing hist " << hist->
GetName() << std::endl;
422 cxcoutF(HistFactory) <<
"hist is empty" << std::endl;
428 unsigned int histndim(1);
429 std::string classname = hist->
ClassName();
430 if (classname.find(
"TH1")==0) { histndim=1; }
431 else if (classname.find(
"TH2")==0) { histndim=2; }
432 else if (classname.find(
"TH3")==0) { histndim=3; }
435 prefix +=
"_Hist_alphanominal";
437 RooDataHist histDHist(prefix +
"DHist",
"",observables,hist);
439 return &emplace<RooHistFunc>(proto, prefix, observables,histDHist,0);
445 std::vector<std::string> & constraintTermNames) {
446 std::string paramName = param.
GetName();
447 std::string nomName =
"nom_" + paramName;
448 std::string constraintName = paramName +
"Constraint";
451 if(proto.pdf(constraintName))
return;
455 const double gaussSigma = isUniform ? 100. : 1.0;
457 cxcoutIHF <<
"Added a uniform constraint for " << paramName <<
" as a Gaussian constraint with a very large sigma " << std::endl;
460 constraintTermNames.emplace_back(constraintName);
462 RooRealVar &nomParam = emplace<RooRealVar>(proto, nomName, 0., -10., 10.);
463 nomParam.setConstant();
464 emplace<RooGaussian>(proto, constraintName, paramVar, nomParam, gaussSigma);
465 paramVar.setError(gaussSigma);
466 const_cast<RooArgSet*
>(proto.set(
"globalObservables"))->add(nomParam);
473 for(
auto const& histoSys : histoSysList) {
474 params.add(getOrCreate<RooRealVar>(proto,
"alpha_" + histoSys.GetName(),
alphaLow,
alphaHigh));
484 RooWorkspace& proto,
const std::vector<HistoSys>& histoSysList,
485 const string& prefix,
492 for(
unsigned int j=0; j<histoSysList.size(); ++j){
493 std::string str = prefix +
"_" + std::to_string(j);
495 const HistoSys& histoSys = histoSysList.at(j);
496 auto lowDHist = std::make_unique<RooDataHist>(str+
"lowDHist",
"",obsList, histoSys.GetHistoLow());
497 auto highDHist = std::make_unique<RooDataHist>(str+
"highDHist",
"",obsList, histoSys.GetHistoHigh());
498 lowSet.addOwned(std::make_unique<RooHistFunc>((str+
"low").c_str(),
"",obsList,std::move(lowDHist),0));
499 highSet.addOwned(std::make_unique<RooHistFunc>((str+
"high").c_str(),
"",obsList,std::move(highDHist),0));
504 interp.setPositiveDefinite();
505 interp.setAllInterpCodes(4);
508 interp.setBinIntegrator(obsSet);
509 interp.forceNumInt();
513 return proto.arg(prefix);
521 std::vector<string> prodNames;
523 vector<NormFactor> normList = sample.GetNormFactorList();
524 vector<string> normFactorNames;
525 vector<string> rangeNames;
527 string overallNorm_times_sigmaEpsilon = sample.GetName() +
"_" + channel +
"_scaleFactors";
528 auto sigEps = proto.arg(sigmaEpsilon);
530 auto normFactor = std::make_unique<RooProduct>(overallNorm_times_sigmaEpsilon.c_str(), overallNorm_times_sigmaEpsilon.c_str(),
RooArgList(*sigEps));
532 if(!normList.empty()){
535 string varname = norm.GetName();
537 varname +=
"_" + channel;
543 std::stringstream range;
544 range <<
"[" << norm.GetVal() <<
"," << norm.GetLow() <<
"," << norm.GetHigh() <<
"]";
546 if( proto.obj(varname) ==
nullptr) {
547 cxcoutI(HistFactory) <<
"making normFactor: " << norm.GetName() << std::endl;
549 emplace<RooRealVar>(proto, varname, norm.GetVal(), norm.GetLow(), norm.GetHigh());
550 proto.var(varname)->setError(0);
553 prodNames.push_back(varname);
554 rangeNames.push_back(range.str());
555 normFactorNames.push_back(varname);
559 for (
const auto&
name : prodNames) {
560 auto arg = proto.arg(
name);
562 normFactor->addTerm(arg);
567 unsigned int rangeIndex=0;
568 for( vector<string>::iterator nit = normFactorNames.begin(); nit!=normFactorNames.end(); ++nit){
569 if( count (normFactorNames.begin(), normFactorNames.end(), *nit) > 1 ){
570 cxcoutI(HistFactory) <<
"<NormFactor Name =\""<<*nit<<
"\"> is duplicated for <Sample Name=\""
571 << sample.GetName() <<
"\">, but only one factor will be included. \n Instead, define something like"
572 <<
"\n\t<Function Name=\""<<*nit<<
"Squared\" Expression=\""<<*nit<<
"*"<<*nit<<
"\" Var=\""<<*nit<<rangeNames.at(rangeIndex)
573 <<
"\"> \nin your top-level XML's <Measurement> entry and use <NormFactor Name=\""<<*nit<<
"Squared\" in your channel XML file."<< std::endl;
583 std::vector<OverallSys>& systList,
584 vector<string>& constraintTermNames,
585 vector<string>& totSystTermNames) {
588 totSystTermNames.push_back(prefix);
591 vector<double> lowVec;
592 vector<double> highVec;
594 std::map<std::string, double>::iterator itconstr;
595 for(
unsigned int i = 0; i < systList.size(); ++i) {
598 std::string strname = sys.
GetName();
599 const char *
name = strname.c_str();
602 if (meas.GetNoSyst().count(sys.GetName()) > 0 ) {
603 cxcoutI(HistFactory) <<
"HistoToWorkspaceFast::AddConstraintTerm - skip systematic " << sys.GetName() << std::endl;
607 if (meas.GetGammaSyst().count(sys.GetName()) > 0 ) {
608 double relerr = meas.GetGammaSyst().find(sys.GetName() )->second;
610 cxcoutI(HistFactory) <<
"HistoToWorkspaceFast::AddConstraintTerm - zero uncertainty assigned - skip systematic " << sys.GetName() << std::endl;
613 const double tauVal = 1./(relerr*relerr);
614 const double sqtau = 1./relerr;
615 RooRealVar &beta = emplace<RooRealVar>(proto,
"beta_" + strname, 1., 0., 10.);
617 RooRealVar &yvar = emplace<RooRealVar>(proto,
"nom_" + std::string{beta.GetName()}, tauVal, 0., 10.);
619 RooRealVar &theta = emplace<RooRealVar>(proto,
"theta_" + strname, 1./tauVal);
621 RooPolyVar &alphaOfBeta = emplace<RooPolyVar>(proto,
"alphaOfBeta_" + strname, beta,
RooArgList{-sqtau, sqtau});
625 RooAddition &kappa = emplace<RooAddition>(proto,
"k_" + std::string{yvar.GetName()},
RooArgList{yvar, 1.0});
626 RooGamma &gamma = emplace<RooGamma>(proto, std::string{beta.GetName()} +
"Constraint", beta, kappa, theta,
RooFit::RooConst(0.0));
628 alphaOfBeta.Print(
"t");
631 constraintTermNames.push_back(gamma.GetName());
633 yvar.setConstant(
true);
634 const_cast<RooArgSet*
>(proto.set(
"globalObservables"))->add(yvar);
637 params.
add(alphaOfBeta);
638 cxcoutI(HistFactory) <<
"Added a gamma constraint for " <<
name << std::endl;
644 const bool isUniform = meas.GetUniformSyst().count(sys.GetName()) > 0;
645 makeGaussianConstraint(alpha, proto, isUniform, constraintTermNames);
648 if (meas.GetLogNormSyst().count(sys.GetName()) == 0 && meas.GetGammaSyst().count(sys.GetName()) == 0 ) {
653 if (meas.GetLogNormSyst().count(sys.GetName()) > 0 ) {
655 const double relerr = meas.GetLogNormSyst().find(sys.GetName() )->second;
658 proto,
"alphaOfBeta_" + sys.GetName(),
"x[0]*(pow(x[1],x[2])-1.)",
659 RooArgList{emplace<RooRealVar>(proto,
"tau_" + sys.GetName(), 1. / relerr),
660 emplace<RooRealVar>(proto,
"kappa_" + sys.GetName(), 1. + relerr), alpha});
662 cxcoutI(HistFactory) <<
"Added a log-normal constraint for " <<
name << std::endl;
664 alphaOfBeta.Print(
"t");
666 params.
add(alphaOfBeta);
671 lowVec.push_back(sys.GetLow());
672 highVec.push_back(sys.GetHigh());
676 if(!systList.empty()){
680 assert(!params.
empty());
681 assert(lowVec.size() == params.
size());
683 FlexibleInterpVar interp( (interpName).c_str(),
"", params, 1., lowVec, highVec);
684 interp.setAllInterpCodes(5);
686 proto.import(interp);
690 emplace<RooConstVar>(proto, interpName, 1.);
696 const vector<RooProduct*>& sampleScaleFactors, std::vector<vector<RooAbsArg*>>& sampleHistFuncs)
const {
697 assert(sampleScaleFactors.size() == sampleHistFuncs.size());
702 throw std::logic_error(
"HistFactory didn't process the observables correctly. Please file a bug report.");
704 auto firstHistFunc =
dynamic_cast<const RooHistFunc*
>(sampleHistFuncs.front().front());
705 if (!firstHistFunc) {
707 firstHistFunc =
dynamic_cast<const RooHistFunc*
>(piecewiseInt->nominalHist());
709 assert(firstHistFunc);
712 auto &binWidth = emplace<RooBinWidthFunction>(proto, totName +
"_binWidth", *firstHistFunc,
true);
717 for (
unsigned int i=0; i < sampleHistFuncs.size(); ++i) {
718 assert(!sampleHistFuncs[i].empty());
719 coefList.
add(*sampleScaleFactors[i]);
721 std::vector<RooAbsArg*>& thisSampleHistFuncs = sampleHistFuncs[i];
722 thisSampleHistFuncs.push_back(&binWidth);
724 if (thisSampleHistFuncs.size() == 1) {
726 shapeList.add(*thisSampleHistFuncs.front());
729 std::string
name = thisSampleHistFuncs.front()->GetName();
730 auto pos =
name.find(
"Hist_alpha");
731 if (pos != std::string::npos) {
732 name =
name.substr(0, pos) +
"shapes";
733 }
else if ( (pos =
name.find(
"nominal")) != std::string::npos) {
734 name =
name.substr(0, pos) +
"shapes";
737 RooProduct shapeProduct(
name.c_str(), thisSampleHistFuncs.front()->GetTitle(),
RooArgSet(thisSampleHistFuncs.begin(), thisSampleHistFuncs.end()));
739 shapeList.add(*proto.function(
name));
744 RooRealSumPdf tot(totName.c_str(), totName.c_str(), shapeList, coefList,
true);
745 tot.specialIntegratorConfig(
true)->method1D().setLabel(
"RooBinIntegrator") ;
746 tot.specialIntegratorConfig(
true)->method2D().setLabel(
"RooBinIntegrator") ;
747 tot.specialIntegratorConfig(
true)->methodND().setLabel(
"RooBinIntegrator") ;
751 tot.setAttribute(
"GenerateBinned");
755 tot.setAttribute(
"BinnedLikelihood");
768 for (
auto const *myargi : static_range_cast<RooRealVar *>(*params)) {
769 if (myargi->isConstant())
771 covFile <<
" & " << myargi->GetName();
773 covFile <<
"\\\\ \\hline \n";
774 for (
auto const *myargi : static_range_cast<RooRealVar *>(*params)) {
775 if(myargi->isConstant())
continue;
776 covFile << myargi->GetName();
777 for (
auto const *myargj : static_range_cast<RooRealVar *>(*params)) {
778 if(myargj->isConstant())
continue;
779 std::cout << myargi->GetName() <<
"," << myargj->GetName();
780 double corr =
result->correlation(*myargi, *myargj);
781 covFile <<
" & " << std::fixed << std::setprecision(2) << corr;
783 std::cout << std::endl;
784 covFile <<
" \\\\\n";
797 Error(
"MakeSingleChannelWorkspace",
798 "The input Channel does not contain any sample - return a nullptr");
802 const TH1* channel_hist_template = channel.
GetSamples().front().GetHisto();
803 if (channel_hist_template ==
nullptr) {
805 channel_hist_template = channel.
GetSamples().front().GetHisto();
807 if (channel_hist_template ==
nullptr) {
808 std::ostringstream stream;
809 stream <<
"The sample " << channel.
GetSamples().front().GetName()
810 <<
" in channel " << channel.
GetName() <<
" does not contain a histogram. This is the channel:\n";
811 channel.
Print(stream);
812 Error(
"MakeSingleChannelWorkspace",
"%s", stream.str().c_str());
818 <<
" has uninitialized histogram pointers" << std::endl;
825 vector<string> systToFix = measurement.GetConstantParams();
829 string channel_name = channel.
GetName();
839 for (
unsigned int idx=0; idx<
fObsNameVec.size(); ++idx ) {
849 throw hf_exc(
"HistFactory is limited to 1- to 3-dimensional histograms.");
852 cxcoutP(HistFactory) <<
"\n-----------------------------------------\n"
853 <<
"\tStarting to process '"
854 << channel_name <<
"' channel with " <<
fObsNameVec.size() <<
" observables"
855 <<
"\n-----------------------------------------\n" << std::endl;
860 auto protoOwner = std::make_unique<RooWorkspace>(channel_name.c_str(), (channel_name+
" workspace").c_str());
862 auto proto_config = std::make_unique<ModelConfig>(
"ModelConfig", &proto);
866 cxcoutI(HistFactory) <<
"will preprocess this line: " << func << std::endl;
871 RooArgSet likelihoodTerms(
"likelihoodTerms");
872 RooArgSet constraintTerms(
"constraintTerms");
873 vector<string> likelihoodTermNames;
874 vector<string> constraintTermNames;
875 vector<string> totSystTermNames;
877 std::vector<std::vector<RooAbsArg*>> allSampleHistFuncs;
878 std::vector<RooProduct*> sampleScaleFactors;
880 std::vector<std::pair<const TH1 *, std::unique_ptr<TH1>>> statHistPairs;
881 const std::string statFuncName =
"mc_stat_" + channel_name;
886 auto &lumiVar = getOrCreate<RooRealVar>(proto,
"Lumi",
fNomLumi, 0.0, 10 *
fNomLumi);
891 emplace<RooGaussian>(proto,
"lumiConstraint", lumiVar, nominalLumiVar,
fLumiError);
893 proto.var(
"nominalLumi")->setConstant();
894 proto.defineSet(
"globalObservables",
"nominalLumi");
896 constraintTermNames.push_back(
"lumiConstraint");
898 proto.var(
"Lumi")->setConstant();
899 proto.defineSet(
"globalObservables",
RooArgSet());
906 string overallSystName = sample.GetName() +
"_" + channel_name +
"_epsilon";
908 string systSourcePrefix =
"alpha_";
913 sample.GetOverallSysList(), constraintTermNames , totSystTermNames);
915 allSampleHistFuncs.emplace_back();
916 std::vector<RooAbsArg*>& sampleHistFuncs = allSampleHistFuncs.back();
919 auto normFactors =
CreateNormFactor(proto, channel_name, overallSystName, sample, doRatio);
929 const TH1* nominal = sample.GetHisto();
941 string expPrefix = sample.
GetName() +
"_" + channel_name;
945 assert(nominalHistFunc);
947 if(sample.GetHistoSysList().empty()) {
949 cxcoutI(HistFactory) << sample.GetName() +
"_" + channel_name +
" has no variation histograms " << std::endl;
951 sampleHistFuncs.push_back(nominalHistFunc);
955 string constraintPrefix = sample.GetName() +
"_" + channel_name +
"_Hist_alpha";
958 RooArgList interpParams = makeInterpolationParameters(sample.GetHistoSysList(), proto);
961 for(std::size_t i = 0; i < interpParams.size(); ++i) {
962 bool isUniform = measurement.GetUniformSyst().count(sample.GetHistoSysList()[i].GetName()) > 0;
963 makeGaussianConstraint(interpParams[i], proto, isUniform, constraintTermNames);
967 sampleHistFuncs.push_back( makeLinInterp(interpParams, nominalHistFunc, proto,
968 sample.GetHistoSysList(), constraintPrefix, observables) );
971 sampleHistFuncs.front()->SetTitle( (nominal && strlen(nominal->
GetTitle())>0) ? nominal->
GetTitle() : sample.GetName().c_str() );
977 if( sample.GetStatError().GetActivate() ) {
980 cxcoutFHF <<
"Cannot include Stat Error for histograms of more than 3 dimensions." << std::endl;
988 cxcoutI(HistFactory) <<
"Sample: " << sample.GetName() <<
" to be included in Stat Error "
989 <<
"for channel " << channel_name
992 string UncertName = sample.GetName() +
"_" + channel_name +
"_StatAbsolUncert";
993 std::unique_ptr<TH1> statErrorHist;
995 if( sample.GetStatError().GetErrorHist() ==
nullptr ) {
997 cxcoutI(HistFactory) <<
"Making Statistical Uncertainty Hist for "
998 <<
" Channel: " << channel_name
999 <<
" Sample: " << sample.GetName()
1006 statErrorHist.reset(
static_cast<TH1*
>(sample.GetStatError().GetErrorHist()->Clone()));
1010 cxcoutI(HistFactory) <<
"Using external histogram for Stat Errors for "
1011 <<
"\tChannel: " << channel_name
1012 <<
"\tSample: " << sample.GetName()
1013 <<
"\tError Histogram: " << statErrorHist->GetName() << std::endl;
1016 statErrorHist->Multiply( nominal );
1017 statErrorHist->SetName( UncertName.c_str() );
1022 statHistPairs.emplace_back(nominal, std::move(statErrorHist));
1040 if( paramHist ==
nullptr ) {
1046 theObservables.
add( *proto.var(obsName) );
1051 std::string ParamSetPrefix =
"gamma_stat_" + channel_name;
1057 ParamHistFunc statUncertFunc(statFuncName.c_str(), statFuncName.c_str(),
1058 theObservables, statFactorParams );
1062 paramHist = proto.function( statFuncName);
1066 sampleHistFuncs.push_back(paramHist);
1075 if( !sample.GetShapeFactorList().empty() ) {
1078 cxcoutFHF <<
"Cannot include Stat Error for histograms of more than 3 dimensions." << std::endl;
1082 cxcoutI(HistFactory) <<
"Sample: " << sample.GetName() <<
" in channel: " << channel_name
1083 <<
" to be include a ShapeFactor."
1086 for(
ShapeFactor& shapeFactor : sample.GetShapeFactorList()) {
1088 std::string funcName = channel_name +
"_" + shapeFactor.GetName() +
"_shapeFactor";
1089 RooAbsArg *paramHist = proto.function(funcName);
1090 if( paramHist ==
nullptr ) {
1094 theObservables.
add( *proto.var(varName) );
1100 for (
auto *comp : shapeFactorParams) {
1103 if (
auto var =
dynamic_cast<RooRealVar *
>(comp)) {
1104 var->setVal(shapeFactor.GetVal());
1105 var->setMin(shapeFactor.GetLow());
1106 var->setMax(shapeFactor.GetHigh());
1111 ParamHistFunc shapeFactorFunc( funcName.c_str(), funcName.c_str(),
1112 theObservables, shapeFactorParams );
1115 if( shapeFactor.GetInitialShape() !=
nullptr ) {
1116 TH1* initialShape =
static_cast<TH1*
>(shapeFactor.GetInitialShape()->Clone());
1117 cxcoutI(HistFactory) <<
"Setting Shape Factor: " << shapeFactor.
GetName()
1118 <<
" to have initial shape from hist: "
1119 << initialShape->GetName()
1121 shapeFactorFunc.setShape( initialShape );
1125 if( shapeFactor.IsConstant() ) {
1126 cxcoutI(HistFactory) <<
"Setting Shape Factor: " << shapeFactor.GetName()
1127 <<
" to be constant" << std::endl;
1128 shapeFactorFunc.setConstant(
true);
1132 paramHist = proto.function(funcName);
1136 sampleHistFuncs.push_back(paramHist);
1146 if( !sample.GetShapeSysList().empty() ) {
1149 cxcoutFHF <<
"Cannot include Stat Error for histograms of more than 3 dimensions.\n";
1154 std::vector<string> ShapeSysNames;
1167 cxcoutI(HistFactory) <<
"Sample: " << sample.GetName() <<
" in channel: " << channel_name
1168 <<
" to include a ShapeSys." << std::endl;
1170 std::string funcName = channel_name +
"_" + shapeSys.GetName() +
"_ShapeSys";
1171 ShapeSysNames.push_back( funcName );
1172 auto paramHist =
static_cast<ParamHistFunc*
>(proto.function(funcName));
1173 if( paramHist ==
nullptr ) {
1180 theObservables.
add( *proto.var(varName) );
1184 std::string funcParams =
"gamma_" + shapeSys.GetName();
1190 ParamHistFunc shapeFactorFunc( funcName.c_str(), funcName.c_str(),
1191 theObservables, shapeFactorParams );
1194 paramHist =
static_cast<ParamHistFunc*
>(proto.function(funcName));
1203 const TH1* shapeErrorHist = shapeSys.GetErrorHist();
1218 for (
auto const& term : shapeConstraintsInfo.constraints) {
1220 constraintTermNames.emplace_back(term->GetName());
1224 for (
RooAbsArg * glob : shapeConstraintsInfo.globalObservables) {
1225 globalSet->
add(*proto.var(glob->GetName()));
1235 for(std::string
const&
name : ShapeSysNames) {
1236 sampleHistFuncs.push_back(proto.function(
name));
1246 if( !sample.GetNormalizeByTheory() ) {
1248 lumi = &emplace<RooRealVar>(proto,
"Lumi", measurement.GetLumi());
1254 normFactors->addTerm(lumi);
1260 auto normFactorsInWS =
dynamic_cast<RooProduct*
>(proto.arg(normFactors->GetName()));
1261 assert(normFactorsInWS);
1263 sampleScaleFactors.push_back(normFactorsInWS);
1268 if(!statHistPairs.empty()) {
1272 std::unique_ptr<TH1> fracStatError(
1274 if( fracStatError ==
nullptr ) {
1275 cxcoutFHF <<
"Error: Failed to make ScaledUncertaintyHist for: " << channel_name +
"_StatUncert" +
"_RelErr\n";
1281 auto chanStatUncertFunc =
static_cast<ParamHistFunc*
>(proto.function( statFuncName ));
1282 cxcoutI(HistFactory) <<
"About to create Constraint Terms from: "
1283 << chanStatUncertFunc->
GetName()
1284 <<
" params: " << chanStatUncertFunc->paramList()
1295 cxcoutI(HistFactory) <<
"Using Gaussian StatErrors in channel: " << channel.
GetName() << std::endl;
1298 cxcoutI(HistFactory) <<
"Using Poisson StatErrors in channel: " << channel.
GetName() << std::endl;
1303 chanStatUncertFunc->paramList(),
histToVector(*fracStatError),
1304 statRelErrorThreshold,
1305 statConstraintType);
1306 for (
auto const& term : statConstraintsInfo.constraints) {
1308 constraintTermNames.emplace_back(term->GetName());
1312 for (
RooAbsArg * glob : statConstraintsInfo.globalObservables) {
1313 globalSet->
add(*proto.var(glob->GetName()));
1322 sampleScaleFactors, allSampleHistFuncs);
1323 likelihoodTermNames.push_back(channel_name+
"_model");
1327 for(
unsigned int i=0; i<systToFix.size(); ++i){
1328 RooRealVar* temp = proto.var(systToFix.at(i));
1330 cxcoutW(HistFactory) <<
"could not find variable " << systToFix.at(i)
1331 <<
" could not set it to constant" << std::endl;
1340 for(
unsigned int i=0; i<constraintTermNames.size(); ++i){
1341 RooAbsArg* proto_arg = proto.arg(constraintTermNames[i]);
1342 if( proto_arg==
nullptr ) {
1343 cxcoutFHF <<
"Error: Cannot find arg set: " << constraintTermNames.at(i)
1344 <<
" in workspace: " << proto.
GetName() << std::endl;
1347 constraintTerms.add( *proto_arg );
1350 for(
unsigned int i=0; i<likelihoodTermNames.size(); ++i){
1351 RooAbsArg* proto_arg = (proto.arg(likelihoodTermNames[i]));
1352 if( proto_arg==
nullptr ) {
1353 cxcoutFHF <<
"Error: Cannot find arg set: " << likelihoodTermNames.at(i)
1354 <<
" in workspace: " << proto.
GetName() << std::endl;
1357 likelihoodTerms.add( *proto_arg );
1359 proto.defineSet(
"constraintTerms",constraintTerms);
1360 proto.defineSet(
"likelihoodTerms",likelihoodTerms);
1364 std::string observablesStr;
1367 observables.
add( *proto.var(
name) );
1368 if (!observablesStr.empty()) { observablesStr +=
","; }
1369 observablesStr +=
name;
1375 proto.defineSet(
"observables", observablesStr.c_str());
1376 proto.defineSet(
"observablesSet", observablesStr.c_str());
1380 cxcoutP(HistFactory) <<
"\n-----------------------------------------\n"
1381 <<
"\timport model into workspace"
1382 <<
"\n-----------------------------------------\n" << std::endl;
1384 auto model = std::make_unique<RooProdPdf>(
1385 (
"model_" + channel_name).c_str(),
1386 "product of Poissons across bins for a single channel", constraintTerms,
1394 proto_config->SetPdf(*model);
1395 proto_config->SetObservables(observables);
1396 proto_config->SetGlobalObservables(*proto.set(
"globalObservables"));
1400 proto.import(*proto_config,proto_config->GetName());
1401 proto.importClassCode();
1408 int asymcalcPrintLevel = 0;
1425 std::unique_ptr<RooDataSet> dataset;
1427 dataset = std::make_unique<RooDataSet>(
"obsData",
"",*proto.set(
"observables"),
RooFit::WeightVar(
"weightVar"));
1429 const char* weightErrName=
"weightErr";
1434 proto.import(*dataset);
1439 if(
data.GetName().empty()) {
1440 cxcoutFHF <<
"Error: Additional Data histogram for channel: " << channel.
GetName()
1441 <<
" has no name! The name always needs to be set for additional datasets, "
1442 <<
"either via the \"Name\" tag in the XML or via RooStats::HistFactory::Data::SetName().\n";
1445 std::string
const& dataName =
data.GetName();
1446 TH1 const* mnominal =
data.GetHisto();
1448 cxcoutFHF <<
"Error: Additional Data histogram for channel: " << channel.
GetName()
1449 <<
" with name: " << dataName <<
" is nullptr\n";
1456 proto.import(dataset);
1469 TH1 const& mnominal,
1471 std::vector<std::string>
const& obsNameVec) {
1477 if (obsNameVec.empty() ) {
1478 Error(
"ConfigureHistFactoryDataset",
"Invalid input - return");
1482 TAxis const* ax = mnominal.GetXaxis();
1483 TAxis const* ay = mnominal.GetYaxis();
1484 TAxis const* az = mnominal.GetZaxis();
1487 const bool storeWeightErr = obsDataUnbinned.weightVar()->getAttribute(
"StoreError");
1489 for (
int i=1; i<=ax->GetNbins(); ++i) {
1492 proto.var( obsNameVec[0] )->setVal( xval );
1494 if(obsNameVec.size()==1) {
1495 double fval = mnominal.GetBinContent(i);
1496 double ferr = storeWeightErr ? mnominal.GetBinError(i) : 0.;
1497 obsDataUnbinned.add( *proto.set(
"observables"), fval, ferr );
1500 for(
int j=1; j<=ay->GetNbins(); ++j) {
1501 double yval = ay->GetBinCenter(j);
1502 proto.var( obsNameVec[1] )->setVal( yval );
1504 if(obsNameVec.size()==2) {
1505 double fval = mnominal.GetBinContent(i,j);
1506 double ferr = storeWeightErr ? mnominal.GetBinError(i, j) : 0.;
1507 obsDataUnbinned.add( *proto.set(
"observables"), fval, ferr );
1510 for(
int k=1; k<=az->GetNbins(); ++k) {
1511 double zval = az->GetBinCenter(k);
1512 proto.var( obsNameVec[2] )->setVal( zval );
1513 double fval = mnominal.GetBinContent(i,j,k);
1514 double ferr = storeWeightErr ? mnominal.GetBinError(i, j, k) : 0.;
1515 obsDataUnbinned.add( *proto.set(
"observables"), fval, ferr );
1532 std::vector<std::unique_ptr<RooWorkspace>> &chs)
1537 if (ch_names.empty() || chs.empty() ) {
1538 Error(
"MakeCombinedModel",
"Input vectors are empty - return a nullptr");
1541 if (chs.size() < ch_names.size() ) {
1542 Error(
"MakeCombinedModel",
"Input vector of workspace has an invalid size - return a nullptr");
1545 std::set<std::string> ch_names_set{ch_names.begin(), ch_names.end()};
1546 if (ch_names.size() != ch_names_set.size()) {
1547 Error(
"MakeCombinedModel",
"Input vector of channel names has duplicate names - return a nullptr");
1555 std::map<string, RooAbsPdf *> pdfMap;
1556 vector<RooAbsPdf *> models;
1559 for (
unsigned int i = 0; i < ch_names.size(); ++i) {
1560 obsList.
add(*
static_cast<ModelConfig *
>(chs[i]->obj(
"ModelConfig"))->GetObservables());
1562 cxcoutI(HistFactory) <<
"full list of observables:\n" << obsList << std::endl;
1565 std::map<std::string, int> channelMap;
1566 for(
unsigned int i = 0; i< ch_names.size(); ++i){
1567 string channel_name=ch_names[i];
1568 if (i == 0 && isdigit(channel_name[0])) {
1569 throw std::invalid_argument(
"The first channel name for HistFactory cannot start with a digit. Got " + channel_name);
1571 if (channel_name.find(
',') != std::string::npos) {
1572 throw std::invalid_argument(
"Channel names for HistFactory cannot contain ','. Got " + channel_name);
1575 channelMap[channel_name] = i;
1580 cxcoutFHF <<
"failed to find model for channel\n";
1583 models.push_back(model);
1584 auto &modelConfig = *
static_cast<ModelConfig *
>(chs[i]->obj(
"ModelConfig"));
1586 globalObs.add(*modelConfig.GetGlobalObservables(),
true);
1589 pdfMap[channel_name]=model;
1592 cxcoutP(HistFactory) <<
"\n-----------------------------------------\n"
1593 <<
"\tEntering combination"
1594 <<
"\n-----------------------------------------\n" << std::endl;
1595 auto combined = std::make_unique<RooWorkspace>(
"combined");
1598 RooCategory& channelCat = emplace<RooCategory>(*combined,
"channelCat", channelMap);
1600 auto simPdf= std::make_unique<RooSimultaneous>(
"simPdf",
"",pdfMap, channelCat);
1601 auto combined_config = std::make_unique<ModelConfig>(
"ModelConfig", combined.get());
1602 combined_config->SetWorkspace(*combined);
1605 combined->import(globalObs);
1606 combined->defineSet(
"globalObservables",globalObs);
1607 combined_config->SetGlobalObservables(*combined->set(
"globalObservables"));
1609 combined->defineSet(
"observables",{obsList, channelCat},
true);
1610 combined_config->SetObservables(*combined->set(
"observables"));
1614 bool isConsistent =
false;
1616 std::set<std::string> allowedInconsistent{
"asimovData"};
1617 std::tie(isConsistent, errMsg) = isChannelDataConsistent(chs, ch_names, allowedInconsistent);
1618 if (!isConsistent) {
1628 if(std::string(
"asimovData") ==
data->GetName()) {
1633 std::map<std::string, RooAbsData*> dataMap;
1634 for(
unsigned int i = 0; i < ch_names.size(); ++i){
1635 dataMap[ch_names[i]] = chs[i]->data(
data->GetName());
1645 cxcoutP(HistFactory) <<
"\n-----------------------------------------\n"
1646 <<
"\tImporting combined model"
1647 <<
"\n-----------------------------------------\n" << std::endl;
1652 std::string paramName = param_itr.first;
1653 double paramVal = param_itr.second;
1655 if(
RooRealVar* temp = combined->var( paramName )) {
1656 temp->setVal( paramVal );
1657 cxcoutI(HistFactory) <<
"setting " << paramName <<
" to the value: " << paramVal << std::endl;
1659 cxcoutE(HistFactory) <<
"could not find variable " << paramName <<
" could not set its value" << std::endl;
1663 for(
unsigned int i=0; i<
fSystToFix.size(); ++i){
1666 temp->setConstant();
1667 cxcoutI(HistFactory) <<
"setting " <<
fSystToFix.at(i) <<
" constant" << std::endl;
1669 cxcoutE(HistFactory) <<
"could not find variable " <<
fSystToFix.at(i) <<
" could not set it to constant" << std::endl;
1677 combined_config->SetPdf(*simPdf);
1680 combined->import(*combined_config,combined_config->GetName());
1681 combined->importClassCode();
1687 cxcoutP(HistFactory) <<
"\n-----------------------------------------\n"
1688 <<
"\tcreate toy data"
1689 <<
"\n-----------------------------------------\n" << std::endl;
1697 *combined->pdf(
"simPdf"),
1699 if( asimov_combined ) {
1700 combined->import( *asimov_combined,
RooFit::Rename(
"asimovData"));
1703 cxcoutFHF <<
"Error: Failed to create combined asimov dataset\n";
1717 auto ErrorHist =
static_cast<TH1*
>(Nominal->Clone( Name.c_str() ));
1720 int numBins = Nominal->GetNbinsX()*Nominal->GetNbinsY()*Nominal->GetNbinsZ();
1724 for(
int i_bin = 0; i_bin < numBins; ++i_bin) {
1728 while( Nominal->IsBinUnderflow(binNumber) || Nominal->IsBinOverflow(binNumber) ){
1732 double histError = Nominal->GetBinError( binNumber );
1735 if( histError != histError ) {
1736 cxcoutFHF <<
"Warning: In histogram " << Nominal->GetName() <<
" bin error for bin " << i_bin
1737 <<
" is NAN. Not using Error!!!\n";
1744 if( histError < 0 ) {
1745 cxcoutWHF <<
"Warning: In histogram " << Nominal->GetName() <<
" bin error for bin " << binNumber
1746 <<
" is < 0. Setting Error to 0" << std::endl;
1751 ErrorHist->SetBinContent( binNumber, histError );
1770 unsigned int numHists = HistVec.size();
1772 if( numHists == 0 ) {
1773 cxcoutE(HistFactory) <<
"Warning: Empty Hist Vector, cannot create total uncertainty" << std::endl;
1777 const TH1* HistTemplate = HistVec.at(0).first;
1778 int numBins = HistTemplate->
GetNbinsX()*HistTemplate->GetNbinsY()*HistTemplate->GetNbinsZ();
1782 for(
unsigned int i = 0; i < HistVec.size(); ++i ) {
1784 const TH1* nominal = HistVec.at(i).first;
1785 const TH1* error = HistVec.at(i).second.get();
1788 cxcoutE(HistFactory) <<
"Error: Provided hists have unequal bins" << std::endl;
1792 cxcoutE(HistFactory) <<
"Error: Provided hists have unequal bins" << std::endl;
1797 std::vector<double> TotalBinContent( numBins, 0.0);
1798 std::vector<double> HistErrorsSqr( numBins, 0.0);
1803 for(
int i_bins = 0; i_bins < numBins; ++i_bins) {
1806 while( HistTemplate->IsBinUnderflow(binNumber) || HistTemplate->IsBinOverflow(binNumber) ){
1810 for(
unsigned int i_hist = 0; i_hist < numHists; ++i_hist ) {
1812 const TH1* nominal = HistVec.at(i_hist).first;
1813 const TH1* error = HistVec.at(i_hist).second.get();
1820 if( histError != histError ) {
1821 cxcoutFHF <<
"In histogram " << error->
GetName() <<
" bin error for bin " << binNumber
1822 <<
" is NAN. Not using error!!";
1826 TotalBinContent.at(i_bins) += histValue;
1827 HistErrorsSqr.at(i_bins) += histError*histError;
1835 TH1* ErrorHist =
static_cast<TH1*
>(HistTemplate->Clone( Name.c_str() ));
1839 for(
int i = 0; i < numBins; ++i) {
1843 while( ErrorHist->IsBinUnderflow(binNumber) || ErrorHist->IsBinOverflow(binNumber) ){
1847 double ErrorsSqr = HistErrorsSqr.at(i);
1848 double TotalVal = TotalBinContent.at(i);
1850 if( TotalVal <= 0 ) {
1851 cxcoutW(HistFactory) <<
"Warning: Sum of histograms for bin: " << binNumber
1852 <<
" is <= 0. Setting error to 0"
1855 ErrorHist->SetBinContent( binNumber, 0.0 );
1859 double RelativeError = sqrt(ErrorsSqr) / TotalVal;
1863 if( RelativeError != RelativeError ) {
1864 cxcoutE(HistFactory) <<
"Error: bin " << i <<
" error is NAN\n"
1865 <<
" HistErrorsSqr: " << ErrorsSqr
1866 <<
" TotalVal: " << TotalVal;
1876 ErrorHist->SetBinError(binNumber, TotalVal);
1877 ErrorHist->SetBinContent(binNumber, RelativeError);
1879 cxcoutI(HistFactory) <<
"Making Total Uncertainty for bin " << binNumber
1880 <<
" Error = " << sqrt(ErrorsSqr)
1881 <<
" CentralVal = " << TotalVal
1882 <<
" RelativeError = " << RelativeError <<
"\n";
1886 return std::unique_ptr<TH1>(ErrorHist);
std::vector< double > histToVector(TH1 const &hist)
constexpr double alphaHigh
constexpr double alphaLow
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
A class which maps the current values of a RooRealVar (or a set of RooRealVars) to one of a number of...
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.
The PiecewiseInterpolation is a class that can morph distributions into each other,...
Common abstract base class for objects that represent a value and a "shape" in RooFit.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
Storage_t::size_type size() const
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
void setConstant(bool value=true)
Abstract base class for objects that represent a real value and implements functionality common to al...
Calculates the sum of a set of RooAbsReal terms, or when constructed with two sets,...
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Implements a RooAbsBinning in terms of an array of boundary values, posing no constraints on the choi...
Object to represent discrete states.
Container class to hold N-dimensional binned data.
Container class to hold unbinned data.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Implementation of the Gamma PDF for RooFit/RooStats.
Switches the message service to a different level while the instance is alive.
A real-valued function sampled from a multidimensional histogram.
static RooMsgService & instance()
Return reference to singleton instance.
A RooAbsReal implementing a polynomial in terms of a list of RooAbsReal coefficients.
Represents the product of a given set of RooAbsReal objects.
Implements a PDF constructed from a sum of functions:
Variable that can be changed from the outside.
void setBins(Int_t nBins, const char *name=nullptr, bool shared=true)
Create a uniform binning under name 'name' for this variable.
void setBinning(const RooAbsBinning &binning, const char *name=nullptr, bool shared=true)
Add given binning under name 'name' with this variable.
static void SetPrintLevel(int level)
set print level (static function)
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
void Print(std::ostream &=std::cout)
HistFactory::StatErrorConfig & GetStatErrorConfig()
get information about threshold for statistical uncertainties and constraint term
RooStats::HistFactory::Data & GetData()
get data object
bool CheckHistograms() const
std::vector< RooStats::HistFactory::Sample > & GetSamples()
get vector of samples for this channel
std::string GetName() const
get name of channel
Configuration for a constrained, coherent shape variation of affected samples.
This class provides helper functions for creating likelihood models from histograms.
std::unique_ptr< RooProduct > CreateNormFactor(RooWorkspace &proto, std::string &channel, std::string &sigmaEpsilon, Sample &sample, bool doRatio)
void GuessObsNameVec(const TH1 *hist)
std::unique_ptr< RooWorkspace > MakeSingleChannelWorkspace(Measurement &measurement, Channel &channel)
void AddConstraintTerms(RooWorkspace &proto, Measurement &measurement, std::string prefix, std::string interpName, std::vector< OverallSys > &systList, std::vector< std::string > &constraintTermNames, std::vector< std::string > &totSystTermNames)
void MakeTotalExpected(RooWorkspace &proto, const std::string &totName, const std::vector< RooProduct * > &sampleScaleFactors, std::vector< std::vector< RooAbsArg * > > &sampleHistFuncs) const
std::unique_ptr< TH1 > MakeScaledUncertaintyHist(const std::string &Name, std::vector< std::pair< const TH1 *, std::unique_ptr< TH1 > > > const &HistVec) const
std::vector< std::string > fPreprocessFunctions
RooHistFunc * MakeExpectedHistFunc(const TH1 *hist, RooWorkspace &proto, std::string prefix, const RooArgList &observables) const
Create the nominal hist function from hist, and register it in the workspace.
void SetFunctionsToPreprocess(std::vector< std::string > lines)
TH1 * MakeAbsolUncertaintyHist(const std::string &Name, const TH1 *Nominal)
std::vector< std::string > fObsNameVec
RooFit::OwningPtr< RooWorkspace > MakeSingleChannelModel(Measurement &measurement, Channel &channel)
RooFit::OwningPtr< RooWorkspace > MakeCombinedModel(std::vector< std::string >, std::vector< std::unique_ptr< RooWorkspace > > &)
std::map< std::string, double > fParamValues
static void ConfigureWorkspaceForMeasurement(const std::string &ModelName, RooWorkspace *ws_single, Measurement &measurement)
void ConfigureHistFactoryDataset(RooDataSet &obsData, TH1 const &nominal, RooWorkspace &proto, std::vector< std::string > const &obsNameVec)
static void PrintCovarianceMatrix(RooFitResult *result, RooArgSet *params, std::string filename)
std::vector< std::string > fSystToFix
HistoToWorkspaceFactoryFast()
RooArgList createObservables(const TH1 *hist, RooWorkspace &proto) const
Create observables of type RooRealVar. Creates 1 to 3 observables, depending on the type of the histo...
The RooStats::HistFactory::Measurement class can be used to construct a model by combining multiple R...
Configuration for an un- constrained overall systematic to scale sample normalisations.
Configuration for a constrained overall systematic to scale sample normalisations.
const std::string & GetName() const
*Un*constrained bin-by-bin variation of affected histogram.
Constrained bin-by-bin variation of affected histogram.
double GetRelErrorThreshold() const
Constraint::Type GetConstraintType() const
< A class that holds configuration information for a model using a workspace as a store
Persistable container for RooFit projects.
RooAbsPdf * pdf(RooStringView name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooAbsArg * arg(RooStringView name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
bool import(const RooAbsArg &arg, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}, const RooCmdArg &arg9={})
Import a RooAbsArg object, e.g.
const Double_t * GetArray() const
Class to manage histogram axis.
Bool_t IsVariableBinSize() const
const char * GetTitle() const override
Returns title of object.
virtual Double_t GetBinCenter(Int_t bin) const
Return center of bin.
const TArrayD * GetXbins() const
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
virtual Int_t GetDimension() const
virtual void Reset(Option_t *option="")
Reset this histogram: contents, errors, etc.
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 Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
const char * GetName() const override
Returns name of object.
const char * GetTitle() const override
Returns title 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.
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
RooCmdArg RecycleConflictNodes(bool flag=true)
RooCmdArg Rename(const char *suffix)
RooCmdArg Conditional(const RooArgSet &pdfSet, const RooArgSet &depSet, bool depsAreCond=false)
RooConstVar & RooConst(double val)
RooCmdArg Index(RooCategory &icat)
RooCmdArg StoreError(const RooArgSet &aset)
RooCmdArg WeightVar(const char *name="weight", bool reinterpretAsWeight=false)
RooCmdArg Import(const char *state, TH1 &histo)
T * OwningPtr
An alias for raw pointers for indicating that the return type of a RooFit function is an owning point...
OwningPtr< T > makeOwningPtr(std::unique_ptr< T > &&ptr)
Internal helper to turn a std::unique_ptr<T> into an OwningPtr.
constexpr double defaultShapeSysGammaMax
constexpr double minShapeUncertainty
constexpr double defaultStatErrorGammaMax
constexpr double defaultGammaMin
CreateGammaConstraintsOutput createGammaConstraints(RooArgList const ¶mSet, std::span< const double > relSigmas, double minSigma, Constraint::Type type)
Namespace for the RooStats classes.
Configuration settings for HistFactory behavior.
bool createPerRegionWorkspaces
Control whether individual workspace files are created for each channel (default true).
bool binnedFitOptimization
Enable or disable optimization for binned likelihood fits (default true).
bool storeDataError
Control whether errors on the data histograms are stored in the workspace (default false).