Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
ana::OscillatableSpectrum Class Reference

Spectrum with true energy information, allowing it to be oscillated More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-02-16/CAFAna/Core/OscillatableSpectrum.h"

Inheritance diagram for ana::OscillatableSpectrum:
ana::ReweightableSpectrum ana::OscCache< Spectrum > ana::OscCache< SpectrumStan > ana::NDOscillatableSpectrum

Public Member Functions

 OscillatableSpectrum (std::string label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 OscillatableSpectrum (SpectrumLoaderBase &loader, const HistAxis &axis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
 
 OscillatableSpectrum (std::string label, const Binning &bins)
 
 OscillatableSpectrum (std::string label, double pot, double livetime, const Binning &bins)
 
 OscillatableSpectrum (TH2 *h, const std::vector< std::string > &labels, const std::vector< Binning > &bins, double pot, double livetime)
 
 ~OscillatableSpectrum ()
 
 OscillatableSpectrum (const OscillatableSpectrum &rhs)
 Copy constructor. More...
 
 OscillatableSpectrum (OscillatableSpectrum &&rhs)
 
OscillatableSpectrumoperator= (const OscillatableSpectrum &rhs)
 Assignment operator. More...
 
OscillatableSpectrumoperator= (OscillatableSpectrum &&rhs)
 
Spectrum Unoscillated () const
 
Spectrum TrueEnergy () const
 
Spectrum Oscillated (osc::IOscCalculator *calc, int from, int to) const
 
SpectrumStan Oscillated (osc::IOscCalculatorStan *calc, int from, int to) const
 
void Scale (double scale) const
 
OscillatableSpectrumoperator+= (const OscillatableSpectrum &rhs)
 
OscillatableSpectrum operator+ (const OscillatableSpectrum &rhs) const
 
OscillatableSpectrumoperator-= (const OscillatableSpectrum &rhs)
 
OscillatableSpectrum operator- (const OscillatableSpectrum &rhs) const
 
void SaveTo (TDirectory *dir) const
 
double POT () const
 
double Livetime () const
 
ReweightableSpectrumoperator+= (const ReweightableSpectrum &rhs)
 
ReweightableSpectrum operator+ (const ReweightableSpectrum &rhs) const
 
const VarReweightVar () const
 The variable that will be used to fill the y-axis. More...
 
const VarReweightVarz () const
 
bool Is3D () const
 
void Fill (double x, double y, double w=1)
 
TH2D * ToTH2 (double pot) const
 
TH3D * ToTH3 (double pot) const
 
Spectrum UnWeighted () const
 
Spectrum WeightingVariable () const
 
Spectrum WeightedBy (const TH1 *weights) const
 
void ReweightByRecoRatio (const TH1 *weights)
 Rescale bins by a ratio TH1*. More...
 
void ReweightByRecoRatio (const TH2 *weights)
 
void ReweightByTrueRatio (const TH1D *weights)
 
void ReweightToTrueSpectrum (const Spectrum &target)
 Rescale bins so that WeightingVariable will return target. More...
 
void ReweightToRecoSpectrum (const Spectrum &target)
 Recale bins so that Unweighted will return target. More...
 
void Clear ()
 
unsigned int NDimensions () const
 
std::vector< std::string > GetLabels () const
 
std::vector< BinningGetBinnings () const
 

Static Public Member Functions

static std::unique_ptr< OscillatableSpectrumLoadFrom (TDirectory *dir)
 

Protected Member Functions

 OscillatableSpectrum (const std::vector< std::string > &labels, const std::vector< Binning > &bins, const Var &rwVar)
 
 OscillatableSpectrum (const std::string &label, const Binning &bins, const Var &rwVar)
 
void RemoveLoader (SpectrumLoaderBase *)
 
void AddLoader (SpectrumLoaderBase *)
 

Protected Attributes

Var fRWVar
 What goes on the y axis? More...
 
Var fRWVarz
 
bool fIs3D = false
 
TH3D * f3DHist
 
TH2D * fHistD
 
TH2F * fHistF
 
double fPOT
 
double fLivetime
 
std::vector< std::string > fLabels
 
std::vector< BinningfBins
 
std::vector< std::string > fTrueLabels
 
std::set< SpectrumLoaderBase * > fLoaderCount
 This count is maintained by SpectrumLoader, as a sanity check. More...
 
std::unique_ptr< TMD5 > hash
 
Spectrum spect
 
std::unique_ptr< TMD5 > hash
 
SpectrumStan spect
 

Friends

class SpectrumLoaderBase
 
class SpectrumLoader
 
class NullLoader
 

Detailed Description

Spectrum with true energy information, allowing it to be oscillated

Definition at line 34 of file OscillatableSpectrum.h.

Constructor & Destructor Documentation

ana::OscillatableSpectrum::OscillatableSpectrum ( std::string  label,
const Binning bins,
SpectrumLoaderBase loader,
const Var var,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

Definition at line 31 of file OscillatableSpectrum.cxx.

References ana::SpectrumLoaderBase::AddReweightableSpectrum(), ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fTrueLabels, ana::gFloatMode, ana::HistCache::NewTH2D(), and ana::HistCache::NewTH2F().

38  {
39  fTrueLabels = std::vector<std::string>(1, "True Energy (GeV)");
40 
41  DontAddDirectory guard;
42 
43  if(gFloatMode)
45  else
47 
48  loader.AddReweightableSpectrum(*this, var, cut, shift, wei);
49  }
static TH2D * NewTH2D(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:80
var
static TH2F * NewTH2F(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:92
const char * label
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:87
loader
Definition: demo0.py:10
const HistogramTypePolicy gFloatMode
const Binning bins
Definition: NumuCC_CPiBin.h:8
const Cut cut
Definition: exporter_fd.C:30
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
std::vector< std::string > fTrueLabels
ana::OscillatableSpectrum::OscillatableSpectrum ( SpectrumLoaderBase loader,
const HistAxis axis,
const Cut cut,
const SystShifts shift = kNoShift,
const Var wei = kUnweighted 
)

Definition at line 52 of file OscillatableSpectrum.cxx.

References ana::SpectrumLoaderBase::AddReweightableSpectrum(), ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fTrueLabels, ana::GenericHistAxis< T >::GetMultiDBinning(), ana::GenericHistAxis< T >::GetMultiDVar(), ana::gFloatMode, ana::HistCache::NewTH2D(), and ana::HistCache::NewTH2F().

57  : ReweightableSpectrum(axis.GetLabels(), axis.GetBinnings(), kTrueE)
58  {
59  fTrueLabels = std::vector<std::string>(1, "True Energy (GeV)");
60 
61  DontAddDirectory guard;
62 
63  if(gFloatMode)
64  fHistF = HistCache::NewTH2F("", axis.GetMultiDBinning());
65  else
66  fHistD = HistCache::NewTH2D("", axis.GetMultiDBinning());
67 
68  Var multiDVar = axis.GetMultiDVar();
69 
70  loader.AddReweightableSpectrum(*this, multiDVar, cut, shift, wei);
71  }
static TH2D * NewTH2D(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:80
GenericVar< caf::SRProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:76
static TH2F * NewTH2F(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:92
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:87
loader
Definition: demo0.py:10
const HistogramTypePolicy gFloatMode
const Cut cut
Definition: exporter_fd.C:30
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
std::vector< std::string > fTrueLabels
ana::OscillatableSpectrum::OscillatableSpectrum ( std::string  label,
const Binning bins 
)

Definition at line 74 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fPOT, ana::ReweightableSpectrum::fTrueLabels, ana::gFloatMode, ana::HistCache::NewTH2D(), and ana::HistCache::NewTH2F().

77  {
78  fTrueLabels = std::vector<std::string>(1, "True Energy (GeV)");
79 
80  DontAddDirectory guard;
81 
82  fPOT = 0;
83  fLivetime = 0;
84 
85  if(gFloatMode)
87  else
89  }
static TH2D * NewTH2D(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:80
static TH2F * NewTH2F(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:92
const char * label
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:87
const HistogramTypePolicy gFloatMode
const Binning bins
Definition: NumuCC_CPiBin.h:8
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
std::vector< std::string > fTrueLabels
ana::OscillatableSpectrum::OscillatableSpectrum ( std::string  label,
double  pot,
double  livetime,
const Binning bins 
)

Definition at line 92 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fPOT, ana::ReweightableSpectrum::fTrueLabels, ana::gFloatMode, livetime, ana::HistCache::NewTH2D(), ana::HistCache::NewTH2F(), and pot.

95  {
96  fTrueLabels = std::vector<std::string>(1, "True Energy (GeV)");
97 
98  DontAddDirectory guard;
99 
100  fPOT = pot;
102 
103  if(gFloatMode)
105  else
107  }
static TH2D * NewTH2D(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:80
static TH2F * NewTH2F(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:92
const char * label
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:87
#define pot
const HistogramTypePolicy gFloatMode
const Binning bins
Definition: NumuCC_CPiBin.h:8
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
std::vector< std::string > fTrueLabels
ana::OscillatableSpectrum::OscillatableSpectrum ( TH2 *  h,
const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
double  pot,
double  livetime 
)

Definition at line 110 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fTrueLabels.

115  {
116  fTrueLabels = std::vector<std::string>(1, "True Energy (GeV)");
117  }
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:87
#define pot
const Binning bins
Definition: NumuCC_CPiBin.h:8
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
h
Definition: demo3.py:41
std::vector< std::string > fTrueLabels
ana::OscillatableSpectrum::~OscillatableSpectrum ( )

Definition at line 120 of file OscillatableSpectrum.cxx.

References ana::HistCache::Delete(), ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLoaderCount, and demo0::loader.

121  {
122  // Nulls fHist out, so it's safe that ~ReweightableSpectrum tries too
125 
127  loader->RemoveReweightableSpectrum(this);
128  }
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
loader
Definition: demo0.py:10
ana::OscillatableSpectrum::OscillatableSpectrum ( const OscillatableSpectrum rhs)

Copy constructor.

Definition at line 131 of file OscillatableSpectrum.cxx.

References ana::HistCache::Copy(), ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fLoaderCount, ana::ReweightableSpectrum::fPOT, ana::OscCache< SpectrumStan >::hash, ana::OscCache< T >::OscCache(), and ana::OscCache< SpectrumStan >::spect.

132  : ReweightableSpectrum(rhs.fLabels, rhs.fBins, kTrueE)
133  {
134  DontAddDirectory guard;
135 
136  if (rhs.fHistD) fHistD = HistCache::Copy(rhs.fHistD);
137  if (rhs.fHistF) fHistF = HistCache::Copy(rhs.fHistF);
138 
139  fPOT = rhs.fPOT;
140  fLivetime = rhs.fLivetime;
141 
142  if (rhs.OscCache<Spectrum>::hash)
143  {
144  OscCache<Spectrum>::spect = rhs.OscCache<Spectrum>::spect;
145  OscCache<Spectrum>::hash = std::make_unique<TMD5>(*rhs.OscCache<Spectrum>::hash);
146  }
147  if (rhs.OscCache<SpectrumStan>::hash)
148  {
149  OscCache<SpectrumStan>::spect = rhs.OscCache<SpectrumStan>::spect;
150  OscCache<SpectrumStan>::hash = std::make_unique<TMD5>(*rhs.OscCache<SpectrumStan>::hash);
151  }
152 
153  assert( rhs.fLoaderCount.empty() ); // Copying with pending loads is unexpected
154  }
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:175
std::unique_ptr< TMD5 > hash
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:87
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
ana::OscillatableSpectrum::OscillatableSpectrum ( OscillatableSpectrum &&  rhs)

Definition at line 157 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fPOT, ana::OscCache< SpectrumStan >::hash, and ana::OscCache< SpectrumStan >::spect.

158  : ReweightableSpectrum(rhs.fLabels, rhs.fBins, kTrueE)
159  {
160  DontAddDirectory guard;
161 
162  fHistD = rhs.fHistD;
163  fHistF = rhs.fHistF;
164  rhs.fHistD = 0;
165  rhs.fHistF = 0;
166 
167  fPOT = rhs.fPOT;
168  fLivetime = rhs.fLivetime;
169 
170  if (rhs.OscCache<Spectrum>::hash)
171  {
172  OscCache<Spectrum>::spect = std::move(rhs.OscCache<Spectrum>::spect);
173  OscCache<Spectrum>::hash = std::move(rhs.OscCache<Spectrum>::hash);
174  }
175  if (rhs.OscCache<SpectrumStan>::hash)
176  {
177  OscCache<SpectrumStan>::spect = std::move(rhs.OscCache<SpectrumStan>::spect);
178  OscCache<SpectrumStan>::hash = std::move(rhs.OscCache<SpectrumStan>::hash);
179  }
180 
181  assert( rhs.fLoaderCount.empty() ); // Copying with pending loads is unexpected
182  }
std::unique_ptr< TMD5 > hash
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:87
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
ana::OscillatableSpectrum::OscillatableSpectrum ( const std::vector< std::string > &  labels,
const std::vector< Binning > &  bins,
const Var rwVar 
)
inlineprotected

Definition at line 107 of file OscillatableSpectrum.h.

110  : ReweightableSpectrum(labels, bins, rwVar)
111  {
112  }
const Binning bins
Definition: NumuCC_CPiBin.h:8
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
ana::OscillatableSpectrum::OscillatableSpectrum ( const std::string &  label,
const Binning bins,
const Var rwVar 
)
inlineprotected

Definition at line 114 of file OscillatableSpectrum.h.

117  : ReweightableSpectrum(label, bins, rwVar)
118  {
119  }
const char * label
const Binning bins
Definition: NumuCC_CPiBin.h:8
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)

Member Function Documentation

void ana::ReweightableSpectrum::AddLoader ( SpectrumLoaderBase p)
protectedinherited

Definition at line 668 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fLoaderCount.

Referenced by ana::SpectrumLoaderBase::AddReweightableSpectrum(), and ana::ReweightableSpectrum::ReweightableSpectrum().

669  { fLoaderCount.insert(p); }
const char * p
Definition: xmltok.h:285
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
void ana::ReweightableSpectrum::Clear ( )
inherited
void ana::ReweightableSpectrum::Fill ( double  x,
double  y,
double  w = 1 
)
inherited

Definition at line 318 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, and ana::ReweightableSpectrum::fHistF.

Referenced by ana::ReweightableSpectrum::Is3D().

319  {
320  if(fHistD) fHistD->Fill(x, y, w);
321  if(fHistF) fHistF->Fill(x, y, w);
322  }
Float_t w
Definition: plot.C:20
std::vector<Binning> ana::ReweightableSpectrum::GetBinnings ( ) const
inlineinherited
std::vector<std::string> ana::ReweightableSpectrum::GetLabels ( ) const
inlineinherited
bool ana::ReweightableSpectrum::Is3D ( ) const
inlineinherited
double ana::OscillatableSpectrum::Livetime ( ) const
inline
std::unique_ptr< OscillatableSpectrum > ana::OscillatableSpectrum::LoadFrom ( TDirectory *  dir)
static

Definition at line 418 of file OscillatableSpectrum.cxx.

References ana::bins, genie::utils::style::Format(), ana::Binning::FromTAxis(), MECModelEnuComparisons::i, label, PandAna.Demos.pi0_spectra::labels, ana::Binning::LoadFrom(), runNovaSAM::ret, ana::OscCache< SpectrumStan >::spect, cvnie::subdir, and getGoodRuns4SAM::tag.

Referenced by ana::NoReweight::LoadFrom(), ana::TruthReweight::LoadFrom(), ana::RecoReweight::LoadFrom(), ana::FluxReweight::LoadFrom(), and nue_bg_stat_err_calc().

419  {
420  TObjString* tag = (TObjString*)dir->Get("type");
421  assert(tag);
422  assert(tag->GetString() == "OscillatableSpectrum");
423  delete tag;
424 
425  TH2D* spectD = 0;
426  TH2F* spectF = 0;
427  dir->GetObject("hist", spectD);
428  dir->GetObject("hist", spectF);
429  assert(spectD || spectF);
430  TH2* spect = spectD ? (TH2*)spectD : (TH2*)spectF;
431 
432  TH1* hPot = (TH1*)dir->Get("pot");
433  assert(hPot);
434  TH1* hLivetime = (TH1*)dir->Get("livetime");
435  assert(hLivetime);
436 
437  std::vector<std::string> labels;
438  std::vector<Binning> bins;
439 
440  for(int i = 0; ; ++i){
441  TDirectory* subdir = dir->GetDirectory(TString::Format("bins%d", i));
442  if(!subdir) break;
443  bins.push_back(*Binning::LoadFrom(subdir));
444  TObjString* label = (TObjString*)dir->Get(TString::Format("label%d", i));
445  labels.push_back(label ? label->GetString().Data() : "");
446  delete subdir;
447  delete label;
448  }
449 
450  if(bins.empty() && labels.empty()){
451  // Must be an old file. Make an attempt at backwards compatibility.
452  bins.push_back(Binning::FromTAxis(spect->GetXaxis()));
453  labels.push_back(spect->GetXaxis()->GetTitle());
454  }
455 
456  std::unique_ptr<OscillatableSpectrum> ret;
457  ret = std::make_unique<OscillatableSpectrum>(spect,
458  labels, bins,
459  hPot->GetBinContent(1),
460  hLivetime->GetBinContent(1));
461 
462  delete spectD;
463  delete spectF;
464  delete hPot;
465  delete hLivetime;
466  return ret;
467  }
subdir
Definition: cvnie.py:7
static Binning FromTAxis(const TAxis *ax)
Definition: Binning.cxx:122
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Definition: AddMC.C:8
const char * label
#define pot
const Binning bins
Definition: NumuCC_CPiBin.h:8
TDirectory * dir
Definition: macro.C:5
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
#define for
Definition: msvc_pragmas.h:3
static std::unique_ptr< Binning > LoadFrom(TDirectory *dir)
Definition: Binning.cxx:221
unsigned int ana::ReweightableSpectrum::NDimensions ( ) const
inlineinherited

Definition at line 111 of file ReweightableSpectrum.h.

References ana::ReweightableSpectrum::fLabels.

111 {return fLabels.size();}
std::vector< std::string > fLabels
ReweightableSpectrum ana::ReweightableSpectrum::operator+ ( const ReweightableSpectrum rhs) const
inherited

Definition at line 243 of file ReweightableSpectrum.cxx.

References runNovaSAM::ret.

Referenced by ana::ReweightableSpectrum::ReweightableSpectrum().

244  {
245  ReweightableSpectrum ret = *this;
246  ret += rhs;
247  return ret;
248  }
ReweightableSpectrum(SpectrumLoaderBase &loader, const HistAxis &recoAxis, const HistAxis &trueAxis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
OscillatableSpectrum ana::OscillatableSpectrum::operator+ ( const OscillatableSpectrum rhs) const

Definition at line 345 of file OscillatableSpectrum.cxx.

References runNovaSAM::ret.

346  {
347  OscillatableSpectrum ret = *this;
348  ret += rhs;
349  return ret;
350  }
OscillatableSpectrum(std::string label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
ReweightableSpectrum & ana::ReweightableSpectrum::operator+= ( const ReweightableSpectrum rhs)
inherited

Definition at line 228 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fPOT, demo3::h, and rh.

Referenced by ana::ReweightableSpectrum::ReweightableSpectrum().

229  {
230  if(rhs.fPOT){
231  TH1* h = fHistD ? (TH1*)fHistD : (TH1*)fHistF;
232  TH1* rh = rhs.fHistD ? (TH1*)rhs.fHistD : (TH1*)rhs.fHistF;
233  h->Add(rh, fPOT/rhs.fPOT);
234  }
235  else{
236  assert(!rhs.fHistD || rhs.fHistD->Integral() == 0);
237  assert(!rhs.fHistF || rhs.fHistF->Integral() == 0);
238  }
239  return *this;
240  }
TH2 * rh
Definition: drawXsec.C:5
h
Definition: demo3.py:41
OscillatableSpectrum & ana::OscillatableSpectrum::operator+= ( const OscillatableSpectrum rhs)

Definition at line 324 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fPOT, demo3::h, and rh.

325  {
326  if(rhs.fPOT){
327  TH1* h = fHistD ? (TH2*)fHistD : (TH2*)fHistF;
328  TH1* rh = rhs.fHistD ? (TH2*)rhs.fHistD : (TH2*)rhs.fHistF;
329  h->Add(rh, fPOT/rhs.fPOT);
330  }
331  else{
332  // How can it have events but no POT?
333  assert(!rhs.fHistD || rhs.fHistD->Integral() == 0);
334  assert(!rhs.fHistF || rhs.fHistF->Integral() == 0);
335  }
336 
337  // invalidate
338  OscCache<Spectrum>::hash.reset(nullptr);
339  OscCache<SpectrumStan>::hash.reset(nullptr);
340 
341  return *this;
342  }
TH2 * rh
Definition: drawXsec.C:5
std::unique_ptr< TMD5 > hash
h
Definition: demo3.py:41
OscillatableSpectrum ana::OscillatableSpectrum::operator- ( const OscillatableSpectrum rhs) const

Definition at line 374 of file OscillatableSpectrum.cxx.

References runNovaSAM::ret.

375  {
376  OscillatableSpectrum ret = *this;
377  ret -= rhs;
378  return ret;
379  }
OscillatableSpectrum(std::string label, const Binning &bins, SpectrumLoaderBase &loader, const Var &var, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
OscillatableSpectrum & ana::OscillatableSpectrum::operator-= ( const OscillatableSpectrum rhs)

Definition at line 353 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fPOT, demo3::h, and rh.

354  {
355  if(rhs.fPOT){
356  TH1* h = fHistD ? (TH2*)fHistD : (TH2*)fHistF;
357  TH1* rh = rhs.fHistD ? (TH2*)rhs.fHistD : (TH2*)rhs.fHistF;
358  h->Add(rh, -fPOT/rhs.fPOT);
359  }
360  else{
361  // How can it have events but no POT?
362  assert(!rhs.fHistD || rhs.fHistD->Integral() == 0);
363  assert(!rhs.fHistF || rhs.fHistF->Integral() == 0);
364  }
365 
366  // invalidate
367  OscCache<Spectrum>::hash.reset(nullptr);
368  OscCache<SpectrumStan>::hash.reset(nullptr);
369 
370  return *this;
371  }
TH2 * rh
Definition: drawXsec.C:5
std::unique_ptr< TMD5 > hash
h
Definition: demo3.py:41
OscillatableSpectrum & ana::OscillatableSpectrum::operator= ( const OscillatableSpectrum rhs)

Assignment operator.

Definition at line 185 of file OscillatableSpectrum.cxx.

References ana::HistCache::Copy(), ana::HistCache::Delete(), ana::ReweightableSpectrum::fBins, ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fLoaderCount, ana::ReweightableSpectrum::fPOT, ana::OscCache< SpectrumStan >::hash, ana::OscCache< T >::OscCache(), and ana::OscCache< SpectrumStan >::spect.

186  {
187  if(this == &rhs) return *this;
188 
189  DontAddDirectory guard;
190 
193  if(rhs.fHistD) fHistD = HistCache::Copy(rhs.fHistD);
194  if(rhs.fHistF) fHistF = HistCache::Copy(rhs.fHistF);
195  fPOT = rhs.fPOT;
196  fLivetime = rhs.fLivetime;
197  fLabels = rhs.fLabels;
198  fBins = rhs.fBins;
199 
200  if (rhs.OscCache<Spectrum>::hash)
201  {
202  OscCache<Spectrum>::spect = rhs.OscCache<Spectrum>::spect;
203  OscCache<Spectrum>::hash = std::make_unique<TMD5>(*rhs.OscCache<Spectrum>::hash);
204  }
205  if (rhs.OscCache<SpectrumStan>::hash)
206  {
207  OscCache<SpectrumStan>::spect = rhs.OscCache<SpectrumStan>::spect;
208  OscCache<SpectrumStan>::hash = std::make_unique<TMD5>(*rhs.OscCache<SpectrumStan>::hash);
209  }
210 
211  assert( rhs.fLoaderCount.empty() ); // Copying with pending loads is unexpected
212  assert( fLoaderCount.empty() ); // Copying with pending loads is unexpected
213 
214  return *this;
215  }
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:175
std::unique_ptr< TMD5 > hash
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
std::vector< std::string > fLabels
std::vector< Binning > fBins
OscillatableSpectrum & ana::OscillatableSpectrum::operator= ( OscillatableSpectrum &&  rhs)

Definition at line 218 of file OscillatableSpectrum.cxx.

References ana::HistCache::Delete(), ana::ReweightableSpectrum::fBins, ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fLoaderCount, ana::ReweightableSpectrum::fPOT, ana::OscCache< SpectrumStan >::hash, and ana::OscCache< SpectrumStan >::spect.

219  {
220  if(this == &rhs) return *this;
221 
222  DontAddDirectory guard;
223 
226  fHistD = rhs.fHistD;
227  fHistF = rhs.fHistF;
228  rhs.fHistD = 0;
229  rhs.fHistF = 0;
230  fPOT = rhs.fPOT;
231  fLivetime = rhs.fLivetime;
232  fLabels = rhs.fLabels;
233  fBins = rhs.fBins;
234 
235  if (rhs.OscCache<Spectrum>::hash)
236  {
237  OscCache<Spectrum>::spect = std::move(rhs.OscCache<Spectrum>::spect);
238  OscCache<Spectrum>::hash = std::move(rhs.OscCache<Spectrum>::hash);
239  }
240  if (rhs.OscCache<SpectrumStan>::hash)
241  {
242  OscCache<SpectrumStan>::spect = std::move(rhs.OscCache<SpectrumStan>::spect);
243  OscCache<SpectrumStan>::hash = std::move(rhs.OscCache<SpectrumStan>::hash);
244  }
245 
246  assert( rhs.fLoaderCount.empty() ); // Copying with pending loads is unexpected
247  assert( fLoaderCount.empty() ); // Copying with pending loads is unexpected
248 
249  return *this;
250  }
std::unique_ptr< TMD5 > hash
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
std::vector< std::string > fLabels
std::vector< Binning > fBins
Spectrum ana::OscillatableSpectrum::Oscillated ( osc::IOscCalculator calc,
int  from,
int  to 
) const

Definition at line 253 of file OscillatableSpectrum.cxx.

References bin, calc, ana::HistCache::Delete(), ana::ReweightableSpectrum::fBins, ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fPOT, osc::_IOscCalculator< T >::GetParamsHash(), demo3::h, ana::OscCache< SpectrumStan >::hash, MECModelEnuComparisons::i, osc::_IOscCalculator< T >::P(), runNovaSAM::ret, ana::OscCurve::ToTH1(), w, ana::ReweightableSpectrum::WeightedBy(), X, submit_syst::x, Y, and submit_syst::y.

Referenced by demo3(), make_extrap_figure(), numu_cut_flow(), ana::FDPredictionSterile::Predict(), ana::PredictionSterile::PredictComponent(), ana::PredictionNueRebinSA::PredictComponent(), ana::FDPredictionSterile::PredictComponent(), and ana::PredictionExtendToPeripheral::PredictComponent().

255  {
256  TMD5* hash = calc->GetParamsHash();
257  if(hash && OscCache<Spectrum>::hash && *hash == *OscCache<Spectrum>::hash){
258  delete hash;
260  }
261 
262  const OscCurve curve(calc, from, to);
263  TH1D* Ps = curve.ToTH1();
264 
265  const Spectrum ret = WeightedBy(Ps);
266  if (hash)
267  {
269  OscCache<Spectrum>::hash.reset(hash);
270  }
271  HistCache::Delete(Ps);
272  return ret;
273  }
std::unique_ptr< TMD5 > hash
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
virtual TMD5 * GetParamsHash() const
Use to check two calculators are in the same state.
Spectrum WeightedBy(const TH1 *weights) const
SpectrumStan ana::OscillatableSpectrum::Oscillated ( osc::IOscCalculatorStan calc,
int  from,
int  to 
) const
double ana::OscillatableSpectrum::POT ( ) const
inline
void ana::ReweightableSpectrum::RemoveLoader ( SpectrumLoaderBase p)
protectedinherited

Definition at line 664 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fLoaderCount.

Referenced by ana::ReweightableSpectrum::ReweightableSpectrum().

665  { fLoaderCount.erase(p); }
const char * p
Definition: xmltok.h:285
std::set< SpectrumLoaderBase * > fLoaderCount
This count is maintained by SpectrumLoader, as a sanity check.
void ana::ReweightableSpectrum::ReweightByRecoRatio ( const TH1 *  weights)
inherited

Rescale bins by a ratio TH1*.

Definition at line 495 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, and ana::ReweightByRecoRatioHelper().

Referenced by ana::ReweightableSpectrum::Livetime().

496  {
497  DontAddDirectory guard;
498 
499  if(fHistD)
501  else
503  }
void ReweightByRecoRatioHelper(T *hist, const TH1 *ws)
void ana::ReweightableSpectrum::ReweightByRecoRatio ( const TH2 *  weights)
inherited

Definition at line 506 of file ReweightableSpectrum.cxx.

References bin, ana::ReweightableSpectrum::f3DHist, w, X, submit_syst::x, Y, submit_syst::y, test::z, and Z.

507  {
508  DontAddDirectory guard;
509  assert(ws->GetNbinsX() == f3DHist->GetNbinsX());
510 
511  const int X = f3DHist->GetNbinsX();
512  const int Y = f3DHist->GetNbinsY();
513  const int Z = f3DHist->GetNbinsZ();
514 
515  double* histTo = ((TH3D*)f3DHist)->GetArray();
516  double* histFrom = ((TH2D*)ws)->GetArray();
517 
518  int bin = 0;
519  for(int z = 0; z < Z+2; ++z){
520  int binfrom = 0;
521  for(int y = 0; y < Y+2; ++y){
522  for(int x = 0; x < X+2; ++x){
523 
524  const double w = histFrom[binfrom];
525  ++binfrom;
526  histTo[bin] *= w;
527  ++bin;
528  }
529  }
530  }
531  }
Float_t Y
Definition: plot.C:38
Float_t Z
Definition: plot.C:38
float bin[41]
Definition: plottest35.C:14
z
Definition: test.py:28
Float_t X
Definition: plot.C:38
Float_t w
Definition: plot.C:20
void ana::ReweightableSpectrum::ReweightByTrueRatio ( const TH1D *  weights)
inherited

Definition at line 555 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, and ana::ReweightByTrueRatioHelper().

Referenced by ana::ReweightableSpectrum::Livetime().

556  {
557  DontAddDirectory guard;
558 
559  if(fHistD)
561  else
563  }
void ReweightByTrueRatioHelper(T *hist, const TH1D *ws)
void ana::ReweightableSpectrum::ReweightToRecoSpectrum ( const Spectrum target)
inherited

Recale bins so that Unweighted will return target.

Definition at line 639 of file ReweightableSpectrum.cxx.

References calib::corr(), ana::HistCache::Delete(), ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightToRecoSpectrumHelper(), ana::Ratio::ToTH1(), and ana::ReweightableSpectrum::UnWeighted().

Referenced by ana::TruthReweight::Eval(), ana::RecoReweight::Eval(), ana::FluxReweight::Eval(), ana::PredictionExtendToPeripheral::ExtendRecoWeightOscillatable(), ana::ReweightableSpectrum::Livetime(), ana::TruthReweight::SavePlots(), and ana::UnfoldIterative::Truth().

640  {
641  // This is a big component of what extrapolations do, so it has been
642  // optimized for speed
643 
644  Ratio corr(target, UnWeighted());
645  std::unique_ptr<TH1D> hcorr(corr.ToTH1());
646 
647  if(fHistD)
648  ReweightToRecoSpectrumHelper(fHistD, hcorr.get());
649  else
650  ReweightToRecoSpectrumHelper(fHistF, hcorr.get());
651 
652  TH1D* todel = hcorr.release();
653  HistCache::Delete(todel);
654  }
const XML_Char * target
Definition: expat.h:268
double corr(TGraph *g, double thresh)
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
void ReweightToRecoSpectrumHelper(T *hist, TH1D *hcorr)
void ana::ReweightableSpectrum::ReweightToTrueSpectrum ( const Spectrum target)
inherited

Rescale bins so that WeightingVariable will return target.

Definition at line 594 of file ReweightableSpectrum.cxx.

References calib::corr(), ana::HistCache::Delete(), ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightToTrueSpectrumHelper(), ana::Ratio::ToTH1(), and ana::ReweightableSpectrum::WeightingVariable().

Referenced by ana::TruthReweight::Eval(), ana::ReweightableSpectrum::Livetime(), and ana::UnfoldIterative::Truth().

595  {
596  // This is a big component of what extrapolations do, so it has been
597  // optimized for speed
598 
599  Ratio corr(target, WeightingVariable());
600  std::unique_ptr<TH1D> hcorr(corr.ToTH1());
601 
602  if(fHistD)
603  ReweightToTrueSpectrumHelper(fHistD, hcorr.get());
604  else
605  ReweightToTrueSpectrumHelper(fHistF, hcorr.get());
606 
607  TH1D* todel = hcorr.release();
608  HistCache::Delete(todel);
609  }
const XML_Char * target
Definition: expat.h:268
double corr(TGraph *g, double thresh)
static void Delete(TH1D *&h)
Definition: HistCache.cxx:215
void ReweightToTrueSpectrumHelper(T *hist, TH1D *hcorr)
const Var& ana::ReweightableSpectrum::ReweightVar ( ) const
inlineinherited

The variable that will be used to fill the y-axis.

By convention, return zero if the information can't be obtained, and this event will be skipped.

Definition at line 72 of file ReweightableSpectrum.h.

References ana::ReweightableSpectrum::fRWVar.

Referenced by ana::SpectrumLoader::HandleRecord().

72 {return fRWVar;}
Var fRWVar
What goes on the y axis?
const Var& ana::ReweightableSpectrum::ReweightVarz ( ) const
inlineinherited
void ana::OscillatableSpectrum::SaveTo ( TDirectory *  dir) const

Definition at line 393 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fBins, ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fLivetime, genie::utils::style::Format(), ana::ReweightableSpectrum::fPOT, MECModelEnuComparisons::i, and tmp.

Referenced by nue_bg_stat_errs_load(), ana::TruthReweight::SavePlots(), ana::PredictionNueRebinSA::SaveTo(), ana::TrivialExtrap::SaveTo(), ana::NoReweight::SaveTo(), ana::TruthReweight::SaveTo(), ana::RecoReweight::SaveTo(), and ana::FluxReweight::SaveTo().

394  {
395  TDirectory* tmp = gDirectory;
396  dir->cd();
397 
398  TObjString("OscillatableSpectrum").Write("type");
399 
400  if(fHistD) fHistD->Write("hist");
401  if(fHistF) fHistF->Write("hist");
402  TH1D hPot("", "", 1, 0, 1);
403  hPot.Fill(.5, fPOT);
404  hPot.Write("pot");
405  TH1D hLivetime("", "", 1, 0, 1);
406  hLivetime.Fill(.5, fLivetime);
407  hLivetime.Write("livetime");
408 
409  for(unsigned int i = 0; i < fBins.size(); ++i){
410  TObjString(fLabels[i].c_str()).Write(TString::Format("label%d", i).Data());
411  fBins[i].SaveTo(dir->mkdir(TString::Format("bins%d", i)));
412  }
413 
414  tmp->cd();
415  }
Float_t tmp
Definition: plot.C:36
std::vector< std::string > fLabels
TDirectory * dir
Definition: macro.C:5
std::vector< Binning > fBins
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
void ana::OscillatableSpectrum::Scale ( double  scale) const

Definition at line 382 of file OscillatableSpectrum.cxx.

References ana::ReweightableSpectrum::fHistD, and ana::ReweightableSpectrum::fHistF.

Referenced by ana::PredictionAddRock::ComponentCC(), ana::NDExtrapComponent::ExtrapComponent(), and ana::PredictionExtendToPeripheral::Scale().

383  {
384  if(fHistD) fHistD->Scale(scale);
385  if(fHistF) fHistF->Scale(scale);
386 
387  // invalidate
388  OscCache<Spectrum>::hash.reset(nullptr);
389  OscCache<SpectrumStan>::hash.reset(nullptr);
390  }
std::unique_ptr< TMD5 > hash
Double_t scale
Definition: plot.C:25
TH2D * ana::ReweightableSpectrum::ToTH2 ( double  pot) const
inherited

Definition at line 252 of file ReweightableSpectrum.cxx.

References ana::HistCache::Copy(), ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fPOT, ana::ReweightableSpectrum::fTrueLabels, submit_hadd::l, ana::HistCache::NewTH2D(), recoLabel, runNovaSAM::ret, and trueLabel.

Referenced by ana::PredictionCombinePeriods::ComponentCC(), demo2(), demo3(), ana::MichelDecomp::GetSum(), ana::MichelDecomp::GetTemplateContent(), ana::ReweightableSpectrum::Is3D(), ana::MichelDecomp::MDCMPLogLikelihood(), ana::PredictionExtendToPeripheral::MergePeripheralOsc(), OscillateWithErrors(), ana::PlotAllRecoTrue(), ana::CrossSectionAnalysis::PlotRecoToTrueMatrix(), ana::SingleNucAnalysis::PlotRecoToTrueMatrix2D(), ana::NumuCC2p2hAnalysis::PlotRecoToTrueMatrix2D(), ana::PredictionNueRebinSA::Reduce(), ana::PredictionExtendToPeripheral::ReduceHelper(), ana::MichelDecomp::SaveTempPlots(), ana::UnfoldSVD::Truth(), Unfold1D(), Unfold3D(), and ana::UnfoldTikhonov::UnfoldTikhonov().

253  {
254  // Could have a file temporarily open
255  DontAddDirectory guard;
256 
257  TH2D* ret = 0;
258  if(fHistD){
259  ret = HistCache::Copy(fHistD);
260  }
261  else if(fHistF){
262  ret = HistCache::NewTH2D(fHistF->GetTitle(), fHistF->GetXaxis(), fHistF->GetYaxis());
263  ret->Add(fHistF);
264  }
265 
266  if(fPOT){
267  ret->Scale(pot/fPOT);
268  }
269  else{
270  // How did it get events with no POT?
271  assert(ret->Integral() == 0);
272  }
273 
274 
276  for(const std::string& l: fLabels) recoLabel += l + " and ";
277  recoLabel.resize(recoLabel.size()-5); // drop the last "and"
278  ret->GetXaxis()->SetTitle(recoLabel.c_str());
280  for(const std::string& l: fTrueLabels) trueLabel += l + " and ";
281  if (trueLabel.size() >= 5)
282  trueLabel.resize(trueLabel.size()-5); // drop the last "and"
283  ret->GetYaxis()->SetTitle(trueLabel.c_str());
284 
285  // Allow GetMean() and friends to work even if this histogram never had any
286  // explicit Fill() calls made.
287  if(ret->GetEntries() == 0) ret->SetEntries(1);
288 
289  return ret;
290  }
static TH2D * NewTH2D(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:80
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:175
const string trueLabel
Definition: UnfoldXSec.C:58
const string recoLabel
Number of targets, calcuted by ???
Definition: UnfoldXSec.C:57
#define pot
std::vector< std::string > fLabels
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::vector< std::string > fTrueLabels
TH3D * ana::ReweightableSpectrum::ToTH3 ( double  pot) const
inherited

Definition at line 293 of file ReweightableSpectrum.cxx.

References ana::HistCache::Copy(), ana::ReweightableSpectrum::f3DHist, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fPOT, ana::ReweightableSpectrum::fTrueLabels, submit_hadd::l, recoLabel, runNovaSAM::ret, and trueLabel.

Referenced by ana::ReweightableSpectrum::Is3D().

294  {
295  DontAddDirectory guard;
296  TH3D* ret = HistCache::Copy((TH3D*)f3DHist);
297  if(fPOT){
298  ret->Scale(pot/fPOT);
299  }
300  else{
301  assert(ret->Integral() == 0);
302  }
304  for(const std::string& l: fLabels) recoLabel += l + " and ";
305  recoLabel.resize(recoLabel.size()-5);
306  ret->GetXaxis()->SetTitle(recoLabel.c_str());
308  for(const std::string& l: fTrueLabels) trueLabel += l + " and ";
309  if (trueLabel.size() >= 5)
310  trueLabel.resize(trueLabel.size()-5);
311  ret->GetZaxis()->SetTitle(trueLabel.c_str());
312  if(ret->GetEntries() == 0) ret->SetEntries(1);
313 
314  return ret;
315  }
static TH1D * Copy(const TH1D *h)
Definition: HistCache.cxx:175
const string trueLabel
Definition: UnfoldXSec.C:58
const string recoLabel
Number of targets, calcuted by ???
Definition: UnfoldXSec.C:57
#define pot
std::vector< std::string > fLabels
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
std::vector< std::string > fTrueLabels
Spectrum ana::OscillatableSpectrum::TrueEnergy ( ) const
inline
Spectrum ana::OscillatableSpectrum::Unoscillated ( ) const
inline
Spectrum ana::ReweightableSpectrum::UnWeighted ( ) const
inherited

Definition at line 352 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fBins, ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fPOT, demo3::h, ana::HistCache::New(), ana::HistCache::NewF(), and ana::ProjectionX().

Referenced by ana::ReweightableSpectrum::Livetime(), ana::ReweightableSpectrum::ReweightToRecoSpectrum(), and ana::UnfoldSVD::Truth().

353  {
354  DontAddDirectory guard;
355 
356  if(fHistD){
357  // Create a suitably-sized space for the result
358  std::unique_ptr<TH1D> h(HistCache::New("", fHistD->GetXaxis()));
359 
360  ProjectionX(fHistD, h.get());
361 
362  return Spectrum(std::move(h), fLabels, fBins, fPOT, fLivetime);
363  }
364  else{
365  // Create a suitably-sized space for the result
366  std::unique_ptr<TH1F> h(HistCache::NewF("", fHistF->GetXaxis()));
367 
368  ProjectionX(fHistF, h.get());
369 
370  return Spectrum(std::move(h), fLabels, fBins, fPOT, fLivetime);
371  }
372  }
std::vector< std::string > fLabels
static TH1F * NewF(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:46
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:24
std::vector< Binning > fBins
void ProjectionX(T *from, U *to)
Helper for Unweighted.
h
Definition: demo3.py:41
Spectrum ana::ReweightableSpectrum::WeightedBy ( const TH1 *  weights) const
inherited

Definition at line 449 of file ReweightableSpectrum.cxx.

References visualisationForPaperMasterPlot::ax, ana::ReweightableSpectrum::fBins, ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fPOT, demo3::h, ana::HistCache::New(), ana::HistCache::NewF(), and ana::WeightedByHelper().

Referenced by ana::ReweightableSpectrum::Livetime(), ana::NDOscillatableSpectrum::Oscillated(), and Oscillated().

450  {
451  // This function is in the inner loop of oscillation fits, so some
452  // optimization has been done.
453 
454  DontAddDirectory guard;
455 
456  TH2* h = fHistD ? (TH2*)fHistD : (TH2*)fHistF;
457  assert(ws->GetNbinsX() == h->GetNbinsY());
458 
459  TAxis* ax = h->GetXaxis();
460 
461  if(fHistD){
462  TH1D* hRet = HistCache::New("", ax);
463  WeightedByHelper(fHistD, ws, hRet);
464  return Spectrum(std::unique_ptr<TH1D>(hRet), fLabels, fBins, fPOT, fLivetime);
465  }
466  else{
467  TH1F* hRet = HistCache::NewF("", ax);
468  WeightedByHelper(fHistF, ws, hRet);
469  return Spectrum(std::unique_ptr<TH1F>(hRet), fLabels, fBins, fPOT, fLivetime);
470  }
471  }
if(dump)
correl_xv GetXaxis() -> SetDecimals()
std::vector< std::string > fLabels
static TH1F * NewF(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:46
void WeightedByHelper(const T *from, const TH1 *ws, U *to)
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:24
std::vector< Binning > fBins
h
Definition: demo3.py:41
Spectrum ana::ReweightableSpectrum::WeightingVariable ( ) const
inherited

Definition at line 401 of file ReweightableSpectrum.cxx.

References ana::ReweightableSpectrum::fBins, ana::ReweightableSpectrum::fHistD, ana::ReweightableSpectrum::fHistF, ana::ReweightableSpectrum::fLabels, ana::ReweightableSpectrum::fLivetime, ana::ReweightableSpectrum::fPOT, demo3::h, ana::HistCache::New(), ana::HistCache::NewF(), and ana::ProjectionY().

Referenced by ana::ReweightableSpectrum::Livetime(), ana::ReweightableSpectrum::ReweightToTrueSpectrum(), ana::UnfoldIterative::Truth(), and ana::UnfoldSVD::Truth().

402  {
403  DontAddDirectory guard;
404 
405  if(fHistD){
406  // Create a suitably-sized space for the result
407  std::unique_ptr<TH1D> h(HistCache::New("", fHistD->GetYaxis()));
408  ProjectionY(fHistD, h.get());
409  return Spectrum(std::move(h), fLabels, fBins, fPOT, fLivetime);
410  }
411  else{
412  // Create a suitably-sized space for the result
413  std::unique_ptr<TH1F> h(HistCache::NewF("", fHistF->GetYaxis()));
414  ProjectionY(fHistF, h.get());
415  return Spectrum(std::move(h), fLabels, fBins, fPOT, fLivetime);
416  }
417  }
std::vector< std::string > fLabels
static TH1F * NewF(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:46
void ProjectionY(T *from, U *to)
Helper for WeightingVariable.
static TH1D * New(const std::string &title, const Binning &bins)
Definition: HistCache.cxx:24
std::vector< Binning > fBins
h
Definition: demo3.py:41

Friends And Related Function Documentation

friend class NullLoader
friend

Definition at line 39 of file OscillatableSpectrum.h.

friend class SpectrumLoader
friend

Definition at line 38 of file OscillatableSpectrum.h.

friend class SpectrumLoaderBase
friend

Definition at line 37 of file OscillatableSpectrum.h.

Member Data Documentation

TH3D* ana::ReweightableSpectrum::f3DHist
mutableprotectedinherited
std::vector<Binning> ana::ReweightableSpectrum::fBins
protectedinherited
TH2D* ana::ReweightableSpectrum::fHistD
protectedinherited
TH2F* ana::ReweightableSpectrum::fHistF
protectedinherited
bool ana::ReweightableSpectrum::fIs3D = false
mutableprotectedinherited
std::vector<std::string> ana::ReweightableSpectrum::fLabels
protectedinherited
double ana::ReweightableSpectrum::fLivetime
protectedinherited
std::set<SpectrumLoaderBase*> ana::ReweightableSpectrum::fLoaderCount
protectedinherited
double ana::ReweightableSpectrum::fPOT
protectedinherited
Var ana::ReweightableSpectrum::fRWVar
protectedinherited
Var ana::ReweightableSpectrum::fRWVarz
mutableprotectedinherited

Definition at line 154 of file ReweightableSpectrum.h.

Referenced by ana::ReweightableSpectrum::ReweightVarz().

std::vector<std::string> ana::ReweightableSpectrum::fTrueLabels
protectedinherited
std::unique_ptr<TMD5> ana::OscCache< SpectrumStan >::hash
mutableinherited

Definition at line 25 of file OscillatableSpectrum.h.

Referenced by operator=(), OscillatableSpectrum(), and Oscillated().

std::unique_ptr<TMD5> ana::OscCache< Spectrum >::hash
mutableinherited

Definition at line 25 of file OscillatableSpectrum.h.

Spectrum ana::OscCache< Spectrum >::spect
mutableinherited

Definition at line 26 of file OscillatableSpectrum.h.

SpectrumStan ana::OscCache< SpectrumStan >::spect
mutableinherited

Definition at line 26 of file OscillatableSpectrum.h.

Referenced by LoadFrom(), operator=(), and OscillatableSpectrum().


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