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 
33  /// \brief Fallback to manual cosmic scaling
34  ///
35  /// \a cosmic must be already scaled so that its bin contents can be
36  /// directly summed onto \a data. If you're using the out-of-time part of
37  /// the beam spill, the easiest thing to do is to pass \ref
38  /// kTimingSidebandWeight as the weight argument when you fill it.
40  const Spectrum& data,
41  const TH1D* cosmic,
42  double cosmicScaleError = 0,
43  double fromlivetime = 1.,
44  double topotlivetime = 1.);
45 
46  /// In MC studies you might not want to bother with cosmics
48  const Spectrum& data)
49  : fMC(pred), fData(data), fCosmic(0)
50  {
51  }
52 
53  virtual ~SingleSampleExperiment();
54 
55  virtual double ChiSq(osc::IOscCalculatorAdjustable* osc,
56  const SystShifts& syst = SystShifts::Nominal()) const override;
57 
58  virtual void Derivative(osc::IOscCalculator* calc,
59  const SystShifts& shift,
60  std::unordered_map<const ISyst*, double>& dch) const override;
61 
62  virtual void SaveTo(TDirectory* dir) const override;
63  static std::unique_ptr<SingleSampleExperiment> LoadFrom(TDirectory* dir);
64 
65  // Didn't make provisions for copying fCosmic or fMC
68 
69  // need to explicitly declare move constructor since copy constructor is deleted
71  : fMC(s.fMC), fData(std::move(s.fData)), fCosmic(s.fCosmic), fCosmicScaleError(s.fCosmicScaleError)
72  {
73  s.fMC = nullptr;
74  s.fCosmic = nullptr;
75  s.fCosmicScaleError = 0;
76  };
77 
78  protected:
79  TH1D* PredHistIncCosmics(osc::IOscCalculator* calc,
80  const SystShifts& syst) const;
81 
82  const IPrediction* fMC;
84  TH1D* fCosmic;
85 
87  };
88 }
osc::OscCalculatorDumb calc
Oscillation analysis framework, runs over CAF files outside of ART.
General interface to oscillation calculators.
Definition: FwdDeclare.h:15
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
Proxy for StandardRecord.
Definition: SRProxy.h:2237
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
General interface to any calculator that lets you set the parameters.
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.
Base class defining interface for experiments.
void Shift(double, caf::SRProxy *, double &) const
Perform the systematic shift.
Oscillation probability calculators.
Definition: Calcs.h:5
TDirectory * dir
Definition: macro.C:5
string syst
Definition: plotSysts.py:176
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.