All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 <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 override
 
- Public Member Functions inherited from ana::IExperiment
virtual ~IExperiment ()
 

Static Public Member Functions

static std::unique_ptr
< CountingExperiment
LoadFrom (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  }
pdgs p
Definition: selectors.fcl:22
const IPrediction * fMC
BEGIN_PROLOG cosmic
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.

17 : fMC(p), fData(d), fCosmic(0) {}
pdgs p
Definition: selectors.fcl:22
const IPrediction * fMC
ana::CountingExperiment::~CountingExperiment ( )

Definition at line 26 of file CountingExperiment.cxx.

27  {
28  delete fCosmic;
29  }

Member Function Documentation

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

Implements ana::IExperiment.

Definition at line 32 of file CountingExperiment.cxx.

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  }
double LogLikelihood(double e, double o)
The log-likelihood formula for a single bin.
double Integral(double exposure, double *err=0, EExposureType expotype=kPOT) const
Return total number of events scaled to pot.
virtual Spectrum PredictSyst(osc::IOscCalc *calc, const SystShifts &syst) const
Definition: IPrediction.cxx:62
double POT() const
Definition: Spectrum.h:289
const IPrediction * fMC
std::unique_ptr< CountingExperiment > ana::CountingExperiment::LoadFrom ( TDirectory *  dir)
static

Definition at line 59 of file CountingExperiment.cxx.

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  }
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir)
tuple dir
Definition: dropbox.py:28
std::unique_ptr< IPrediction > LoadFrom< IPrediction >(TDirectory *dir)
Definition: IPrediction.cxx:26
BEGIN_PROLOG cosmic
void ana::CountingExperiment::SaveTo ( TDirectory *  dir) const
overridevirtual

Reimplemented from ana::IExperiment.

Definition at line 43 of file CountingExperiment.cxx.

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
Definition: IPrediction.cxx:85
tuple dir
Definition: dropbox.py:28
const IPrediction * fMC
void SaveTo(TDirectory *dir) const

Member Data Documentation

TH1* ana::CountingExperiment::fCosmic
protected

Definition at line 27 of file CountingExperiment.h.

Spectrum ana::CountingExperiment::fData
protected

Definition at line 26 of file CountingExperiment.h.

const IPrediction* ana::CountingExperiment::fMC
protected

Definition at line 25 of file CountingExperiment.h.


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