CheatDecomp.cxx
Go to the documentation of this file.
2 
6 
7 #include <cassert>
8 
9 #include "TDirectory.h"
10 #include "TObjString.h"
11 
12 namespace ana
13 {
14  REGISTER_LOADFROM("CheatDecomp", IDecomp, CheatDecomp);
15 
16  //----------------------------------------------------------------------
19  const Binning& bins,
20  const Var& var,
21  const Cut& cut,
22  const SystShifts& shift,
23  const Var& wei)
24  : CheatDecomp(loader, HistAxis(label, bins, var), cut, shift, wei)
25  {
26  }
27 
28  //----------------------------------------------------------------------
30  const HistAxis& axis,
31  const Cut& cut,
32  const SystShifts& shift,
33  const Var& wei)
34  : //nc
35  fNCTot (loader, axis, cut && kIsNC, shift, wei),
36  fNC (loader, axis, cut && kIsNC && !kIsAntiNu, shift, wei),
37  fNCAnti (loader, axis, cut && kIsNC && kIsAntiNu, shift, wei),
38  //end nc
39  fNumu (loader, axis, cut && kIsNumuCC && !kIsAntiNu, shift, wei),
40  fNue (loader, axis, cut && kIsBeamNue && !kIsAntiNu, shift, wei),
41  fAntiNumu(loader, axis, cut && kIsNumuCC && kIsAntiNu, shift, wei),
42  fAntiNue (loader, axis, cut && kIsBeamNue && kIsAntiNu, shift, wei)
43  {
44  }
45 
46  //----------------------------------------------------------------------
47  void CheatDecomp::SaveTo(TDirectory* dir, const std::string& name) const
48  {
49  TDirectory* tmp = gDirectory;
50 
51  dir = dir->mkdir(name.c_str()); // switch to subdir
52  dir->cd();
53 
54  TObjString("CheatDecomp").Write("type");
55 
56  // nc
57  fNCTot.SaveTo(dir, "nc_tot_comp");
58  fNC.SaveTo(dir, "nc_comp");
59  fNCAnti.SaveTo(dir, "nc_anti_comp");
60  //end nc
61  fNumu.SaveTo(dir, "numu_comp");
62  fNue.SaveTo(dir, "nue_comp");
63  fAntiNumu.SaveTo(dir, "antinumu_comp");
64  fAntiNue.SaveTo(dir, "antinue_comp");
65 
66  dir->Write();
67  delete dir;
68 
69  tmp->cd();
70  }
71 
72  //----------------------------------------------------------------------
73  std::unique_ptr<CheatDecomp> CheatDecomp::LoadFrom(TDirectory* dir, const std::string& name)
74  {
75  dir = dir->GetDirectory(name.c_str()); // switch to subdir
76  assert(dir);
77 
78  std::unique_ptr<CheatDecomp> ret(new CheatDecomp);
79 
80  //nc
81  ret->fNCTot = *Spectrum::LoadFrom(dir, "nc_tot_comp");
82  ret->fNC = *Spectrum::LoadFrom(dir, "nc_comp");
83  ret->fNCAnti = *Spectrum::LoadFrom(dir, "nc_anti_comp");
84  //end nc
85  ret->fNumu = *Spectrum::LoadFrom(dir, "numu_comp");
86  ret->fNue = *Spectrum::LoadFrom(dir, "nue_comp");
87  ret->fAntiNumu = *Spectrum::LoadFrom(dir, "antinumu_comp");
88  ret->fAntiNue = *Spectrum::LoadFrom(dir, "antinue_comp");
89 
90  delete dir;
91 
92  return ret;
93  }
94 }
void SaveTo(TDirectory *dir, const std::string &name) const override
Definition: CheatDecomp.cxx:47
const XML_Char * name
Definition: expat.h:151
const Cut kIsNumuCC(CCFlavSel(14, 14))
Select CC .
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
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
const Cut kIsAntiNu([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return sr->mc.nu[0].pdg< 0;})
Is this truly an antineutrino?
Definition: TruthCuts.h:53
const Cut kIsBeamNue(CCFlavSel(12, 12))
Select CC .
Float_t tmp
Definition: plot.C:36
const char * label
static std::unique_ptr< CheatDecomp > LoadFrom(TDirectory *dir, const std::string &name)
Definition: CheatDecomp.cxx:73
Spectrum fNumu
Definition: CheatDecomp.h:59
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:546
Spectrum fNCAnti
Definition: CheatDecomp.h:57
const Cut kIsNC([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return!sr->mc.nu[0].iscc;})
Is this a Neutral Current event?
Definition: TruthCuts.h:8
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
Spectrum fAntiNumu
Definition: CheatDecomp.h:61
loader
Definition: demo0.py:10
Base class for the various types of spectrum loader.
const Binning bins
Definition: NumuCC_CPiBin.h:8
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut cut
Definition: exporter_fd.C:30
TDirectory * dir
Definition: macro.C:5
REGISTER_LOADFROM("BENDecomp", IDecomp, BENDecomp)
Spectrum fNCTot
Definition: CheatDecomp.h:52
assert(nhit_max >=nhit_nbins)
Just return the ND truth spectra as the decomposition.
Definition: CheatDecomp.h:10
Spectrum fAntiNue
Definition: CheatDecomp.h:62