CrossSectionAnalysis.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "CAFAna/Core/Ratio.h"
4 #include "CAFAna/Core/Spectrum.h"
7 
10 #include "CAFAna/XSec/Efficiency.h"
11 #include "CAFAna/XSec/Flux.h"
12 
13 #include <vector>
14 
15 namespace ana
16 {
17  // enum XSecType{kTotalXSec, kFluxAvgDifXSec};
18 
19  /// Enumerator for unfolding methods. TODO: Allow swapping to RooUnfold, TUnfold, etc?
25  };
26 
27 
28  /// Generic organizational class for a cross section analysis
30  public:
32  SpectrumLoaderBase &lDA,
33  HistAxis axisreco,
34  NuTruthHistAxis axistrue,
35  Binning EBins,
36  Cut sel,
37  NuTruthCut isSig,
38  IBkgdEstimator * bkgdest,
39  TVector3 min,
40  TVector3 max,
41  double unfoldReg,
42  UnfoldMethod_t unfoldmethod = kIterative,
43  const SystShifts &shiftMC = kNoShift,
44  const SystShifts &shiftDA = kNoShift,
45  const NuTruthVar &wei = kNuTruthUnweighted,
46  const Var &weiDA = kUnweighted);
47 
48 
50  SpectrumLoaderBase &lDA,
51  HistAxis axisreco,
52  NuTruthHistAxis axistrue,
53  Binning EBins,
54  Cut sel,
55  NuTruthCut isSig,
56  IBkgdEstimator * bkgdest,
57  TVector3 min,
58  TVector3 max,
59  double nTargets,
60  double unfoldReg,
61  UnfoldMethod_t unfoldmethod = kIterative,
62  const SystShifts &shiftMC = kNoShift,
63  const SystShifts &shiftDA = kNoShift,
64  const NuTruthVar &wei = kNuTruthUnweighted,
65  const Var &weiDA = kUnweighted);
66 
67  virtual ~CrossSectionAnalysis() {};
68 
69  TH1* Result();
70  TH1* PlotEfficiency();
71  TH1* PlotSignalEstimate();
72  TH1* PlotUnfoldedSignal();
73  TH1* PlotFluxEstimate();
75  TH1* PlotData();
76  TH2D* PlotRecoToTrueMatrix();
77 
78  virtual double NTargets(); // override if you need something other than cross sec "per nucleon"
79 
80  void SaveTo(TDirectory* dir, const std::string& name) const;
81  static std::unique_ptr<CrossSectionAnalysis> LoadFrom(TDirectory* dir, const std::string& name, UnfoldMethod_t unfoldmethod = kIterative);
82  static std::unique_ptr<CrossSectionAnalysis> LoadFrom(TDirectory* dir,
83  const std::string& name,
84  UnfoldMethod_t unfoldmethod,
85  double nTargets);
86 
87  protected:
89  Spectrum *mcsig, Spectrum *mcsignutree,
91  IBkgdEstimator *bkgdest, double unfoldreg,
92  UnfoldMethod_t unfoldmethod,
93  TVector3 min, TVector3 max, Spectrum* flux)
94  : fData(data),
95  fMC(mc),
96  fMCSig(mcsig),
97  fMCSigNuTree(mcsignutree),
98  fRecoTrue(rt),
99  fBkgdEst(bkgdest),
100  fNTargets(0),
101  fUnfoldReg(unfoldreg),
102  fUnfoldMethod(unfoldmethod),
103  fFidMin(min),
104  fFidMax(max),
105  fTarget(min,max,1e6),
106  fFlux(flux)
107  {}
108 
110  Spectrum *mcsig, Spectrum *mcsignutree,
112  IBkgdEstimator *bkgdest,
113  double nTargets, double unfoldreg,
114  UnfoldMethod_t unfoldmethod,
115  TVector3 min, TVector3 max, Spectrum* flux)
116  : fData(data),
117  fMC(mc),
118  fMCSig(mcsig),
119  fMCSigNuTree(mcsignutree),
120  fRecoTrue(rt),
121  fBkgdEst(bkgdest),
122  fNTargets(nTargets),
123  fUnfoldReg(unfoldreg),
124  fUnfoldMethod(unfoldmethod),
125  fFidMin(min),
126  fFidMax(max),
127  fFlux(flux)
128  {}
129 
130 
131 
134  Ratio Efficiency();
135  double NucleonCount(); // for use in NTargets() (used by default)
136  double NucleusCount(int Z=-1, int A=-1); // for use in NTargets(), if desired
137 
140  // fMCSig and fMCSigNuTree taken from Efficiency(...)
144 
146 
147  double fNTargets;
148 
149  //UnfoldType fUnfold;
150  double fUnfoldReg;
152 
153  TVector3 fFidMin;
154  TVector3 fFidMax;
155 
158 };
159 
160 }
double NucleusCount(int Z=-1, int A=-1)
CrossSectionAnalysis(Spectrum data, Spectrum mc, Spectrum *mcsig, Spectrum *mcsignutree, ReweightableSpectrum rt, IBkgdEstimator *bkgdest, double nTargets, double unfoldreg, UnfoldMethod_t unfoldmethod, TVector3 min, TVector3 max, Spectrum *flux)
const XML_Char * name
Definition: expat.h:151
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
Spectrum UnfoldedSignal(Spectrum signal, ReweightableSpectrum *rt=NULL)
CrossSectionAnalysis(Spectrum data, Spectrum mc, Spectrum *mcsig, Spectrum *mcsignutree, ReweightableSpectrum rt, IBkgdEstimator *bkgdest, double unfoldreg, UnfoldMethod_t unfoldmethod, TVector3 min, TVector3 max, Spectrum *flux)
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
void SaveTo(TDirectory *dir, const std::string &name) const
Spectrum with the value of a second variable, allowing for reweighting
Loaders::FluxType flux
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const XML_Char const XML_Char * data
Definition: expat.h:268
Float_t Z
Definition: plot.C:38
virtual double NTargets()
Default implementation returns number of nucleons. Override if needed.
static std::unique_ptr< CrossSectionAnalysis > LoadFrom(TDirectory *dir, const std::string &name, UnfoldMethod_t unfoldmethod=kIterative)
Spectrum SignalEst(Spectrum bkgd)
Represent the ratio between two spectra.
Definition: Ratio.h:8
const SystShifts kNoShift
Definition: SystShifts.cxx:21
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
Base class for the various types of spectrum loader.
UnfoldMethod_t
Enumerator for unfolding methods. TODO: Allow swapping to RooUnfold, TUnfold, etc?
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
static const double A
Definition: Units.h:82
TDirectory * dir
Definition: macro.C:5
const NuTruthVar kNuTruthUnweighted
Definition: Var.h:100
Generic organizational class for a cross section analysis.
ReweightableSpectrum fRecoTrue
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)
Template for Var and SpillVar.
T max(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
Definition: statistics.h:68
Count number of targets within the main part of the ND (vSuperBlockND)
Definition: TargetCount.h:10
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96