SingleSampleExperiment.h
Go to the documentation of this file.
1 #pragma once
2 
5 #include "CAFAna/Core/Spectrum.h"
6 #include "CAFAna/Core/ISyst.h"
7 
8 namespace ana
9 {
10  /// Dummy syst to communicate with \ref SingleSampleExperiment
11  class CosmicBkgScaleSyst: public ISyst
12  {
13  public:
14  CosmicBkgScaleSyst() : ISyst("cosmicScale", "Cosmic background scale") {}
15  void Shift(double, caf::SRProxy*, double&) const {}
16  };
17 
19 
20  /// Compare a single data spectrum to the MC + cosmics expectation
22  {
23  public:
24  /// \param pred Source of oscillated MC beam predictions
25  /// \param data Data spectrum to compare to
26  /// \param cosmic Cosmic ray background component
27  /// \param cosmicScaleError fractional uncertainty on cosmic normalization
29  const Spectrum& data,
30  const Spectrum& cosmic,
31  double cosmicScaleError = 0,
32  bool PoissonError = false);
33 
34  /// In MC studies you might not want to bother with cosmics
36  const Spectrum& data)
37  : fMC(pred), fData(data), fCosmic(0)
38  {
39  }
40 
41  virtual ~SingleSampleExperiment();
42 
43  virtual double ChiSq(osc::IOscCalculatorAdjustable* osc,
44  const SystShifts& syst = SystShifts::Nominal()) const override;
45 
46  virtual void Derivative(osc::IOscCalculator* calc,
47  const SystShifts& shift,
48  std::unordered_map<const ISyst*, double>& dch) const override;
49 
51  const SystShifts &syst = SystShifts::Nominal()) const override;
52 
53  virtual void SaveTo(TDirectory* dir) const override;
54  static std::unique_ptr<SingleSampleExperiment> LoadFrom(TDirectory* dir);
55 
56  // Didn't make provisions for copying fCosmic or fMC
59 
60  // need to explicitly declare move constructor since copy constructor is deleted
62  : fMC(s.fMC), fData(std::move(s.fData)), fCosmic(s.fCosmic), fCosmicScaleError(s.fCosmicScaleError)
63  {
64  s.fMC = nullptr;
65  s.fCosmic = nullptr;
66  s.fCosmicScaleError = 0;
67  };
68 
69  protected:
70  TH1D* PredHistIncCosmics(osc::IOscCalculator* calc,
71  const SystShifts& syst) const;
72  const IPrediction* fMC;
74  TH1D* fCosmic;
77  std::vector < std::pair <double, double> > fBinErrors;
78  };
79 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: CutFlow_header.h:5
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
Proxy for caf::StandardRecord.
Definition: SRProxy.h:1969
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
const CosmicBkgScaleSyst kCosmicBkgScaleSyst
static SystShifts Nominal()
Definition: SystShifts.h:34
Encapsulate code to systematically shift a caf::SRProxy.
Definition: ISyst.h:14
ISyst & operator=(const ISyst &)=delete
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
const XML_Char const XML_Char * data
Definition: expat.h:268
void SaveTo(const osc::IOscCalculator &x, TDirectory *dir)
SingleSampleExperiment(SingleSampleExperiment &&s)
const XML_Char * s
Definition: expat.h:262
Sum up livetimes from individual cosmic triggers.
SingleSampleExperiment(const IPrediction *pred, const Spectrum &data)
In MC studies you might not want to bother with cosmics.
std::vector< std::pair< double, double > > fBinErrors
void Shift(double, caf::SRProxy *, double &) const
Perform the systematic shift.
osc::OscCalculatorDumb calc
Oscillation probability calculators.
Definition: Calcs.h:5
TDirectory * dir
Definition: macro.C:5
Base class defining interface for experiments.
Definition: IExperiment.h:14
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
Dummy syst to communicate with SingleSampleExperiment.
std::unique_ptr< T > LoadFrom(TDirectory *dir)
Definition: LoadFromFile.h:18
Compare a single data spectrum to the MC + cosmics expectation.