Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ana::NumuCCIncAnalysis Class Reference

Generic organizational class for a cross section analysis. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-03/NDAna/numucc_inc/NumuCCIncAnalysis.h"

Inheritance diagram for ana::NumuCCIncAnalysis:
ana::CrossSectionAnalysis

Public Types

enum  XSecType_t { kVsE, kVsTCos }
 Enumeration of the type of cross-section we are measuring. More...
 

Public Member Functions

 NumuCCIncAnalysis (SpectrumLoader &lMC, SpectrumLoader &lDA, TrivialBkgdEstimator *bkgdest, TrivialBkgdEstimator *bkgdest3D, XSecType_t xsectype=kVsE, double unfoldReg=1, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar wei=kXSecCVWgt2017ST *kPPFXFluxCVWgtST, const Var weiDA=kXSecCVWgt2017 *kPPFXFluxCVWgt, const bool efficiencyIn3D=false)
 Constructor to create a NumuCCIncAnalysis object. lMC is the MC loader lDA is the data loader bkgdest is the background estimator in 1/2D. One has to make sure that the bkgdest is setup in a way that's consistent with the way the NumuCCIncAnalysis object is setup, ie it has the same weights and the same axes (1D or 2D) as the xsec object bkgdest3D Background estimator in 3D. Use 3D axes to construct this unfoldReg Regularization parameter for unfolding. This parameter does not have any consequence if you are going to save the xsec object to file You can set it to a different value when loading from file too. unfoldmethod Which unfolding method to use, choose from the enumerated options in UnfoldMethod_t. This too can be over-ridden when loading xsec object from file shiftMC systematic shift applied to MC shiftMC systematic shift applied to data wei Weight to be applied to the MC weiDA Weight to be applied to the data efficiencyIn3D boolean to specify if the measurement is being done in 3D or not. More...
 
 NumuCCIncAnalysis (SpectrumLoader &lMC, TrivialBkgdEstimator *bkgdest, TrivialBkgdEstimator *bkgdest3D, XSecType_t xsectype=kVsE, double unfoldReg=1, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar wei=kXSecCVWgt2017ST *kPPFXFluxCVWgtST, const Var weiDA=kXSecCVWgt2017 *kPPFXFluxCVWgt)
 Constructor to create a NumuCCIncAnalysis object to plot the true cross-section. The setup is similar to the other constructor. More...
 
 ~NumuCCIncAnalysis ()
 
void SaveTo (TDirectory *dir) const
 Save the NumuCCAnalysis cross-section object to file so it can be used later. More...
 
std::vector< TH1 * > PlotEfficiency ()
 
std::vector< TH1 * > PlotSignalEstimate ()
 Returns a vector of histograms containing signal estimate that is, (data - background) in reco space. More...
 
std::vector< TH1 * > PlotMCSignalEstimate ()
 Returns a vector of histograms of MC in reco space, with true reco signal selection cuts applied, ie does not contain background For comparison with the output of ana::NumuCCIncAnalysis::PlotSignalEstimate. More...
 
std::vector< TH1 * > PlotUnfoldedSignal ()
 Returns a vector of histograms containing unfolded signal. More...
 
std::vector< TH1 * > PlotTrueSelectedSignal ()
 Returns a vector of histograms of MC in true space, with true and reco signal selection cuts applied. For comparison with the output of ana::NumuCCIncAnalysis::PlotUnfoldedSignal. More...
 
std::vector< TH1 * > PlotBackgroundEstimate ()
 Returns a vector of histograms with background estimate. More...
 
std::vector< TH1 * > PlotEfficiencyCorrectedSignal ()
 Returns a vector of histograms with the best estimate of signal, after background subtraction, unfolding and efficiency correction. More...
 
std::vector< TH1 * > PlotTrueSignal ()
 Returns a vector of histograms with MC signal in true space drawn from nuTree. For comparison with the output of ana::NumuCCIncAnalysis::PlotEfficiencyCorrectedSignal. More...
 
std::vector< TH1 * > PlotData ()
 Returns a vector of histograms of data in reco space. More...
 
std::vector< TH1 * > PlotMCReco ()
 Returns a vector of histograms of MC in the reco space For comparison with the output of ana::NumuCCIncAnalysis::PlotData. More...
 
std::vector< TH1 * > Result ()
 Returns a vector of histograms of the cross-section results. More...
 
Ratio Efficiency ()
 Return the efficiency Ratio. More...
 
Spectrum SignalEst ()
 Return estimated signal, ie data-bg. More...
 
Spectrum UnfoldedSignal (Spectrum sig)
 Function to return the unfolded spectrum. It checks if the cross-section is being computed in 3D or 1/2D and passes the reco-to-true matrix accordingly. More...
 
TH2 * Result2D ()
 Represent the double-differential result in 2D, rather than in 1D slices. More...
 
std::vector< TH1 * > PlotHelper (const TH2 *spec)
 Helper function to convert a 2D plot of the muon cos theta vs muon kinetic energy into a vector of 1D histograms of muon kinetic energy for each cos theta bin. Used by all the plotting functions in this class. More...
 
TH1 * PlotFluxEstimate ()
 
TH2D * PlotRecoToTrueMatrix ()
 
virtual double NTargets ()
 Default implementation returns number of nucleons. Override if needed. More...
 
void SaveTo (TDirectory *dir, const std::string &name) const
 

Static Public Member Functions

static std::unique_ptr< NumuCCIncAnalysisLoadFrom (TDirectory *dir, UnfoldMethod_t unfoldmethod, bool eff3D=false, bool muonkine=false, double regStrength=-5)
 Load the spectra etc from the file and create a NumuCCAnalysis object. More...
 
static std::unique_ptr< CrossSectionAnalysisLoadFrom (TDirectory *dir, const std::string &name, UnfoldMethod_t unfoldmethod=kIterative)
 
static std::unique_ptr< CrossSectionAnalysisLoadFrom (TDirectory *dir, const std::string &name, UnfoldMethod_t unfoldmethod, double nTargets)
 

Protected Member Functions

Spectrum SignalEst (Spectrum bkgd)
 
Spectrum UnfoldedSignal (Spectrum signal, ReweightableSpectrum *rt=NULL)
 
double NucleonCount ()
 
double NucleusCount (int Z=-1, int A=-1)
 

Protected Attributes

Spectrum fData
 
Spectrum fMC
 
SpectrumfMCSig
 
SpectrumfMCSigNuTree
 
ReweightableSpectrum fRecoTrue
 
IBkgdEstimatorfBkgdEst
 
double fNTargets
 
double fUnfoldReg
 
UnfoldMethod_t fUnfoldMethod
 
TVector3 fFidMin
 
TVector3 fFidMax
 
TargetCount fTarget
 
SpectrumfFlux
 

Private Member Functions

 NumuCCIncAnalysis (Spectrum data, Spectrum data3D, Spectrum mc, Spectrum mc3D, Spectrum *mcsig, Spectrum *mcsig3D, Spectrum *mcsignutree, Spectrum *mcsignutree3D, ReweightableSpectrum rt, ReweightableSpectrum rt3D, IBkgdEstimator *bkgdest, IBkgdEstimator *bkgdest3D, double unfoldreg, UnfoldMethod_t unfoldmethod, XSecType_t xsectype, Spectrum *flux, bool eff3D)
 Constructor used by the LoadFrom function to load pre-made data and MC spectra and create a NumuCCAnalysis cross-section object Allows one to chose which unfolding method and what regularization parameter to use. Also allows the user to select between 3D or 2/1D cross- section methods. More...
 
TH1 * Project (const Spectrum spec, const double pot)
 
TH1 * Project (const Ratio rat)
 
TH1 * ProjectHist (const TH3 *temp)
 Helper function to project from 3D to 2D or 1D More...
 
TH2 * ProjectMuTCos (const TH3 *h3)
 
TH1 * ProjectE (const TH3 *h3)
 
std::vector< TH1 * > ReturnHists (Spectrum spec)
 Makes the vector of 1D hists by calling Project and PlotHelper. More...
 

Private Attributes

const double fNNucleons = 5.68917e+31
 Pre-computed number of nucleon targets in our fiducial volume. More...
 
XSecType_t fXSecType
 Which xsec are we measureing? vs Energy or vs Muon Kinematics? More...
 
Spectrum fData3D
 
