ProtoDUNEFit.h
Go to the documentation of this file.
1 #ifndef PROTOANA_PROTODUNEFIT_H
2 #define PROTOANA_PROTODUNEFIT_H
3 
4 // FHiCL libraries
9 
10 // ROOT includes
11 #include "TH1.h"
12 #include "TH2.h"
13 #include "TTree.h"
14 #include "TFile.h"
15 #include "TString.h"
16 #include "TGraphAsymmErrors.h"
17 #include "TCanvas.h"
18 #include "TRandom3.h"
19 
20 #include "RooStats/HistFactory/Measurement.h"
21 #include <RooFitResult.h>
22 
23 // C/C++ standard libraries
24 #include <string>
25 #include <vector>
26 #include <map>
27 
28 namespace protoana{
29 
30  enum HistType {
34  };
35 
36  class ProtoDUNEFit{
37  public:
38 
39  ProtoDUNEFit();
40  ProtoDUNEFit(std::string configPath);
41  virtual ~ProtoDUNEFit();
42 
43  // Create histograms, fit, and save
44  void BuildWorkspace(TString Outputfile, int analysis=-1);
45 
46  // Apply systematics to sample
47  bool ApplySystematicToSample(RooStats::HistFactory::Sample& sample, TH1* histo, std::vector<TH1*> systvec, bool hasnormfactor, bool isnorm);
48 
49  bool BuildSystThenApplyToSample(RooStats::HistFactory::Sample& sample,
50  TH1* histo, bool hasnormfactor,
51  bool isnorm,
52  protoana::HistType this_histType,
53  size_t iChan, size_t iTopo,
54  size_t iTruthBin=999);
56  RooStats::HistFactory::Sample& sample, TH1* histo,
57  bool hasnormfactor, bool isnorm,
58  size_t iChan, size_t iTopo, size_t iTruthBin);
59 
61  RooStats::HistFactory::Sample& sample, TH1* histo,
62  bool hasnormfactor, bool isnorm,
63  size_t iChan, size_t iTopo);
64 
66  RooStats::HistFactory::Sample& sample, TH1* histo,
67  bool hasnormfactor, bool isnorm, size_t iTopo);
68 
69  std::vector<std::vector<std::pair<TH1*, TH1*>>>
70  BuildIncidentSignalSyst(size_t iTopo);
71 
72  bool ApplyBuiltSystToSample(TH1 * histo, TH1 * high_hist, TH1 * low_hist,
73  RooStats::HistFactory::Sample& sample,
74  std::string syst_name, std::string syst_type,
75  bool hasnormfactor);
76  std::vector<TH1 *> DrawXSecs(RooFitResult *fitresult = 0x0);
77  std::vector<TH2 *> DrawSmearingMatrix(RooFitResult *fitresult, bool doPostFit = false);
78 
79 
80  private:
81  // Configure input from fcl file
82  bool Configure(std::string configPath);
83 
84  // Read the input root file and create the histograms
87 
88  // Scale MC to Data
89  void ScaleMCToData(bool data_is_mc = false);
90 
91  // Fix Muon content
92  void ScaleMuonContent();
93 
94  // Build samples and channels
95  void AddSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement& meas);
96  void AddIncidentSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement& meas);
97  void AddSidebandSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement& meas);
98 
99  void DecorateEfficiency(TGraphAsymmErrors * eff,
100  std::string x_title = "E_{true} at vertex [MeV]");
101 
103 
104  std::vector<double> _RecoBinning, _TruthBinning;
105  std::vector<double> _SidebandBinning;
106 
108 
109  std::vector<std::string> _DataFileNames, _MCFileNames,
116  std::vector<int> _SidebandTopology;
117 
123 
125  std::vector<TH1*> _syst_hists;
126  std::vector<size_t> _bkg_chan_index, _sig_chan_index;
131 
132  std::vector<TGraphAsymmErrors*> _efficiencyGraphs;
133 
134  TGraphAsymmErrors * _incidentEfficiency;
137  std::vector< TH1 * > _interactingEfficiencyDenoms;
138  std::vector< TH1 * > _interactingEfficiencyNums;
139  std::vector< TGraphAsymmErrors * > _interactingEfficiencies;
140 
144  bool _RandSigPriors; // unused -- comment out to make clang happy, _StatFluctuation;
145  TRandom3 rand;
146  //bool _AddIncidentBackgroundFactors;
150  bool _DataIsMC;
152 
153  double _ScaleFactor = 1.;
154  double _IncidentScaleFactor = 1.;
155 
157  };
158 }
159 
160 #endif
std::vector< std::string > _SystFileNames
Definition: ProtoDUNEFit.h:109
std::vector< TH1 * > _interactingEfficiencyNums
Definition: ProtoDUNEFit.h:138
std::vector< std::vector< std::pair< TH1 *, TH1 * > > > BuildIncidentSignalSyst(size_t iTopo)
std::vector< std::string > _IncidentDataFileNames
Definition: ProtoDUNEFit.h:109
std::vector< TGraphAsymmErrors * > _efficiencyGraphs
Definition: ProtoDUNEFit.h:132
std::vector< std::string > _DataFileNames
Definition: ProtoDUNEFit.h:109
std::vector< std::string > _SignalTopologyName
Definition: ProtoDUNEFit.h:109
std::vector< std::string > _SidebandTopologyName
Definition: ProtoDUNEFit.h:109
TGraphAsymmErrors * _incidentEfficiency
Definition: ProtoDUNEFit.h:134
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)
std::string string
Definition: nybbler.cc:12
std::vector< int > _AddBackgroundFactors
Definition: ProtoDUNEFit.h:147
std::vector< size_t > _sig_truth_index
Definition: ProtoDUNEFit.h:127
std::vector< TH1 * > _truthsighistos
Definition: ProtoDUNEFit.h:124
std::vector< std::string > _BackgroundTopologyName
Definition: ProtoDUNEFit.h:109
std::vector< TH1 * > _incsighistos
Definition: ProtoDUNEFit.h:129
std::vector< TH1 * > _incdatahistos
Definition: ProtoDUNEFit.h:129
std::vector< size_t > _sig_topo_index
Definition: ProtoDUNEFit.h:127
std::vector< int > _enable_bkg_factor
Definition: ProtoDUNEFit.h:147
std::vector< TH1 * > _bkghistos
Definition: ProtoDUNEFit.h:124
std::vector< size_t > _sig_chan_index
Definition: ProtoDUNEFit.h:126
void AddIncidentSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement &meas)
std::vector< TH1 * > _interactingEfficiencyDenoms
Definition: ProtoDUNEFit.h:137
std::vector< int > _BackgroundTopology
Definition: ProtoDUNEFit.h:107
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)
std::vector< std::string > _SystToConsider
Definition: ProtoDUNEFit.h:109
std::vector< TH1 * > _sideband_hists_mc
Definition: ProtoDUNEFit.h:130
std::vector< TH1 * > _syst_hists
Definition: ProtoDUNEFit.h:125
void AddSidebandSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement &meas)
void AddSamplesAndChannelsToMeasurement(RooStats::HistFactory::Measurement &meas)
std::vector< double > _SidebandBinning
Definition: ProtoDUNEFit.h:105
std::vector< std::string > _ChannelNames
Definition: ProtoDUNEFit.h:109
std::vector< double > _TruthBinning
Definition: ProtoDUNEFit.h:104
std::vector< std::string > _MCFileNames
Definition: ProtoDUNEFit.h:109
std::string _TruthTreeName
Definition: ProtoDUNEFit.h:102
std::vector< TH2 * > DrawSmearingMatrix(RooFitResult *fitresult, bool doPostFit=false)
std::vector< int > _AddIncidentBackgroundFactors
Definition: ProtoDUNEFit.h:147
std::vector< std::string > _IncidentMCFileNames
Definition: ProtoDUNEFit.h:109
std::vector< TGraphAsymmErrors * > _interactingEfficiencies
Definition: ProtoDUNEFit.h:139
std::vector< int > _IncidentTopology
Definition: ProtoDUNEFit.h:107
double _IgnoreSystematicErrorBelow
Definition: ProtoDUNEFit.h:119
std::vector< size_t > _inc_sig_topo_index
Definition: ProtoDUNEFit.h:127
double _IgnoreStatisticalErrorBelow
Definition: ProtoDUNEFit.h:119
bool Configure(std::string configPath)
std::vector< std::string > _SystType
Definition: ProtoDUNEFit.h:109
std::vector< TH1 * > DrawXSecs(RooFitResult *fitresult=0x0)
std::vector< std::string > _IncidentTopologyName
Definition: ProtoDUNEFit.h:109
std::vector< int > _SidebandTopology
Definition: ProtoDUNEFit.h:116
std::string _RecoTreeName
Definition: ProtoDUNEFit.h:102
bool BuildIncidentSystThenApplyToSample(RooStats::HistFactory::Sample &sample, TH1 *histo, bool hasnormfactor, bool isnorm, size_t iTopo)
std::vector< int > _enable_inc_bkg_factor
Definition: ProtoDUNEFit.h:147
void BuildWorkspace(TString Outputfile, int analysis=-1)
std::vector< TH1 * > _datahistos
Definition: ProtoDUNEFit.h:124
std::vector< size_t > _bkg_chan_index
Definition: ProtoDUNEFit.h:126
bool BuildBackgroundSystThenApplyToSample(RooStats::HistFactory::Sample &sample, TH1 *histo, bool hasnormfactor, bool isnorm, size_t iChan, size_t iTopo)
std::vector< int > _SignalTopology
Definition: ProtoDUNEFit.h:107
std::vector< std::string > _DataControlSampleFiles
Definition: ProtoDUNEFit.h:109
std::vector< TH1 * > _incbkghistos
Definition: ProtoDUNEFit.h:129
std::vector< size_t > _bkg_topo_index
Definition: ProtoDUNEFit.h:127
std::vector< TH1 * > _sideband_hists_data
Definition: ProtoDUNEFit.h:130
std::vector< double > _RecoBinning
Definition: ProtoDUNEFit.h:104
void ScaleMCToData(bool data_is_mc=false)
std::vector< TH1 * > _sighistos
Definition: ProtoDUNEFit.h:124
void DecorateEfficiency(TGraphAsymmErrors *eff, std::string x_title="E_{true} at vertex [MeV]")
std::vector< size_t > _inc_bkg_topo_index
Definition: ProtoDUNEFit.h:127
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< std::string > _MCControlSampleFiles
Definition: ProtoDUNEFit.h:109