Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ana::ICrossSectionAnalysis Class Referenceabstract

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-02/CAFAna/XSec/ICrossSectionAnalysis.h"

Inheritance diagram for ana::ICrossSectionAnalysis:
ana::TrivialCrossSectionAnalysis

Public Types

enum  UnfoldMethod_t {
  kNone, kIterative, kTikhonov, kSVD,
  kMaxEnt, RooUnfold, TUnfold
}
 enum for unfolding methods More...
 

Public Member Functions

virtual TH1 * RelativeUncertainty (XSecSysts::Syst_t)=0
 
virtual std::pair< TH1 *, TH1 * > TotalErrors ()=0
 
virtual std::pair< TH1 *, TH1 * > FluxError ()=0
 
virtual TH1 * Flux (XSecSysts::Syst_t)=0
 
virtual TH1 * Efficiency (XSecSysts::Syst_t)=0
 
virtual TH1 * Purity (XSecSysts::Syst_t)=0
 
virtual ICrossSectionAnalysisClone () const =0
 
virtual void SaveTo (TDirectory *dir, const std::string &name) const =0
 
const CrossSectionSpectraGetCrossSectionSpectra (XSecSysts::Syst_t)
 
const SpectrumSignalEstimate (XSecSysts::Syst_t)
 
const TargetCountGetTarget ()
 
const TVector3 * GetFidMax ()
 
const TVector3 * GetFixMin ()
 
void SetWeight (XSecSysts::Syst_t, const Var *)
 
void SetNuTruthWeight (XSecSysts::Syst_t, const NuTruthVar *)
 
void SetSystShifts (XSecSysts::Syst_t, const SystShifts *)
 
void InitSystematicSpectra (XSecSysts::Syst_t, CrossSectionSpectra *)
 
void InitSystematicSpectra (XSecSysts::Syst_t, SpectrumLoaderBase *, ISignalEstimator *)
 
void InitSystematicSpectra (XSecSysts::Syst_t, ReweightableSpectrum *, ISignalEstimator *, Spectrum *, Spectrum *, Spectrum *, Spectrum *, Spectrum *)
 
void InitDataSpectrum (SpectrumLoaderBase *)
 
void SetData (Spectrum *)
 
void SetSelectionCut (const Cut *)
 
void SetSignalCut (const NuTruthCut *)
 
void SetAxis (const HistAxis *)
 
void SetAxisNT (const NuTruthHistAxis *)
 
void SetTarget (TargetCount)
 
void SetFidMax (TVector3)
 
void SetFidMin (TVector3)
 
void SetUnfoldingMethod (UnfoldMethod_t)
 
void SetUnfoldingReg (double)
 
void SetPOT (double)
 
void CalculateCrossSections ()
 
const TH1 * UnfoldedSignal (XSecSysts::Syst_t)
 
TH1 * GetCrossSection (XSecSysts::Syst_t)
 
double NTargets ()
 
int NDimensions ()
 
virtual ~ICrossSectionAnalysis ()
 

Static Public Member Functions

static Spectrum GetGeniePrediction ()
 

Protected Member Functions

TH1 * CrossSection (XSecSysts::Syst_t)
 
TH1 * ToHist (const Spectrum &, double=-1)
 
void DivideByBinWidth (TH1 *)
 
void DX (TH1 *)
 
void DXDY (TH1 *)
 
void DXDYDZ (TH1 *)
 
bool HasENuBinning () const
 
bool HasPDG () const
 
bool HasWeights () const
 
bool HasNuTruthWeights () const
 
bool HasSystShifts () const
 
bool HasData () const
 
bool HasSpectra () const
 
bool HasXSecs () const
 
bool HasUnfoldMethod () const
 
bool HasUnfoldReg () const
 
bool HasDimensions () const
 
bool HasSignalCut () const
 
bool HasSelectionCut () const
 
bool HasRecoAxis () const
 
bool HasTruthAxis () const
 
bool HasFiducialVolume () const
 
bool CanFillSpectra () const
 
bool CanCalculateCrossSection () const
 
CutCopy (const Cut *)
 
NuTruthCutCopy (const NuTruthCut *)
 
HistAxisCopy (const HistAxis *)
 
NuTruthHistAxisCopy (const NuTruthHistAxis *)
 
VarCopy (const Var *)
 
NuTruthVarCopy (const NuTruthVar *)
 
SystShiftsCopy (const SystShifts *)
 

Protected Attributes

std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
 
std::map< XSecSysts::Syst_t, const Var * > fWeights
 
std::map< XSecSysts::Syst_t, const NuTruthVar * > fNuTruthWeights
 
std::map< XSecSysts::Syst_t, const SystShifts * > fSystShifts
 
std::map< XSecSysts::Syst_t, TH1 * > fXSec
 
const SpectrumfData = NULL
 
TargetCount fTarget
 
TVector3 fFidMax
 
TVector3 fFidMin
 
const CutfSelectionCut = NULL
 
const HistAxisfRecoAxis = NULL
 
const NuTruthCutfSignalCut = NULL
 
const NuTruthHistAxisfTruthAxis = NULL
 
UnfoldMethod_t fUnfoldMethod = kNone
 