Spectrum fMC3D
 
SpectrumfMCSigNuTree3D
 
SpectrumfMCSig3D
 
ReweightableSpectrum fRecoTrue3D
 
IBkgdEstimatorfBkgdEst3D
 
bool fEfficiencyIn3D
 Are we measuring the cross-section in 3D? More...
 

Detailed Description

Generic organizational class for a cross section analysis.

Definition at line 28 of file NumuCCIncAnalysis.h.

Member Enumeration Documentation

Enumeration of the type of cross-section we are measuring.

Enumerator
kVsE 
kVsTCos 

Definition at line 34 of file NumuCCIncAnalysis.h.

Constructor & Destructor Documentation

ana::NumuCCIncAnalysis::NumuCCIncAnalysis ( SpectrumLoader lMC,
SpectrumLoader lDA,
TrivialBkgdEstimator bkgdest,
TrivialBkgdEstimator bkgdest3D,
XSecType_t  xsectype = kVsE,
double  unfoldReg = 1,
UnfoldMethod_t  unfoldmethod = kIterative,
const SystShifts shiftMC = kNoShift,
const SystShifts shiftDA = kNoShift,
const NuTruthVar  wei = kXSecCVWgt2017ST*kPPFXFluxCVWgtST,
const Var  weiDA = kXSecCVWgt2017*kPPFXFluxCVWgt,
const bool  efficiencyIn3D = false 
)

Constructor to create a NumuCCIncAnalysis object. lMC is the MC loader lDA is the data loader bkgdest is the background estimator in 1/2D. One has to make sure that the bkgdest is setup in a way that's consistent with the way the NumuCCIncAnalysis object is setup, ie it has the same weights and the same axes (1D or 2D) as the xsec object bkgdest3D Background estimator in 3D. Use 3D axes to construct this unfoldReg Regularization parameter for unfolding. This parameter does not have any consequence if you are going to save the xsec object to file You can set it to a different value when loading from file too. unfoldmethod Which unfolding method to use, choose from the enumerated options in UnfoldMethod_t. This too can be over-ridden when loading xsec object from file shiftMC systematic shift applied to MC shiftMC systematic shift applied to data wei Weight to be applied to the MC weiDA Weight to be applied to the data efficiencyIn3D boolean to specify if the measurement is being done in 3D or not.

Definition at line 27 of file NumuCCIncAnalysis.cxx.

References nd_projection_maker::eff, ana::Efficiency(), fBkgdEst3D, fEfficiencyIn3D, fMCSig3D, fMCSigNuTree3D, ana::CrossSectionAnalysis::fUnfoldMethod, fXSecType, ana::kAllNumuCCCuts, ana::kIsTrueSigST, and ana::kTrueMuKEVsCosVsEnuStandardAxisST().

Referenced by LoadFrom().

40  : CrossSectionAnalysis(lMC, lDA,
41  xsectype == kVsTCos?
44  xsectype == kVsTCos?
47  enubins,
50  bkgdest,
51  vtxmin, vtxmax,
52  unfoldReg,
53  unfoldmethod,
54  shiftMC, shiftDA, wei, weiDA),
59  shiftMC, VarFromNuTruthVar(wei))
60  {
61 
62  fUnfoldMethod = unfoldmethod;
63  fXSecType = xsectype;
64 
65  // for the 3D efficiency, use the 3D axis and extract the true and true-selected signal
66  // from it
67  std::pair<Spectrum*,Spectrum*> eff = ana::Efficiency(lMC,
70  kIsTrueSigST, shiftMC, wei);
71  fMCSig3D = eff.first;
72  fMCSigNuTree3D = eff.second;
73  fEfficiencyIn3D = efficiencyIn3D;
74  fBkgdEst3D = bkgdest3D;
75 
76  }// End of constructor
const NuTruthHistAxis kTrueMuKEVsCosVsEnuStandardAxisST("True T_{#mu} vs cos #{theta} vs Neutrino Energy (GeV)", angvsmukevsebins, kTrueMuKEVsCosVsEnuST)
const NuTruthCut kIsTrueSigST
const NuTruthHistAxis kTrueMuKEVsCosStandardAxisST("True T_{#mu} vs cos #{theta};T_{#mu} [GeV];cos #{theta}", angvsmukebins, kTrueMuKEVsCosST)
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
const TVector3 vtxmin(-130,-176, 225)
IBkgdEstimator * fBkgdEst3D
ReweightableSpectrum fRecoTrue3D
const HistAxis kTrueMuKEVsCosVsEnuStandardAxis
const HistAxis kRecoMuKEVsCosStandardAxis("Reconstructed T_{#mu} vs cos #{theta};T_{#mu} [GeV];cos #{theta}", angvsmukebins, kRecoMuKEVsCos)
const Binning enubins
std::pair< Spectrum *, Spectrum * > Efficiency(SpectrumLoaderBase &loader, const NuTruthHistAxis &axis, const Cut &seln, const NuTruthCut &truthSeln, const SystShifts &shift, const NuTruthVar &weight)
Definition: Efficiency.cxx:10
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
Var VarFromNuTruthVar(const NuTruthVar &stv, double _default)
Definition: Var.cxx:7
const HistAxis kRecoMuKEVsCosVsEnuStandardAxis("Reco. T_{#mu} vs cos #{theta} vs Available Energy (GeV)", angvsmukevsebins, kRecoMuKEVsCosVsEnu)
const TVector3 vtxmax(160, 160, 1000)
CrossSectionAnalysis(SpectrumLoaderBase &lMC, SpectrumLoaderBase &lDA, HistAxis axisreco, NuTruthHistAxis axistrue, Binning EBins, Cut sel, NuTruthCut isSig, IBkgdEstimator *bkgdest, TVector3 min, TVector3 max, double unfoldReg, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar &wei=kNuTruthUnweighted, const Var &weiDA=kUnweighted)
const HistAxis kRecoEStandardAxis("Reconstructed Neutrino Energy (GeV)", enubins, kRecoE)
const NuTruthHistAxis kTrueEStandardAxisST("True Neutrino Energy (GeV)", enubins, kTrueEST)
const Cut kAllNumuCCCuts
Cut CutFromNuTruthCut(const NuTruthCut &stc)
Definition: Cut.cxx:7
ana::NumuCCIncAnalysis::NumuCCIncAnalysis ( SpectrumLoader lMC,
TrivialBkgdEstimator bkgdest,
TrivialBkgdEstimator bkgdest3D,
XSecType_t  xsectype = kVsE,
double  unfoldReg = 1,
UnfoldMethod_t  unfoldmethod = kIterative,
const SystShifts shiftMC = kNoShift,
const SystShifts shiftDA = kNoShift,
const NuTruthVar  wei = kXSecCVWgt2017ST*kPPFXFluxCVWgtST,
const Var  weiDA = kXSecCVWgt2017*kPPFXFluxCVWgt 
)

Constructor to create a NumuCCIncAnalysis object to plot the true cross-section. The setup is similar to the other constructor.

Definition at line 80 of file NumuCCIncAnalysis.cxx.

References nd_projection_maker::eff, ana::Efficiency(), fBkgdEst3D, fEfficiencyIn3D, fMCSig3D, fMCSigNuTree3D, ana::CrossSectionAnalysis::fUnfoldMethod, fXSecType, ana::kAllNumuCCCuts, ana::kIsTrueSigST, and ana::kTrueMuKEVsCosVsEnuStandardAxisST().

