77 #define alpha_Low "-5"
78 #define alpha_High "5"
79 #define NoHistConst_Low "0"
80 #define NoHistConst_High "2000"
83 using namespace RooFit ;
84 using namespace RooStats ;
91 namespace HistFactory{
93 HistoToWorkspaceFactory::HistoToWorkspaceFactory() :
103 HistoToWorkspaceFactory::~HistoToWorkspaceFactory(){
107 HistoToWorkspaceFactory::HistoToWorkspaceFactory(
string filePrefix,
string row, vector<string> syst,
double nomL,
double lumiE,
int low,
int high, TFile*
f):
108 fFileNamePrefix(filePrefix),
118 fResultsPrefixStr<<
"_" << fRowTitle;
119 while(fRowTitle.find(
"\\ ")!=string::npos){
120 int pos=fRowTitle.find(
"\\ ");
121 fRowTitle.replace(pos, 1,
"");
123 pFile = fopen ((filePrefix+
"_results.table").c_str(),
"a");
128 string HistoToWorkspaceFactory::FilePrefixStr(
string prefix){
131 ss << prefix <<
"_" << fNomLumi<<
"_" << fLumiError<<
"_" << fLowBin<<
"_" << fHighBin<<
"_"<<fRowTitle;
136 void HistoToWorkspaceFactory::ProcessExpectedHisto(
TH1* hist,
RooWorkspace* proto,
string prefix,
string productPrefix,
string systTerm,
double low,
double high,
int lowBin,
int highBin){
138 cout <<
"processing hist " << hist->
GetName() << endl;
140 cout <<
"hist is empty" << endl;
142 string highStr =
"inf";
143 for(
Int_t i=lowBin; i<highBin; ++i){
144 std::stringstream str;
145 std::stringstream range;
148 range<<
"["<<hist->
GetBinContent(i+1) <<
"," << low <<
"," << highStr <<
"]";
150 range<<
"["<< low <<
"," << high <<
"]";
151 cout <<
"for bin N"+str.str() <<
" var " << prefix+str.str()+
" with range " << range.str() << endl;
155 if(! (productPrefix.empty() || systTerm.empty()) )
156 proto->
factory((
"prod:"+productPrefix+str.str()+
"("+prefix+str.str()+
","+systTerm+
")").c_str() );
165 void HistoToWorkspaceFactory::AddMultiVarGaussConstraint(
RooWorkspace* proto,
string prefix,
int lowBin,
int highBin, vector<string>& likelihoodTermNames){
170 for(
Int_t i=lowBin; i<highBin; ++i){
171 std::stringstream str;
178 for(
int i=lowBin; i<highBin; ++i){
179 for(
int j=0; j<highBin-lowBin; ++j){
181 Cov(i,j) =
sqrt(mean(i));
189 floating, mean, Cov);
191 proto->
import(constraint);
193 likelihoodTermNames.push_back(constraint.GetName());
198 void HistoToWorkspaceFactory::LinInterpWithConstraint(
RooWorkspace* proto,
TH1* nominal, vector<TH1*> lowHist, vector<TH1*> highHist,
199 vector<string> sourceName,
string prefix,
string productPrefix,
string systTerm,
200 int lowBin,
int highBin, vector<string>& likelihoodTermNames){
208 for(
unsigned int j=0; j<lowHist.size(); ++j){
209 std::stringstream str;
217 string command=(
"Gaussian::alpha_"+sourceName.at(j)+
"Constraint(alpha_"+sourceName.at(j)+
",nom_"+sourceName.at(j)+
"[0.,-10,10],1.)");
218 cout << command << endl;
219 likelihoodTermNames.push_back( proto->
factory( command.c_str() )->GetName() );
220 proto->
var((
"nom_"+sourceName.at(j)).c_str())->setConstant();
221 const_cast<RooArgSet*
>(proto->
set(
"globalObservables"))->add(*proto->
var((
"nom_"+sourceName.at(j)).c_str()));
230 for(
Int_t i=lowBin; i<highBin; ++i){
231 std::stringstream str;
235 vector<double> low, high;
236 for(
unsigned int j=0; j<lowHist.size(); ++j){
237 low.push_back( lowHist.at(j)->GetBinContent(i+1) );
238 high.push_back( highHist.at(j)->GetBinContent(i+1) );
239 cout <<
"for "+prefix+
" bin "+str.str()+
" creating linear interp of nominal " << nominal->
GetBinContent(i+1)
240 <<
" in parameter " << sourceName.at(j)
241 <<
" between " << low.back() <<
" - " << high.back()
242 <<
" about " << 100.*
fabs(low.back() - high.back() )/nominal->
GetBinContent(i+1) <<
" % error"
247 LinInterpVar interp( (prefix+str.str()).c_str(),
"", params, nominal->
GetBinContent(i+1), low, high);
253 proto->
factory((
"prod:"+productPrefix+str.str()+
"("+prefix+str.str()+
","+systTerm+
")").c_str() );
259 string HistoToWorkspaceFactory::AddNormFactor(
RooWorkspace * proto,
string & channel,
string & sigmaEpsilon, EstimateSummary & es,
bool doRatio){
260 string overallNorm_times_sigmaEpsilon ;
262 vector<EstimateSummary::NormFactor>
norm=es.normFactor;
264 for(vector<EstimateSummary::NormFactor>::iterator itr=norm.begin(); itr!=norm.end(); ++itr){
265 cout <<
"making normFactor: " << itr->name << endl;
267 std::stringstream range;
268 range<<
"["<<itr->val<<
","<<itr->low<<
","<<itr->high<<
"]";
272 if(!prodNames.empty()) prodNames+=
",";
274 varname=itr->name+
"_"+channel;
279 proto->
factory((varname+range.str()).c_str());
283 cout <<
"WARNING: Const attribute to <NormFactor> tag is deprecated, will ignore."<<
284 " Instead, add \n\t<ParamSetting Const=\"True\">"<<varname<<
"</ParamSetting>\n"<<
285 " to your top-level XML's <Measurment> entry"<< endl;
289 overallNorm_times_sigmaEpsilon = es.name+
"_"+channel+
"_overallNorm_x_sigma_epsilon";
290 proto->
factory((
"prod::"+overallNorm_times_sigmaEpsilon+
"("+prodNames+
","+sigmaEpsilon+
")").c_str());
293 if(!overallNorm_times_sigmaEpsilon.empty())
294 return overallNorm_times_sigmaEpsilon;
300 void HistoToWorkspaceFactory::AddEfficiencyTerms(
RooWorkspace* proto,
string prefix,
string interpName,
301 map<
string,pair<double,double> > systMap,
302 vector<string>& likelihoodTermNames, vector<string>& totSystTermNames){
308 totSystTermNames.push_back(prefix);
311 vector<double> lowVec, highVec;
312 for(map<
string,pair<double,double> >::iterator it=systMap.begin(); it!=systMap.end(); ++it){
318 string command=(
"Gaussian::"+prefix+it->first+
"Constraint("+prefix+it->first+
",nom_"+prefix+it->first+
"[0.,-10,10],1.)");
319 cout << command << endl;
320 likelihoodTermNames.push_back( proto->
factory( command.c_str() )->GetName() );
321 proto->
var((
"nom_"+prefix+it->first).c_str())->setConstant();
322 const_cast<RooArgSet*
>(proto->
set(
"globalObservables"))->add(*proto->
var((
"nom_"+prefix+it->first).c_str()));
328 std::stringstream lowhigh;
329 double low = it->second.first;
330 double high = it->second.second;
331 lowVec.push_back(low);
332 highVec.push_back(high);
335 if(systMap.size()>0){
337 LinInterpVar interp( (interpName).c_str(),
"", params, 1., lowVec, highVec);
349 void HistoToWorkspaceFactory::MakeTotalExpected(
RooWorkspace* proto,
string totName,
string ,
string ,
350 int lowBin,
int highBin, vector<string>& syst_x_expectedPrefixNames,
351 vector<string>& normByNames){
355 for(
Int_t i=lowBin; i<highBin; ++i){
356 std::stringstream str;
358 string command=
"sum::"+totName+str.str()+
"(";
361 for(
unsigned int j=0; j<syst_x_expectedPrefixNames.size();++j){
362 command+=prepend+normByNames.at(j)+
"*"+syst_x_expectedPrefixNames.at(j)+str.str();
366 cout <<
"function to calculate total: " << command << endl;
367 proto->
factory(command.c_str());
371 void HistoToWorkspaceFactory::AddPoissonTerms(
RooWorkspace* proto,
string prefix,
string obsPrefix,
string expPrefix,
int lowBin,
int highBin,
372 vector<string>& likelihoodTermNames){
377 for(
Int_t i=lowBin; i<highBin; ++i){
378 std::stringstream str;
381 string command(
"Poisson::"+prefix+str.str()+
"("+obsPrefix+str.str()+
","+expPrefix+str.str()+
",1)");
385 cout <<
"Poisson Term " << command << endl;
389 likelihoodTermNames.push_back( temp->GetName() );
395 void HistoToWorkspaceFactory::SetObsToExpected(
RooWorkspace* proto,
string obsPrefix,
string expPrefix,
int lowBin,
int highBin){
402 for(
Int_t i=lowBin; i<highBin; ++i){
403 std::stringstream str;
406 cout <<
"expected number of events called: " << expPrefix << endl;
412 cout <<
"setting obs"+str.str()+
" to expected = " << exp->
getVal() <<
" check: " << obs->
getVal() << endl;
415 obsForTree[i] = exp->
getVal();
416 tree->
Branch((obsPrefix+str.str()).c_str(), obsForTree+i ,(obsPrefix+str.str()+
"/D").c_str());
419 cout <<
"problem retrieving obs or exp " << obsPrefix+str.str() << obs <<
" " << expPrefix+str.str() << exp << endl;
429 void HistoToWorkspaceFactory::Customize(
RooWorkspace* proto,
const char* pdfNameChar, map<string,string> renameMap) {
430 cout <<
"in customizations" << endl;
431 string pdfName(pdfNameChar);
432 map<string,string>::iterator it;
433 string edit=
"EDIT::customized("+pdfName+
",";
435 for(it=renameMap.begin(); it!=renameMap.end(); ++it) {
436 cout << it->first +
"=" + it->second << endl;
437 edit+=precede + it->first +
"=" + it->second;
442 proto->
factory( edit.c_str() );
448 void HistoToWorkspaceFactory::EditSyst(
RooWorkspace* proto,
const char* pdfNameChar, map<string,double> gammaSyst, map<string,double> uniformSyst,map<string,double> logNormSyst) {
449 string pdfName(pdfNameChar);
454 string edit=
"EDIT::newSimPdf("+pdfName+
",";
456 string lastPdf=pdfName;
458 unsigned int numReplacements = 0;
459 unsigned int nskipped = 0;
460 map<string,double>::iterator it;
463 for(it=gammaSyst.begin(); it!=gammaSyst.end(); ++it) {
465 if(! proto->
var((
"alpha_"+it->first).c_str())){
472 double relativeUncertainty = it->second;
473 double scale = 1/
sqrt((1+1/
pow(relativeUncertainty,2)));
476 proto->
factory(
Form(
"beta_%s[1,0,10]",it->first.c_str()));
477 proto->
factory(
Form(
"y_%s[%f]",it->first.c_str(),1./
pow(relativeUncertainty,2))) ;
478 proto->
factory(
Form(
"theta_%s[%f]",it->first.c_str(),
pow(relativeUncertainty,2))) ;
479 proto->
factory(
Form(
"Gamma::beta_%sConstraint(beta_%s,sum::k_%s(y_%s,one[1]),theta_%s,zero[0])",
484 it->first.c_str())) ;
500 proto->
factory(
Form(
"PolyVar::alphaOfBeta_%s(beta_%s,{%f,%f})",it->first.c_str(),it->first.c_str(),-1./scale,1./scale));
512 editList+=precede +
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint";
515 editList+=precede +
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first;
525 if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
526 edit=
"EDIT::"+lastPdf+
"_("+lastPdf+
","+editList+
")";
530 cout <<
"Going to issue this edit command\n" << edit<< endl;
531 proto->
factory( edit.c_str() );
534 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
540 for(it=uniformSyst.begin(); it!=uniformSyst.end(); ++it) {
541 cout <<
"edit for " << it->first <<
"with rel uncert = " << it->second << endl;
542 if(! proto->
var((
"alpha_"+it->first).c_str())){
543 cout <<
"systematic not there" << endl;
550 proto->
factory(
Form(
"beta_%s[1,0,10]",it->first.c_str()));
551 proto->
factory(
Form(
"Uniform::beta_%sConstraint(beta_%s)",it->first.c_str(),it->first.c_str()));
552 proto->
factory(
Form(
"PolyVar::alphaOfBeta_%s(beta_%s,{-1,1})",it->first.c_str(),it->first.c_str()));
563 cout <<
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint" << endl;
564 editList+=precede +
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint";
566 cout <<
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first << endl;
567 editList+=precede +
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first;
569 if( proto->
pdf((
"alpha_"+it->first+
"Constraint").c_str()) && proto->
var((
"alpha_"+it->first).c_str()) )
570 cout <<
" checked they are there" << proto->
pdf((
"alpha_"+it->first+
"Constraint").c_str()) <<
" " << proto->
var((
"alpha_"+it->first).c_str()) << endl;
572 cout <<
"NOT THERE" << endl;
575 if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
576 edit=
"EDIT::"+lastPdf+
"_("+lastPdf+
","+editList+
")";
581 proto->
factory( edit.c_str() );
584 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
594 for(it=logNormSyst.begin(); it!=logNormSyst.end(); ++it) {
595 cout <<
"edit for " << it->first <<
"with rel uncert = " << it->second << endl;
596 if(! proto->
var((
"alpha_"+it->first).c_str())){
597 cout <<
"systematic not there" << endl;
603 double relativeUncertainty = it->second;
604 double kappa = 1+relativeUncertainty;
608 double scale = relativeUncertainty;
612 proto->
factory(
Form(
"beta_%s[1,0,10]",it->first.c_str()));
613 proto->
factory(
Form(
"kappa_%s[%f]",it->first.c_str(),kappa));
614 proto->
factory(
Form(
"Lognormal::beta_%sConstraint(beta_%s,one[1],kappa_%s)",
617 it->first.c_str())) ;
618 proto->
factory(
Form(
"PolyVar::alphaOfBeta_%s(beta_%s,{%f,%f})",it->first.c_str(),it->first.c_str(),-1./scale,1./scale));
630 cout <<
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint" << endl;
631 editList+=precede +
"alpha_"+it->first+
"Constraint=beta_" + it->first+
"Constraint";
633 cout <<
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first << endl;
634 editList+=precede +
"alpha_"+it->first+
"=alphaOfBeta_"+ it->first;
636 if( proto->
pdf((
"alpha_"+it->first+
"Constraint").c_str()) && proto->
var((
"alpha_"+it->first).c_str()) )
637 cout <<
" checked they are there" << proto->
pdf((
"alpha_"+it->first+
"Constraint").c_str()) <<
" " << proto->
var((
"alpha_"+it->first).c_str()) << endl;
639 cout <<
"NOT THERE" << endl;
642 if(numReplacements%10 == 0 && numReplacements+nskipped!=gammaSyst.size()){
643 edit=
"EDIT::"+lastPdf+
"_("+lastPdf+
","+editList+
")";
648 proto->
factory( edit.c_str() );
651 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
660 edit=
"EDIT::newSimPdf("+lastPdf+
","+editList+
")";
662 proto->
factory( edit.c_str() );
667 combined_config->
SetPdf(*newOne);
670 cout <<
"\n\n ---------------------\n WARNING: failed to make EDIT\n\n" << endl;
676 pFile = fopen ((filename).c_str(),
"w");
685 fprintf(pFile,
" & %s", myargi->
GetName());
687 fprintf(pFile,
"\\\\ \\hline \n" );
691 fprintf(pFile,
"%s", myargi->
GetName());
696 fprintf(pFile,
" & %.2f", result->
correlation(*myargi, *myargj));
699 fprintf(pFile,
" \\\\\n");
707 RooWorkspace* HistoToWorkspaceFactory::MakeSingleChannelModel(vector<EstimateSummary> summary, vector<string> systToFix,
bool doRatio)
710 if (summary.empty() ) {
711 Error(
"MakeSingleChannelModel",
"vector of EstimateSummry is empty - return a nullptr");
718 string channel=summary[0].channel;
719 cout <<
"\n\n-------------------\nStarting to process " << channel <<
" channel" << endl;
728 RooArgSet likelihoodTerms(
"likelihoodTerms");
729 vector<string> likelihoodTermNames, totSystTermNames,syst_x_expectedPrefixNames, normalizationNames;
731 string prefix, range;
736 if (summary.at(0).name==
"Data") {
737 ProcessExpectedHisto(summary.at(0).nominal,proto,
"obsN",
"",
"",0,100000,fLowBin,fHighBin);
739 cout <<
"Will use expected (\"Asimov\") data set" << endl;
740 ProcessExpectedHisto(
NULL,proto,
"obsN",
"",
"",0,100000,fLowBin,fHighBin);
748 std::stringstream lumiStr;
750 lumiStr<<
"["<<fNomLumi<<
",0,"<<10.*fNomLumi<<
"]";
751 proto->
factory((
"Lumi"+lumiStr.str()).c_str());
752 cout <<
"lumi str = " << lumiStr.str() << endl;
754 std::stringstream lumiErrorStr;
756 lumiErrorStr <<
"nominalLumi["<<fNomLumi <<
",0,"<<fNomLumi+10*fLumiError<<
"]," << fLumiError ;
757 proto->
factory((
"Gaussian::lumiConstraint(Lumi,"+lumiErrorStr.str()+
")").c_str());
759 proto->
defineSet(
"globalObservables",
"nominalLumi");
760 likelihoodTermNames.push_back(
"lumiConstraint");
761 cout <<
"lumi Error str = " << lumiErrorStr.str() << endl;
767 vector<EstimateSummary>::iterator it = summary.begin();
768 for(; it!=summary.end(); ++it){
769 if(it->name==
"Data")
continue;
771 string overallSystName = it->name+
"_"+it->channel+
"_epsilon";
772 string systSourcePrefix =
"alpha_";
773 AddEfficiencyTerms(proto,systSourcePrefix, overallSystName,
775 likelihoodTermNames, totSystTermNames);
777 overallSystName=AddNormFactor(proto, channel, overallSystName, *it, doRatio);
779 TH1* nominal = it->nominal;
780 if(it->lowHists.size() == 0){
781 cout << it->name+
"_"+it->channel+
" has no variation histograms " <<endl;
782 string expPrefix=it->name+
"_"+it->channel+
"_expN";
783 string syst_x_expectedPrefix=it->name+
"_"+it->channel+
"_overallSyst_x_Exp";
785 syst_x_expectedPrefixNames.push_back(syst_x_expectedPrefix);
786 }
else if(it->lowHists.size() != it->highHists.size()){
787 cout <<
"problem in "+it->name+
"_"+it->channel
788 <<
" number of low & high variation histograms don't match" << endl;
791 string constraintPrefix = it->name+
"_"+it->channel+
"_Hist_alpha";
792 string syst_x_expectedPrefix = it->name+
"_"+it->channel+
"_overallSyst_x_HistSyst";
793 LinInterpWithConstraint(proto, nominal, it->lowHists, it->highHists, it->systSourceForHist,
794 constraintPrefix, syst_x_expectedPrefix, overallSystName,
795 fLowBin, fHighBin, likelihoodTermNames);
796 syst_x_expectedPrefixNames.push_back(syst_x_expectedPrefix);
802 normalizationNames.push_back(
"Lumi" );
804 normalizationNames.push_back( it->normName);
810 MakeTotalExpected(proto,channel+
"_totN",channel+
"_expN",
"Lumi",fLowBin,fHighBin,
811 syst_x_expectedPrefixNames, normalizationNames);
815 AddPoissonTerms(proto,
"Pois_"+channel,
"obsN", channel+
"_totN", fLowBin, fHighBin, likelihoodTermNames);
819 if(summary.at(0).name!=
"Data"){
820 SetObsToExpected(proto,
"obsN",channel+
"_totN", fLowBin, fHighBin);
821 cout <<
" using asimov data" << endl;
823 SetObsToExpected(proto,
"obsN",
"obsN", fLowBin, fHighBin);
824 cout <<
" using input data histogram" << endl;
829 for(
unsigned int i=0; i<systToFix.size(); ++i){
832 else cout <<
"could not find variable " << systToFix.at(i) <<
" could not set it to constant" << endl;
837 for(
unsigned int i=0; i<likelihoodTermNames.size(); ++i){
839 likelihoodTerms.
add(* (proto->
arg(likelihoodTermNames[i].c_str())) );
843 proto->
defineSet(
"likelihoodTerms",likelihoodTerms);
846 cout <<
"-----------------------------------------"<<endl;
847 cout <<
"import model into workspace" << endl;
849 "product of Poissons accross bins for a single channel",
853 proto_config->
SetPdf(*model);
863 RooWorkspace* HistoToWorkspaceFactory::MakeCombinedModel(vector<string> ch_names, vector<RooWorkspace*> chs)
879 if (ch_names.empty() || chs.empty() ) {
880 Error(
"MakeCombinedModel",
"Input vectors are empty - return a nullptr");
883 if (chs.size() < ch_names.size() ) {
884 Error(
"MakeCombinedModel",
"Input vector of workspace has an invalid size - return a nullptr");
888 map<string, RooAbsPdf*> pdfMap;
889 vector<RooAbsPdf*> models;
893 for(
unsigned int i = 0; i< ch_names.size(); ++i){
894 string channel_name=ch_names[i];
896 if (ss.str().empty()) ss << channel_name ;
897 else ss <<
',' << channel_name ;
900 RooAbsPdf* model = ch->
pdf((
"model_"+channel_name).c_str());
901 models.push_back(model);
902 globalObs.
add(*ch->
set(
"globalObservables"));
905 pdfMap[channel_name]=model;
909 cout <<
"\n\n------------------\n Entering combination" << endl;
917 combined->
import(globalObs);
918 combined->
defineSet(
"globalObservables",globalObs);
923 cout <<
"-----------------------------------------"<<endl;
924 cout <<
"create toy data for " << ss.str() << endl;
926 const RooArgSet* obsN = chs[0]->set(
"obsN");
930 for(
unsigned int i = 1; i< ch_names.size(); ++i){
933 simData->
append(*simData_ch);
940 cout <<
"\n\n----------------\n Importing combined model" << endl;
943 cout <<
"check pointer " << simPdf << endl;
945 for(
unsigned int i=0; i<fSystToFix.size(); ++i){
947 RooRealVar* temp = combined->
var((fSystToFix.at(i)).c_str());
950 cout <<
"setting " << fSystToFix.at(i) <<
" constant" << endl;
952 else cout <<
"could not find variable " << fSystToFix.at(i) <<
" could not set it to constant" << endl;
960 combined_config->
SetPdf(*simPdf);
962 combined->
import(*combined_config,combined_config->
GetName());
999 cout <<
"\n\n---------------" << endl;
1000 cout <<
"---------------- Doing "<< channel <<
" Fit" << endl;
1001 cout <<
"---------------\n\n" << endl;
1013 while((params_obj=params_itr->
Next())){
1023 TCanvas*
c1 =
new TCanvas( channel.c_str(),
"",800,600);
1030 c1->SaveAs( (fFileNamePrefix+
"_"+channel+
"_"+fRowTitle+
"_profileLR.eps").c_str() );
1032 fOut_f->mkdir(channel.c_str())->mkdir(
"Summary")->cd();
1055 delete frame;
delete c1;
1074 for(
int i=0; i<curve_N; i++){
1075 double f=curve_x[i];
1078 y_arr_nll[i]=nll->getVal();
1080 TGraph *
g =
new TGraph(curve_N, x_arr, y_arr_nll);
1081 g->SetName((FilePrefixStr(channel)+
"_nll").c_str());
1085 delete [] y_arr_nll;
1113 TLine *
line =
new TLine(xmin,.5,xmax,.5);
1114 line->SetLineColor(
kGreen);
1115 TLine * line90 =
new TLine(xmin,2.71/2.,xmax,2.71/2.);
1116 line90->SetLineColor(
kGreen);
1117 TLine * line95 =
new TLine(xmin,3.84/2.,xmax,3.84/2.);
1118 line95->SetLineColor(
kGreen);
1125 if(! file)
return file;
1128 for(vector<string>::iterator itr=names.begin(); itr != names.end(); ++itr){
1129 if( ! path.empty() ) path+=
"/";
1132 if( ! ptr ) ptr=file->
mkdir((*itr).c_str());
1138 if(! file)
return file;
1141 if( ! ptr ) ptr=file->
mkdir(name.c_str());
virtual RooAbsReal * createNLL(RooAbsData &data, const RooLinkedList &cmdList)
Construct representation of -log(L) of PDFwith given dataset.
virtual const char * GetTitle() const
Returns title of object.
virtual RooPlot * plotOn(RooPlot *frame, 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(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add the specified argument to list.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
A RooCurve is a one-dimensional graphical representation of a real-valued function.
RooAbsPdf * GetPdf() const
get model PDF (return NULL if pdf has not been specified or does not exist)
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
void Start(Bool_t reset=kTRUE)
Start the stopwatch.
void SetStatColor(Color_t color=19)
RooCmdArg LineColor(Color_t color)
ClassImp(RooStats::HistFactory::HistoToWorkspaceFactory) namespace RooStats
virtual void SetWorkspace(RooWorkspace &ws)
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
RooCmdArg PrintLevel(Int_t code)
RooProdPdf is an efficient implementation of a product of PDFs of the form.
RooCmdArg Minos(Bool_t flag=kTRUE)
R__EXTERN TStyle * gStyle
virtual Int_t Fill()
Fill all branches.
static const char * filename()
virtual Double_t getMin(const char *name=0) const
virtual TDirectory * mkdir(const char *name, const char *title="")
Create a sub-directory and return a pointer to the created directory.
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
RooCmdArg RecycleConflictNodes(Bool_t flag=kTRUE)
Iterator abstract base class.
void SetCanvasColor(Color_t color=19)
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...
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
void SetFrameFillColor(Color_t color=1)
RooAbsPdf * pdf(const char *name) const
Retrieve p.d.f (RooAbsPdf) with given name. A null pointer is returned if not found.
RooCmdArg LineStyle(Style_t style)
double pow(double, double)
TIterator * createIterator(Bool_t dir=kIterForward) const
virtual void SetPdf(const RooAbsPdf &pdf)
Set the Pdf, add to the the workspace if not already there.
RooConstVar represent a constant real-valued object.
Double_t getVal(const RooArgSet *set=0) const
void Error(const char *location, const char *msgfmt,...)
Double_t correlation(const RooAbsArg &par1, const RooAbsArg &par2) const
RooRealVar represents a fundamental (non-derived) real valued object.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
VecExpr< UnaryOp< Fabs< T >, VecExpr< A, T, D >, T >, T, D > fabs(const VecExpr< A, T, D > &rhs)
void SetPadBorderMode(Int_t mode=1)
void SetCanvasBorderMode(Int_t mode=1)
void SetPadColor(Color_t color=19)
void setConstant(Bool_t value=kTRUE)
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
Bool_t defineSet(const char *name, const RooArgSet &aset, Bool_t importMissing=kFALSE)
Define a named RooArgSet with given constituents.
void FitModel(RooWorkspace *, std::string data_name="obsData")
char * Form(const char *fmt,...)
virtual const char * GetName() const
Returns name of object.
RooAbsRealLValue * getPlotVar() const
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
RooDataSet is a container class to hold unbinned data.
Double_t getErrorHi() const
RooCategory represents a fundamental (non-derived) discrete value object.
RooRealVar * var(const char *name) const
Retrieve real-valued variable (RooRealVar) with given name. A null pointer is returned if not found...
Bool_t isConstant() const
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
RooCmdArg Import(const char *state, TH1 &histo)
Multivariate Gaussian p.d.f.
RooCmdArg Index(RooCategory &icat)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Describe directory structure in memory.
void append(RooDataSet &data)
Add all data points of given data set to this data set.
TObject * obj(const char *name) const
Return any type of object (RooAbsArg, RooAbsData or generic object) with given name) ...
Mother of all ROOT objects.
RooFactoryWSTool & factory()
Return instance to factory tool.
virtual Int_t Branch(TCollection *list, Int_t bufsize=32000, Int_t splitlevel=99, const char *name="")
Create one branch for each element in the collection.
virtual Double_t getMax(const char *name=0) const
RooAbsRealLValue is the common abstract base class for objects that represent a real value that may a...
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
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.
RooAbsArg * arg(const char *name) const
Return RooAbsArg with given name. A null pointer is returned if none is found.
void SetTitleFillColor(Color_t color=1)
RooCurve * getCurve(const char *name=0) const
Return a RooCurve pointer of the named object in this plot, or zero if the named object does not exis...
virtual RooAbsReal * createProfile(const RooArgSet ¶msOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function...
virtual TObject * Next()=0
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...
virtual TDirectory * GetDirectory(const char *namecycle, Bool_t printError=false, const char *funcname="GetDirectory")
Find a directory using apath.
void FormatFrameForLikelihood(RooPlot *frame, std::string xTitle=std::string("#sigma / #sigma_{SM}"), std::string yTitle=std::string("-log likelihood"))
virtual RooFitResult * fitTo(RooAbsData &data, const RooCmdArg &arg1=RooCmdArg::none(), const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none())
Fit PDF to given dataset.
A TTree object has a header with a name and a title.
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return NULL if not existing)
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
virtual void SetGlobalObservables(const RooArgSet &set)
specify the global observables
Double_t getErrorLo() const
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
RooSimultaneous facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset...
double norm(double *x, double *p)
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
The RooWorkspace is a persistable container for RooFit projects.
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
RooAbsReal * function(const char *name) const
Retrieve function (RooAbsReal) with given name. Note that all RooAbsPdfs are also RooAbsReals...