11 #include <TLegendEntry.h> 13 #include <TDirectory.h> 14 #include <Math/MinimizerOptions.h> 16 #include <RooFitResult.h> 17 #include <RooWorkspace.h> 19 #include <RooStats/ModelConfig.h> 20 #include <RooStats/HistFactory/Sample.h> 21 #include <RooStats/HistFactory/Systematics.h> 22 #include <RooStats/HistFactory/HistoToWorkspaceFactory.h> 23 #include <RooStats/HistFactory/HistoToWorkspaceFactoryFast.h> 24 #include <RooStats/HistFactory/MakeModelAndMeasurementsFast.h> 25 #include <RooStats/HistFactory/PiecewiseInterpolation.h> 28 #include "cetlib_except/exception.h" 70 bool hfilled_sidebands =
false;
84 if (!hfilled_sidebands)
return;
91 mf::LogInfo(
"BuildWorkspace") <<
"Only drawing XSecs. Exiting";
93 TFile *
f =
new TFile(Outputfile.Data(),
"RECREATE");
94 TDirectory *HistoDir = f->mkdir(
"OriginalHistograms");
97 std::vector<TH1 *> pre_xsecs =
DrawXSecs();
98 for (
size_t k = 0;
k < pre_xsecs.size(); ++
k) {
99 pre_xsecs[
k]->Write();
103 for (
size_t k = 0;
k < pre_smear.size(); ++
k) {
104 pre_smear[
k]->Write();
124 TCanvas* ceffgraph =
new TCanvas(Form(
"ceffgraph%i",i),Form(
"Efficiency for channel %i",i));
127 effgraph->Draw(
"*a");
176 RooStats::HistFactory::Measurement meas(
"ProtoDUNEFitExample",
"ProtoDUNE fit example");
180 meas.SetLumiRelErr(0.001);
181 meas.AddConstantParam(
"Lumi");
184 meas.SetExportOnly(
false);
201 RooStats::HistFactory::HistoToWorkspaceFactoryFast h2w(meas);
202 RooWorkspace*
ws = h2w.MakeCombinedModel(meas);
219 RooFitResult *fitresult = NULL;
220 TTree *toys_tree = NULL;
221 TString treename(
"protodUNE_dataresults");
224 std::vector<TString> truebinsnameVec;
225 std::vector<TString> sidebandNames;
229 truebinsnameVec.push_back(str);
235 truebinsnameVec.push_back(str);
241 sidebandNames.push_back(str);
244 std::vector< TString > incidentNameVec;
247 std::cout <<
"NameVec " <<
l <<
" " << str <<
std::endl;
248 incidentNameVec.push_back(str);
251 incidentNameVec.push_back(Form(
"%s_%.1f-%.1f",
253 std::cout << incidentNameVec.back() <<
std::endl;
256 std::vector<TCanvas*> bfplots =
258 ws,
"beforefit",
"Poisson",
"ratio", truebinsnameVec,
_RecoBinning,
261 RooAbsData *asimovdata = ws->data(
"asimovData");
262 std::vector<TCanvas*> bfAsimovplots =
264 ws,
"asimov",
"Poisson",
"ratio", truebinsnameVec,
_RecoBinning,
273 std::cout <<
"Got tree " << toys_tree <<
std::endl;
274 toys_tree->SetNameTitle(
"protodUNE_mctoysresults",
"protodUNE_mctoysresults");
277 TTree *mctoys_results1 = (TTree*)toys_tree->Clone();
280 TTree *mctoys_results2 = (TTree*)toys_tree->Clone();
283 TTree *mctoys_results3 = (TTree*)toys_tree->Clone();
286 TTree *mctoys_results4 = (TTree*)toys_tree->Clone();
294 TFile *
f =
new TFile(Outputfile.Data(),
"UPDATE");
300 nuisancecanvas->Write();
302 pullscanvas->Write();
303 nuispullscanvas->Write();
305 avresultcanvas->Write();
307 for(
unsigned int i=0; i < bfAsimovplots.size(); i++){
308 bfAsimovplots[i]->Write();
310 for(
unsigned int i=0; i < bfplots.size(); i++){
377 treename =
"protodUNE_asimovresults";
380 fitresult = fitandgen->
FitData(ws);
387 if(fitresult->status() != 0){
388 std::cout <<
"WARNING::Fit failed - trying with Scan" <<
std::endl;
390 fitresult = fitandgen->
FitData(ws);
393 if(fitresult->status() != 0){
395 std::cout <<
"WARNING::Fit failed with fit strategy 0 - trying with fit strategy 1." <<
std::endl;
396 fitandgen->
SetAlgorithm(ROOT::Math::MinimizerOptions::DefaultMinimizerAlgo().c_str());
398 fitresult = fitandgen->
FitData(ws);
402 if(fitresult->status() != 0){
403 std::cout <<
"WARNING::Fit failed - trying with improve" <<
std::endl;
406 fitresult = fitandgen->
FitData(ws);
411 std::cerr <<
"No fit resuls found. Will exit!" <<
std::endl;
416 ws->import(*fitresult,kTRUE);
421 std::vector<TCanvas*> afplots =
423 ws,
"afterfit",
"Poisson",
"ratio", truebinsnameVec,
_RecoBinning,
436 toys_tree->SetNameTitle(treename.Data(),treename.Data());
440 ws,
"PDFit", fitresult);
442 TTree *mctoys_results1 = (TTree*)toys_tree->Clone();
445 TTree *mctoys_results2 = (TTree*)toys_tree->Clone();
447 RooArgList prefit_POI = fitresult->floatParsInit();
480 TFile *
f =
new TFile(Outputfile.Data(),
"UPDATE");
489 nuisancecanvas->Write();
491 avresultcanvas->Write();
495 for(
unsigned int i=0; i < bfAsimovplots.size(); i++){
496 bfAsimovplots[i]->Write();
498 for(
unsigned int i=0; i < bfplots.size(); i++){
501 for(
unsigned int i=0; i < afplots.size(); i++){
505 TDirectory *NLLDir = f->mkdir(
"NLLPlots");
507 for (
size_t i = 0; i < nllplots.size(); ++i) {
508 nllplots[i]->Write();
519 TDirectory *HistoDir = f->mkdir(
"OriginalHistograms");
536 TDirectory * SystDir = f->mkdir(
"SystematicHists");
548 TCanvas* ceffgraph =
new TCanvas(Form(
"ceffgraph%i",i),Form(
"Efficiency for channel %i",i));
551 effgraph->Draw(
"*a");
558 std::vector<TH1 *> pre_xsecs =
DrawXSecs();
559 for (
size_t k = 0;
k < pre_xsecs.size(); ++
k) {
560 pre_xsecs[
k]->Write();
563 std::vector<TH1 *> post_xsecs =
DrawXSecs(fitresult);
564 for (
size_t k = 0;
k < post_xsecs.size(); ++
k) {
565 post_xsecs[
k]->Write();
567 std::cout <<
"Finished XSec" <<
std::endl;
580 std::cout <<
"Wrote incident" <<
std::endl;
583 TCanvas* ceffgraph =
new TCanvas(
"ceffgraph",
"Efficiency" );
620 for(
int i=0; i < nmcchannels; i++){
621 TString channelname = Form(
"Channel%s",
_ChannelNames[i].c_str());
622 RooStats::HistFactory::Channel
channel(channelname.Data());
625 for(
unsigned int j=0; j <
_datahistos.size(); j++){
629 TString hname(htemp->GetName());
630 if(hname.Contains(channelname.Data()) && hname.Contains(
"Data")){
631 mf::LogInfo(
"AddSamplesAndChannelsToMeasurement") <<
"Adding dataset " <<
632 hname.Data() <<
" to channel " << channelname.Data() <<
" with " <<
633 htemp->Integral() <<
" events";
635 data.SetHisto(htemp);
642 std::vector<TH1*> systvec;
646 std::cout <<
"Got " << systvec.size() <<
" systematic histograms" <<
std::endl;
650 for(
unsigned int j=0; j <
_bkghistos.size(); j++){
654 TString hname(htemp->GetName());
656 if(hname.Contains(channelname.Data()) && hname.Contains(
"MC")){
657 mf::LogInfo(
"AddSamplesAndChannelsToMeasurement") <<
658 "Adding MC sample " << hname.Data() <<
" to channel " <<
659 channelname.Data() <<
" with " << htemp->Integral() <<
" events " <<
662 TString samplename = hname + TString(
"_sample");
663 RooStats::HistFactory::Sample sample(samplename.Data());
664 sample.SetNormalizeByTheory(
true);
669 sample.ActivateStatError();
671 RooStats::HistFactory::StatError& staterror = sample.GetStatError();
672 staterror.SetUseHisto();
673 staterror.SetErrorHist(staterrorhisto);
689 sample.SetHisto(htemp);
692 if (htemp->Integral() > 0) {
693 TString poiname = hname;
694 poiname.ReplaceAll(
"MC",
"POI");
695 poiname.ReplaceAll(
"_Histo",
"");
696 poiname.ReplaceAll(
".",
"");
697 poiname.ReplaceAll(
"-",
"_");
698 poiname.ReplaceAll(channelname.Data(),
"");
699 poiname.ReplaceAll(
"__",
"_");
700 meas.SetPOI(poiname.Data());
703 sample.AddNormFactor(poiname.Data(),
rand.Gaus(1.0, .1), 0., 100.);
706 sample.AddNormFactor(poiname.Data(), 1.0, 0.0, 100.0);
708 mf::LogInfo(
"BuildMeasurement") <<
"Sample " << sample.GetName() <<
" has normalisation parameter " << poiname.Data();
718 for(
unsigned int j=0; j <
_sighistos.size(); j++){
722 TString hname(htemp->GetName());
724 if(hname.Contains(channelname.Data()) && hname.Contains(
"MC")){
725 mf::LogInfo(
"AddSamplesAndChannelsToMeasurement") <<
"Adding MC sample" << hname.Data() <<
" to channel " << channelname.Data() <<
" with " << htemp->Integral() <<
" events";
726 TString samplename = hname + TString(
"_sample");
727 RooStats::HistFactory::Sample sample(samplename.Data());
728 sample.SetNormalizeByTheory(
true);
733 sample.ActivateStatError();
735 RooStats::HistFactory::StatError& staterror = sample.GetStatError();
736 staterror.SetUseHisto();
737 staterror.SetErrorHist(staterrorhisto);
752 sample.SetHisto(htemp);
755 TString poiname = hname;
756 poiname.ReplaceAll(
"MC",
"POI");
757 poiname.ReplaceAll(
"_Histo",
"");
758 poiname.ReplaceAll(
".0",
"");
759 poiname.ReplaceAll(
"-",
"_");
760 poiname.ReplaceAll(channelname.Data(),
"");
761 poiname.ReplaceAll(
"__",
"_");
762 poiname.ReplaceAll(
"_0_1000000",
"");
763 meas.SetPOI(poiname.Data());
766 sample.AddNormFactor(poiname.Data(),
rand.Gaus(1.0, .1), 0., 100.);
769 sample.AddNormFactor(poiname.Data(), 1.0, 0.0, 100.0);
771 mf::LogInfo(
"AddSamplesAndChannelsToMeasurement") <<
"Sample " << sample.GetName() <<
" has normalisation parameter " << poiname.Data();
782 mf::LogInfo(
"AddSamplesAndChannelsToMeasurement") <<
"Adding channel " <<
channel.GetName() <<
" to measurement " << meas.GetName();
792 TString channelname(
"ChannelIncident");
793 RooStats::HistFactory::Channel
channel(channelname.Data());
800 mf::LogInfo(
"AddIncidentSamplesAndChannelsToMeasurement") <<
"Adding Incident dataset " << htemp->GetName() <<
" to channel " << channelname.Data() <<
" with " << htemp->Integral() <<
" events";
801 data.SetHisto(htemp);
807 std::vector<TH1*> systvec;
811 std::cout <<
"Got " << systvec.size() <<
" syst hists" <<
std::endl;
819 TString hname(htemp->GetName());
822 mf::LogInfo(
"AddIncidentSamplesAndChannelsToMeasurement") <<
"Adding Incident MC sample " << hname.Data() <<
" to channel " << channelname.Data() <<
" with " << htemp->Integral() <<
" events";
823 TString samplename = hname + TString(
"_sample");
824 RooStats::HistFactory::Sample sample(samplename.Data());
825 sample.SetNormalizeByTheory(
true);
830 sample.ActivateStatError();
832 RooStats::HistFactory::StatError& staterror = sample.GetStatError();
833 staterror.SetUseHisto();
834 staterror.SetErrorHist(staterrorhisto);
851 sample.SetHisto(htemp);
853 std::cout <<
"Check: " << j <<
" " << hname <<
" " <<
856 if (htemp->Integral() > 0) {
857 TString poiname = hname;
858 poiname.ReplaceAll(
"MC",
"POI");
859 poiname.ReplaceAll(
"_Histo",
"");
860 poiname.ReplaceAll(
".",
"");
861 poiname.ReplaceAll(
"-",
"_");
862 poiname.ReplaceAll(channelname.Data(),
"");
863 poiname.ReplaceAll(
"__",
"_");
864 meas.SetPOI(poiname.Data());
867 sample.AddNormFactor(poiname.Data(),
rand.Gaus(1.0, .1), 0., 2.);
870 sample.AddNormFactor(poiname.Data(), 1.0, 0.0, 2.0);
872 mf::LogInfo(
"BuildMeasurement") <<
"Sample " << sample.GetName() <<
" has normalisation parameter " << poiname.Data();
880 std::vector<std::vector<std::pair<TH1*, TH1*>>> inc_sig_systs;
892 TString hname(htemp->GetName());
895 mf::LogInfo(
"AddSamplesAndChannelsToMeasurement") <<
"Adding Incident MC sample" << hname.Data() <<
" to channel " << channelname.Data() <<
" with " << htemp->Integral() <<
" events";
896 TString samplename = hname + TString(
"_sample");
897 RooStats::HistFactory::Sample sample(samplename.Data());
898 sample.SetNormalizeByTheory(
true);
903 sample.ActivateStatError();
905 RooStats::HistFactory::StatError& staterror = sample.GetStatError();
906 staterror.SetUseHisto();
907 staterror.SetErrorHist(staterrorhisto);
918 htemp->GetName() <<
" " << inc_sig_systs[
k][j].first <<
921 inc_sig_systs[
k][j].
second, sample,
929 sample.SetHisto(htemp);
932 TString poiname = hname;
933 poiname.ReplaceAll(
"MC",
"POI");
934 poiname.ReplaceAll(
"_Histo",
"");
935 poiname.ReplaceAll(
".0",
"");
936 poiname.ReplaceAll(
"-",
"_");
937 meas.SetPOI(poiname.Data());
940 sample.AddNormFactor(poiname.Data(),
rand.Gaus(1.0, .1), 0., 100.);
943 sample.AddNormFactor(poiname.Data(), 1.0, 0.0, 100.0);
945 mf::LogInfo(
"AddIncidentSamplesAndChannelsToMeasurement") <<
"Sample " << sample.GetName() <<
" has normalisation parameter " << poiname.Data();
955 mf::LogInfo(
"AddIncidentSamplesAndChannelsToMeasurement") <<
"Adding channel " <<
channel.GetName() <<
" to measurement " << meas.GetName();
962 RooStats::HistFactory::Measurement& meas){
965 std::string message_source =
"AddSidebandSamplesAndChannelsToMeasurement";
971 TString channelname = Form(
"SidebandChannelAPA2");
974 RooStats::HistFactory::Channel
channel(channelname.Data());
980 TString hname(htemp->GetName());
982 if(hname.Contains(channelname.Data()) && hname.Contains(
"Data")){
984 "Adding sideband dataset " << hname.Data() <<
" to channel " <<
985 channelname.Data() <<
" with " << htemp->Integral() <<
" events";
986 data.SetHisto(htemp);
994 mf::LogInfo(message_source) <<
"sideband " << j <<
" " <<
995 htemp->GetName() <<
" " <<
996 htemp->GetEntries() <<
" " <<
998 TString hname(htemp->GetName());
999 if (htemp->Integral() == 0)
continue;
1000 if(hname.Contains(channelname.Data()) && hname.Contains(
"MC")){
1001 mf::LogInfo(message_source) <<
"Adding MC sideband sample " <<
1002 hname.Data() <<
" to channel " << channelname.Data() <<
1003 " with " << htemp->Integral() <<
" events";
1005 TString samplename = hname + TString(
"_sample");
1006 RooStats::HistFactory::Sample sample(samplename.Data());
1007 sample.SetNormalizeByTheory(
true);
1012 sample.ActivateStatError();
1013 TH1* staterrorhisto =
1015 RooStats::HistFactory::StatError& staterror = sample.GetStatError();
1016 staterror.SetUseHisto();
1017 staterror.SetErrorHist(staterrorhisto);
1025 sample.SetHisto(htemp);
1030 TString poiname = hname;
1031 poiname.ReplaceAll(
"MC",
"POI");
1032 poiname.ReplaceAll(
"_Histo",
"");
1033 poiname.ReplaceAll(
"_Hist",
"");
1034 poiname.ReplaceAll(channelname.Data(),
"");
1035 poiname.ReplaceAll(
"SidebandChannel",
"");
1036 poiname.ReplaceAll(
".",
"");
1037 poiname.ReplaceAll(
"-",
"_");
1038 poiname.ReplaceAll(
"__",
"_");
1039 meas.SetPOI(poiname.Data());
1042 sample.AddNormFactor(poiname.Data(),
rand.Gaus(1.0, .1), 0., 100.);
1045 sample.AddNormFactor(poiname.Data(), 1.0, 0.0, 100.0);
1047 mf::LogInfo(message_source) <<
"Sample " << sample.GetName() <<
1048 " has normalisation parameter " << poiname.Data();
1061 mf::LogInfo(message_source) <<
"Adding sideband channel " <<
1062 channel.GetName() <<
" to measurement " << meas.GetName();
1083 if(nmcchannels != ndatachannels){
1084 mf::LogError(
"FillHistogramVectors_Pions") <<
"The number of data and MC channels is not the same. Check MCFileNames and DataFileNames in the fcl file. Time to die!";
1088 if(nmcchannels != nchannelnames || ndatachannels != nchannelnames){
1089 mf::LogError(
"FillHistogramVectors_Pions") <<
"The channel names do not correspond to the input files. Check MCFileNames, DataFileNames and ChannelNames in the fcl file. Time to die!";
1093 if(nbkgtopo != nbkgtoponames){
1094 mf::LogError(
"FillHistogramVectors_Pions") <<
"Background topologies and background names do not have the same length. Check BackgroundTopology and BackgroundTopologyName in the fcl file. Time to die!";
1098 if(nsigtopo != nsigtoponames){
1099 mf::LogError(
"FillHistogramVectors_Pions") <<
"Signal topologies and background name vectors do not have the same size. Check SignalTopology and SignalTopologyName in the fcl file. Time to die!";
1103 if(ninctopo != ninctoponames){
1104 mf::LogError(
"FillHistogramVectors_Pions") <<
"Incident topologies and name vectors do not have the same size. Check IncidentTopology and IncidentTopologyName in the fcl file. Time to die!";
1121 for(
int i=0; i < nmcchannels; i++){
1122 for(
int j=0; j < nbkgtopo; j++){
1142 for(
int j=0; j < nsigtopo; j++){
1153 for(
int k=1;
k <= hsignal->GetNbinsX();
k++){
1154 TString hname = Form(
"%s_RecoBin%i",hsignal->GetName(),
k);
1155 TH1 *hsignal_clone = (TH1*)hsignal->Clone();
1156 hsignal_clone->SetName(hname.Data());
1157 hsignal_clone->SetBinContent(
k, hsignal->GetBinContent(
k));
1158 for(
int kk=1; kk <= hsignal_clone->GetNbinsX(); kk++){
1159 if(kk ==
k)
continue;
1160 hsignal_clone->SetBinContent(kk, 0.0);
1206 for(
int i=0; i < ndatachannels; i++){
1221 for(
int i=0; i < ninctopo; i++){
1240 TString hname = Form(
"%s_TrueBin_%.1f-%.1f", inchisto->GetName(),
1242 inchisto->SetName(hname.Data());
1264 inchisto->SetNameTitle(Form(
"MC_ChannelIncident_%s_Histo",
1266 Form(
"Incident MC for topology %s",
1298 std::pair<TH1 *, TH1 *> inc_eff_num_denom =
1314 TH1D * incident_numerator =
new TH1D(
"incident_numerator",
"",
1319 incident_numerator->SetBinContent(i+1,
_incsighistos[i]->Integral());
1328 std::map<std::string, std::vector<TH1 *>> signal_hists_by_topo;
1330 for (
size_t i = 0; i <
_sighistos.size(); ++i) {
1333 if (name.find(
"_" + topo +
"_") == std::string::npos)
continue;
1334 if (name.find(
"MC_Channel" + topo) != std::string::npos) {
1335 signal_hists_by_topo[topo].push_back(
_sighistos[i]);
1341 for(
int i = 0; i < nsigtopo; ++i ){
1344 std::pair< TH1 *, TH1 * > eff_num_denom =
1351 for (
int i = 1; i < eff_num_denom.second->GetNbinsX(); ++i) {
1352 if (eff_num_denom.second->GetBinContent(i) < 1.e-5)
1353 eff_num_denom.second->SetBinContent(i, 1.);
1360 TH1D * interacting_numerator =
new TH1D(
"incident_numerator",
"",
1364 std::cout <<
"n bins: " << eff_num_denom.first->GetNbinsX() <<
" " <<
1365 eff_num_denom.second->GetNbinsX() <<
" " <<
1366 interacting_numerator->GetNbinsX() <<
std::endl;
1368 for (
size_t j = 0; j < signal_hists_by_topo[_SignalTopologyName[i]].size(); ++j) {
1369 interacting_numerator->SetBinContent(
1370 j+1, signal_hists_by_topo[_SignalTopologyName[i]][j]->Integral());
1373 TGraphAsymmErrors * eff =
new TGraphAsymmErrors(interacting_numerator, eff_num_denom.second);
1376 _SignalTopologyName[i] +
"_Interacting_Efficiency";
1378 eff->SetNameTitle(name.c_str(),
"Efficiency");
1394 std::string message_source =
"FillSidebandHistograms_Pions";
1397 mf::LogError(message_source) <<
"The number of data and MC control " <<
1398 "samples is not the same. Check MCControlSampleFiles and " <<
1399 "DataControlSampleFiles in the fcl file.";
1404 mf::LogError(message_source) <<
"The number of Sideband topologies " <<
1405 "does not match the number of sideband topology names. Check " <<
1406 "SidebandTopologyName and SidebandTopology in the fcl file.";
1442 double nIncidentPionsMC = 0.;
1443 double nPrimaryPionsMC = 0.;
1447 TTree * incident_tree = (TTree*)incidentFile.Get(
_RecoTreeName.c_str());
1450 nIncidentPionsMC += incident_tree->GetEntries();
1452 std::string cut =
"passBeamCut && primary_ends_inAPA3";
1454 nPrimaryPionsMC += incident_tree->GetEntries(cut.c_str());
1455 incidentFile.Close();
1457 std::cout <<
"Got " << nIncidentPionsMC <<
" incident MC Pions" <<
std::endl;
1460 double nIncidentPionsData = 0.;
1461 double nPrimaryPionsData = 0.;
1465 TTree * incident_tree = (TTree*)incidentFile.Get(
_RecoTreeName.c_str());
1470 nIncidentPionsData += incident_tree->GetEntries();
1472 std::string cut =
"passBeamCut && primary_ends_inAPA3";
1474 nPrimaryPionsData += incident_tree->GetEntries(cut.c_str());
1476 incidentFile.Close();
1511 TTree * incident_tree = (TTree*)incidentFile.Get(
_RecoTreeName.c_str());
1513 nPiMC += incident_tree->GetEntries(
"true_beam_PDG == 211");
1514 nMuMC += incident_tree->GetEntries(
"true_beam_PDG == -13");
1515 incidentFile.Close();
1519 std::cout <<
"nMu & nPi: " << nMuMC <<
" " << nPiMC <<
std::endl;
1530 std::cerr <<
"ERROR::No input histogram found! Will not apply systematics!" <<
std::endl;
1534 if(systvec.empty()){
1535 std::cout <<
"INFO::No detector systematic vector found! Will not apply systematics!" <<
std::endl;
1539 TString hname(histo->GetName());
1540 hname.ReplaceAll(
"_Histo",
"");
1543 std::cerr <<
"Vectors SystToConsider and SystType do not have the same size. Will not apply systematics. Check your fcl file." <<
std::endl;
1551 TH1* highhist = NULL; TH1* lowhist = NULL;
1552 for (
size_t j = 0; j < systvec.size(); ++j) {
1553 TH1* systhisto = (TH1*)systvec[j];
1554 TString systhistoname(systhisto->GetName());
1556 if (!systhistoname.Contains(hname.Data())) {
1559 if (!systhistoname.Contains(systname.Data())) {
1563 if(systhistoname.Contains(
"LOW") || systhistoname.Contains(
"Low") || systhistoname.Contains(
"low")){
1564 lowhist = systhisto;
1566 if(systhistoname.Contains(
"HIGH") || systhistoname.Contains(
"High") || systhistoname.Contains(
"high")){
1567 highhist = systhisto;
1571 if(!highhist || !lowhist){
1572 std::cerr <<
"ERROR::Stage1: Systematic histograms not found! " <<
1573 "Will not apply systematic " << systname.Data() <<
1574 " to histogram " << histo->GetName() <<
". Will skip!" <<
1580 histo, highhist,
"UP");
1582 histo, lowhist,
"DOWN");
1584 if(!highsyst || !lowsyst){
1585 std::cerr <<
"ERROR::Stage2: Systematic histograms not found! " <<
1586 "Will not apply systematic " << systname.Data() <<
1587 " to histogram " << histo->GetName() <<
". Will skip!" <<
std::endl;
1591 Double_t highval = highsyst->Integral()/histo->Integral();
1592 Double_t lowval = lowsyst->Integral()/histo->Integral();
1597 std::cout <<
"WARNING::Ignoring systematic uncertainty " << systname
1598 <<
" for sample " << hname <<
" as it is below the threshold " 1600 << 1. - lowval <<
" , " << highval - 1. <<
std::endl;
1606 if(systtype ==
"NormOnly"){
1607 if(isnorm && hname.Contains(
"Signal")){
1608 if(highval > 0. && lowval > 0.){
1609 std::cout <<
"INFO::Normalised systematic " << systname.Data() <<
" is considered." <<
std::endl;
1610 highsyst->Scale(1./highval);
1611 lowsyst->Scale(1./lowval);
1614 sample.AddOverallSys(systname.Data(), lowval, highval);
1615 std::cout <<
"INFO::Adding norm systematic by default with name " << systname <<
" , to sample " << hname <<
" , with high value = " << highval <<
" , and low value = " << lowval <<
" , with nominal integral = " << histo->Integral() <<
" , high histogram integral = " << highsyst->Integral() <<
" , low histogram integral = " << lowsyst->Integral() <<
" , and syst fraction = " << 1.-lowsyst->Integral()/histo->Integral() <<
" , " << highsyst->Integral()/histo->Integral()-1. <<
std::endl;
1622 sample.AddOverallSys(systname.Data(), lowval, highval);
1623 std::cout <<
"INFO::Adding single bin and without norm parameter norm systematic " << systname <<
" , to sample " << hname <<
" , with high value = " << highval <<
" , and low value = " << lowval <<
" , with nominal integral = " << histo->Integral() <<
" , high histogram integral = " << highsyst->Integral() <<
" , low histogram integral = " << lowsyst->Integral() <<
" , and syst fraction = " << 1.-lowsyst->Integral()/histo->Integral() <<
" , " << highsyst->Integral()/histo->Integral()-1. <<
std::endl;
1626 RooStats::HistFactory::HistoSys syst;
1627 syst.SetName(systname.Data());
1628 syst.SetHistoHigh(highsyst);
1629 syst.SetHistoLow(lowsyst);
1630 sample.AddHistoSys(syst);
1631 std::cout <<
"INFO::Adding multi-bin and without norm parameter shape+norm systematic " << systname <<
" , to sample " << hname <<
" , with nominal integral = " << histo->Integral() <<
" , high histogram integral = " << highsyst->Integral() <<
" , low histogram integral = " << lowsyst->Integral() <<
", and syst fraction = " << 1.-lowsyst->Integral()/histo->Integral() <<
" , " << highsyst->Integral()/histo->Integral()-1. <<
std::endl;
1636 if(isnorm && hname.Contains(
"Signal")){
1637 if(highval > 0. && lowval > 0.){
1638 std::cout <<
"INFO::Normalised systematic " << systname.Data() <<
" is considered." <<
std::endl;
1639 highsyst->Scale(1./highval);
1640 lowsyst->Scale(1./lowval);
1645 sample.AddOverallSys(systname.Data(), lowval, highval);
1646 std::cout <<
"INFO::Adding norm systematic " << systname <<
" , to sample " << hname <<
" , with high value = " << highval <<
" , and low value = " << lowval <<
" , with nominal integral = " << histo->Integral() <<
" , high histogram integral = " << highsyst->Integral() <<
" , low histogram integral = " << lowsyst->Integral() <<
" , and syst fraction = " << 1.-lowsyst->Integral()/histo->Integral() <<
" , " << highsyst->Integral()/histo->Integral()-1. <<
std::endl;
1649 RooStats::HistFactory::HistoSys syst;
1650 syst.SetName(systname.Data());
1651 syst.SetHistoHigh(highsyst);
1652 syst.SetHistoLow(lowsyst);
1653 sample.AddHistoSys(syst);
1654 std::cout <<
"INFO::Adding shape+norm systematic " << systname <<
" , to sample " << hname <<
" , with nominal integral = " << histo->Integral() <<
" , high histogram integral = " << highsyst->Integral() <<
" , low histogram integral = " << lowsyst->Integral() <<
", and syst fraction = " << 1.-lowsyst->Integral()/histo->Integral() <<
" , " << highsyst->Integral()/histo->Integral()-1. <<
std::endl;
1676 _DataFileNames = pset.get<std::vector<std::string>>(
"DataFileNames");
1677 _MCFileNames = pset.get<std::vector<std::string>>(
"MCFileNames");
1686 _SystFileNames = pset.get<std::vector<std::string>>(
"SystFileNames");
1687 _SystToConsider = pset.get<std::vector<std::string>>(
"SystToConsider");
1688 _SystType = pset.get<std::vector<std::string>>(
"SystType");
1692 _ChannelNames = pset.get<std::vector<std::string>>(
"ChannelNames");
1695 _NToys = pset.get<
int>(
"NToys");
1707 _RecoBinning = pset.get< std::vector<double> >(
"RecoBinning");
1708 _TruthBinning = pset.get< std::vector<double> >(
"TruthBinning");
1718 _EndZCut = pset.get<
double>(
"EndZCut");
1725 if (_DoScaleMuonContent)
1741 TAxis *
ax = eff->GetHistogram()->GetXaxis();
1742 double x1 = ax->GetBinLowEdge(1);
1748 ax->SetBinLabel(i, label.Data());
1752 eff->SetMarkerStyle(20);
1753 eff->SetMarkerColor(1);
1754 eff->SetTitle(
"Efficiency");
1755 eff->GetXaxis()->SetTitle(x_title.c_str());
1756 eff->GetYaxis()->SetTitle(
"Efficiency");
1757 eff->GetYaxis()->SetTitleOffset(1.25);
1763 RooStats::HistFactory::Sample& sample, TH1* histo,
1764 bool hasnormfactor,
bool isnorm,
1765 size_t iChan,
size_t iTopo,
size_t iTruthBin) {
1767 TH1 * low_hist = 0x0;
1768 TH1 * high_hist = 0x0;
1775 std::cout <<
"Error! Requesting truth bin " << iTruthBin <<
1776 " from binning vector of size " <<
1795 if (!(low_hist && high_hist)) {
1799 std::cout <<
"Adding systs: " << low_hist->GetName() <<
" " <<
1805 syst_type, hasnormfactor);
1812 RooStats::HistFactory::Sample& sample, TH1* histo,
1813 bool hasnormfactor,
bool isnorm,
1814 size_t iChan,
size_t iTopo) {
1816 TH1 * low_hist = 0x0;
1817 TH1 * high_hist = 0x0;
1844 if (!(low_hist && high_hist)) {
1848 std::cout <<
"Adding systs: " << low_hist->GetName() <<
" " <<
1854 syst_type, hasnormfactor);
1861 RooStats::HistFactory::Sample& sample, TH1* histo,
1862 bool hasnormfactor,
bool isnorm,
size_t iTopo) {
1864 TH1 * low_hist = 0x0;
1865 TH1 * high_hist = 0x0;
1900 if (!(low_hist && high_hist)) {
1904 std::cout <<
"Adding systs: " << low_hist->GetName() <<
" " <<
1910 syst_type, hasnormfactor);
1916 std::vector<std::vector<std::pair<TH1*, TH1*>>>
1921 std::vector<std::vector<std::pair<TH1*, TH1*>>> results;
1923 TH1 * low_hist = 0x0;
1924 TH1 * high_hist = 0x0;
1959 if (!(low_hist && high_hist)) {
1964 results.push_back(
std::vector<std::pair<TH1*, TH1*>>());
1967 for (
int j = 1; j <= low_hist->GetNbinsX(); j++) {
1968 TString low_name = Form(
"%s_IncBin%i", low_hist->GetName(),j);
1969 TString high_name = Form(
"%s_IncBin%i", high_hist->GetName(),j);
1971 TH1* temp_low_hist = (TH1*)low_hist->Clone();
1972 temp_low_hist->Reset();
1973 temp_low_hist->SetName(low_name.Data());
1975 TH1* temp_high_hist = (TH1*)high_hist->Clone();
1976 temp_high_hist->Reset();
1977 temp_high_hist->SetName(high_name.Data());
1979 for (
int k = 1;
k <= low_hist->GetNbinsX();
k++) {
1981 temp_low_hist->SetBinContent(
k, low_hist->GetBinContent(
k));
1982 temp_high_hist->SetBinContent(
k, high_hist->GetBinContent(
k));
1985 temp_low_hist->SetBinContent(
k, 0.0);
1986 temp_high_hist->SetBinContent(
k, 0.0);
1989 results.back().push_back({temp_high_hist, temp_low_hist});
1992 std::cout <<
"Adding systs: " << temp_low_hist->GetName() <<
" " <<
1994 _syst_hists.push_back((TH1*)temp_low_hist->Clone());
1995 _syst_hists.push_back((TH1*)temp_high_hist->Clone());
2003 for (
size_t j = 0; j < results[i].size(); ++j) {
2004 std::cout << results[i][j].first <<
" " << results[i][j].second <<
std::endl;
2013 RooStats::HistFactory::Sample& sample, TH1* histo,
2015 size_t iChan,
size_t iTopo,
size_t iTruthBin) {
2017 TH1 * low_hist = 0x0;
2018 TH1 * high_hist = 0x0;
2024 switch (this_histType) {
2028 std::cout <<
"Error! Requesting truth bin " << iTruthBin <<
2029 " from binning vector of size " <<
2087 if (!(low_hist && high_hist)) {
2094 double nominal_integral = histo->Integral();
2095 double high_integral = high_hist->Integral();
2096 double high_val = high_integral/nominal_integral;
2097 double low_integral = low_hist->Integral();
2098 double low_val = low_integral/nominal_integral;
2103 std::cout <<
"WARNING::Ignoring systematic uncertainty " << syst_name <<
2104 " for sample " << hname <<
" as it is below the threshold " <<
2106 fabs(1. - low_val) <<
" , " << fabs(high_val - 1.) <<
std::endl;
2110 if (nominal_integral < 1.
e-4 ||
2111 high_integral < 1.
e-4 ||
2112 low_integral < 1.
e-4 ) {
2121 if (syst_type ==
"NormOnly") {
2130 sample.AddOverallSys(syst_name.c_str(), low_val, high_val);
2132 std::cout <<
"INFO::Adding single bin and without norm parameter " <<
2133 "norm systematic " << syst_name <<
" , to sample " << hname <<
2134 " , with high value = " << high_val <<
2135 " , and low value = " << low_val <<
2136 " , with nominal integral = " << nominal_integral <<
2137 " , high histogram integral = " << high_integral <<
2138 " , low histogram integral = " << low_integral <<
2139 " , and syst fraction = " << 1. - low_val <<
2144 RooStats::HistFactory::HistoSys syst;
2145 syst.SetName(syst_name.c_str());
2146 syst.SetHistoHigh(high_hist);
2147 syst.SetHistoLow(low_hist);
2148 sample.AddHistoSys(syst);
2150 std::cout <<
"INFO::Adding multi-bin and without norm parameter " <<
2151 "shape+norm systematic " << syst_name <<
2152 " , to sample " << hname <<
2153 " , with nominal integral = " << nominal_integral <<
2154 " , high histogram integral = " << high_integral <<
2155 " , low histogram integral = " << low_integral <<
2156 ", and syst fraction = " << 1. - low_val <<
2168 TH1 * histo, TH1 * high_hist, TH1 * low_hist,
2169 RooStats::HistFactory::Sample& sample,
2171 bool hasnormfactor) {
2173 double nominal_integral = histo->Integral();
2174 double high_integral = high_hist->Integral();
2175 double high_val = high_integral/nominal_integral;
2176 double low_integral = low_hist->Integral();
2177 double low_val = low_integral/nominal_integral;
2182 std::cout <<
"WARNING::Ignoring systematic uncertainty " << syst_name <<
2183 " for sample " << hname <<
" as it is below the threshold " <<
2185 1. - low_val <<
" , " << high_val - 1. <<
std::endl;
2189 if (nominal_integral < 1.
e-4 ||
2190 high_integral < 1.
e-4 ||
2191 low_integral < 1.
e-4 ) {
2196 if (syst_type ==
"NormOnly") {
2205 sample.AddOverallSys(syst_name.c_str(), low_val, high_val);
2207 std::cout <<
"INFO::Adding single bin and without norm parameter " <<
2208 "norm systematic " << syst_name <<
" , to sample " << hname <<
2209 " , with high value = " << high_val <<
2210 " , and low value = " << low_val <<
2211 " , with nominal integral = " << nominal_integral <<
2212 " , high histogram integral = " << high_integral <<
2213 " , low histogram integral = " << low_integral <<
2214 " , and syst fraction = " << 1. - low_val <<
2219 RooStats::HistFactory::HistoSys syst;
2220 syst.SetName(syst_name.c_str());
2221 syst.SetHistoHigh(high_hist);
2222 syst.SetHistoLow(low_hist);
2223 sample.AddHistoSys(syst);
2225 std::cout <<
"INFO::Adding multi-bin and without norm parameter " <<
2226 "shape+norm systematic " << syst_name <<
2227 " , to sample " << hname <<
2228 " , with nominal integral = " << nominal_integral <<
2229 " , high histogram integral = " << high_integral <<
2230 " , low histogram integral = " << low_integral <<
2231 ", and syst fraction = " << 1. - low_val <<
2242 std::cout <<
"Drawing XSec" <<
std::endl;
2244 std::vector<TH1 *> xsecs;
2246 std::map<std::string, std::vector<double>> POI_vals;
2249 RooArgList floatParsList = fitresult->floatParsFinal();
2250 TIterator* itr = floatParsList.createIterator();
2251 RooRealVar *
var = 0x0;
2252 while ( (var = (RooRealVar*)itr->Next()) ) {
2254 if (name.find(
"POI") == std::string::npos)
continue;
2255 std::cout << var->GetName() <<
" " << var->getVal() <<
std::endl;
2266 POI_vals[
"INC"].push_back(var->getVal());
2272 std::string incident_name = (fitresult ?
"IncidentSignalPostFit" :
"IncidentSignalPreFit");
2273 TH1 * inc_signal_hist =
new TH1D(incident_name.c_str(),
"",
2280 std::cout <<
"Making bin for Truth Bin: " <<
_TruthBinning[i] <<
" " <<
2285 inc_signal_hist->SetBinContent(i+1,
2286 _incsighistos[i]->Integral()*(fitresult ? POI_vals[
"INC"][i] : 1.));
2295 inc_signal_hist->SetBinContent(i+1,
2302 xsecs.push_back(inc_signal_hist);
2304 std::map<std::string, std::vector<TH1 *>> signal_hists_by_topo;
2305 std::map<std::string, std::vector<TH1 *>> mixed_hists_by_topo;
2307 for (
size_t i = 0; i <
_sighistos.size(); ++i) {
2309 if (name.find(
"_" + topo +
"_") == std::string::npos)
continue;
2310 if (name.find(
"MC_Channel" + topo) == std::string::npos) {
2311 mixed_hists_by_topo[topo].push_back(
_sighistos[i]);
2314 signal_hists_by_topo[topo].push_back(
_sighistos[i]);
2322 (fitresult ?
"PostFit" :
"PreFit");
2323 TH1 * signal_hist =
new TH1D(signal_name.c_str(),
"",
2324 inc_signal_hist->GetNbinsX(), 0,
2325 inc_signal_hist->GetNbinsX());
2330 TGraphAsymmErrors * eff = 0x0;
2333 if (name.find(topo) != std::string::npos) {
2339 for (
size_t i = 0; i < signal_hists_by_topo[topo].size(); ++i) {
2341 double from_signal = signal_hists_by_topo[topo][i]->Integral();
2342 from_signal = from_signal / (eff->GetY()[i] > 1.e-5 ? eff->GetY()[i] : 1.);
2346 double combined = (from_signal ) ;
2348 signal_hist->SetBinContent(i+1, (fitresult ? POI_vals[topo][i] : 1.)*combined);
2352 xsecs.push_back(signal_hist);
2358 (fitresult ?
"_PostFit" :
"_PreFit");
2359 TH1 * xsec = (TH1*)signal_hist->Clone(xsec_name.c_str());
2361 inc_signal_hist->Sumw2();
2362 xsec->Divide(inc_signal_hist);
2363 xsec->Scale(1.E27/ (
_WirePitch * 1.4 * 6.022E23 / 39.948 ));
2367 xsec->GetXaxis()->SetBinLabel(i, ibinstr);
2371 xsec->SetMinimum(0.);
2372 xsec->SetMarkerColor(1);
2373 xsec->SetLineColor(1);
2374 xsec->SetMarkerStyle(20);
2375 xsec->SetMarkerSize(.75);
2376 xsec->SetLineWidth(2);
2377 xsecs.push_back(xsec);
2386 std::vector<TH2 *> smearing_hists;
2388 std::map<std::string, std::vector<double>> POI_vals;
2391 RooArgList floatParsList = fitresult->floatParsFinal();
2392 TIterator* itr = floatParsList.createIterator();
2393 RooRealVar *
var = 0x0;
2394 while ( (var = (RooRealVar*)itr->Next()) ) {
2396 if (name.find(
"POI") == std::string::npos)
continue;
2397 std::cout << var->GetName() <<
" " << var->getVal() <<
std::endl;
2408 POI_vals[
"INC"].push_back(var->getVal());
2412 std::string incident_name = (doPostFit ?
"IncidentSignalPostFit2D" :
2413 "IncidentSignalPreFit2D");
2414 TH2 * inc_signal_hist =
new TH2D(incident_name.c_str(),
"",
2423 for (
int j = 1; j <= inc_signal_hist->GetNbinsY(); ++j) {
2425 inc_signal_hist->SetBinContent(i+1, j,
2426 _incsighistos[i]->GetBinContent(j)*(doPostFit ? POI_vals[
"INC"][i] : 1.));
2430 inc_signal_hist->GetYaxis()->SetBinLabel(j,
"< 0");
2434 inc_signal_hist->GetYaxis()->SetBinLabel(j, jbinstr);
2438 inc_signal_hist->GetYaxis()->SetBinLabel(j, jbinstr);
2444 inc_signal_hist->GetXaxis()->SetBinLabel(i+1, ibinstr);
2445 inc_signal_hist->SetTitle(
";E_{True} (MeV);E_{Reco} (MeV)");
2447 smearing_hists.push_back(inc_signal_hist);
2449 std::map<std::string, std::vector<TH1 *>> signal_hists_by_topo;
2450 std::map<std::string, std::vector<TH1 *>> mixed_hists_by_topo;
2452 for (
size_t i = 0; i <
_sighistos.size(); ++i) {
2454 if (name.find(
"_" + topo +
"_") == std::string::npos)
continue;
2455 if (name.find(
"MC_Channel" + topo) == std::string::npos) {
2456 mixed_hists_by_topo[topo].push_back(
_sighistos[i]);
2459 signal_hists_by_topo[topo].push_back(
_sighistos[i]);
2467 (doPostFit ?
"PostFit2D" :
"PreFit2D");
2468 int nBinsY = inc_signal_hist->GetNbinsY();
2470 new TH2D(signal_name.c_str(),
"",
2471 inc_signal_hist->GetNbinsX(), 0,
2472 inc_signal_hist->GetNbinsX(),
2474 inc_signal_hist->GetYaxis()->GetBinLowEdge(1),
2475 (inc_signal_hist->GetYaxis()->GetBinLowEdge(nBinsY) +
2476 inc_signal_hist->GetYaxis()->GetBinWidth(nBinsY)));
2480 for (
size_t i = 0; i < signal_hists_by_topo[topo].size(); ++i) {
2481 TH1 *
hist = signal_hists_by_topo[topo][i];
2482 double scale = (doPostFit ? POI_vals[topo][i] : 1.);
2483 for (
int j = 1; j <= inc_signal_hist->GetNbinsY(); ++j) {
2484 signal_hist->SetBinContent(
2485 i+1, j, scale*hist->GetBinContent(j));
2488 signal_hist->GetYaxis()->SetBinLabel(j,
"< 0");
2492 signal_hist->GetYaxis()->SetBinLabel(j, jbinstr);
2496 signal_hist->GetYaxis()->SetBinLabel(j, jbinstr);
2502 signal_hist->GetXaxis()->SetBinLabel(i+1, ibinstr);
2503 signal_hist->SetTitle(
";E_{True} (MeV);E_{Reco} (MeV)");
2505 smearing_hists.push_back(signal_hist);
2508 return smearing_hists;
TH1 * FillMCIncidentHistogram_Pions(std::string filename, std::string treename, std::vector< double > recoBins, std::string topo, int toponum, double reco_beam_endZ_cut, double minval=0., double maxval=100000., bool doNegativeReco=false, int doSyst=0, std::string systName="", double weight=1.0, std::pair< double, double > PiMuScale={1., 1.})
void SetAlgorithm(std::string min)
std::vector< std::string > _SystFileNames
bool IsSingleBinHisto(TH1 *histo)
std::vector< TH1 * > _interactingEfficiencyNums
std::vector< std::vector< std::pair< TH1 *, TH1 * > > > BuildIncidentSignalSyst(size_t iTopo)
std::vector< std::string > _IncidentDataFileNames
std::vector< TGraphAsymmErrors * > _efficiencyGraphs
TH1 * _incidentEfficiencyNum
std::vector< std::string > _DataFileNames
std::vector< TCanvas * > PlotDatasetsAndPdfs(RooWorkspace *work, TString name, TString error, TString plottodraw, std::vector< TString > binnames, std::vector< double > recobins, std::vector< TString > incidentBinNames, std::vector< TString > sidebandBinNames, std::vector< double > sidebandBins, TString measurement="PDFit", bool doNegativeReco=false, RooAbsData *data=NULL, RooFitResult *result=NULL)
bool FillSidebandHistograms_Pions()
void SetMinimiser(std::string min)
void SetInterpolationCode(RooWorkspace *ws, int code)
RooFitResult * FitData(RooWorkspace *ws, bool isWeighted=false)
TH1 * FillMCBackgroundHistogram_Pions(std::string filename, std::string treename, std::vector< double > recoBins, std::string channel, std::string topo, int toponum, double endZ_cut, double minval=0.0, double maxval=100000.0, bool doNegativeReco=false, int doSyst=0, std::string systName="", double weight=1.0, std::pair< double, double > PiMuScale={1., 1.})
std::vector< std::string > _SignalTopologyName
void SaveWorkspace(RooWorkspace *ws, TString outFileName)
std::vector< std::string > _SidebandTopologyName
TGraphAsymmErrors * _incidentEfficiency
bool BuildSignalSystThenApplyToSample(RooStats::HistFactory::Sample &sample, TH1 *histo, bool hasnormfactor, bool isnorm, size_t iChan, size_t iTopo, size_t iTruthBin)
bool ApplySystematicToSample(RooStats::HistFactory::Sample &sample, TH1 *histo, std::vector< TH1 * > systvec, bool hasnormfactor, bool isnorm)
TH1 * FillDataHistogram_Pions(std::string filename, std::string treename, std::vector< double > recoBins, std::string channel, double reco_beam_endZ_cut, bool doNegativeReco=false, bool IsIncidentHisto=false)
TH1 * GetStatsSystHistogram(TH1 *nominal)
static ParameterSet make(intermediate_table const &tbl)
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
std::vector< int > _AddBackgroundFactors
std::vector< size_t > _sig_truth_index
bool _AddSidebandsToMeasurement
std::vector< TH1 * > _truthsighistos
std::vector< std::string > _BackgroundTopologyName
std::vector< TH1 * > _incsighistos
std::vector< TH1 * > _incdatahistos
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
std::vector< size_t > _sig_topo_index
std::vector< int > _enable_bkg_factor
std::vector< TH1 * > _bkghistos
std::vector< size_t > _sig_chan_index
void AddIncidentSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement &meas)
std::vector< TH1 * > _interactingEfficiencyDenoms
std::vector< int > _BackgroundTopology
bool BuildSystThenApplyToSample(RooStats::HistFactory::Sample &sample, TH1 *histo, bool hasnormfactor, bool isnorm, protoana::HistType this_histType, size_t iChan, size_t iTopo, size_t iTruthBin=999)
bool _EnableStatisticalError
std::vector< std::string > _SystToConsider
std::vector< TH1 * > _sideband_hists_mc
TH1 * GetSystematicHistoFromNominal(TH1 *nominal, TH1 *syst, TString name)
std::vector< TH1 * > _syst_hists
void AddSidebandSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement &meas)
void AddSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement &meas)
TH1 * _incidentEfficiencyDenom
RooFitResult * FitAsimovData(RooWorkspace *w)
std::vector< double > _SidebandBinning
TH2 * GetFitCovariance(RooFitResult *result)
std::vector< std::string > _ChannelNames
TCanvas * PlotParametersPull(TTree *tree, RooWorkspace *ws)
bool _EnableSystematicError
std::vector< double > _TruthBinning
std::vector< std::string > _MCFileNames
std::string _TruthTreeName
std::vector< TH2 * > DrawSmearingMatrix(RooFitResult *fitresult, bool doPostFit=false)
std::vector< int > _AddIncidentBackgroundFactors
std::vector< std::string > _IncidentMCFileNames
std::vector< TGraphAsymmErrors * > _interactingEfficiencies
std::pair< TH1 *, TH1 * > GetMCIncidentEfficiency(std::string fileName, std::string treeName, std::vector< double > bins, double reco_beam_endZ_cut, int doSyst=0, double weight=1.)
std::vector< int > _IncidentTopology
bool _AddIncidentToMeasurement
double _IgnoreSystematicErrorBelow
std::vector< size_t > _inc_sig_topo_index
double _IgnoreStatisticalErrorBelow
bool Configure(std::string configPath)
TCanvas * PlotNuisanceParameters(TTree *tree, RooWorkspace *ws)
std::vector< std::string > _SystType
std::vector< TH1 * > DrawXSecs(RooFitResult *fitresult=0x0)
double _IncidentScaleFactor
std::vector< std::string > _IncidentTopologyName
bool FillHistogramVectors_Pions()
std::vector< int > _SidebandTopology
std::string _RecoTreeName
TH1 * FillDataSidebandHistogram_Pions(std::string filename, std::string treename, std::string channel, double endZ_cut, std::vector< double > binning, double weight=1.)
std::vector< TCanvas * > PlotNLL(RooWorkspace *work, TString name, RooFitResult *result, bool plotPLL=false)
TH2 * GetFitCorrelationMatrix(RooFitResult *result)
bool BuildIncidentSystThenApplyToSample(RooStats::HistFactory::Sample &sample, TH1 *histo, bool hasnormfactor, bool isnorm, size_t iTopo)
std::vector< int > _enable_inc_bkg_factor
void SetFitStrategy(int fs)
void SaveSnapshot(RooWorkspace *ws, TString snapshotname)
void BuildWorkspace(TString Outputfile, int analysis=-1)
std::vector< TH1 * > _datahistos
std::vector< size_t > _bkg_chan_index
bool BuildBackgroundSystThenApplyToSample(RooStats::HistFactory::Sample &sample, TH1 *histo, bool hasnormfactor, bool isnorm, size_t iChan, size_t iTopo)
std::pair< TH1 *, TH1 * > GetMCInteractingEfficiency(std::string fileName, std::string treeName, std::vector< double > bins, std::string channel, std::string topo, int toponum, double endZ_cut, int doSyst=0, double weight=1.)
bool _NormalisedSystematic
std::vector< int > _SignalTopology
std::vector< std::string > _DataControlSampleFiles
std::vector< TH1 * > _incbkghistos
std::vector< size_t > _bkg_topo_index
TTree * GenerateAndFit(RooWorkspace *ws, int nexp)
std::vector< TH1 * > _sideband_hists_data
TCanvas * PlotAverageResultsFromToys(TTree *tree, RooWorkspace *ws, TString channelname, TString catname, RooArgList *PreFit_POI=0x0)
second_as<> second
Type of time stored in seconds, in double precision.
TH1 * FillMCSignalHistogram_Pions(std::string filename, std::string treename, std::vector< double > recoBins, std::string channel, std::string topo, int toponum, double minval, double maxval, double endZ_cut, bool doNegativeReco=false, int doSyst=0, std::string systName="", double weight=1.0, std::pair< double, double > PiMuScale={1., 1.})
TH1 * FillMCSidebandHistogram_Pions(std::string filename, std::string treename, std::string channel, std::string topo, int toponum, double endZ_cut, std::vector< double > binning, double weight=1.)
TTree * RooFitResultToTTree(RooWorkspace *ws, RooFitResult *res)
std::vector< double > _RecoBinning
void ScaleMCToData(bool data_is_mc=false)
TCanvas * PlotNuisanceParametersPull(TTree *tree, RooWorkspace *ws)
RooFitResult * GenerateAndFitOneToy(RooWorkspace *ws)
std::vector< TH1 * > _sighistos
void DecorateEfficiency(TGraphAsymmErrors *eff, std::string x_title="E_{true} at vertex [MeV]")
std::vector< size_t > _inc_bkg_topo_index
QTextStream & endl(QTextStream &s)
bool ApplyBuiltSystToSample(TH1 *histo, TH1 *high_hist, TH1 *low_hist, RooStats::HistFactory::Sample &sample, std::string syst_name, std::string syst_type, bool hasnormfactor)
std::vector< TH1 * > GetSystHistograms(std::string name)
std::vector< std::string > _MCControlSampleFiles