make_RHC_WrongSign_Numu_Pd8Data.C
Go to the documentation of this file.
1 // ----------------------------------------------------------------
2 // Make the Predictions at ND for numu, Data only.
3 // to be combined with Matt's neutron study
4 // See docDB-29919 for tech note on WS study
5 // ----------------------------------------------------------------
6 
7 #include "CAFAna/Core/Binning.h"
8 #include "CAFAna/Core/Spectrum.h"
10 #include "CAFAna/Cuts/Cuts.h"
11 #include "CAFAna/Cuts/TruthCuts.h"
12 #include "CAFAna/Cuts/SpillCuts.h"
18 #include "CAFAna/Vars/Vars.h"
24 
27 #include "OscLib/OscCalcPMNSOpt.h"
28 
29 #include "TCanvas.h"
30 #include "TH2.h"
31 #include "TLegend.h"
32 #include "TLatex.h"
33 #include "TFile.h"
34 #include "TProfile.h"
35 #include "TString.h"
36 using namespace ana;
37 
39 {
40  // ND MC data set, Prod 4 RHC
41  // nue
42  std::string fname_numuRHC = "prod_caf_R17-11-14-prod4reco.k_nd_numi_rhc_epoch8b_v1_goodruns";
43  SpectrumLoader ld_dataRHCNumu(fname_numuRHC);
44  ld_dataRHCNumu.SetSpillCut(kStandardSpillCuts);
45 
46  // Extra Cuts and Vars for analysis
47  // -------------------------------------------------------------------------------------------------
48  const Cut kCutHighCVNSSe = kCVNSSe >= 0.98; // Ana 2018 Hi CVN bin (docDB-27317)
49  const Cut kCutLowCVNSSe = kCVNSSe >= 0.89; // Ana 2018 Lo CVN bin has this as low edge
50 
51  const Cut kSelectRSNumuND0 = kNumuCutND2018 && kCVNFSProtonScore2018<0.49;
52  const Cut kSelectRSNumuND1 = kNumuCutND2018 && !kCVNProngProtonCtNumu;
53  const Cut kSelectRSNumuND2 = kNumuCutND2018 && kAntiNumuBDTCVN>0.11;
54 
55  const Cut kSelectWSNumuND0 = kNumuCutND2018 && kCVNFSProtonScore2018>=0.49;
56  const Cut kSelectWSNumuND1 = kNumuCutND2018 && kCVNProngProtonCtNumu;
57  const Cut kSelectWSNumuND2 = kNumuCutND2018 && kAntiNumuBDTCVN<=0.11;
58 
59  // Nue-style Binnings for BDT
60  const Var kNueBDT3Bin([](const caf::SRProxy *sr)
61  {
62  if( kAntiNueBDTCVN(sr)>0. ) return float(0.5);
63  else return float(1.5);
64 
65  return float(-1.5);
66  });
67 
68  const Var kNueBDT3AnaBinning([&](const caf::SRProxy *sr)
69  {
70  int selBin = kNueBDT3Bin(sr);
71 
72  float nuE = kNueEnergy2018(sr);
73  int nuEBin = nuE/0.5;
74  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
75 
76  int anaBin = 9*selBin + nuEBin;
77  return anaBin;
78  });
79 
80  const HistAxis kAxisFSProton("NuE Energy / Analysis Bin",Binning::Simple(18,0,18),kNueFSProtonAnaBinning);
81  const HistAxis kAxisCVNProng("NuE Energy / Analysis Bin",Binning::Simple(18,0,18),kNueCVNProngAnaBinning);
82  const HistAxis kAxisBDT3("NuE Energy / Analysis Bin",Binning::Simple(18,0,18),kNueBDT3AnaBinning);
83  // -------------------------------------------------------------------------------------------------
84 
85  // ------------------------------------------------------------------------------------------------
86  // Numu DATA
87  Spectrum sQ1NumuData_FSProtonRS(ld_dataRHCNumu,kNumuCCOptimisedAxis,kSelectRSNumuND0,kNoShift,kUnweighted);
88  Spectrum sQ1NumuData_FSProtonWS(ld_dataRHCNumu,kNumuCCOptimisedAxis,kSelectWSNumuND0,kNoShift,kUnweighted);
89 
90  Spectrum sQ1NumuDataTot(ld_dataRHCNumu,kNumuCCOptimisedAxis,kNumuCutND2018,kNoShift,kUnweighted);
91  // ------------------------------------------------------------------------------------------------
92 
93  // Press play
94  ld_dataRHCNumu.Go();
95 
96  // Save the predictions
97  TFile *outFile = new TFile("./WrongSign-XCheck2019-NumuDataPeriod8b.root","RECREATE");
98  outFile->cd();
99 
100  sQ1NumuData_FSProtonRS.SaveTo(outFile, "sQ1NumuData_FSProtonRS");
101  sQ1NumuData_FSProtonWS.SaveTo(outFile, "sQ1NumuData_FSProtonWS");
102 
103  sQ1NumuDataTot.SaveTo(outFile, "sQ1NumuDataTot");
104 
105  outFile->Close();
106 }
Cuts and Vars for the 2020 FD DiF Study.
Definition: vars.h:6
const Cut kNumuCutND2018
Definition: NumuCuts2018.h:41
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2108
const Var kAntiNueBDTCVN
void SetSpillCut(const SpillCut &cut)
void make_RHC_WrongSign_Numu_Pd8Data()
const Var kNueEnergy2018([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;if(kIsRHC(sr)) return kNueEnergyRHC(sr);else return kNueEnergyFHC(sr);})
Definition: NueEnergy2018.h:25
const Cut Energy
caf::StandardRecord * sr
const Var kCVNFSProtonScore2018([](const caf::SRProxy *sr){return CVNFinalStateScore2018(sr, 2212);})
Proton score from CVN Final State labels, using Prod3Train CVN.
const Var kCVNSSe([](const caf::SRProxy *sr){throw std::runtime_error("kCVNSSe is no longer available. Fix your macro so you don't use it.");return-5.;})
2018 nue PID
Definition: Vars.h:52
const Cut kCVNProngProtonCtNumu([](const caf::SRProxy *sr){ int count=0;if(sr->vtx.elastic.fuzzyk.npng==1) return false;for(unsigned int i=0;i< sr->vtx.elastic.fuzzyk.npng;++i){if(sr->vtx.elastic.fuzzyk.png[i].cvnpart.pdgmax!=2212) continue;if(util::pythag(sr->vtx.elastic.vtx.X()-sr->vtx.elastic.fuzzyk.png[i].start.X(), sr->vtx.elastic.vtx.Y()-sr->vtx.elastic.fuzzyk.png[i].start.Y(), sr->vtx.elastic.vtx.Z()-sr->vtx.elastic.fuzzyk.png[i].start.Z()) > 20) continue;if(sr->vtx.elastic.fuzzyk.png[i].cvnpart.maxval< 0.72) continue;count++;}return count >0;})
::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 kAntiNumuBDTCVN
assert(nhit_max >=nhit_nbins)
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49