All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RatioExperiment.cxx
Go to the documentation of this file.
2 
6 
8 
9 #include "TDirectory.h"
10 #include "TObjString.h"
11 
12 #include "TH1.h"
13 
14 #include <cassert>
15 
16 namespace ana
17 {
18  //----------------------------------------------------------------------
20  const SystShifts& syst) const
21  {
22  osc->SetL(kBaselineSBND);
23  Spectrum predND = fPredND->PredictSyst(osc, syst);
24  osc->SetL(kBaselineIcarus);
25  Spectrum predFD = fPredFD->PredictSyst(osc, syst);
26 
27  predFD *= Ratio(fSpectND, predND);
28 
29  TH1D* hpred = predFD.ToTH1(fSpectFD.POT());
30  TH1D* hdata = fSpectFD.ToTH1(fSpectFD.POT());
31 
32  const double ret = LogLikelihood(hpred, hdata);
33 
34  HistCache::Delete(hpred);
35  HistCache::Delete(hdata);
36 
37  return ret;
38  }
39 
40  // //----------------------------------------------------------------------
41  // void RatioExperiment::SaveTo(TDirectory* dir) const
42  // {
43  // bool hasCorr = false;
44  // for(auto it: fSystCorrelations) if(!it.empty()) hasCorr = true;
45 
46  // if(hasCorr){
47  // std::cerr << "Warning in RatioExperiment: systematic correlations are set and will not be serialized by this call to SaveTo(). You will have to re-set them once you load the experiment back in." << std::endl;
48  // }
49 
50  // TDirectory* tmp = dir;
51 
52  // dir->cd();
53  // TObjString("RatioExperiment").Write("type");
54 
55  // for(unsigned int i = 0; i < fExpts.size(); ++i){
56  // fExpts[i]->SaveTo(dir->mkdir(TString::Format("expt%d", i)));
57  // }
58 
59  // tmp->cd();
60  // }
61 
62  // //----------------------------------------------------------------------
63  // std::unique_ptr<RatioExperiment> RatioExperiment::LoadFrom(TDirectory* dir)
64  // {
65  // TObjString* ptag = (TObjString*)dir->Get("type");
66  // assert(ptag);
67  // assert(ptag->GetString() == "RatioExperiment");
68 
69  // std::vector<const IExperiment*> expts;
70 
71  // for(int i = 0; ; ++i){
72  // TDirectory* subdir = dir->GetDirectory(TString::Format("expt%d", i));
73  // if(!subdir) break;
74 
75  // expts.push_back(ana::LoadFrom<IExperiment>(subdir).release());
76  // }
77 
78  // assert(!expts.empty());
79 
80  // return std::unique_ptr<RatioExperiment>(new RatioExperiment(expts));
81  // }
82 }
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
double LogLikelihood(double e, double o)
The log-likelihood formula for a single bin.
const double kBaselineIcarus
Definition: ExpInfo.h:10
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:16
const IPrediction * fPredFD
virtual double ChiSq(osc::IOscCalcAdjustable *osc, const SystShifts &syst=SystShifts::Nominal()) const override
process_name opflashCryoW ana
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:30
static void Delete(TH1D *&h)
Definition: HistCache.cxx:92
virtual Spectrum PredictSyst(osc::IOscCalc *calc, const SystShifts &syst) const
Definition: IPrediction.cxx:62
double POT() const
Definition: Spectrum.h:289
const IPrediction * fPredND
Represent the ratio between two spectra.
Definition: Ratio.h:8
const double kBaselineSBND
Definition: ExpInfo.h:8