double fUnfoldReg = 0
 
int fPDG = 0
 
const BinningfENuBinning = NULL
 
int fNDims = 0
 
bool fIsDifferential
 
double fPOT
 

Detailed Description

Definition at line 18 of file ICrossSectionAnalysis.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

ana::ICrossSectionAnalysis::~ICrossSectionAnalysis ( )
virtual

Definition at line 700 of file ICrossSectionAnalysis.cxx.

References fRecoAxis, fSelectionCut, fSignalCut, fSystShifts, fTruthAxis, fWeights, fXSecSpectra, ana::weight, and xsec.

701  {
702  std::for_each(fXSecSpectra.begin(), fXSecSpectra.end(),
703  [](std::pair<XSecSysts::Syst_t, CrossSectionSpectra *> xsec)
704  {
705  delete xsec.second;
706  });
707  std::for_each(fWeights.begin(), fWeights.end(),
708  [](std::pair<XSecSysts::Syst_t, const Var *> weight)
709  {
710  delete weight.second;
711  });
712  std::for_each(fSystShifts.begin(), fSystShifts.end(),
713  [](std::pair<XSecSysts::Syst_t, const SystShifts *> shift)
714  {
715  delete shift.second;
716  });
717  delete fSelectionCut;
718  delete fSignalCut;
719  delete fRecoAxis;
720  delete fTruthAxis;
721  }
const Var weight
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
Double_t xsec[nknots]
Definition: testXsec.C:47
std::map< XSecSysts::Syst_t, const Var * > fWeights
std::map< XSecSysts::Syst_t, const SystShifts * > fSystShifts
const NuTruthHistAxis * fTruthAxis

Member Function Documentation

void ana::ICrossSectionAnalysis::CalculateCrossSections ( )

Definition at line 25 of file ICrossSectionAnalysis.cxx.

References CrossSection(), fXSec, fXSecSpectra, and xsec.

Referenced by demo_trivial_xsec_analysis().

26  {
27  std::for_each(fXSecSpectra.begin(), fXSecSpectra.end(),
28  [this](std::pair<XSecSysts::Syst_t, CrossSectionSpectra*> xsec)
29  {
30  this->fXSec
31  .insert(std::pair<XSecSysts::Syst_t, TH1 *>
32  (xsec.first,
33  CrossSection(xsec.first)));
34  });
35  }
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
TH1 * CrossSection(XSecSysts::Syst_t)
Double_t xsec[nknots]
Definition: testXsec.C:47
std::map< XSecSysts::Syst_t, TH1 * > fXSec
bool ana::ICrossSectionAnalysis::CanCalculateCrossSection ( ) const
protected

Definition at line 124 of file ICrossSectionAnalysis.cxx.

References HasDimensions(), HasFiducialVolume(), HasSpectra(), HasUnfoldMethod(), and HasUnfoldReg().

Referenced by CrossSection().

125  {
126  return
127  HasSpectra() &&
128  HasUnfoldMethod () &&
129  HasUnfoldReg() &&
130  HasDimensions() &&
132  }
bool ana::ICrossSectionAnalysis::CanFillSpectra ( ) const
protected

Definition at line 109 of file ICrossSectionAnalysis.cxx.

References HasFiducialVolume(), HasNuTruthWeights(), HasRecoAxis(), HasSelectionCut(), HasSignalCut(), HasSystShifts(), HasTruthAxis(), and HasWeights().

Referenced by ana::TrivialCrossSectionAnalysis::InitGenieUniverses(), ana::TrivialCrossSectionAnalysis::InitPPFXUniverses(), ana::TrivialCrossSectionAnalysis::InitSystematicSpectra(), and InitSystematicSpectra().

virtual ICrossSectionAnalysis* ana::ICrossSectionAnalysis::Clone ( ) const
pure virtual

Analyzers override. This needs to be overridden in derived class wherein member pointers are copied explicitly with 'new' to protect against memory leaks when using copy constructors

Implemented in ana::TrivialCrossSectionAnalysis.

Cut * ana::ICrossSectionAnalysis::Copy ( const Cut ptr)
protected

Definition at line 39 of file ICrossSectionAnalysis.cxx.

Referenced by Copy(), ana::TrivialCrossSectionAnalysis::operator=(), and ana::TrivialCrossSectionAnalysis::TrivialCrossSectionAnalysis().

40  {
41  if(ptr)
42  return new Cut(*ptr);
43  else
44  return NULL;
45  }
_Cut< caf::SRProxy > Cut
Representation of a cut (selection) to be applied to a caf::StandardRecord object.
Definition: Cut.h:96
NuTruthCut * ana::ICrossSectionAnalysis::Copy ( const NuTruthCut ptr)
protected

Definition at line 49 of file ICrossSectionAnalysis.cxx.

50  {
51  if(ptr)
52  return new NuTruthCut(*ptr);
53  else
54  return NULL;
55  }
_Cut< caf::SRNeutrinoProxy > NuTruthCut
Cut designed to be used over the nuTree, ie all neutrinos, not just those that got slices...
Definition: Cut.h:104
HistAxis * ana::ICrossSectionAnalysis::Copy ( const HistAxis ptr)
protected

