make_RHC_WrongSign_Numu_Pd4_6Data.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 
37 using namespace ana;
38 
40 {
41  // ND MC data set, Prod 4 RHC
42  // nue
43  std::string fname_numuRHC = "prod_sumdecaf_R17-09-05-prod4recopreview.f_nd_numi_rhc_full_v1_addShortSimpleCVN_goodruns_numu2018";
44  SpectrumLoader ld_dataRHCNumu(fname_numuRHC);
45  ld_dataRHCNumu.SetSpillCut(kStandardSpillCuts);
46 
47  // Extra Cuts and Vars for analysis
48  // -------------------------------------------------------------------------------------------------
49  const Cut kCutHighCVNSSe = kCVNSSe >= 0.98; // Ana 2018 Hi CVN bin (docDB-27317)
50  const Cut kCutLowCVNSSe = kCVNSSe >= 0.89; // Ana 2018 Lo CVN bin has this as low edge
51 
52  const Cut kSelectRSNumuND0 = kNumuCutND2018 && kCVNFSProtonScore2018<0.49;
53  const Cut kSelectRSNumuND1 = kNumuCutND2018 && !kCVNProngProtonCtNumu;
54  const Cut kSelectRSNumuND2 = kNumuCutND2018 && kAntiNumuBDTCVN>0.11;
55 
56  const Cut kSelectWSNumuND0 = kNumuCutND2018 && kCVNFSProtonScore2018>=0.49;
57  const Cut kSelectWSNumuND1 = kNumuCutND2018 && kCVNProngProtonCtNumu;
58  const Cut kSelectWSNumuND2 = kNumuCutND2018 && kAntiNumuBDTCVN<=0.11;
59 
60  // Nue-style Binnings for BDT
61  const Var kNueBDT3Bin([](const caf::SRProxy *sr)
62  {
63  if( kAntiNueBDTCVN(sr)>0. ) return float(0.5);
64  else return float(1.5);
65 
66  return float(-1.5);
67  });
68 
69  const Var kNueBDT3AnaBinning([&](const caf::SRProxy *sr)
70  {
71  int selBin = kNueBDT3Bin(sr);
72 
73  float nuE = kNueEnergy2018(sr);
74  int nuEBin = nuE/0.5;
75  assert(nuEBin <= 8 && "An event with nuE > 4.5 should never happen");
76 
77  int anaBin = 9*selBin + nuEBin;
78  return anaBin;
79  });
80 
81  const HistAxis kAxisFSProton("NuE Energy / Analysis Bin",Binning::Simple(18,0,18),kNueFSProtonAnaBinning);
82  const HistAxis kAxisCVNProng("NuE Energy / Analysis Bin",Binning::Simple(18,0,18),kNueCVNProngAnaBinning);
83  const HistAxis kAxisBDT3("NuE Energy / Analysis Bin",Binning::Simple(18,0,18),kNueBDT3AnaBinning);
84  // -------------------------------------------------------------------------------------------------
85 
86  // ------------------------------------------------------------------------------------------------
87  // Numu DATA
88  Spectrum sQ1NumuData_FSProtonRS(ld_dataRHCNumu,kNumuCCOptimisedAxis,kSelectRSNumuND0,kNoShift,kUnweighted);
89  Spectrum sQ1NumuData_FSProtonWS(ld_dataRHCNumu,kNumuCCOptimisedAxis,kSelectWSNumuND0,kNoShift,kUnweighted);
90 
91  Spectrum sQ1NumuDataTot(ld_dataRHCNumu,kNumuCCOptimisedAxis,kNumuCutND2018,kNoShift,kUnweighted);
92  // ------------------------------------------------------------------------------------------------
93 
94  // Press play
95  ld_dataRHCNumu.Go();
96 
97  // Save the predictions
98  TFile *outFile = new TFile("./WrongSign-XCheck2019-NumuDataPeriods4-6.root","RECREATE");
99  outFile->cd();
100 
101  sQ1NumuData_FSProtonRS.SaveTo(outFile, "sQ1NumuData_FSProtonRS");
102  sQ1NumuData_FSProtonWS.SaveTo(outFile, "sQ1NumuData_FSProtonWS");
103 
104  sQ1NumuDataTot.SaveTo(outFile, "sQ1NumuDataTot");
105 
106  outFile->Close();
107 }
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)
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
root
Link up the nodes tree #####.
const Cut Energy
void make_RHC_WrongSign_Numu_Pd4_6Data()
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