datamc_ND_numu_kinematics_RHC.C
Go to the documentation of this file.
1 
5 
6 // Core
7 //#include "CAFAna/Core/EventList.h"
9 #include "CAFAna/Core/Spectrum.h"
11 #include "CAFAna/Core/HistAxis.h"
12 #include "CAFAna/Core/Binning.h"
13 #include "CAFAna/Core/Cut.h"
14 
15 // Cuts
16 #include "CAFAna/Cuts/Cuts.h"
17 #include "CAFAna/Cuts/SpillCuts.h"
18 #include "CAFAna/Cuts/NueCutsFirstAna.h"
19 #include "CAFAna/Cuts/NueCutsSecondAna.h"
25 #include "CAFAna/Cuts/TruthCuts.h"
26 
27 // Vars
28 #include "CAFAna/Vars/Vars.h"
34 #include "CAFAna/Vars/HistAxes.h"
36 
37 #include "CAFAna/Analysis/Style.h"
38 #include "CAFAna/Decomp/IDecomp.h"
40 
44 
47 
48 #include "TFile.h"
49 
50 #include "CAFAna/Core/Spectrum.h"
51 #include "CAFAna/Core/Utilities.h"
52 
53 
54 
55 #include <fstream>
56 #include <iostream>
57 #include <cmath>
58 #include <string>
59 
60 using namespace ana;
61 
62 #include "Utilities/func/MathUtil.h"
63 
64 
66 {
67  std::string nameData = "prod_caf_R17-09-05-prod4recopreview.f_nd_numi_rhc_full_v1_addShortSimpleCVN_goodruns";
68  std::string nameMC = "prod_caf_R17-11-14-prod4reco.e_nd_genie_nonswap_rhc_nova_v08_full_v1";
69 
70  //choose your samweb datasets or concat files:
71  SpectrumLoader loaderData(nameData);
72  SpectrumLoader loaderMC(nameMC);
73 
74  loaderData.SetSpillCut(kStandardSpillCuts);
75  loaderMC.SetSpillCut(kStandardDQCuts);
76 
77  //which variables do you want to look at?
78  const int kNumVars = 7;
79 
80  const HistDef defs[kNumVars] = {
81  {"numu", kNumuCCAxis},
82  {"trueQ2", {"true Q^{2} (GeV^{2})", Binning::Simple(500, 0, 5), kTrueQ2}},
83  {"recoQ2", {"reco Q^{2} (GeV^{2})", Binning::Simple(500, 0, 5), kRecoQ2}},
84  {"trueW2", {"true W^{2} (GeV^{2})", Binning::Simple(100, 0, 2), kTrueW}},
85  {"trueE", {"true E (GeV)", Binning::Simple(100, 0, 5), kTrueE}},
86  {"PtP", {"p_{t}/p", Binning::Simple(500,0,1), kPtP}},
87  {"CosNumi", {"CosNumi", Binning::Simple(500,0,1), kCosNumi}}
88  };
89 
90  const int kNumSels = 1;
91  const Cut sels[kNumSels] = {
93  };
94  const std::string selNames[kNumSels] = {
95  "numuND"
96  };
97 
98  Spectrum* spects[kNumSels][kNumVars];
99  IPrediction* preds[kNumSels][kNumVars];
100 
101  //loop over the selectors and variables to create a full selection
102  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
103  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
104  const HistAxis& axis = defs[varIdx].axis;
105  spects[selIdx][varIdx] = new Spectrum(loaderData, axis, sels[selIdx], kNoShift);
106  preds[selIdx][varIdx] = new PredictionNoExtrap(loaderMC, kNullLoader, kNullLoader,
107  axis.GetLabels()[0], axis.GetBinnings()[0], axis.GetVars()[0],
108  sels[selIdx], kNoShift, kXSecCVWgt2018*kPPFXFluxCVWgt);
109  }
110  }
111 
112  loaderMC.Go();
113  loaderData.Go();
114 
115  TString fname = "datamc_ND_numu_kinematics.root";
116  TFile* fout = new TFile(fname, "RECREATE");
117  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
118  TDirectory* d = fout->mkdir(selNames[selIdx].c_str());
119  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
120  const char* name = defs[varIdx].name.c_str();
121  spects[selIdx][varIdx]->SaveTo(d, TString::Format("spect_%s", name));
122  preds[selIdx][varIdx]->SaveTo(d, TString::Format("pred_%s", name));
123  }
124  }
125 }
126 
void datamc_ND_numu_kinematics_RHC()
const XML_Char * name
Definition: expat.h:151
const ana::Var kRecoQ2([](const caf::SRProxy *sr){const double M_mu_sqrd=util::sqr(0.1056);double E_mu=kMuE(sr);double p_mu=sqrt(util::sqr(E_mu)-M_mu_sqrd);return 2 *kCCE(sr)*(E_mu-p_mu *kCosNumi(sr))-M_mu_sqrd;})
Reconstructed four-momentum transfer invariant (Q^2)
Definition: NumuVars.h:146
const int kNumVars
Definition: vars.h:14
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const std::vector< T > & GetVars() const
Definition: HistAxis.h:92
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const Cut kNumuCutND2018
Definition: NumuCuts2018.h:41
std::string name
Definition: NuePlotLists.h:12
virtual void SaveTo(TDirectory *dir, const std::string &name) const
void SetSpillCut(const SpillCut &cut)
const Var kTrueQ2
Definition: TruthVars.h:27
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Var kPtP
Transverse momentum fraction in slice.
Definition: NueVars.cxx:90
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:85
const Cut sels[kNumSels]
Definition: vars.h:44
const HistAxis kNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNumuEnergyBinning, kCCE)
Definition: HistAxes.h:8
const SpillCut kStandardDQCuts([](const caf::SRSpillProxy *spill){if(spill->dcmedgematchfrac==0 &&spill->fracdcm3hits==0 &&spill->nmissingdcmslg==0) return bool(spill->isgoodspill); if(spill->det==caf::kNEARDET && (spill->fracdcm3hits > 0.45|| spill->nmissingdcms > 0)) return false; if(spill->eventincomplete) return false; if(spill->det==caf::kFARDET && spill->nmissingdcmslg > 0) return false; if(spill->det==caf::kFARDET && !spill->ismc && spill->dcmedgematchfrac<=0.2) return false;return true;})
Cut out events with a noisy detector or with parts missing.
Definition: SpillCuts.h:16
Float_t d
Definition: plot.C:236
virtual void Go() override
Load all the registered spectra.
void SaveTo(TDirectory *dir, const std::string &name) const
Definition: Spectrum.cxx:517
const HistDef defs[kNumVars]
Definition: vars.h:15
const int kNumSels
Definition: vars.h:43
std::vector< float > Spectrum
Definition: Constants.h:570
HistAxis axis
Definition: NuePlotLists.h:13
const SystShifts kNoShift
Definition: SystShifts.cxx:21
const std::vector< Binning > & GetBinnings() const
Definition: LabelsAndBins.h:69
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var kXSecCVWgt2018
Definition: XsecTunes.h:49
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
Prediction that just uses FD MC, with no extrapolation.
const std::string selNames[kNumSels]
Definition: vars.h:46
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:114
const Var kTrueW
Definition: TruthVars.h:22
const Var kCosNumi([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks > 0 &&sr->trk.kalman.idxremid!=999){if(sr->hdr.det==1){return sr->trk.kalman.tracks[0].dir.Dot(beamDirND);}if(sr->hdr.det==2){return sr->trk.kalman.tracks[0].dir.Dot(beamDirFD);}}return-5.f;})
Definition: NumuVars.h:43
static NullLoader kNullLoader
Dummy loader that doesn&#39;t load any files.
const std::vector< std::string > & GetLabels() const
Definition: LabelsAndBins.h:68