Definition at line 59 of file ICrossSectionAnalysis.cxx.

60  {
61  if(ptr)
62  return new HistAxis(*ptr);
63  else
64  return NULL;
65  }
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
NuTruthHistAxis * ana::ICrossSectionAnalysis::Copy ( const NuTruthHistAxis ptr)
protected

Definition at line 69 of file ICrossSectionAnalysis.cxx.

70  {
71  if(ptr)
72  return new NuTruthHistAxis(*ptr);
73  else
74  return NULL;
75  }
_HistAxis< NuTruthVar > NuTruthHistAxis
Definition: HistAxis.h:106
NuTruthVar * ana::ICrossSectionAnalysis::Copy ( const Var ptr)
protected

Definition at line 79 of file ICrossSectionAnalysis.cxx.

References Copy().

80  {
81  if(ptr)
82  return new Var(*ptr);
83  else
84  return NULL;
85  }
_Var< caf::SRProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:74
NuTruthVar* ana::ICrossSectionAnalysis::Copy ( const NuTruthVar )
protected
SystShifts * ana::ICrossSectionAnalysis::Copy ( const SystShifts ptr)
protected

Definition at line 99 of file ICrossSectionAnalysis.cxx.

100  {
101  if(ptr)
102  return new SystShifts(*ptr);
103  else
104  return NULL;
105  }
TH1 * ana::ICrossSectionAnalysis::CrossSection ( XSecSysts::Syst_t  syst)
protected

Definition at line 531 of file ICrossSectionAnalysis.cxx.

References ana::assert(), CanCalculateCrossSection(), DivideByBinWidth(), e, Efficiency(), efficiency(), fIsDifferential, flux, Flux(), NTargets(), UnfoldedSignal(), and xsec.

Referenced by CalculateCrossSections().

532  {
534  "CrossSectionAnalysis not ready for cross section calculation" );
535 
536  const TH1 * unfolded_signal_est = UnfoldedSignal(syst);
537  const TH1 * efficiency = Efficiency(syst);
538  TH1 * flux = Flux(syst);
539  flux->Scale(1e-4); // Convert nu/m^2 to nu/cm^2
540  double ntargets = NTargets();
541  TH1 * xsec = (TH1*) unfolded_signal_est->Clone();
542  xsec->Divide(efficiency);
543  xsec->Divide(flux);
544  xsec->Scale(1./ntargets);
545  if(fIsDifferential)
546  DivideByBinWidth(xsec);
547  return xsec;
548  }
virtual TH1 * Flux(XSecSysts::Syst_t)=0
Loaders::FluxType flux
const TH1 * UnfoldedSignal(XSecSysts::Syst_t)
virtual TH1 * Efficiency(XSecSysts::Syst_t)=0
Double_t xsec[nknots]
Definition: testXsec.C:47
assert(nhit_max >=nhit_nbins)
Float_t e
Definition: plot.C:35
void efficiency()
Definition: efficiency.C:58
void ana::ICrossSectionAnalysis::DivideByBinWidth ( TH1 *  xsec)
protected

Definition at line 621 of file ICrossSectionAnalysis.cxx.

References om::cout, DX(), DXDY(), DXDYDZ(), allTimeWatchdog::endl, and fNDims.

Referenced by CrossSection().

622  {
623  TH1 * binning;
624  switch(fNDims) {
625  case(1) : {
626  binning = (TH1D*) xsec->Clone();
627  DX(binning);
628  break;
629  }
630  case(2) : {
631  binning = (TH2D*) xsec->Clone();
632  DXDY(binning);
633  break;
634  }
635  case(3) : {
636  binning = (TH3D*) xsec->Clone();
637  DXDYDZ(binning);
638  break;
639  }
640  default : {
641  std::cout << "Dimension of measurement undetermined." << std::endl;
642  abort();
643  }
644  } // end of switch-case
645  }
Double_t xsec[nknots]
Definition: testXsec.C:47
OStream cout
Definition: OStream.cxx:6
void ana::ICrossSectionAnalysis::DX ( TH1 *  binning)
protected

Definition at line 649 of file ICrossSectionAnalysis.cxx.

References MECModelEnuComparisons::i, and makeTrainCVSamples::int.

Referenced by DivideByBinWidth().

650  {
651  for(int i = 1; i <= (int) binning->GetNbinsX(); i++) {
652  binning->SetBinContent(i, binning->GetXaxis()->GetBinWidth(i));
653  }
654  }
void ana::ICrossSectionAnalysis::DXDY ( TH1 *  binning)
protected

Definition at line 658 of file ICrossSectionAnalysis.cxx.

References dx, dy, MECModelEnuComparisons::i, makeTrainCVSamples::int, and calib::j.

Referenced by DivideByBinWidth().

659  {
660  for(int i = 1; i <= (int) binning->GetNbinsX(); i++) {
661  double dx = binning->GetXaxis()->GetBinWidth(i);
662  for(int j = 1; j <= (int) binning->GetNbinsY(); j++) {
663  double dy = binning->GetYaxis()->GetBinWidth(j);
664  binning->SetBinContent(i, j, dx * dy);
665  }
666  }
667  }
double dy[NP][NC]
double dx[NP][NC]
const double j
Definition: BetheBloch.cxx:29
void ana::ICrossSectionAnalysis::DXDYDZ ( TH1 *  binning)
protected