91  : CrossSectionAnalysis(lMC, lMC,
92  xsectype == kVsTCos?
95  xsectype == kVsTCos?
98  enubins,
99  kIsTrueSig,
100  kIsTrueSigST,
101  bkgdest,
102  vtxmin, vtxmax,
103  unfoldReg,
104  unfoldmethod,
105  shiftMC, shiftDA, wei, weiDA),
108  fRecoTrue3D(lMC,
111  shiftMC, VarFromNuTruthVar(wei))
112  {
113 
114  fUnfoldMethod = unfoldmethod;
115  fXSecType = xsectype;
116 
117  std::pair<Spectrum*,Spectrum*> eff = ana::Efficiency(lMC, kTrueMuKEVsCosVsEnuStandardAxisST,
118  kAllNumuCCCuts, kIsTrueSigST, shiftMC, wei);
119 
120  fMCSig3D = eff.first;
121  fMCSigNuTree3D = eff.second;
122  fBkgdEst3D = bkgdest3D;
123 
124  fEfficiencyIn3D = false;
125  }// End of constructor
const NuTruthHistAxis kTrueMuKEVsCosVsEnuStandardAxisST("True T_{#mu} vs cos #{theta} vs Neutrino Energy (GeV)", angvsmukevsebins, kTrueMuKEVsCosVsEnuST)
const HistAxis kTrueEStandardAxis
const NuTruthCut kIsTrueSigST
const NuTruthHistAxis kTrueMuKEVsCosStandardAxisST("True T_{#mu} vs cos #{theta};T_{#mu} [GeV];cos #{theta}", angvsmukebins, kTrueMuKEVsCosST)
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
const TVector3 vtxmin(-130,-176, 225)
IBkgdEstimator * fBkgdEst3D
ReweightableSpectrum fRecoTrue3D
const HistAxis kTrueMuKEVsCosVsEnuStandardAxis
const Binning enubins
std::pair< Spectrum *, Spectrum * > Efficiency(SpectrumLoaderBase &loader, const NuTruthHistAxis &axis, const Cut &seln, const NuTruthCut &truthSeln, const SystShifts &shift, const NuTruthVar &weight)
Definition: Efficiency.cxx:10
const Cut kIsTrueSig
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
Var VarFromNuTruthVar(const NuTruthVar &stv, double _default)
Definition: Var.cxx:7
const HistAxis kRecoMuKEVsCosVsEnuStandardAxis("Reco. T_{#mu} vs cos #{theta} vs Available Energy (GeV)", angvsmukevsebins, kRecoMuKEVsCosVsEnu)
const HistAxis kTrueMuKEVsCosStandardAxis
const TVector3 vtxmax(160, 160, 1000)
CrossSectionAnalysis(SpectrumLoaderBase &lMC, SpectrumLoaderBase &lDA, HistAxis axisreco, NuTruthHistAxis axistrue, Binning EBins, Cut sel, NuTruthCut isSig, IBkgdEstimator *bkgdest, TVector3 min, TVector3 max, double unfoldReg, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar &wei=kNuTruthUnweighted, const Var &weiDA=kUnweighted)
const NuTruthHistAxis kTrueEStandardAxisST("True Neutrino Energy (GeV)", enubins, kTrueEST)
const Cut kAllNumuCCCuts
Cut CutFromNuTruthCut(const NuTruthCut &stc)
Definition: Cut.cxx:7
ana::NumuCCIncAnalysis::~NumuCCIncAnalysis ( )
inline
ana::NumuCCIncAnalysis::NumuCCIncAnalysis ( Spectrum  data,
Spectrum  data3D,
Spectrum  mc,
Spectrum  mc3D,
Spectrum mcsig,
Spectrum mcsig3D,
Spectrum mcsignutree,
Spectrum mcsignutree3D,
ReweightableSpectrum  rt,
ReweightableSpectrum  rt3D,
IBkgdEstimator bkgdest,
IBkgdEstimator bkgdest3D,
double  unfoldreg,
UnfoldMethod_t  unfoldmethod,
XSecType_t  xsectype,
Spectrum flux,
bool  eff3D 
)
inlineprivate

Constructor used by the LoadFrom function to load pre-made data and MC spectra and create a NumuCCAnalysis cross-section object Allows one to chose which unfolding method and what regularization parameter to use. Also allows the user to select between 3D or 2/1D cross- section methods.

Definition at line 169 of file NumuCCIncAnalysis.h.

References fBkgdEst3D, fEfficiencyIn3D, fMCSig3D, fMCSigNuTree3D, and fXSecType.

181  mcsig, mcsignutree,
182  rt, bkgdest,
183  unfoldreg, unfoldmethod,
184  TVector3(-5,-5,-5), TVector3(-5,-5,-5),
185  flux),
186  fData3D(data3D),
187  fMC3D(mc3D),
188  fRecoTrue3D(rt3D)
189  {
190  fXSecType = xsectype;
191  fMCSig3D = mcsig3D;
192  fMCSigNuTree3D = mcsignutree3D;
193  fEfficiencyIn3D = eff3D;
194  fBkgdEst3D = bkgdest3D;
195  }
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
IBkgdEstimator * fBkgdEst3D
ReweightableSpectrum fRecoTrue3D
Loaders::FluxType flux
const XML_Char const XML_Char * data
Definition: expat.h:268
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
CrossSectionAnalysis(SpectrumLoaderBase &lMC, SpectrumLoaderBase &lDA, HistAxis axisreco, NuTruthHistAxis axistrue, Binning EBins, Cut sel, NuTruthCut isSig, IBkgdEstimator *bkgdest, TVector3 min, TVector3 max, double unfoldReg, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar &wei=kNuTruthUnweighted, const Var &weiDA=kUnweighted)

Member Function Documentation

Ratio ana::NumuCCIncAnalysis::Efficiency ( )

Return the efficiency Ratio.

Definition at line 129 of file NumuCCIncAnalysis.cxx.

References fEfficiencyIn3D, ana::CrossSectionAnalysis::fMCSig, and fMCSig3D.

Referenced by PlotEfficiency(), PlotEfficiencyCorrectedSignal(), Result(), Result2D(), and ~NumuCCIncAnalysis().

130  {
131  if(!fEfficiencyIn3D)
132  return (*fMCSig) / (*fMCSigNuTree);
133  else
134  return (*fMCSig3D) / (*fMCSigNuTree3D);
135  }// end of Efficiency
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
std::unique_ptr< CrossSectionAnalysis > ana::CrossSectionAnalysis::LoadFrom ( TDirectory *  dir,
const std::string name,
UnfoldMethod_t  unfoldmethod = kIterative 
)
staticinherited

Definition at line 263 of file CrossSectionAnalysis.cxx.

References ana::assert(), ana::CrossSectionAnalysis::CrossSectionAnalysis(), dir, flux, ana::LoadFrom< IBkgdEstimator >(), cet::sqlite::max(), mc, min(), and runNovaSAM::release.

Referenced by test_xsecanalysis(), and ana::CrossSectionAnalysis::~CrossSectionAnalysis().

264  {
265  dir = dir->GetDirectory(name.c_str()); // switch to subdir
266  assert(dir);
267 
268  Spectrum* data = ana::LoadFrom<Spectrum>(dir, "fData").release();
269  Spectrum* mc = ana::LoadFrom<Spectrum>(dir, "fMC").release();
270  Spectrum* mcsig= ana::LoadFrom<Spectrum>(dir, "fMCSig").release();
271  Spectrum* mcsignutree = ana::LoadFrom<Spectrum>(dir, "fMCSigNuTree").release();
272  ReweightableSpectrum* rt = ana::LoadFrom<ReweightableSpectrum>(dir, "fRecoTrue").release();
273 
274  IBkgdEstimator* bkgdest = ana::LoadFrom<IBkgdEstimator>(dir, "fBkgdEst").release();
275 
276  TVectorD* unfoldreg = (TVectorD*)dir->Get("fUnfoldReg");
277  TVector3* min = (TVector3*)dir->Get("fFidMin");
278  TVector3* max = (TVector3*)dir->Get("fFidMax");
279 
280  Spectrum* flux = ana::LoadFrom<Spectrum>(dir, "fFlux").release();
281 
282  delete dir;
283 
284  return std::unique_ptr<CrossSectionAnalysis>(
285  new CrossSectionAnalysis(*data, *mc, mcsig, mcsignutree, *rt, bkgdest,
286  (*unfoldreg)[0], unfoldmethod, *min, *max, flux));
287  }
const XML_Char * name
Definition: expat.h:151
Loaders::FluxType flux
const XML_Char const XML_Char * data
Definition: expat.h:268
std::vector< float > Spectrum
Definition: Constants.h:610
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
std::unique_ptr< IBkgdEstimator > LoadFrom< IBkgdEstimator >(TDirectory *dir, const std::string &label)
CrossSectionAnalysis(SpectrumLoaderBase &lMC, SpectrumLoaderBase &lDA, HistAxis axisreco, NuTruthHistAxis axistrue, Binning EBins, Cut sel, NuTruthCut isSig, IBkgdEstimator *bkgdest, TVector3 min, TVector3 max, double unfoldReg, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar &wei=kNuTruthUnweighted, const Var &weiDA=kUnweighted)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
std::unique_ptr< CrossSectionAnalysis > ana::CrossSectionAnalysis::LoadFrom ( TDirectory *  dir,
const std::string name,
UnfoldMethod_t  unfoldmethod,
double  nTargets 
)
staticinherited

