PredictionXSecTuning.cxx
Go to the documentation of this file.
2 
6 
7 #include "CAFAna/Core/Loaders.h"
9 
10 #include "CAFAna/Cuts/TruthCuts.h"
11 
12 #include "TDirectory.h"
13 #include "TObjString.h"
14 
15 
16 namespace ana
17 {
18  REGISTER_LOADFROM("PredictionXSecTuning", IPrediction, PredictionXSecTuning);
19 
20  //----------------------------------------------------------------------
22  const HistAxis& axis,
23  const Cut& cut,
24  const SystShifts& shift,
25  const Var& wei )
26  : fSpectrum( loaders.GetLoader( caf::kNEARDET, Loaders::kMC ),
27  axis, cut, shift, wei )
28  {
29  }
30 
31  //----------------------------------------------------------------------
33  Flavors::Flavors_t flav,
35  Sign::Sign_t sign) const
36  {
37  // basically the whole prediction is regarded as being one component
38  if (flav == ana::Flavors::kNuMuToNuMu && curr == ana::Current::kCC && sign == ana::Sign::kBoth)
39  {
40  return Predict((osc::IOscCalc*)(nullptr)); // Faster
41  }
42  else
43  {
44  auto spec = ana::Spectrum( fSpectrum );
45  spec.Clear();
46  return std::move( spec );
47  }
48  }
49 
50  //----------------------------------------------------------------------
51  void PredictionXSecTuning::SaveTo( TDirectory* dir, const std::string& name ) const
52  {
53  TDirectory* tmp = gDirectory;
54 
55  dir = dir->mkdir(name.c_str()); // switch to subdir
56  dir->cd();
57 
58  TObjString( "PredictionXSecTuning" ).Write( "type");
59  fSpectrum.SaveTo( dir, "spec" );
60 
61  dir->Write();
62  delete dir;
63 
64  tmp->cd();
65  }
66 
67  //----------------------------------------------------------------------
68  std::unique_ptr<PredictionXSecTuning> PredictionXSecTuning::LoadFrom( TDirectory* dir, const std::string& name )
69  {
70  dir = dir->GetDirectory(name.c_str()); // switch to subdir
71  assert(dir);
72 
73  PredictionXSecTuning* ret = new PredictionXSecTuning(*ana::LoadFrom<Spectrum>( dir, "spec" ) );
74 
75  delete dir;
76 
77  // Can't use make_unique because constructor is protected
78  return std::unique_ptr<PredictionXSecTuning>( ret );
79  }
80 }
virtual void SaveTo(TDirectory *dir, const std::string &name) const override
const XML_Char * name
Definition: expat.h:151
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
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
const Color_t kMC
static std::unique_ptr< PredictionXSecTuning > LoadFrom(TDirectory *dir, const std::string &name)
Float_t tmp
Definition: plot.C:36
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
virtual Spectrum PredictComponent(osc::IOscCalc *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
Charged-current interactions.
Definition: IPrediction.h:39
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
PredictionXSecTuning(Loaders &loaders, const HistAxis &axis, const Cut &cut, const SystShifts &shift=kNoShift, const Var &wei=kUnweighted)
std::vector< float > Spectrum
Definition: Constants.h:570
(&#39; survival&#39;)
Definition: IPrediction.h:19
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut cut
Definition: exporter_fd.C:30
Prediction that wraps a simple Spectrum.
TDirectory * dir
Definition: macro.C:5
REGISTER_LOADFROM("BENDecomp", IDecomp, BENDecomp)
std::vector< Loaders * > loaders
Definition: syst_header.h:386
virtual Spectrum Predict(osc::IOscCalc *) const override
assert(nhit_max >=nhit_nbins)
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
This module creates Common Analysis Files.
Definition: FileReducer.h:10
def sign(x)
Definition: canMan.py:197