NDExtrapBeamComponent.cxx
Go to the documentation of this file.
2 
3 #include <utility>
4 
6 #include "CAFAna/Core/Loaders.h"
9 #include "CAFAna/Cuts/Cuts.h"
10 
11 #include "TDirectory.h"
12 #include "TH1D.h"
13 #include "TObject.h"
14 #include "TObjString.h"
15 
16 namespace ana
17 {
18  //---------------------------------------------------------------------------
20  const HistAxis& axis,
21  const Cut& selection,
22  const int beamParent,
23  const SystShifts& shiftMC,
24  const Var& weight)
25  {
26  if(beamParent==Beam::BeamMode::kIsKaon)
27  {
28  NDExtrapBeamComponent::fNDOscSpecComp = std::unique_ptr<NDOscillatableSpectrum>
30  (loader, axis, selection && kIsKaon, shiftMC, weight));
31  // NDExtrapBeamComponent::fCompSpec = std::unique_ptr<Spectrum>
32  // (new Spectrum
33  // (label, bins, loader, var, selection && kIsKaon, shiftMC, weight));
34  }
35  else if(beamParent==Beam::BeamMode::kIsPion)
36  {
37  NDExtrapBeamComponent::fNDOscSpecComp = std::unique_ptr<NDOscillatableSpectrum>
39  (loader, axis, selection && kIsPion, shiftMC, weight));
40  // NDExtrapBeamComponent::fCompSpec = std::unique_ptr<Spectrum>
41  // (new Spectrum
42  // (label, bins, loader, var, selection && kIsPion, shiftMC, weight));
43  }
44  else if(beamParent==Beam::BeamMode::kIsMuon)
45  {
46  NDExtrapBeamComponent::fNDOscSpecComp = std::unique_ptr<NDOscillatableSpectrum>
48  (loader, axis, selection && kIsMuon, shiftMC, weight));
49  // NDExtrapBeamComponent::fCompSpec = std::unique_ptr<Spectrum>
50  // (new Spectrum
51  // (label, bins, loader, var, selection && kIsMuon, shiftMC, weight));
52  }
53  }
54 
55  //---------------------------------------------------------------------------
57  {
59  }
60 
61  // //---------------------------------------------------------------------------
62  // NDOscillatableSpectrum NDExtrapBeamComponent::NueComponent()
63  // {
64  // return *NDExtrapBeamComponent::fNDOscSpecNue;
65  // }
66 
67  //---------------------------------------------------------------------------
68  void NDExtrapBeamComponent::SaveTo(TDirectory* dir, const std::string& name) const
69  {
70  TDirectory* tmp = gDirectory;
71 
72  dir = dir->mkdir(name.c_str()); // switch to subdir
73  dir->cd();
74 
75  TObjString("NDExtrapBeamComponent").Write("type");
76 
77  fNDOscSpecComp->SaveTo(dir, "ndoscspeccomp");
78  // fNDOscSpecNue->SaveTo(dir, "ndoscspecnue")
79 
80  dir->Write();
81  delete dir;;
82 
83  tmp->cd();
84  }
85 
86  //---------------------------------------------------------------------------
87 
88  std::unique_ptr<NDExtrapBeamComponent> NDExtrapBeamComponent::LoadFrom(TDirectory* dir, const std::string& name)
89  {
90  dir = dir->GetDirectory(name.c_str()); // switch to subdir
91  assert(dir);
92 
93  std::unique_ptr<NDExtrapBeamComponent> ret(new NDExtrapBeamComponent);
94 
95  ret->fNDOscSpecComp = ana::LoadFrom<NDOscillatableSpectrum>(dir, "ndoscspeccomp");
96  // ret->fNDOscSpecNue = ana::LoadFrom<NDOscillatableSpectrum>(dir, "ndoscspecnue");
97 
98  delete dir;
99 
100  return ret;
101  }
102 
103 } ///// end of namespace ana //
const XML_Char * name
Definition: expat.h:151
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
NDOscillatableSpectrum Component()
const Var weight
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
std::unique_ptr< NDOscillatableSpectrum > fNDOscSpecComp
static std::unique_ptr< NDExtrapBeamComponent > LoadFrom(TDirectory *dir, const std::string &name)
virtual void SaveTo(TDirectory *dir, const std::string &name) const
Float_t tmp
Definition: plot.C:36
const Cut kIsKaon([](const caf::SRProxy *sr){return(abs(sr->mc.nu[0].beam.ptype)==321||sr->mc.nu[0].beam.ptype==310||sr->mc.nu[0].beam.ptype==311||sr->mc.nu[0].beam.ptype==130);})
Definition: TruthCuts.h:83
const Cut kIsMuon([](const caf::SRProxy *sr){return(abs(sr->mc.nu[0].beam.ptype)==13);})
Definition: TruthCuts.h:84
loader
Definition: demo0.py:10
Base class for the various types of spectrum loader.
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut kIsPion([](const caf::SRProxy *sr){return(abs(sr->mc.nu[0].beam.ptype)==211||sr->mc.nu[0].beam.ptype==111);})
Definition: TruthCuts.h:80
TDirectory * dir
Definition: macro.C:5
assert(nhit_max >=nhit_nbins)
Spectrum with true L/E information, allowing it to be oscillated