Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
ana::CountingExperiment Class Reference

Compare a data spectrum to MC expectation using only the event count. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N19-12-08/CAFAna/Experiment/CountingExperiment.h"

Inheritance diagram for ana::CountingExperiment:
ana::IChiSqExperiment

Public Member Functions

 CountingExperiment (const IPrediction *p, const Spectrum &d, const Spectrum &cosmic)
 
 CountingExperiment (const IPrediction *p, const Spectrum &d)
 Version without cosmics may be wanted for MC studies. More...
 
 ~CountingExperiment ()
 
virtual double ChiSq (osc::IOscCalculatorAdjustable *osc, const SystShifts &syst=SystShifts::Nominal()) const override
 
virtual void SaveTo (TDirectory *dir) const override
 
virtual void Derivative (osc::IOscCalculator *calc, const SystShifts &shift, std::unordered_map< const ISyst *, double > &dchi) const
 

Static Public Member Functions

static std::unique_ptr< CountingExperimentLoadFrom (TDirectory *dir)
 

Protected Attributes

const IPredictionfMC
 
Spectrum fData
 
TH1 * fCosmic
 

Detailed Description

Compare a data spectrum to MC expectation using only the event count.

Definition at line 12 of file CountingExperiment.h.

Constructor & Destructor Documentation

ana::CountingExperiment::CountingExperiment ( const IPrediction p,
const Spectrum d,
const Spectrum cosmic 
)

Definition at line 17 of file CountingExperiment.cxx.

20  : fMC(p), fData(d),
21  fCosmic(cosmic.ToTH1(d.Livetime(), kLivetime))
22  {
23  }
const char * p
Definition: xmltok.h:285
Sum up livetimes from individual cosmic triggers.
Float_t d
Definition: plot.C:236
const IPrediction * fMC
ana::CountingExperiment::CountingExperiment ( const IPrediction p,
const Spectrum d 
)
inline

Version without cosmics may be wanted for MC studies.

Definition at line 17 of file CountingExperiment.h.

References ChiSq(), dir, LoadFrom(), ana::SystShifts::Nominal(), SaveTo(), plotSysts::syst, and ~CountingExperiment().

17 : fMC(p), fData(d), fCosmic(0) {}
const char * p
Definition: xmltok.h:285
Float_t d
Definition: plot.C:236
const IPrediction * fMC
ana::CountingExperiment::~CountingExperiment ( )

Definition at line 26 of file CountingExperiment.cxx.

References fCosmic.

Referenced by CountingExperiment().

27  {
28  delete fCosmic;
29  }

Member Function Documentation

double ana::CountingExperiment::ChiSq ( osc::IOscCalculatorAdjustable osc,
const SystShifts syst = SystShifts::Nominal() 
) const
overridevirtual

Implements ana::IChiSqExperiment.

Definition at line 32 of file CountingExperiment.cxx.

References fCosmic, fData, fMC, ana::Spectrum::Integral(), ana::LogLikelihood(), ana::Spectrum::POT(), and ana::IPrediction::PredictSyst().

Referenced by CountingExperiment().

34  {
35  double exp = fMC->PredictSyst(osc, syst).Integral(fData.POT());
36  if (fCosmic) exp += fCosmic->Integral(0,-1);
37  double obs = fData.Integral(fData.POT());
38 
39  return LogLikelihood(exp, obs);
40  }
stan::math::var LogLikelihood(const std::vector< stan::math::var > &exp, const TH1 *obs)
Variant that handles the prediction in the form of Stan vars.
Definition: StanUtils.cxx:11
double Integral(double exposure, double *err=0, EExposureType expotype=kPOT) const
Return total number of events scaled to pot.
Definition: Spectrum.cxx:742
virtual Spectrum PredictSyst(osc::IOscCalculator *calc, const SystShifts &syst) const
Definition: IPrediction.cxx:98
double POT() const
Definition: Spectrum.h:263
const IPrediction * fMC
string syst
Definition: plotSysts.py:176
virtual void ana::IChiSqExperiment::Derivative ( osc::IOscCalculator calc,
const SystShifts shift,
std::unordered_map< const ISyst *, double > &  dchi 
) const
inlinevirtualinherited