Definition at line 671 of file ICrossSectionAnalysis.cxx.

References dx, dy, dz, MECModelEnuComparisons::i, makeTrainCVSamples::int, and calib::j.

Referenced by DivideByBinWidth().

672  {
673  for(int i = 1; i <= (int) binning->GetNbinsX(); i++) {
674  double dx = binning->GetXaxis()->GetBinWidth(i);
675  for(int j = 1; j <= (int) binning->GetNbinsY(); j++) {
676  double dy = binning->GetYaxis()->GetBinWidth(j);
677  for(int k = 1; k <= (int) binning->GetNbinsZ(); k++) {
678  double dz = binning->GetZaxis()->GetBinWidth(k);
679  binning->SetBinContent(i, j, k, dx * dy * dz);
680  }
681  }
682  }
683  }
double dy[NP][NC]
double dx[NP][NC]
double dz[NP][NC]
const double j
Definition: BetheBloch.cxx:29
virtual TH1* ana::ICrossSectionAnalysis::Efficiency ( XSecSysts::Syst_t  )
pure virtual

Analyzers override. Function that calculates the efficiency that will be used in the cross section calculation

Implemented in ana::TrivialCrossSectionAnalysis.

Referenced by CrossSection(), and ana::PlotAllEfficiency().

virtual TH1* ana::ICrossSectionAnalysis::Flux ( XSecSysts::Syst_t  )
pure virtual

Analyzers override. Function that calculates the flux object that will be used in the cross section calculation

Implemented in ana::TrivialCrossSectionAnalysis.

Referenced by CrossSection(), and ana::PlotAllFlux().

virtual std::pair<TH1 *, TH1 *> ana::ICrossSectionAnalysis::FluxError ( )
pure virtual

Analyzers override. Function that calculates the up (first) and down (second) error on the flux estimation

Implemented in ana::TrivialCrossSectionAnalysis.

TH1 * ana::ICrossSectionAnalysis::GetCrossSection ( XSecSysts::Syst_t  syst)

Definition at line 524 of file ICrossSectionAnalysis.cxx.

References fXSec.

Referenced by ana::PlotAllCrossSectionOverENu(), and ana::PlotAllCrossSectionResult().

525  {
526  return (TH1 *) fXSec[syst]->Clone();
527  }
std::map< XSecSysts::Syst_t, TH1 * > fXSec
const CrossSectionSpectra * ana::ICrossSectionAnalysis::GetCrossSectionSpectra ( XSecSysts::Syst_t  syst)

Definition at line 420 of file ICrossSectionAnalysis.cxx.

References fXSecSpectra.

Referenced by ana::PlotAllRecoTrue(), and ana::PlotAllSelectionDecomposition().

421  {
422  return fXSecSpectra[syst];
423  }
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
const TVector3 * ana::ICrossSectionAnalysis::GetFidMax ( )

Definition at line 434 of file ICrossSectionAnalysis.cxx.

References fFidMax.

435  {
436  return &fFidMax;
437  }
const TVector3 * ana::ICrossSectionAnalysis::GetFixMin ( )

Definition at line 441 of file ICrossSectionAnalysis.cxx.

References fFidMin.

442  {
443  return &fFidMin;
444  }
static Spectrum ana::ICrossSectionAnalysis::GetGeniePrediction ( )
static

Static function to get the genie prediction of the cross section from the CAF trees – a per nucleon measurement

const TargetCount * ana::ICrossSectionAnalysis::GetTarget ( )

Definition at line 427 of file ICrossSectionAnalysis.cxx.

References fTarget.

428  {
429  return &fTarget;
430  }
bool ana::ICrossSectionAnalysis::HasData ( ) const
protected

Definition at line 188 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fData.

Referenced by ana::TrivialCrossSectionAnalysis::SaveTo().

