OscillatableSpectrum.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 #include "CAFAna/Core/Binning.h"
7 #include "CAFAna/Core/Spectrum.h"
11 
12 #include <string>
13 
14 #include "TMD5.h"
15 
16 class TH2;
17 class TH2D;
18 
19 #include "CAFAna/Core/FwdDeclare.h"
20 
21 namespace ana
22 {
23  class Binning;
24 
25  struct OscCache
26  {
27  std::unique_ptr<TMD5> hash;
29 
31  : spect(Spectrum::Uninitialized())
32  {}
33  };
34 
35  /// %Spectrum with true energy information, allowing it to be oscillated
37  {
38  public:
39  friend class SpectrumLoaderBase;
40  friend class SpectrumLoader;
41  friend class NullLoader;
42 
44  const Binning& bins,
46  const Var& var,
47  const Cut& cut,
48  const SystShifts& shift = kNoShift,
49  const Var& wei = kUnweighted);
50 
52  const HistAxis& axis,
53  const Cut& cut,
54  const SystShifts& shift = kNoShift,
55  const Var& wei = kUnweighted);
56 
57  OscillatableSpectrum(const Eigen::MatrixXd&& mat,
58  const HistAxis& recoAxis,
59  double pot, double livetime);
60 
61  /// The only valid thing to do with such a spectrum is to assign something
62  /// else into it.
64 
66 
67  /// Copy constructor
70  /// Assignment operator
71  OscillatableSpectrum& operator=(const OscillatableSpectrum& rhs);
73 
74  // Expose these ones directly
78 
79  /// Rescale bins so that \ref TrueEnergy will return \a target
81  /// Rescale bins so that \ref Unoscillated will return \a target
83 
84  // These under a different name
85  Spectrum Unoscillated() const {return UnWeighted();}
86  Spectrum TrueEnergy() const {return WeightingVariable();}
87 
88  Spectrum Oscillated(osc::IOscCalc* calc, int from, int to) const;
89  Spectrum Oscillated(osc::IOscCalcStan* calc, int from, int to) const;
90 
93 
94  OscillatableSpectrum& operator-=(const OscillatableSpectrum& rhs);
96 
97  void SaveTo(TDirectory* dir, const std::string& name) const;
98  static std::unique_ptr<OscillatableSpectrum> LoadFrom(TDirectory* dir, const std::string& name);
99 
100  protected:
101 
102  /// Constructor for Uninitialized()
104  {
105  }
106 
107  template<class T> Spectrum _Oscillated(osc::_IOscCalc<T>* calc, int from, int to) const;
108 
110  };
111 }
const XML_Char * name
Definition: expat.h:151
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
TDC::value_type operator-(TDC lhs, TDC rhs)
Definition: BaseProducts.h:47
TDC::value_type operator+=(TDC lhs, TDC rhs)
Definition: BaseProducts.h:53
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
void Fill(double x, double y, double w=1)
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
TDC::value_type operator+(TDC lhs, TDC rhs)
Definition: BaseProducts.h:49
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
ThreadLocal< OscCache > fCache
Spectrum with the value of a second variable, allowing for reweighting
void ReweightToRecoSpectrum(const Spectrum &target)
Recale bins so that Unweighted will return target.
OscillatableSpectrum()
Constructor for Uninitialized()
osc::OscCalcDumb calc
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const char * label
#define pot
static OscillatableSpectrum Uninitialized()
loader
Definition: demo0.py:10
const SystShifts kNoShift
Definition: SystShifts.cxx:22
Base class for the various types of spectrum loader.
const Binning bins
Definition: NumuCC_CPiBin.h:8
const Cut cut
Definition: exporter_fd.C:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
TDirectory * dir
Definition: macro.C:5
double livetime
Definition: saveFDMCHists.C:21
Dummy loader that doesn&#39;t load any files.
std::unique_ptr< TMD5 > hash
void ReweightToTrueSpectrum(const Spectrum &target)
Rescale bins so that WeightingVariable will return target.
Spectrum with true energy information, allowing it to be oscillated
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
Eigen::MatrixXd mat
TH2D * ToTH2(double pot) const
enum BeamMode string