Definition at line 290 of file CrossSectionAnalysis.cxx.

References ana::assert(), ana::CrossSectionAnalysis::CrossSectionAnalysis(), dir, flux, ana::LoadFrom< IBkgdEstimator >(), cet::sqlite::max(), mc, min(), and runNovaSAM::release.

294  {
295  dir = dir->GetDirectory(name.c_str()); // switch to subdir
296  assert(dir);
297 
298  Spectrum* data = ana::LoadFrom<Spectrum>(dir, "fData").release();
299  Spectrum* mc = ana::LoadFrom<Spectrum>(dir, "fMC").release();
300  Spectrum* mcsig= ana::LoadFrom<Spectrum>(dir, "fMCSig").release();
301  Spectrum* mcsignutree = ana::LoadFrom<Spectrum>(dir, "fMCSigNuTree").release();
302  ReweightableSpectrum* rt = ana::LoadFrom<ReweightableSpectrum>(dir, "fRecoTrue").release();
303 
304  IBkgdEstimator* bkgdest = ana::LoadFrom<IBkgdEstimator>(dir, "fBkgdEst").release();
305 
306  TVectorD* unfoldreg = (TVectorD*)dir->Get("fUnfoldReg");
307  TVector3* min = (TVector3*)dir->Get("fFidMin");
308  TVector3* max = (TVector3*)dir->Get("fFidMax");
309 
310  Spectrum* flux = ana::LoadFrom<Spectrum>(dir, "fFlux").release();
311 
312  delete dir;
313 
314  return std::unique_ptr<CrossSectionAnalysis>(
315  new CrossSectionAnalysis(*data, *mc, mcsig, mcsignutree, *rt, bkgdest, nTargets,
316  (*unfoldreg)[0], unfoldmethod, *min, *max, flux));
317  }
const XML_Char * name
Definition: expat.h:151
Loaders::FluxType flux
const XML_Char const XML_Char * data
Definition: expat.h:268
std::vector< float > Spectrum
Definition: Constants.h:610
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
std::unique_ptr< IBkgdEstimator > LoadFrom< IBkgdEstimator >(TDirectory *dir, const std::string &label)
CrossSectionAnalysis(SpectrumLoaderBase &lMC, SpectrumLoaderBase &lDA, HistAxis axisreco, NuTruthHistAxis axistrue, Binning EBins, Cut sel, NuTruthCut isSig, IBkgdEstimator *bkgdest, TVector3 min, TVector3 max, double unfoldReg, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar &wei=kNuTruthUnweighted, const Var &weiDA=kUnweighted)
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
std::unique_ptr< NumuCCIncAnalysis > ana::NumuCCIncAnalysis::LoadFrom ( TDirectory *  dir,
UnfoldMethod_t  unfoldmethod,
bool  eff3D = false,
bool  muonkine = false,
double  regStrength = -5 
)
static

Load the spectra etc from the file and create a NumuCCAnalysis object.

Definition at line 413 of file NumuCCIncAnalysis.cxx.

References ana::enubins, flux, ana::Spectrum::GetBinnings(), kVsE, kVsTCos, ana::LoadFrom< IBkgdEstimator >(), mc, ana::Binning::NBins(), NumuCCIncAnalysis(), runNovaSAM::release, and APDHVSetting::temp.

Referenced by ~NumuCCIncAnalysis().

417  {
418  Spectrum* data = ana::LoadFrom<Spectrum>
419  (dir->GetDirectory("fData")).release();
420  Spectrum* mc = ana::LoadFrom<Spectrum>
421  (dir->GetDirectory("fMC")).release();
422  Spectrum* mcsig= ana::LoadFrom<Spectrum>
423  (dir->GetDirectory("fMCSig")).release();
424  Spectrum* mcsignutree = ana::LoadFrom<Spectrum>
425  (dir->GetDirectory("fMCSigNuTree")).release();
426 
427  Spectrum* data3D = ana::LoadFrom<Spectrum>
428  (dir->GetDirectory("fData3D")).release();
429  Spectrum* mc3D = ana::LoadFrom<Spectrum>
430  (dir->GetDirectory("fMC3D")).release();
431  Spectrum* mcsig3D= ana::LoadFrom<Spectrum>
432  (dir->GetDirectory("fMCSig3D")).release();
433  Spectrum* mcsignutree3D = ana::LoadFrom<Spectrum>
434  (dir->GetDirectory("fMCSigNuTree3D")).release();
435 
436 
437  ReweightableSpectrum* rt = ana::LoadFrom<ReweightableSpectrum>
438  (dir->GetDirectory("fRecoTrue")).release();
439  ReweightableSpectrum* rt3D = ana::LoadFrom<ReweightableSpectrum>
440  (dir->GetDirectory("fRecoTrue3D")).release();
441 
442 
443  IBkgdEstimator* bkgdest = ana::LoadFrom<IBkgdEstimator>
444  (dir->GetDirectory("fBkgdEst")).release();
445  IBkgdEstimator* bkgdest3D = ana::LoadFrom<IBkgdEstimator>
446  (dir->GetDirectory("fBkgdEst3D")).release();
447 
448 
449  double unfoldreg = regStrength;
450  if(regStrength == -5 ){
451  TVectorD* temp = (TVectorD*)dir->Get("fUnfoldReg");
452  unfoldreg = (*temp)[0];
453  }
454 
455  Spectrum* flux = ana::LoadFrom<Spectrum>
456  (dir->GetDirectory("fFlux")).release();
457 
458 
460  if(data->GetBinnings()[0].NBins() == enubins.NBins() && !(eff3D && muonkine))
461  xsectype = ana::NumuCCIncAnalysis::kVsE;
462 
463  return std::unique_ptr<NumuCCIncAnalysis>(new NumuCCIncAnalysis(*data, *data3D, *mc, *mc3D,
464  mcsig, mcsig3D, mcsignutree, mcsignutree3D,
465  *rt, *rt3D,
466  bkgdest, bkgdest3D,
467  unfoldreg, unfoldmethod, xsectype, flux,
468  eff3D));
469 
470  }
NumuCCIncAnalysis(SpectrumLoader &lMC, SpectrumLoader &lDA, TrivialBkgdEstimator *bkgdest, TrivialBkgdEstimator *bkgdest3D, XSecType_t xsectype=kVsE, double unfoldReg=1, UnfoldMethod_t unfoldmethod=kIterative, const SystShifts &shiftMC=kNoShift, const SystShifts &shiftDA=kNoShift, const NuTruthVar wei=kXSecCVWgt2017ST *kPPFXFluxCVWgtST, const Var weiDA=kXSecCVWgt2017 *kPPFXFluxCVWgt, const bool efficiencyIn3D=false)
Constructor to create a NumuCCIncAnalysis object. lMC is the MC loader lDA is the data loader bkgdest...
Loaders::FluxType flux
const XML_Char const XML_Char * data
Definition: expat.h:268
const Binning enubins
std::vector< float > Spectrum
Definition: Constants.h:610
TDirectory * dir
Definition: macro.C:5
XSecType_t
Enumeration of the type of cross-section we are measuring.
int NBins() const
Definition: Binning.h:29
std::unique_ptr< IBkgdEstimator > LoadFrom< IBkgdEstimator >(TDirectory *dir, const std::string &label)
double ana::CrossSectionAnalysis::NTargets ( )
virtualinherited
double ana::CrossSectionAnalysis::NucleonCount ( )
protectedinherited

Definition at line 165 of file CrossSectionAnalysis.cxx.

References ana::CrossSectionAnalysis::fTarget, and ana::TargetCount::NNucleons().

Referenced by ana::CrossSectionAnalysis::CrossSectionAnalysis(), and ana::CrossSectionAnalysis::NTargets().

