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/N20-07-07/CAFAna/Experiment/CountingExperiment.h"

Inheritance diagram for ana::CountingExperiment:
ana::IExperiment

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
 
virtual stan::math::var LogLikelihood (osc::IOscCalculatorAdjustableStan *osc, const SystShifts &syst=kNoShift) 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

Reimplemented from ana::IExperiment.

Definition at line 32 of file CountingExperiment.cxx.

References stan::math::exp(), 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  // use namespace to disabiguate from method inherited from IExperiment
40  return ana::LogLikelihood(exp, obs);
41  }
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:753
virtual Spectrum PredictSyst(osc::IOscCalculator *calc, const SystShifts &syst) const
Definition: IPrediction.cxx:98
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
double POT() const
Definition: Spectrum.h:263
const IPrediction * fMC
string syst
Definition: plotSysts.py:176
virtual void ana::IExperiment::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 25 of file IExperiment.h.

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

28  {
29  // Optional to implement
30  //
31  // NB the convention is to *add* your contribution to the dchi values.
32  //
33  // If unimplemented, this default will be called, signaling no result to
34  // the caller
35  dchi.clear();
36  }
std::unique_ptr< CountingExperiment > ana::CountingExperiment::LoadFrom ( TDirectory *  dir)
static

Definition at line 60 of file CountingExperiment.cxx.

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

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

61  {
62  TObjString* ptag = (TObjString*)dir->Get("type");
63  assert(ptag);
64  assert(ptag->GetString() == "CountingExperiment");
65 
66  assert(dir->GetDirectory("mc"));
67  assert(dir->GetDirectory("data"));
68 
69 
70  const IPrediction* mc = ana::LoadFrom<IPrediction>(dir->GetDirectory("mc")).release();
71  const std::unique_ptr<Spectrum> data = Spectrum::LoadFrom(dir->GetDirectory("data"));
72 
73  TH1* cosmic = 0;
74  if(dir->Get("cosmic")) cosmic = (TH1*)dir->Get("cosmic");
75 
76  auto ret = std::make_unique<CountingExperiment>(mc, *data);
77  if(cosmic) ret->fCosmic = cosmic;
78  return ret;
79  }
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
assert(nhit_max >=nhit_nbins)
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir)
Definition: Spectrum.cxx:1066
virtual stan::math::var ana::IExperiment::LogLikelihood ( osc::IOscCalculatorAdjustableStan osc,
const SystShifts syst = kNoShift 
) const
inlinevirtualinherited

Reimplemented in test::GaussQuadExperiment.

Definition at line 38 of file IExperiment.h.

References ana::assert(), dir, and ana::IExperiment::SaveTo().

Referenced by ana::StanFitter::log_prob().

40  {
41  assert(false && "unimplemented");
42  return 0;
43  };
assert(nhit_max >=nhit_nbins)
void ana::CountingExperiment::SaveTo ( TDirectory *  dir) const
overridevirtual

Reimplemented from ana::IExperiment.

Definition at line 44 of file CountingExperiment.cxx.

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

Referenced by CountingExperiment().

45  {
46  TDirectory* tmp = dir;
47 
48  dir->cd();
49  TObjString("CountingExperiment").Write("type");
50 
51  fMC->SaveTo(dir->mkdir("mc"));
52  fData.SaveTo(dir->mkdir("data"));
53 
54  if(fCosmic) fCosmic->Write("cosmic");
55 
56  tmp->cd();
57  }
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:1040

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: