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-12-03/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::IOscCalcAdjustable *osc, const SystShifts &syst=SystShifts::Nominal()) const override
 
virtual void SaveTo (TDirectory *dir, const std::string &name) const override
 
virtual stan::math::var LogLikelihood (osc::IOscCalcAdjustableStan *osc, const SystShifts &syst=kNoShift) const
 

Static Public Member Functions

static std::unique_ptr< CountingExperimentLoadFrom (TDirectory *dir, const std::string &name)
 

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 20 of file CountingExperiment.cxx.

23  : fMC(p), fData(d),
24  fCosmic(cosmic.ToTH1(d.Livetime(), kLivetime))
25  {
26  }
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(), string, 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 29 of file CountingExperiment.cxx.

References fCosmic.

Referenced by CountingExperiment().

30  {
31  delete fCosmic;
32  }

Member Function Documentation

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

Reimplemented from ana::IExperiment.

Definition at line 35 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().

37  {
38  double exp = fMC->PredictSyst(osc, syst).Integral(fData.POT());
39  if (fCosmic) exp += fCosmic->Integral(0,-1);
40  double obs = fData.Integral(fData.POT());
41 
42  // use namespace to disabiguate from method inherited from IExperiment
43  return ana::LogLikelihood(exp, obs);
44  }
double Integral(double exposure, double *err=0, EExposureType expotype=kPOT) const
Return total number of events scaled to pot.
Definition: Spectrum.cxx:249
double LogLikelihood(const Eigen::ArrayXd &ea, const Eigen::ArrayXd &oa, bool useOverflow)
The log-likelihood formula from the PDG.
Definition: EigenUtils.cxx:36
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
virtual Spectrum PredictSyst(osc::IOscCalc *calc, const SystShifts &syst) const
Definition: IPrediction.cxx:49
double POT() const
Definition: Spectrum.h:227
const IPrediction * fMC
std::unique_ptr< CountingExperiment > ana::CountingExperiment::LoadFrom ( TDirectory *  dir,
const std::string name 
)
static

Definition at line 68 of file CountingExperiment.cxx.

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

Referenced by CountingExperiment().

69  {
70  dir = dir->GetDirectory(name.c_str()); // switch to subdir
71  assert(dir);
72 
73  TObjString* ptag = (TObjString*)dir->Get("type");
74  assert(ptag);
75  assert(ptag->GetString() == "CountingExperiment");
76  delete ptag;
77 
78  assert(dir->GetDirectory("mc"));
79  assert(dir->GetDirectory("data"));
80 
81 
82  const IPrediction* mc = ana::LoadFrom<IPrediction>(dir, "mc").release();
83  const std::unique_ptr<Spectrum> data = Spectrum::LoadFrom(dir, "data");
84 
85  TH1* cosmic = 0;
86  if(dir->Get("cosmic")) cosmic = (TH1*)dir->Get("cosmic");
87 
88  delete dir;
89 
90  auto ret = std::make_unique<CountingExperiment>(mc, *data);
91  if(cosmic) ret->fCosmic = cosmic;
92  return ret;
93  }
const XML_Char * name
Definition: expat.h:151
const XML_Char const XML_Char * data
Definition: expat.h:268
Sum up livetimes from individual cosmic triggers.
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:535
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir, const std::string &label)
Definition: IPrediction.cxx:18
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
virtual stan::math::var ana::IExperiment::LogLikelihood ( osc::IOscCalcAdjustableStan osc,
const SystShifts syst = kNoShift 
) const
inlinevirtualinherited

Reimplemented in test::GaussQuadExperiment, ana::SingleSampleExperiment, and ana::MultiExperiment.

Definition at line 25 of file IExperiment.h.

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

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

27  {
28  assert(false && "unimplemented");
29  return 0;
30  };
assert(nhit_max >=nhit_nbins)
void ana::CountingExperiment::SaveTo ( TDirectory *  dir,
const std::string name 
) const
overridevirtual

Reimplemented from ana::IExperiment.

Definition at line 47 of file CountingExperiment.cxx.

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

Referenced by CountingExperiment().

48  {
49  TDirectory* tmp = dir;
50 
51  dir = dir->mkdir(name.c_str()); // switch to subdir
52  dir->cd();
53 
54  TObjString("CountingExperiment").Write("type");
55 
56  fMC->SaveTo(dir, "mc");
57  fData.SaveTo(dir, "data");
58 
59  if(fCosmic) fCosmic->Write("cosmic");
60 
61  dir->Write();
62  delete dir;
63 
64  tmp->cd();
65  }
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
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:506
const IPrediction * fMC
TDirectory * dir
Definition: macro.C:5

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: