NumuDecomp.cxx
Go to the documentation of this file.
2 
5 #include "CAFAna/Core/Ratio.h"
6 
7 #include <cassert>
8 #include <iostream>
9 
10 #include "TDirectory.h"
11 #include "TObjString.h"
12 
13 namespace ana
14 {
15  REGISTER_LOADFROM("NumuDecomp", IDecomp, NumuDecomp);
16 
17  //----------------------------------------------------------------------
19  SpectrumLoaderBase& loaderData,
20  const std::string& label,
21  const Binning& bins,
22  const Var& var,
23  const Cut& cut,
24  const SystShifts& shiftMC,
25  const SystShifts& shiftData,
26  const Var& wei)
27  : NumuDecomp(loaderMC, loaderData, HistAxis(label, bins, var),
28  cut, shiftMC, shiftData, wei)
29  {
30  }
31 
32  //----------------------------------------------------------------------
34  SpectrumLoaderBase& loaderData,
35  const HistAxis& axis,
36  const Cut& cut,
37  const SystShifts& shiftMC,
38  const SystShifts& shiftData,
39  const Var& wei)
40  : fData (loaderData, axis, cut, shiftData, wei),
41  //nc
42  fNCTot (loaderMC, axis, cut && kIsNC, shiftMC, wei),
43  //end nc
44  fNue (loaderMC, axis, cut && kIsBeamNue&&!kIsAntiNu, shiftMC, wei),
45  fAntiNue (loaderMC, axis, cut && kIsBeamNue&& kIsAntiNu, shiftMC, wei),
46  fNumu (loaderMC, axis, cut && kIsNumuCC &&!kIsAntiNu, shiftMC, wei),
47  fAntiNumu(loaderMC, axis, cut && kIsNumuCC && kIsAntiNu, shiftMC, wei),
48  fNotNumu (loaderMC, axis, cut && !kIsNumuCC&& kHasNu, shiftMC, wei)
49  {
50  }
51 
52  //----------------------------------------------------------------------
54  const HistAxis& axis,
55  const Cut& cut,
56  const SystShifts& shiftMC,
57  const SystShifts& shiftData,
58  const Var& wei)
59  : NumuDecomp(loaders.GetLoader(caf::kNEARDET, Loaders::kMC),
60  loaders.GetLoader(caf::kNEARDET, Loaders::kData),
61  axis, cut, shiftMC, shiftData, wei)
62  {
63  }
64 
65  //----------------------------------------------------------------------
67  {
68  // Subtract backgrounds from data using MC, then split into nu/antinu
69  // components using MC ratio
70  return (fNumu/(fNumu+fAntiNumu))*(fData-fNotNumu);
71  }
72 
73  //----------------------------------------------------------------------
75  {
76  return (fAntiNumu/(fNumu+fAntiNumu))*(fData-fNotNumu);
77  }
78 
79  //nc
80  Spectrum NumuDecomp::NCComponent() const {std::cout << "NumuDecomp::NCComponent() not implemented" <<std::endl; abort();}
81  Spectrum NumuDecomp::NCAntiComponent() const {std::cout << "NumuDecomp::NCAntiComponent() not implemented" << std::endl; abort();}
82  //end nc
83  //----------------------------------------------------------------------
84  void NumuDecomp::SaveTo(TDirectory* dir, const std::string& name) const
85  {
86  TDirectory* tmp = gDirectory;
87 
88  dir = dir->mkdir(name.c_str()); // switch to subdir
89  dir->cd();
90 
91  TObjString("NumuDecomp").Write("type");
92 
93  fNCTot.SaveTo(dir, "nc_tot_comp");
94  fData.SaveTo(dir, "data_comp");
95  fNue.SaveTo(dir, "nue_comp");
96  fAntiNue.SaveTo(dir, "antinue_comp");
97  fNumu.SaveTo(dir, "numu_comp");
98  fAntiNumu.SaveTo(dir, "antinumu_comp");
99  fNotNumu.SaveTo(dir, "notnumu_comp");
100 
101  dir->Write();
102  delete dir;
103 
104  tmp->cd();
105  }
106 
107  //----------------------------------------------------------------------
108  std::unique_ptr<NumuDecomp> NumuDecomp::LoadFrom(TDirectory* dir, const std::string& name)
109  {
110  dir = dir->GetDirectory(name.c_str()); // switch to subdir
111  assert(dir);
112 
113  std::unique_ptr<NumuDecomp> ret(new NumuDecomp);
114 
115  ret->fNCTot = *Spectrum::LoadFrom(dir, "nc_tot_comp");
116  ret->fData = *Spectrum::LoadFrom(dir, "data_comp");
117  ret->fNue = *Spectrum::LoadFrom(dir, "nue_comp");
118  ret->fAntiNue = *Spectrum::LoadFrom(dir, "antinue_comp");
119  ret->fNumu = *Spectrum::LoadFrom(dir, "numu_comp");
120  ret->fAntiNumu = *Spectrum::LoadFrom(dir, "antinumu_comp");
121  ret->fNotNumu = *Spectrum::LoadFrom(dir, "notnumu_comp");
122 
123  delete dir;
124 
125  return ret;
126  }
127 }
Spectrum NumuComponent() const override
Definition: NumuDecomp.cxx:66
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
Spectrum fAntiNumu
Definition: NumuDecomp.h:74
Simple record of shifts applied to systematic parameters.
Definition: SystShifts.h:20
Spectrum fData
Definition: NumuDecomp.h:66
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
const Color_t kMC
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
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const char * label
Spectrum fAntiNue
Definition: NumuDecomp.h:71
Uses MC for NC and CC components, assigns remainder of data to CC.
Definition: NumuDecomp.h:10
static std::unique_ptr< Spectrum > LoadFrom(TDirectory *dir, const std::string &name)
Definition: Spectrum.cxx:546
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
Spectrum NCAntiComponent() const override
Definition: NumuDecomp.cxx:81
void SaveTo(TDirectory *dir, const std::string &name) const override
Definition: NumuDecomp.cxx:84
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
OStream cout
Definition: OStream.cxx:6
Base class for the various types of spectrum loader.
const Binning bins
Definition: NumuCC_CPiBin.h:8
Spectrum fNCTot
Definition: NumuDecomp.h:69
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut cut
Definition: exporter_fd.C:30
const Cut kHasNu([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return false;assert(sr->mc.nnu==1);return true;})
Definition: TruthCuts.h:56
TDirectory * dir
Definition: macro.C:5
REGISTER_LOADFROM("BENDecomp", IDecomp, BENDecomp)
Spectrum fNotNumu
Definition: NumuDecomp.h:76
std::vector< Loaders * > loaders
Definition: syst_header.h:386
Spectrum AntiNumuComponent() const override
Definition: NumuDecomp.cxx:74
assert(nhit_max >=nhit_nbins)
This module creates Common Analysis Files.
Definition: FileReducer.h:10
Spectrum fNue
Definition: NumuDecomp.h:70
static std::unique_ptr< NumuDecomp > LoadFrom(TDirectory *dir, const std::string &name)
Definition: NumuDecomp.cxx:108
Spectrum fNumu
Definition: NumuDecomp.h:73
Spectrum NCComponent() const override
Definition: NumuDecomp.cxx:80