189  {
190  if(fData)
191  return true;
192  else {
193  std::cout << "CrossSectionAnalysis object does not have data" << std::endl;
194  return false;
195  }
196  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasDimensions ( ) const
protected

Definition at line 284 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fNDims.

Referenced by CanCalculateCrossSection().

285  {
286  if(fNDims != 0)
287  return true;
288  else {
289  std::cout << "Measurement dimensions not set" << std::endl;
290  return false;
291  }
292  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasENuBinning ( ) const
protected

Definition at line 164 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fENuBinning.

Referenced by InitSystematicSpectra().

165  {
166  if(fENuBinning)
167  return true;
168  else {
169  std::cout << "Binning not initialized" << std::endl;
170  return false;
171  }
172  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasFiducialVolume ( ) const
protected

Definition at line 344 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, fFidMax, and fFidMin.

Referenced by CanCalculateCrossSection(), and CanFillSpectra().

345  {
346  if((fFidMax.X() != 0 &&
347  fFidMax.Y() != 0 &&
348  fFidMax.Z() != 0) ||
349  (fFidMin.X() != 0 &&
350  fFidMin.Y() != 0 &&
351  fFidMin.Z() != 0))
352  return true;
353  else {
354  std::cout << "Fiducial volume not defined" << std::endl;
355  return false;
356  }
357  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasNuTruthWeights ( ) const
protected

Definition at line 224 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fNuTruthWeights.

Referenced by CanFillSpectra().

225  {
226  if(!fNuTruthWeights.empty())
227  return true;
228  else {
229  std::cout << "NuTruthWeights not initialized" << std::endl;
230  return false;
231  }
232  }
std::map< XSecSysts::Syst_t, const NuTruthVar * > fNuTruthWeights
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasPDG ( ) const
protected

Definition at line 176 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fPDG.

Referenced by InitSystematicSpectra().

177  {
178  if(fPDG != 0)
179  return true;
180  else {
181  std::cout << "Particle PDG not set" << std::endl;
182  return false;
183  }
184  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasRecoAxis ( ) const
protected

Definition at line 320 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fRecoAxis.

Referenced by CanFillSpectra(), and InitDataSpectrum().

321  {
322  if(fRecoAxis)
323  return true;
324  else {
325  std::cout << "Reco axis not initialized" << std::endl;
326  return false;
327  }
328  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasSelectionCut ( ) const
protected

Definition at line 308 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fSelectionCut.

Referenced by CanFillSpectra(), and InitDataSpectrum().

309  {
310  if(fSelectionCut)
311  return true;
312  else {
313  std::cout << "Selection Cut not defined" << std::endl;
314  return false;
315  }
316  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasSignalCut ( ) const
protected

Definition at line 296 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fSignalCut.

Referenced by CanFillSpectra().

297  {
298  if(fSignalCut)
299  return true;
300  else {
301  std::cout << "Signal cut not defined" << std::endl;
302  return false;
303  }
304  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasSpectra ( ) const
protected

Definition at line 200 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fXSecSpectra.

Referenced by CanCalculateCrossSection().

201  {
202  if(!fXSecSpectra.empty())
203  return true;
204  else {
205  std::cout << "CrossSectionAnalysis object does not have MC spectra" << std::endl;
206  return false;
207  }
208  }
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasSystShifts ( ) const
protected

Definition at line 236 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fSystShifts.

Referenced by CanFillSpectra().

237  {
238  if(!fSystShifts.empty())
239  return true;
240  else {
241  std::cout << "SystShifts not initialized" << std::endl;
242  return false;
243  }
244  }
OStream cout
Definition: OStream.cxx:6
std::map< XSecSysts::Syst_t, const SystShifts * > fSystShifts
bool ana::ICrossSectionAnalysis::HasTruthAxis ( ) const
protected

Definition at line 332 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fTruthAxis.

Referenced by CanFillSpectra().

333  {
334  if(fTruthAxis)
335  return true;
336  else {
337  std::cout << "Truth axis not initialized" << std::endl;
338  return false;
339  }
340  }
OStream cout
Definition: OStream.cxx:6
const NuTruthHistAxis * fTruthAxis
bool ana::ICrossSectionAnalysis::HasUnfoldMethod ( ) const
protected

Definition at line 260 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fUnfoldMethod.

Referenced by CanCalculateCrossSection().

261  {
262  if(fUnfoldMethod != 0)
263  return true;
264  else {
265  std::cout << "Unfolding method not set: " << fUnfoldMethod << std::endl;
266  return false;
267  }
268  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasUnfoldReg ( ) const
protected

Definition at line 272 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fUnfoldReg.

Referenced by CanCalculateCrossSection().

273  {
274  if(fUnfoldReg != 0)
275  return true;
276  else {
277  std::cout << "Unfolding reg not set" << std::endl;
278  return false;
279  }
280  }
OStream cout
Definition: OStream.cxx:6
bool ana::ICrossSectionAnalysis::HasWeights ( ) const
protected

Definition at line 212 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fWeights.

Referenced by CanFillSpectra().

213  {
214  if(!fWeights.empty())
215  return true;
216  else {
217  std::cout << "Weights not initialized" << std::endl;
218  return false;
219  }
220  }
OStream cout
Definition: OStream.cxx:6
std::map< XSecSysts::Syst_t, const Var * > fWeights
bool ana::ICrossSectionAnalysis::HasXSecs ( ) const
protected

Definition at line 248 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, and fXSec.

249  {
250  if(!fXSec.empty())
251  return true;
252  else {
253  std::cout << "CrossSectionAnalysis object has not caluclated cross sections" << std::endl;
254  return false;
255  }
256  }
OStream cout
Definition: OStream.cxx:6
std::map< XSecSysts::Syst_t, TH1 * > fXSec
void ana::ICrossSectionAnalysis::InitDataSpectrum ( SpectrumLoaderBase loader)

Definition at line 143 of file ICrossSectionAnalysis.cxx.

References ana::assert(), fData, fRecoAxis, fSelectionCut, HasRecoAxis(), HasSelectionCut(), ana::kNoShift, and ana::kUnweighted.

Referenced by demo_trivial_xsec_analysis().

144  {
145  assert( HasRecoAxis() &&
146  HasSelectionCut() &&
147  "Analysis not ready to fill data spectrum" );
148 
149  fData = new Spectrum(*loader,
150  *fRecoAxis,
151  *fSelectionCut,
152  kNoShift,
153  kUnweighted);
154  }
loader
Definition: demo0.py:10
std::vector< float > Spectrum
Definition: Constants.h:610
const SystShifts kNoShift
Definition: SystShifts.cxx:22
assert(nhit_max >=nhit_nbins)
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
void ana::ICrossSectionAnalysis::InitSystematicSpectra ( XSecSysts::Syst_t  syst,
CrossSectionSpectra xsec 
)

Definition at line 361 of file ICrossSectionAnalysis.cxx.

References fXSecSpectra.

363  {
364  fXSecSpectra.insert(std::pair<XSecSysts::Syst_t, CrossSectionSpectra *>
365  (syst, xsec));
366  }
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
Double_t xsec[nknots]
Definition: testXsec.C:47
void ana::ICrossSectionAnalysis::InitSystematicSpectra ( XSecSysts::Syst_t  syst,
SpectrumLoaderBase loader,
ISignalEstimator signal_est 
)

Definition at line 370 of file ICrossSectionAnalysis.cxx.

References ana::assert(), CanFillSpectra(), fENuBinning, fFidMax, fFidMin, fNuTruthWeights, fPDG, fRecoAxis, fSelectionCut, fSignalCut, fSystShifts, fTruthAxis, fWeights, fXSecSpectra, HasENuBinning(), and HasPDG().

373  {
374 
375  assert( CanFillSpectra() &&
376  HasENuBinning() &&
377  HasPDG() &&
378  "CrossSectionAnalysis object not yet ready to setup systematic spectra." );
379  fXSecSpectra.insert(std::pair<XSecSysts::Syst_t, CrossSectionSpectra *>
380  (syst,
381  new CrossSectionSpectra(*loader,
382  *fRecoAxis,
383  *fTruthAxis,
384  *fSelectionCut,
385  *fSignalCut,
386  signal_est,
387  fFidMax,
388  fFidMin,
389  *fENuBinning,
390  fPDG,
391  *fWeights[syst],
392  *fNuTruthWeights[syst],
393  *fSystShifts[syst])));
394  }
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
std::map< XSecSysts::Syst_t, const NuTruthVar * > fNuTruthWeights
loader
Definition: demo0.py:10
std::map< XSecSysts::Syst_t, const Var * > fWeights
std::map< XSecSysts::Syst_t, const SystShifts * > fSystShifts
assert(nhit_max >=nhit_nbins)
const NuTruthHistAxis * fTruthAxis
void ana::ICrossSectionAnalysis::InitSystematicSpectra ( XSecSysts::Syst_t  syst,
ReweightableSpectrum reco_true,
ISignalEstimator signal_est,
Spectrum flux,
Spectrum mc_selected,
Spectrum sig_selected_truth,
Spectrum sig_selected_reco,
Spectrum sig_truth 
)

Definition at line 398 of file ICrossSectionAnalysis.cxx.

References fXSecSpectra.

406  {
407  fXSecSpectra.insert(std::pair<XSecSysts::Syst_t, CrossSectionSpectra *>
408  (syst,
409  new CrossSectionSpectra(reco_true,
410  signal_est,
411  flux,
412  mc_selected,
413  sig_selected_truth,
414  sig_selected_reco,
415  sig_truth)));
416  }
Loaders::FluxType flux
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
int ana::ICrossSectionAnalysis::NDimensions ( )

Definition at line 589 of file ICrossSectionAnalysis.cxx.

References fNDims.

590  {
591  return fNDims;
592  }
double ana::ICrossSectionAnalysis::NTargets ( )

Definition at line 582 of file ICrossSectionAnalysis.cxx.

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

Referenced by CrossSection().

583  {
584  return fTarget.NNucleons();
585  }
double NNucleons() const
Number of nucleons (mass * avogadro&#39;s number)
Definition: TargetCount.h:31
virtual TH1* ana::ICrossSectionAnalysis::Purity ( XSecSysts::Syst_t  )
pure virtual

Analyzers override. Function that returns the purity of the specified sample

Implemented in ana::TrivialCrossSectionAnalysis.

Referenced by ana::PlotAllPurity().

virtual TH1* ana::ICrossSectionAnalysis::RelativeUncertainty ( XSecSysts::Syst_t  )
pure virtual

Analyzers override. Function that calculates relative uncertainty on the cross section result

Implemented in ana::TrivialCrossSectionAnalysis.

virtual void ana::ICrossSectionAnalysis::SaveTo ( TDirectory *  dir,
const std::string name 
) const
pure virtual

Analyzers override. Override to enable saving your analysis to a root file

Implemented in ana::TrivialCrossSectionAnalysis.

void ana::ICrossSectionAnalysis::SetAxis ( const HistAxis axis)

Definition at line 489 of file ICrossSectionAnalysis.cxx.

References allInOneTrainingPlots::axis, and fRecoAxis.

void ana::ICrossSectionAnalysis::SetAxisNT ( const NuTruthHistAxis axis)

Definition at line 496 of file ICrossSectionAnalysis.cxx.

References allInOneTrainingPlots::axis, and fTruthAxis.

497  {
498  fTruthAxis = axis;
499  }
const NuTruthHistAxis * fTruthAxis
void ana::ICrossSectionAnalysis::SetData ( Spectrum data)

Definition at line 158 of file ICrossSectionAnalysis.cxx.

References fData.

159  {
160  fData = data;
161  }
const XML_Char const XML_Char * data
Definition: expat.h:268
void ana::ICrossSectionAnalysis::SetFidMax ( TVector3  fidmax)

Definition at line 510 of file ICrossSectionAnalysis.cxx.

References fFidMax.

511  {
512  fFidMax = fidmax;
513  }
void ana::ICrossSectionAnalysis::SetFidMin ( TVector3  fidmin)

Definition at line 517 of file ICrossSectionAnalysis.cxx.

References fFidMin.

518  {
519  fFidMin = fidmin;
520  }
void ana::ICrossSectionAnalysis::SetNuTruthWeight ( XSecSysts::Syst_t  syst,
const NuTruthVar nt_var 
)

Definition at line 457 of file ICrossSectionAnalysis.cxx.

References fNuTruthWeights.

Referenced by ana::TrivialCrossSectionAnalysis::InitSystematicSpectra().

459  {
460  fNuTruthWeights.insert(std::pair<XSecSysts::Syst_t, const NuTruthVar *>
461  (syst, new NuTruthVar(*nt_var)));
462  }
_Var< caf::SRNeutrinoProxy > NuTruthVar
Var designed to be used over the nuTree, ie all neutrinos, not just those that got slices...
Definition: Var.h:82
std::map< XSecSysts::Syst_t, const NuTruthVar * > fNuTruthWeights
void ana::ICrossSectionAnalysis::SetPOT ( double  POT)

Definition at line 18 of file ICrossSectionAnalysis.cxx.

References fPOT, and POT.

19  {
20  fPOT = POT;
21  }
std::vector< double > POT
void ana::ICrossSectionAnalysis::SetSelectionCut ( const Cut cut)

Definition at line 475 of file ICrossSectionAnalysis.cxx.

References cut, and fSelectionCut.

476  {
477  fSelectionCut = cut;
478  }
const Cut cut
Definition: exporter_fd.C:30
void ana::ICrossSectionAnalysis::SetSignalCut ( const NuTruthCut cut)

Definition at line 482 of file ICrossSectionAnalysis.cxx.

References cut, and fSignalCut.

483  {
484  fSignalCut = cut;
485  }
const Cut cut
Definition: exporter_fd.C:30
void ana::ICrossSectionAnalysis::SetSystShifts ( XSecSysts::Syst_t  syst,
const SystShifts shift 
)

Definition at line 466 of file ICrossSectionAnalysis.cxx.

References fSystShifts.

Referenced by ana::TrivialCrossSectionAnalysis::InitSystematicSpectra().

468  {
469  fSystShifts.insert(std::pair<XSecSysts::Syst_t, const SystShifts *>
470  (syst, new SystShifts(*shift)));
471  }
std::map< XSecSysts::Syst_t, const SystShifts * > fSystShifts
void ana::ICrossSectionAnalysis::SetTarget ( TargetCount  target)

Definition at line 503 of file ICrossSectionAnalysis.cxx.

References fTarget.

504  {
505  fTarget = target;
506  }
const XML_Char * target
Definition: expat.h:268
void ana::ICrossSectionAnalysis::SetUnfoldingMethod ( UnfoldMethod_t  method)

Definition at line 687 of file ICrossSectionAnalysis.cxx.

References fUnfoldMethod.

Referenced by demo_trivial_xsec_analysis().

688  {
689  this->fUnfoldMethod = method;
690  }
void ana::ICrossSectionAnalysis::SetUnfoldingReg ( double  reg)

Definition at line 694 of file ICrossSectionAnalysis.cxx.

References fUnfoldReg.

Referenced by demo_trivial_xsec_analysis().

695  {
696  this->fUnfoldReg = reg;
697  }
void ana::ICrossSectionAnalysis::SetWeight ( XSecSysts::Syst_t  syst,
const Var var 
)

Definition at line 448 of file ICrossSectionAnalysis.cxx.

References fWeights.

Referenced by ana::TrivialCrossSectionAnalysis::InitSystematicSpectra().

450  {
451  fWeights.insert(std::pair<XSecSysts::Syst_t, const Var *>
452  (syst, new Var(*var)));
453  }
_Var< caf::SRProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:74
std::map< XSecSysts::Syst_t, const Var * > fWeights
const Spectrum * ana::ICrossSectionAnalysis::SignalEstimate ( XSecSysts::Syst_t  syst)

Definition at line 136 of file ICrossSectionAnalysis.cxx.

References fData, and fXSecSpectra.

Referenced by ana::PlotAllSignalEstimates(), and UnfoldedSignal().

137  {
138  return fXSecSpectra[syst]->GetSignalEstimator()->Signal(fData);
139  }
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
TH1 * ana::ICrossSectionAnalysis::ToHist ( const Spectrum spec,
double  POT = -1 
)
protected

Definition at line 596 of file ICrossSectionAnalysis.cxx.

References om::cout, allTimeWatchdog::endl, fNDims, ana::Spectrum::POT(), ana::Spectrum::ToTH1(), ana::Spectrum::ToTH2(), and ana::Spectrum::ToTH3().

Referenced by ana::TrivialCrossSectionAnalysis::Efficiency(), ana::TrivialCrossSectionAnalysis::Flux(), ana::TrivialCrossSectionAnalysis::Purity(), and UnfoldedSignal().

598  {
599  if(POT < 0)
600  POT = spec.POT();
601 
602  switch(fNDims) {
603  case(1) : {
604  return spec.ToTH1(POT);
605  }
606  case(2) : {
607  return spec.ToTH2(POT);
608  }
609  case(3) : {
610  return spec.ToTH3(POT);
611  }
612  default : {
613  std::cout << "Dimension of measurement undetermined." << std::endl;
614  abort();
615  }
616  } // end switch case
617  }
OStream cout
Definition: OStream.cxx:6
std::vector< double > POT
virtual std::pair<TH1 *, TH1 *> ana::ICrossSectionAnalysis::TotalErrors ( )
pure virtual

Analyzers override. Function that calculates total uncertainty on the cross section result Returns pair of histograms. First and second in pair are up and down shifts respectively

Implemented in ana::TrivialCrossSectionAnalysis.

const TH1 * ana::ICrossSectionAnalysis::UnfoldedSignal ( XSecSysts::Syst_t  syst)

Definition at line 552 of file ICrossSectionAnalysis.cxx.

References fUnfoldMethod, fUnfoldReg, fXSecSpectra, ana::kMaxEnt, ana::kSVD, ana::kTikhonov, SignalEstimate(), ToHist(), ana::UnfoldIterative::Truth(), ana::UnfoldSVD::Truth(), and ana::UnfoldTikhonov::Truth().

Referenced by CrossSection(), ana::TrivialCrossSectionAnalysis::FluxError(), ana::TrivialCrossSectionAnalysis::GenieError(), and ana::PlotAllUnfoldedSignalEstimates().

553  {
554  const ReweightableSpectrum * recotrue = fXSecSpectra[syst]->GetRecoTrue();
555  const Spectrum * signal = SignalEstimate(syst);
556 
557  switch(fUnfoldMethod) {
558  case(UnfoldMethod_t::kTikhonov) : {
559  UnfoldTikhonov unfold(*recotrue, fUnfoldReg);
560  return ToHist(unfold.Truth(*signal));
561 
562  }
563  case(UnfoldMethod_t::kSVD) : {
564  UnfoldSVD unfold(*recotrue, fUnfoldReg);
565  return ToHist(unfold.Truth(*signal));
566 
567  }
568  case(UnfoldMethod_t::kMaxEnt) : {
569  UnfoldMaxEnt unfold(*recotrue, fUnfoldReg);
570  return ToHist(unfold.Truth(*signal));
571 
572  }
573  default : {
574  UnfoldIterative unfold(*recotrue, fUnfoldReg);
575  return ToHist(unfold.Truth(*signal));
576  }
577  } // end switch-case
578  }
std::map< XSecSysts::Syst_t, CrossSectionSpectra * > fXSecSpectra
std::vector< float > Spectrum
Definition: Constants.h:610
TH1 * ToHist(const Spectrum &, double=-1)
const Spectrum * SignalEstimate(XSecSysts::Syst_t)

Member Data Documentation

const Spectrum* ana::ICrossSectionAnalysis::fData = NULL
protected
const Binning* ana::ICrossSectionAnalysis::fENuBinning = NULL
protected
TVector3 ana::ICrossSectionAnalysis::fFidMax
protected
TVector3 ana::ICrossSectionAnalysis::fFidMin
protected
bool ana::ICrossSectionAnalysis::fIsDifferential
protected
int ana::ICrossSectionAnalysis::fNDims = 0
protected
std::map<XSecSysts::Syst_t, const NuTruthVar *> ana::ICrossSectionAnalysis::fNuTruthWeights
protected
int ana::ICrossSectionAnalysis::fPDG = 0
protected
double ana::ICrossSectionAnalysis::fPOT
protected
const HistAxis* ana::ICrossSectionAnalysis::fRecoAxis = NULL
protected
const Cut* ana::ICrossSectionAnalysis::fSelectionCut = NULL
protected
const NuTruthCut* ana::ICrossSectionAnalysis::fSignalCut = NULL
protected
std::map<XSecSysts::Syst_t, const SystShifts *> ana::ICrossSectionAnalysis::fSystShifts
protected
TargetCount ana::ICrossSectionAnalysis::fTarget
protected
const NuTruthHistAxis* ana::ICrossSectionAnalysis::fTruthAxis = NULL
protected
UnfoldMethod_t ana::ICrossSectionAnalysis::fUnfoldMethod = kNone
protected
double ana::ICrossSectionAnalysis::fUnfoldReg = 0
protected
std::map<XSecSysts::Syst_t, const Var *> ana::ICrossSectionAnalysis::fWeights
protected
std::map<XSecSysts::Syst_t, TH1 *> ana::ICrossSectionAnalysis::fXSec
protected
std::map<XSecSysts::Syst_t, CrossSectionSpectra * > ana::ICrossSectionAnalysis::fXSecSpectra
protected

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