Reimplemented in ana::SingleSampleExperiment, ana::Ssth23Constraint, ana::AtmConstraint, ana::MultiExperiment, ana::T2KToyExperiment, ana::GaussianConstraint, ana::SolarConstraints, ana::Dmsq32Constraint, and ana::ReactorExperiment.

Definition at line 19 of file IChiSqExperiment.h.

References dir, and ana::IChiSqExperiment::SaveTo().

Referenced by ana::MinuitFitter::Gradient(), and ana::MinuitFitter::SupportsDerivatives().

22  {
23  // Optional to implement
24  //
25  // NB the convention is to *add* your contribution to the dchi values.
26  //
27  // If unimplemented, this default will be called, signaling no result to
28  // the caller
29  dchi.clear();
30  }
std::unique_ptr< CountingExperiment > ana::CountingExperiment::LoadFrom ( TDirectory *  dir)
static

Definition at line 59 of file CountingExperiment.cxx.

References ana::Spectrum::LoadFrom(), ana::LoadFrom< IPrediction >(), mc, runNovaSAM::release, and runNovaSAM::ret.

Referenced by CountingExperiment(), and ana::LoadFrom< IChiSqExperiment >().

60  {
61  TObjString* ptag = (TObjString*)dir->Get("type");
62  assert(ptag);
63  assert(ptag->GetString() == "CountingExperiment");
64 
65  assert(dir->GetDirectory("mc"));
66  assert(dir->GetDirectory("data"));
67 
68 
69  const IPrediction* mc = ana::LoadFrom<IPrediction>(dir->GetDirectory("mc")).release();
70  const std::unique_ptr<Spectrum> data = Spectrum::LoadFrom(dir->GetDirectory("data"));
71 
72  TH1* cosmic = 0;
73  if(dir->Get("cosmic")) cosmic = (TH1*)dir->Get("cosmic");
74 
75  auto ret = std::make_unique<CountingExperiment>(mc, *data);
76  if(cosmic) ret->fCosmic = cosmic;
77  return ret;
78  }
const XML_Char const XML_Char * data
Definition: expat.h:268
Sum up livetimes from individual cosmic triggers.
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir)
Definition: IPrediction.cxx:38
TDirectory * dir
Definition: macro.C:5
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir)
Definition: Spectrum.cxx:1055
void ana::CountingExperiment::SaveTo ( TDirectory *  dir) const
overridevirtual

Reimplemented from ana::IChiSqExperiment.

Definition at line 43 of file CountingExperiment.cxx.

References dir, fCosmic, fData, fMC, ana::IPrediction::SaveTo(), ana::Spectrum::SaveTo(), and tmp.

Referenced by CountingExperiment().

44  {
45  TDirectory* tmp = dir;
46 
47  dir->cd();
48  TObjString("CountingExperiment").Write("type");
49 
50  fMC->SaveTo(dir->mkdir("mc"));
51  fData.SaveTo(dir->mkdir("data"));
52 
53  if(fCosmic) fCosmic->Write("cosmic");
54 
55  tmp->cd();
56  }
virtual void SaveTo(TDirectory *dir) const
Float_t tmp
Definition: plot.C:36
const IPrediction * fMC
TDirectory * dir
Definition: macro.C:5
void SaveTo(TDirectory *dir) const
Definition: Spectrum.cxx:1029

Member Data Documentation

TH1* ana::CountingExperiment::fCosmic
protected

Definition at line 27 of file CountingExperiment.h.

Referenced by ChiSq(), SaveTo(), and ~CountingExperiment().

Spectrum ana::CountingExperiment::fData
protected

Definition at line 26 of file CountingExperiment.h.

Referenced by ChiSq(), and SaveTo().

const IPrediction* ana::CountingExperiment::fMC
protected

Definition at line 25 of file CountingExperiment.h.

Referenced by ChiSq(), and SaveTo().


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