sidebandfittest.C
Go to the documentation of this file.
1 #ifdef __CINT__
2 void sidebandfittest()
3 {
4  std::cout << "Sorry, you must run in compiled mode" << std::endl;
5 }
6 #else
7 
9 #include "CAFAna/Core/Spectrum.h"
10 #include "CAFAna/Core/SystShifts.h"
11 
12 #include "CAFAna/Cuts/SpillCuts.h"
13 #include "CAFAna/Cuts/TruthCuts.h"
14 #include "3FlavorAna/Cuts/NueCutsSecondAna.h"
15 
19 
21 
25 
26 #include "TH1.h"
27 #include "TH2.h"
28 #include "THStack.h"
29 #include "TCanvas.h"
30 #include "TLegend.h"
31 
32 #include <vector>
33 #include <string>
34 
35 using namespace ana;
36 
38 {
39  //Setup the loaders and apply spill cuts
40  const std::string MCfiles = "defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1 with stride 4 offset 1";
41  SpectrumLoader lNDMC(MCfiles);
43 
44  const std::string Datafiles = "defname: prod_caf_R17-03-01-prod3reco.d_nd_genie_nonswap_fhc_nova_v08_full_v1 with stride 4 offset 0";
45  SpectrumLoader lNDData(Datafiles);
47 
48 
49  //Rewighting for Mock Data Challenge
50  const Var kReweight = kNumuSBWeight * kNCSBWeight * kTuftsWeightCC;
51 
52 
53  //Now make the data spectra
54  Spectrum data_reweighted (lNDData, sideband_x_axis, sideband_y_axis,
55  kCVNCutSideband, kNoShift, kReweight);
56  Spectrum data_tufts (lNDData, sideband_x_axis, sideband_y_axis,
57  kCVNCutSideband, kNoShift, kTuftsWeightCC);
58 
59 
60 
61  //Break down of MC and Data by truth cut in sideband
62  Spectrum data_sig_sb(lNDData, sideband_x_axis, sideband_y_axis,
63  kCVNCutSideband && kIsNueCC,
64  kNoShift, kTuftsWeightCC);
65  Spectrum data_bkg_numu_sb(lNDData, sideband_x_axis, sideband_y_axis,
66  kCVNCutSideband && kIsNumuBkg,
67  kNoShift, kTuftsWeightCC);
68  Spectrum data_bkg_nc_sb(lNDData, sideband_x_axis, sideband_y_axis,
69  kCVNCutSideband && kIsNC,
70  kNoShift, kTuftsWeightCC);
71  Spectrum data_sig_anti_sb(lNDData, sideband_x_axis, sideband_y_axis,
72  kCVNCutSideband && kIsAntiNueCC,
73  kNoShift, kTuftsWeightCC);
74  Spectrum data_bkg_other_sb(lNDData, sideband_x_axis, sideband_y_axis,
75  kCVNCutSideband && kIsOther_nueccinc,
76  kNoShift, kTuftsWeightCC);
77 
78  Spectrum data_sig_sb_weight(lNDData, sideband_x_axis, sideband_y_axis,
79  kCVNCutSideband && kIsNueCC,
80  kNoShift, kReweight);
81 
82  Spectrum data_bkg_numu_sb_weight(lNDData, sideband_x_axis, sideband_y_axis,
83  kCVNCutSideband && kIsNumuBkg,
84  kNoShift, kReweight);
85  Spectrum data_bkg_nc_sb_weight(lNDData, sideband_x_axis, sideband_y_axis,
86  kCVNCutSideband && kIsNC,
87  kNoShift, kReweight);
88  Spectrum data_sig_anti_sb_weight(lNDData, sideband_x_axis, sideband_y_axis,
89  kCVNCutSideband && kIsAntiNueCC,
90  kNoShift, kReweight);
91  Spectrum data_bkg_other_sb_weight(lNDData, sideband_x_axis, sideband_y_axis,
92  kCVNCutSideband && kIsOther_nueccinc,
93  kNoShift, kReweight);
94 
95  Spectrum mc_sig_sb(lNDMC, sideband_x_axis, sideband_y_axis,
96  kCVNCutSideband && kIsNueCC,
97  kNoShift, kTuftsWeightCC);
98  Spectrum mc_bkg_numu_sb(lNDMC, sideband_x_axis, sideband_y_axis,
99  kCVNCutSideband && kIsNumuBkg,
100  kNoShift, kTuftsWeightCC);
101  Spectrum mc_bkg_nc_sb(lNDMC, sideband_x_axis, sideband_y_axis,
102  kCVNCutSideband && kIsNC,
103  kNoShift, kTuftsWeightCC);
104  Spectrum mc_sig_anti_sb(lNDMC, sideband_x_axis, sideband_y_axis,
105  kCVNCutSideband && kIsAntiNueCC,
106  kNoShift, kTuftsWeightCC);
107  Spectrum mc_bkg_other_sb(lNDMC, sideband_x_axis, sideband_y_axis,
108  kCVNCutSideband && kIsOther_nueccinc,
109  kNoShift, kTuftsWeightCC);
110 
111 
112  //Do it.
113  lNDMC.Go();
114  lNDData.Go();
115 
116  TFile* out = new TFile("SidebandFittest.root", "recreate");
117  out->cd();
118 
119  data_reweighted.SaveTo(out->mkdir("data_reweighted"));
120  data_tufts.SaveTo(out->mkdir("data_tufts"));
121  data_sig_sb.SaveTo(out->mkdir("data_sig_sb"));
122  data_bkg_numu_sb.SaveTo(out->mkdir("data_bkg_numu_sb"));
123  data_bkg_nc_sb.SaveTo(out->mkdir("data_bkg_nc_sb"));
124  data_sig_anti_sb.SaveTo(out->mkdir("data_sig_anti_sb"));
125  data_bkg_other_sb.SaveTo(out->mkdir("data_bkg_other_sb"));
126  mc_sig_sb.SaveTo(out->mkdir("mc_sig_sb"));
127  mc_bkg_numu_sb.SaveTo(out->mkdir("mc_bkg_numu_sb"));
128  mc_bkg_nc_sb.SaveTo(out->mkdir("mc_bkg_nc_sb"));
129  mc_sig_anti_sb.SaveTo(out->mkdir("mc_sig_anti_sb"));
130  mc_bkg_other_sb.SaveTo(out->mkdir("mc_bkg_other_sb"));
131  data_sig_sb_weight.SaveTo(out->mkdir("data_sig_sb_weight"));
132  data_bkg_numu_sb_weight.SaveTo(out->mkdir("data_bkg_numu_sb_weight"));
133  data_bkg_nc_sb_weight.SaveTo(out->mkdir("data_bkg_nc_sb_weight"));
134  data_sig_anti_sb_weight.SaveTo(out->mkdir("data_sig_anti_sb_weight"));
135  data_bkg_other_sb_weight.SaveTo(out->mkdir("data_bkg_other_sb_weight"));
136  out->Close();
137 
138 }
139 
140 
141 #endif
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const Cut kIsAntiNueCC
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
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:534
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
void sidebandfittest()
const Var kTuftsWeightCC
Definition: XsecTunes.h:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const Cut kIsNueCC
enum BeamMode string