166  {
167  return fTarget.NNucleons();
168  }
double NNucleons() const
Number of nucleons (mass * avogadro&#39;s number)
Definition: TargetCount.h:31
double ana::CrossSectionAnalysis::NucleusCount ( int  Z = -1,
int  A = -1 
)
protectedinherited

Definition at line 170 of file CrossSectionAnalysis.cxx.

References ana::CrossSectionAnalysis::fTarget, and ana::TargetCount::NNuclei().

Referenced by ana::CrossSectionAnalysis::CrossSectionAnalysis(), and ana::SingleNucAnalysis::NTargets().

171  {
172  return fTarget.NNuclei(Z, A);
173  }
Float_t Z
Definition: plot.C:38
double NNuclei(int Z=-1, int A=-1) const
Number of nuclei, optionally restricted to a particular element or isotope.
static const double A
Definition: Units.h:82
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotBackgroundEstimate ( )

Returns a vector of histograms with background estimate.

Definition at line 278 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, ana::IBkgdEstimator::Background(), ana::CrossSectionAnalysis::fBkgdEst, ana::CrossSectionAnalysis::fData, fXSecType, ana::kPOT, kVsE, ana::mukebins, PlotHelper(), ana::Spectrum::POT(), ana::Spectrum::ToTH1(), and ana::ToTH2().

Referenced by ~NumuCCIncAnalysis().

279  {
280  Spectrum bkgd = fBkgdEst->Background();
281 
282  if(fXSecType != kVsE)
283  return PlotHelper( ToTH2( bkgd, fData.POT(), kPOT,
285  else
286  return {bkgd.ToTH1(fData.POT())};
287  }
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
std::vector< TH1 * > PlotHelper(const TH2 *spec)
Helper function to convert a 2D plot of the muon cos theta vs muon kinetic energy into a vector of 1D...
virtual Spectrum Background() const =0
std::vector< float > Spectrum
Definition: Constants.h:610
double POT() const
Definition: Spectrum.h:227
const Binning mukebins
Definition: NumuCCIncBins.h:90
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
For use with Var2D.
Definition: UtilsExt.cxx:115
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotData ( )

Returns a vector of histograms of data in reco space.

Definition at line 291 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, ana::CrossSectionAnalysis::fData, fXSecType, ana::kPOT, kVsE, ana::mukebins, PlotHelper(), ana::Spectrum::POT(), ana::Spectrum::ToTH1(), and ana::ToTH2().

Referenced by ~NumuCCIncAnalysis().

292  {
293  if(fXSecType != kVsE)
294  return PlotHelper( ToTH2( fData, fData.POT(), kPOT,
296  else
297  return {fData.ToTH1(fData.POT())};
298  }
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
std::vector< TH1 * > PlotHelper(const TH2 *spec)
Helper function to convert a 2D plot of the muon cos theta vs muon kinetic energy into a vector of 1D...
double POT() const
Definition: Spectrum.h:227
const Binning mukebins
Definition: NumuCCIncBins.h:90
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
For use with Var2D.
Definition: UtilsExt.cxx:115
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotEfficiency ( )

Definition at line 226 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, Efficiency(), fEfficiencyIn3D, fXSecType, kVsE, ana::mukebins, PlotHelper(), Project(), APDHVSetting::temp, ana::Ratio::ToTH1(), and ana::ToTH2().

Referenced by ~NumuCCIncAnalysis().

227  {
228 
229  if(fXSecType != kVsE){
230  TH2* temp = fEfficiencyIn3D ? (TH2*)Project(Efficiency()):
232  return PlotHelper( temp);
233  }
234  else{
235  if(fEfficiencyIn3D)
236  return {Project(Efficiency())};
237  return {Efficiency().ToTH1()};
238  }
239  }
Ratio Efficiency()
Return the efficiency Ratio.
TH1D * ToTH1(Color_t col=kBlack, Style_t style=kSolid) const
Definition: Ratio.cxx:67
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
std::vector< TH1 * > PlotHelper(const TH2 *spec)
Helper function to convert a 2D plot of the muon cos theta vs muon kinetic energy into a vector of 1D...
TH1 * Project(const Spectrum spec, const double pot)
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
const Binning mukebins
Definition: NumuCCIncBins.h:90
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
For use with Var2D.
Definition: UtilsExt.cxx:115
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotEfficiencyCorrectedSignal ( )

Returns a vector of histograms with the best estimate of signal, after background subtraction, unfolding and efficiency correction.

Definition at line 257 of file NumuCCIncAnalysis.cxx.

References Efficiency(), ReturnHists(), SignalEst(), and UnfoldedSignal().

Referenced by ~NumuCCIncAnalysis().

258  {
260  }
Ratio Efficiency()
Return the efficiency Ratio.
std::vector< TH1 * > ReturnHists(Spectrum spec)
Makes the vector of 1D hists by calling Project and PlotHelper.
Spectrum SignalEst()
Return estimated signal, ie data-bg.
Spectrum UnfoldedSignal(Spectrum sig)
Function to return the unfolded spectrum. It checks if the cross-section is being computed in 3D or 1...
TH1 * ana::CrossSectionAnalysis::PlotFluxEstimate ( )
inherited

Definition at line 201 of file CrossSectionAnalysis.cxx.

References ana::CrossSectionAnalysis::fFlux, make_syst_table_plots::h, and ana::Spectrum::ToTH1().

Referenced by test_xsecanalysis(), and ana::CrossSectionAnalysis::~CrossSectionAnalysis().

202  {
203  TH1 *h = fFlux->ToTH1(1);
204  //h->Scale(1e-4);
205  h->GetYaxis()->SetTitle("Flux / POT / m^{2}");
206  return h;
207  }
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotHelper ( const TH2 *  spec)

Helper function to convert a 2D plot of the muon cos theta vs muon kinetic energy into a vector of 1D histograms of muon kinetic energy for each cos theta bin. Used by all the plotting functions in this class.

Definition at line 367 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, make_true_q0q3_plots::caption, ana::CenterTitles(), e, make_syst_table_plots::h, make_syst_table_plots::ibin, nbins, ana::Binning::NBins(), runNovaSAM::ret, string, and ana::UniqueName().

Referenced by PlotBackgroundEstimate(), PlotData(), PlotEfficiency(), ReturnHists(), and ~NumuCCIncAnalysis().

368  {
369  std::vector<TH1*> ret;
370 
371  int nbins = angbinsCustom.NBins();
372  for(int ibin = 1; ibin < nbins+1; ibin++){
373 
374  std::stringstream low;
375  low<<std::fixed<<std::setprecision(3)<<
376  spec->GetXaxis()->GetBinLowEdge(ibin);
377  std::stringstream high;
378  high<<std::fixed<<std::setprecision(3)<<
379  spec->GetXaxis()->GetBinUpEdge(ibin);
380 
381  std::string caption = low.str() + " #leq cos #theta_{#mu} < " + high.str();
382 
383  TH1* h = spec->ProjectionY(Form("bin%d",ibin),ibin,ibin);
384  h->SetTitle(caption.c_str());
385  h->GetXaxis()->SetTitle("Muon Kinetic Energy, T_{#mu} (GeV)");
386  h->GetYaxis()->SetTitle("#frac{d^{2} #sigma}{dcos#theta dT_{#mu}} #left(#frac{10^{-38} cm^{2}}{nucleon GeV}#right)");
387  h->Scale(1e+38);
388  h->SetName(UniqueName().c_str());
389  CenterTitles(h);
390  ret.push_back(h);
391  }// end loop over cos theta bins
392 
393  return ret;
394  }// End of PlotHelper
void CenterTitles(TH1 *histo)
Definition: Plots.cxx:1481
const int nbins
Definition: cellShifts.C:15
int NBins() const
Definition: Binning.h:29
Float_t e
Definition: plot.C:35
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
std::string UniqueName()
Return a different string each time, for creating histograms.
Definition: Utilities.cxx:29
enum BeamMode string
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotMCReco ( )

Returns a vector of histograms of MC in the reco space For comparison with the output of ana::NumuCCIncAnalysis::PlotData.

Definition at line 302 of file NumuCCIncAnalysis.cxx.

References fEfficiencyIn3D, ana::CrossSectionAnalysis::fMC, fMC3D, and ReturnHists().

Referenced by ~NumuCCIncAnalysis().

303  {
305  ReturnHists(fMC);
306  }
std::vector< TH1 * > ReturnHists(Spectrum spec)
Makes the vector of 1D hists by calling Project and PlotHelper.
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
std::vector<TH1*> ana::NumuCCIncAnalysis::PlotMCSignalEstimate ( )

Returns a vector of histograms of MC in reco space, with true reco signal selection cuts applied, ie does not contain background For comparison with the output of ana::NumuCCIncAnalysis::PlotSignalEstimate.

Referenced by ~NumuCCIncAnalysis().

TH2D * ana::CrossSectionAnalysis::PlotRecoToTrueMatrix ( )
inherited
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotSignalEstimate ( )

Returns a vector of histograms containing signal estimate that is, (data - background) in reco space.

Definition at line 243 of file NumuCCIncAnalysis.cxx.

References ReturnHists(), and SignalEst().

Referenced by ~NumuCCIncAnalysis().

244  {
245  return ReturnHists(SignalEst());
246  }
std::vector< TH1 * > ReturnHists(Spectrum spec)
Makes the vector of 1D hists by calling Project and PlotHelper.
Spectrum SignalEst()
Return estimated signal, ie data-bg.
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotTrueSelectedSignal ( )

Returns a vector of histograms of MC in true space, with true and reco signal selection cuts applied. For comparison with the output of ana::NumuCCIncAnalysis::PlotUnfoldedSignal.

Definition at line 264 of file NumuCCIncAnalysis.cxx.

References fEfficiencyIn3D, ana::CrossSectionAnalysis::fMCSig, fMCSig3D, and ReturnHists().

Referenced by ~NumuCCIncAnalysis().

265  {
266  return fEfficiencyIn3D ? ReturnHists(*fMCSig3D): ReturnHists(*fMCSig);
267  }
std::vector< TH1 * > ReturnHists(Spectrum spec)
Makes the vector of 1D hists by calling Project and PlotHelper.
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotTrueSignal ( )

Returns a vector of histograms with MC signal in true space drawn from nuTree. For comparison with the output of ana::NumuCCIncAnalysis::PlotEfficiencyCorrectedSignal.

Definition at line 271 of file NumuCCIncAnalysis.cxx.

References fEfficiencyIn3D, ana::CrossSectionAnalysis::fMCSigNuTree, fMCSigNuTree3D, and ReturnHists().

Referenced by ~NumuCCIncAnalysis().

272  {
273  return fEfficiencyIn3D ? ReturnHists(*fMCSigNuTree3D) : ReturnHists(*fMCSigNuTree);
274  }
std::vector< TH1 * > ReturnHists(Spectrum spec)
Makes the vector of 1D hists by calling Project and PlotHelper.
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
std::vector< TH1 * > ana::NumuCCIncAnalysis::PlotUnfoldedSignal ( )

Returns a vector of histograms containing unfolded signal.

Definition at line 250 of file NumuCCIncAnalysis.cxx.

References ReturnHists(), SignalEst(), and UnfoldedSignal().

Referenced by ~NumuCCIncAnalysis().

251  {
253  }
std::vector< TH1 * > ReturnHists(Spectrum spec)
Makes the vector of 1D hists by calling Project and PlotHelper.
Spectrum SignalEst()
Return estimated signal, ie data-bg.
Spectrum UnfoldedSignal(Spectrum sig)
Function to return the unfolded spectrum. It checks if the cross-section is being computed in 3D or 1...
TH1 * ana::NumuCCIncAnalysis::Project ( const Spectrum  spec,
const double  pot 
)
private

Helper function to project from 3D to 2D or 1D Used internally to call ProjectHist

Definition at line 344 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, ana::enubins, ana::kPOT, ana::mukebins, ProjectHist(), APDHVSetting::temp, and ana::ToTH3().

Referenced by PlotEfficiency(), Result(), and ReturnHists().

346  {
347  TH3* temp = ana::ToTH3(spec, pot, kPOT, angbinsCustom,
348  mukebins, enubins);
349 
350  return ProjectHist(temp);
351  }
TH1 * ProjectHist(const TH3 *temp)
Helper function to project from 3D to 2D or 1D
const Binning enubins
#define pot
const Binning mukebins
Definition: NumuCCIncBins.h:90
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
TH3 * ToTH3(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, const Binning &binsz, ana::EBinType bintype)
Same as ToTH2, but with 3 dimensions.
Definition: UtilsExt.cxx:162
TH1 * ana::NumuCCIncAnalysis::Project ( const Ratio  rat)
private

Helper function to project from 3D to 2D or 1D Used internally to call ProjectHist

Definition at line 356 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, ana::enubins, ana::mukebins, ProjectHist(), APDHVSetting::temp, and ana::ToTH3().

357  {
358  TH3* temp = ana::ToTH3(rat, angbinsCustom,
359  mukebins, enubins);
360 
361  return ProjectHist(temp);
362  }
TH1 * ProjectHist(const TH3 *temp)
Helper function to project from 3D to 2D or 1D
const Binning enubins
const Binning mukebins
Definition: NumuCCIncBins.h:90
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
TH3 * ToTH3(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, const Binning &binsz, ana::EBinType bintype)
Same as ToTH2, but with 3 dimensions.
Definition: UtilsExt.cxx:162
TH1* ana::NumuCCIncAnalysis::ProjectE ( const TH3 *  h3)
private

Helper function to project from 3D to 1D, called by ProjectHist

TH1 * ana::NumuCCIncAnalysis::ProjectHist ( const TH3 *  temp)
private

Helper function to project from 3D to 2D or 1D

Definition at line 328 of file NumuCCIncAnalysis.cxx.

References fXSecType, make_syst_table_plots::h, and kVsE.

Referenced by Project().

329  {
330 
331  if(fXSecType == kVsE){
332  TH1* h = temp->Project3D("z");
333  return h;
334  }
335  else {
336  TH2* h = (TH2*)temp->Project3D("yx");
337  h->Scale(1, "width"); // normalize by bin-width
338  return h;
339  }
340  }
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
TH2* ana::NumuCCIncAnalysis::ProjectMuTCos ( const TH3 *  h3)
private

Helper function to project from 3D to 2D, called by ProjectHist

std::vector< TH1 * > ana::NumuCCIncAnalysis::Result ( )

Returns a vector of histograms of the cross-section results.

Definition at line 190 of file NumuCCIncAnalysis.cxx.

References ana::CenterTitles(), e, nd_projection_maker::eff, Efficiency(), ana::CrossSectionAnalysis::fData, fEfficiencyIn3D, ana::CrossSectionAnalysis::fFlux, flux, fNNucleons, fXSecType, hflux, ana::kPOT, kVsE, ana::Spectrum::POT(), Project(), ReturnHists(), ana::Spectrum::Scale(), SignalEst(), ana::Spectrum::ToTH1(), UnfoldedSignal(), and xsec.

Referenced by ~NumuCCIncAnalysis().

191  {
192 
193  Ratio eff = Efficiency();
194  Spectrum sig_unfolded = UnfoldedSignal(SignalEst());
195 
196  Spectrum xsec_spec = (sig_unfolded/eff);
197 
198  TH1* hflux = fFlux->ToTH1(fData.POT());
199  hflux->Scale(1e-4); // Convert nu/m^2 to nu/cm^2
200  double flux = hflux->Integral();
201 
202  if(fXSecType == kVsE){
203  TH1* xsec;
204  if(!fEfficiencyIn3D)
205  xsec = xsec_spec.ToTH1(fData.POT(), kPOT);
206  else
207  xsec = Project(xsec_spec, fData.POT());
208 
209  xsec->Divide(hflux);
210  xsec->Scale(1./fNNucleons);
211  xsec->GetYaxis()->SetTitle("#sigma (cm^{2}/nucleon)");
212  xsec->GetXaxis()->SetTitle("Neutrino Energy, E_{#nu} (GeV)");
213  CenterTitles(xsec);
214  return {xsec};
215  }
216  else{
217  xsec_spec.Scale(1./flux);
218  xsec_spec.Scale(1./fNNucleons);
219  return ReturnHists(xsec_spec);
220  }
221  }// End of Result
Ratio Efficiency()
Return the efficiency Ratio.
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
void CenterTitles(TH1 *histo)
Definition: Plots.cxx:1481
Loaders::FluxType flux
std::vector< TH1 * > ReturnHists(Spectrum spec)
Makes the vector of 1D hists by calling Project and PlotHelper.
TH1 * Project(const Spectrum spec, const double pot)
TH1F * hflux
Definition: Xdiff_gwt.C:121
std::vector< float > Spectrum
Definition: Constants.h:610
double POT() const
Definition: Spectrum.h:227
Double_t xsec[nknots]
Definition: testXsec.C:47
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
Float_t e
Definition: plot.C:35
Spectrum SignalEst()
Return estimated signal, ie data-bg.
Spectrum UnfoldedSignal(Spectrum sig)
Function to return the unfolded spectrum. It checks if the cross-section is being computed in 3D or 1...
const double fNNucleons
Pre-computed number of nucleon targets in our fiducial volume.
TH2 * ana::NumuCCIncAnalysis::Result2D ( )

Represent the double-differential result in 2D, rather than in 1D slices.

Definition at line 162 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, om::cerr, e, nd_projection_maker::eff, Efficiency(), ana::CrossSectionAnalysis::fData, ana::CrossSectionAnalysis::fFlux, flux, fNNucleons, fXSecType, hflux, ana::kBinDensity, ana::kPOT, kVsE, ana::mukebins, ana::Spectrum::POT(), ana::Spectrum::Scale(), SignalEst(), ana::Spectrum::ToTH1(), ana::ToTH2(), UnfoldedSignal(), and xsec.

Referenced by ~NumuCCIncAnalysis().

163  {
164  if(fXSecType == kVsE){
165  std::cerr<<"NumuCCIncAnalysis class has been setup for 1D cross-section vs Energy\n"
166  <<"Can not retrieve 2D results. Returning NULL histogram\n";
167  return NULL;
168  }
169 
170  Ratio eff = Efficiency();
171  Spectrum sig_unfolded = UnfoldedSignal(SignalEst());
172 
173  Spectrum xsec_spec = (sig_unfolded/eff);
174 
175  TH1* hflux = fFlux->ToTH1(fData.POT());
176  hflux->Scale(1e-4); // Convert nu/m^2 to nu/cm^2
177  double flux = hflux->Integral();
178 
179  xsec_spec.Scale(1./flux);
180  xsec_spec.Scale(1./fNNucleons);
181 
182  TH2 *xsec = ToTH2(xsec_spec, fData.POT(), kPOT,
184  return xsec;
185 
186  }// End of Result
Ratio Efficiency()
Return the efficiency Ratio.
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
Divide bin contents by bin widths.
Definition: UtilsExt.h:31
OStream cerr
Definition: OStream.cxx:7
Loaders::FluxType flux
TH1F * hflux
Definition: Xdiff_gwt.C:121
std::vector< float > Spectrum
Definition: Constants.h:610
double POT() const
Definition: Spectrum.h:227
Double_t xsec[nknots]
Definition: testXsec.C:47
const Binning mukebins
Definition: NumuCCIncBins.h:90
Float_t e
Definition: plot.C:35
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
Spectrum SignalEst()
Return estimated signal, ie data-bg.
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
For use with Var2D.
Definition: UtilsExt.cxx:115
Spectrum UnfoldedSignal(Spectrum sig)
Function to return the unfolded spectrum. It checks if the cross-section is being computed in 3D or 1...
const double fNNucleons
Pre-computed number of nucleon targets in our fiducial volume.
std::vector< TH1 * > ana::NumuCCIncAnalysis::ReturnHists ( Spectrum  spec)
private

Makes the vector of 1D hists by calling Project and PlotHelper.

Definition at line 310 of file NumuCCIncAnalysis.cxx.

References ana::angbinsCustom, ana::CrossSectionAnalysis::fData, fEfficiencyIn3D, fXSecType, ana::kBinDensity, ana::kPOT, kVsE, ana::mukebins, PlotHelper(), ana::Spectrum::POT(), Project(), APDHVSetting::temp, ana::Spectrum::ToTH1(), and ana::ToTH2().

Referenced by PlotEfficiencyCorrectedSignal(), PlotMCReco(), PlotSignalEstimate(), PlotTrueSelectedSignal(), PlotTrueSignal(), PlotUnfoldedSignal(), and Result().

311  {
312 
313  if(fXSecType != kVsE){
314  TH2* temp = fEfficiencyIn3D ? (TH2*)Project(spec, fData.POT()):
315  ToTH2( spec, fData.POT(), kPOT,
317  return PlotHelper( temp);
318  }
319  else{
320  if(fEfficiencyIn3D)
321  return {Project(spec, fData.POT())};
322  return {spec.ToTH1(fData.POT())};
323  }
324  }
XSecType_t fXSecType
Which xsec are we measureing? vs Energy or vs Muon Kinematics?
Divide bin contents by bin widths.
Definition: UtilsExt.h:31
std::vector< TH1 * > PlotHelper(const TH2 *spec)
Helper function to convert a 2D plot of the muon cos theta vs muon kinetic energy into a vector of 1D...
TH1 * Project(const Spectrum spec, const double pot)
double POT() const
Definition: Spectrum.h:227
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
const Binning mukebins
Definition: NumuCCIncBins.h:90
const Binning angbinsCustom
Definition: NumuCCIncBins.h:72
TH2 * ToTH2(const Spectrum &s, double exposure, ana::EExposureType expotype, const Binning &binsx, const Binning &binsy, ana::EBinType bintype)
For use with Var2D.
Definition: UtilsExt.cxx:115
void ana::CrossSectionAnalysis::SaveTo ( TDirectory *  dir,
const std::string name 
) const
inherited

Definition at line 232 of file CrossSectionAnalysis.cxx.

References dir, ana::CrossSectionAnalysis::fBkgdEst, ana::CrossSectionAnalysis::fData, ana::CrossSectionAnalysis::fFidMax, ana::CrossSectionAnalysis::fFidMin, ana::CrossSectionAnalysis::fFlux, ana::CrossSectionAnalysis::fMC, ana::CrossSectionAnalysis::fMCSig, ana::CrossSectionAnalysis::fMCSigNuTree, ana::CrossSectionAnalysis::fRecoTrue, ana::CrossSectionAnalysis::fUnfoldReg, ana::IBkgdEstimator::SaveTo(), ana::ReweightableSpectrum::SaveTo(), ana::Spectrum::SaveTo(), and tmp.

Referenced by SaveTo(), test_xsecanalysis(), and ana::CrossSectionAnalysis::~CrossSectionAnalysis().

232  {
233  TDirectory *tmp = gDirectory;
234 
235  dir = dir->mkdir(name.c_str()); // switch to subdir
236  dir->cd();
237 
238  TObjString("CrossSectionAnlaysis").Write("type");
239 
240  fData.SaveTo(dir, "fData");
241  fMC.SaveTo(dir, "fMC");
242  fMCSig->SaveTo(dir, "fMCSig");
243  fMCSigNuTree->SaveTo(dir, "fMCSigNuTree");
244  fRecoTrue.SaveTo(dir, "fRecoTrue");
245 
246  fBkgdEst->SaveTo(dir, "fBkgdEst");
247 
248  TVectorD unfoldreg(1);
249  unfoldreg[0] = fUnfoldReg;
250  unfoldreg.Write("fUnfoldReg");
251 
252  fFidMin.Write("fFidMin");
253  fFidMax.Write("fFidMax");
254  fFlux->SaveTo(dir, "fFlux");
255 
256  dir->Write();
257  delete dir;
258 
259  tmp->cd();
260  }
const XML_Char * name
Definition: expat.h:151
Float_t tmp
Definition: plot.C:36
virtual void SaveTo(TDirectory *dir, const std::string &name) const =0
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
TDirectory * dir
Definition: macro.C:5
void SaveTo(TDirectory *dir, const std::string &name) const
ReweightableSpectrum fRecoTrue
void ana::NumuCCIncAnalysis::SaveTo ( TDirectory *  dir) const

Save the NumuCCAnalysis cross-section object to file so it can be used later.

Definition at line 398 of file NumuCCIncAnalysis.cxx.

References fBkgdEst3D, fData3D, fMC3D, fMCSig3D, fMCSigNuTree3D, fRecoTrue3D, ana::IBkgdEstimator::SaveTo(), ana::ReweightableSpectrum::SaveTo(), ana::CrossSectionAnalysis::SaveTo(), and ana::Spectrum::SaveTo().

Referenced by ~NumuCCIncAnalysis().

398  {
399 
401 
402  dir->cd();
403  fData3D.SaveTo(dir->mkdir("fData3D"));
404  fMC3D.SaveTo(dir->mkdir("fMC3D"));
405  fMCSig3D->SaveTo(dir->mkdir("fMCSig3D"));
406  fMCSigNuTree3D->SaveTo(dir->mkdir("fMCSigNuTree3D"));
407  fBkgdEst3D->SaveTo(dir->mkdir("fBkgdEst3D"));
408  fRecoTrue3D.SaveTo(dir->mkdir("fRecoTrue3D"));
409  }
void SaveTo(TDirectory *dir, const std::string &name) const
IBkgdEstimator * fBkgdEst3D
ReweightableSpectrum fRecoTrue3D
virtual void SaveTo(TDirectory *dir, const std::string &name) const =0
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
TDirectory * dir
Definition: macro.C:5
void SaveTo(TDirectory *dir, const std::string &name) const
Spectrum ana::CrossSectionAnalysis::SignalEst ( Spectrum  bkgd)
protectedinherited
Spectrum ana::NumuCCIncAnalysis::SignalEst ( )

Return estimated signal, ie data-bg.

Definition at line 140 of file NumuCCIncAnalysis.cxx.

References ana::IBkgdEstimator::Background(), ana::CrossSectionAnalysis::fBkgdEst, fBkgdEst3D, ana::CrossSectionAnalysis::fData, fData3D, and fEfficiencyIn3D.

Referenced by PlotEfficiencyCorrectedSignal(), PlotSignalEstimate(), PlotUnfoldedSignal(), Result(), Result2D(), and ~NumuCCIncAnalysis().

141  {
142  if(!fEfficiencyIn3D)
143  return fData - fBkgdEst->Background();
144 
145  else
146  return fData3D - fBkgdEst3D->Background();
147  }
IBkgdEstimator * fBkgdEst3D
virtual Spectrum Background() const =0
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?
Spectrum ana::CrossSectionAnalysis::UnfoldedSignal ( Spectrum  signal,
ReweightableSpectrum rt = NULL 
)
protectedinherited

Definition at line 124 of file CrossSectionAnalysis.cxx.

References ana::CrossSectionAnalysis::fRecoTrue, ana::CrossSectionAnalysis::fUnfoldMethod, ana::CrossSectionAnalysis::fUnfoldReg, ana::kMaxEnt, ana::kSVD, ana::kTikhonov, ana::UnfoldIterative::Truth(), ana::UnfoldSVD::Truth(), and ana::UnfoldTikhonov::Truth().

Referenced by ana::CrossSectionAnalysis::CrossSectionAnalysis(), ana::CrossSectionAnalysis::PlotUnfoldedSignal(), ana::SingleNucAnalysis::PlotUnfoldedSignal2D(), ana::NumuCC2p2hAnalysis::PlotUnfoldedSignal2D(), ana::CrossSectionAnalysis::Result(), ana::NumuCC2p2hAnalysis::Result1DFluxInt(), ana::NumuCC2p2hAnalysis::Result2D(), ana::SingleNucAnalysis::Result2D(), and UnfoldedSignal().

126  {
127 
128  if(rt == NULL)
129  rt = &fRecoTrue;
130 
131  switch(fUnfoldMethod){
132  case(UnfoldMethod_t::kTikhonov) : {
133  UnfoldTikhonov unfold(*rt, fUnfoldReg);
134  return unfold.Truth(sig);
135  }
136  case(UnfoldMethod_t::kSVD) : {
137  UnfoldSVD unfold(*rt, fUnfoldReg);
138  return unfold.Truth(sig);
139  }
140  case(UnfoldMethod_t::kMaxEnt) : {
141  UnfoldMaxEnt unfold(*rt, fUnfoldReg);
142  return unfold.Truth(sig);
143  }
144  default : {
145  UnfoldIterative unfold(*rt, fUnfoldReg);
146  return unfold.Truth(sig);
147  }
148 
149  }// end of switch-case
150 
151  }
ReweightableSpectrum fRecoTrue
Spectrum ana::NumuCCIncAnalysis::UnfoldedSignal ( Spectrum  sig)

Function to return the unfolded spectrum. It checks if the cross-section is being computed in 3D or 1/2D and passes the reco-to-true matrix accordingly.

Definition at line 151 of file NumuCCIncAnalysis.cxx.

References fEfficiencyIn3D, fRecoTrue3D, and ana::CrossSectionAnalysis::UnfoldedSignal().

Referenced by PlotEfficiencyCorrectedSignal(), PlotUnfoldedSignal(), Result(), Result2D(), and ~NumuCCIncAnalysis().

152  {
153  if(!fEfficiencyIn3D)
155  else
157  }
Spectrum UnfoldedSignal(Spectrum signal, ReweightableSpectrum *rt=NULL)
ReweightableSpectrum fRecoTrue3D
bool fEfficiencyIn3D
Are we measuring the cross-section in 3D?

Member Data Documentation

IBkgdEstimator* ana::CrossSectionAnalysis::fBkgdEst
protectedinherited
IBkgdEstimator* ana::NumuCCIncAnalysis::fBkgdEst3D
private

Definition at line 233 of file NumuCCIncAnalysis.h.

Referenced by NumuCCIncAnalysis(), SaveTo(), and SignalEst().

Spectrum ana::CrossSectionAnalysis::fData
protectedinherited
Spectrum ana::NumuCCIncAnalysis::fData3D
private

Definition at line 228 of file NumuCCIncAnalysis.h.

Referenced by SaveTo(), and SignalEst().

bool ana::NumuCCIncAnalysis::fEfficiencyIn3D
private
TVector3 ana::CrossSectionAnalysis::fFidMax
protectedinherited
TVector3 ana::CrossSectionAnalysis::fFidMin
protectedinherited
Spectrum* ana::CrossSectionAnalysis::fFlux
protectedinherited
Spectrum ana::CrossSectionAnalysis::fMC
protectedinherited

Definition at line 139 of file CrossSectionAnalysis.h.

Referenced by PlotMCReco(), and ana::CrossSectionAnalysis::SaveTo().

Spectrum ana::NumuCCIncAnalysis::fMC3D
private

Definition at line 229 of file NumuCCIncAnalysis.h.

Referenced by PlotMCReco(), and SaveTo().

Spectrum* ana::CrossSectionAnalysis::fMCSig
protectedinherited
Spectrum* ana::NumuCCIncAnalysis::fMCSig3D
private

Definition at line 231 of file NumuCCIncAnalysis.h.

Referenced by Efficiency(), NumuCCIncAnalysis(), PlotTrueSelectedSignal(), and SaveTo().

Spectrum* ana::CrossSectionAnalysis::fMCSigNuTree
protectedinherited
Spectrum* ana::NumuCCIncAnalysis::fMCSigNuTree3D
private

Definition at line 230 of file NumuCCIncAnalysis.h.

Referenced by NumuCCIncAnalysis(), PlotTrueSignal(), and SaveTo().

const double ana::NumuCCIncAnalysis::fNNucleons = 5.68917e+31
private

Pre-computed number of nucleon targets in our fiducial volume.

Definition at line 198 of file NumuCCIncAnalysis.h.

Referenced by Result(), and Result2D().

double ana::CrossSectionAnalysis::fNTargets
protectedinherited

Definition at line 147 of file CrossSectionAnalysis.h.

Referenced by ana::CrossSectionAnalysis::NTargets().

ReweightableSpectrum ana::CrossSectionAnalysis::fRecoTrue
protectedinherited
ReweightableSpectrum ana::NumuCCIncAnalysis::fRecoTrue3D
private

Definition at line 232 of file NumuCCIncAnalysis.h.

Referenced by SaveTo(), and UnfoldedSignal().

TargetCount ana::CrossSectionAnalysis::fTarget
protectedinherited
UnfoldMethod_t ana::CrossSectionAnalysis::fUnfoldMethod
protectedinherited
double ana::CrossSectionAnalysis::fUnfoldReg
protectedinherited
XSecType_t ana::NumuCCIncAnalysis::fXSecType
private

Which xsec are we measureing? vs Energy or vs Muon Kinematics?

Definition at line 201 of file NumuCCIncAnalysis.h.

Referenced by NumuCCIncAnalysis(), PlotBackgroundEstimate(), PlotData(), PlotEfficiency(), ProjectHist(), Result(), Result2D(), and ReturnHists().


The documentation for this class was generated from the following files: