getFlatWeightedFittingSpectra.C
Go to the documentation of this file.
1 // I found that the energy estimator used by the nuebar oscillation analysis
2 // was not sufficient for this analysis due to training on a sample of
3 // neutrinos with energy less than 4.5 GeV.
4 //
5 // This script marks the first piece of training a new estimator.
6 // Following docdb-26696, we need to normalize the true energy distribution
7 // to avoid biasing the energy estimation toward our peak beam energy.
8 //
9 // Grab flat-weighted true energy, recoEME, and recoHADE energy distributions
10 // dddoyle@colostate.edu
11 
13 #include "CAFAna/Core/Spectrum.h"
14 #include "CAFAna/Core/Var.h"
15 #include "CAFAna/Cuts/SpillCuts.h"
16 #include "CAFAna/Cuts/TruthCuts.h"
17 #include "3FlavorAna/Cuts/NueCutsSecondAna.h"
20 #include "CAFAna/Vars/XsecTunes.h"
22 
26 
27 using namespace ana;
28 
29 // selection used in the nuebar CC inclusive analysis
33 Cut cuts = kcPresel && kIsTrueSig; // ktIsNuebarCCST && kTrueFiducialST
34 std::string training_data = NominalMC_energy_training_RHC_prod4;
35 
36 const Binning energy_bins = Binning::Simple(50, 0, 10);
37 
38 
40 {
42 
43  std::vector<std::pair<Var, std::string>> weights = {{weight_nominal, "nominal"},
44  {weight_flat, "flat"},
45  {weight_flat_energy_sum, "flat_energy_sum"}};
46  std::vector<Spectrum*> trueE;
47  std::vector<Spectrum*> recoE_EM_vs_HAD;
48  std::vector<Spectrum*> recoE_EM_vs_HAD_vs_trueE;
49 
50  for(int i = 0; i < (int) weights.size(); i++) {
51  trueE.push_back( new Spectrum("True #nu Energy ("
52  + weights[i].second
53  + ") [GeV]",
54  energy_bins,
55  *loader,
56  kTrueE,
57  cuts,
58  kNoShift,
59  weights[i].first) );
60  recoE_EM_vs_HAD.push_back( new Spectrum("EM Shower Energy [GeV]",
61  "Hadronic Energy [GeV]",
62  *loader,
63  energy_bins, kRecoEME,
64  energy_bins, kRecoHADE,
65  cuts,
66  kNoShift,
67  weights[i].first) );
68  }
69 
70  loader->Go();
71 
72  TFile* out_file = new TFile("flat_energy_spectra.root", "recreate");
73  for(int i = 0; i < (int) weights.size(); i++) {
74  trueE[i]->SaveTo(out_file, ("trueE_" + weights[i].second).c_str());
75  recoE_EM_vs_HAD[i]->SaveTo(out_file, ("em_vs_had_" + weights[i].second).c_str());
76  }
77 }
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
const Binning energy_bins
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const Cut kcPresel
Definition: NueCCIncCuts.h:139
const Var kFlatWeightNDSig([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return 0.0;double trueE=sr->mc.nu[0].E;double index=trueE/0.2;if(trueE > 10) return 0.0;int i=(int) index;if(trueE/0.2==i) return flat_weight[i];return flat_weight[i+1];})
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:33
virtual void Go()=0
Load all the registered spectra.
out_file
Append EOF lines.
Definition: modifyFHiCL.py:113
Var weight_flat_energy_sum
const Var kTrueE([](const caf::SRProxy *sr){return(sr->mc.nnu==0)?0.:float(sr->mc.nu[0].E);})
Definition: Vars.cxx:85
const Var kRecoEME([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;double CVNem_CalE=0.0;const caf::SRFuzzyKProngProxy &prim_png=sr->vtx.elastic.fuzzyk.png[0];for(const caf::SRFuzzyKProngProxy &png:sr->vtx.elastic.fuzzyk.png){double png_CalE=png.shwlid.calE;double emPID=((double) png.cvnpart.photonid+ (double) png.cvnpart.pizeroid+ (double) png.cvnpart.electronid);double haPID=((double) png.cvnpart.protonid+ (double) png.cvnpart.pionid+ (double) png.cvnpart.neutronid+ (double) png.cvnpart.otherid+ (double) png.cvnpart.muonid);if(emPID< 0) continue;if(emPID >=haPID ) CVNem_CalE+=png_CalE;else continue;}if(CVNem_CalE==0.0) CVNem_CalE=prim_png.shwlid.calE;return CVNem_CalE *CalibrationBugCorrectionFactor(sr->hdr);})
Definition: NueEnergy2018.h:17
Var weights
loader
Definition: demo0.py:10
const SystShifts kNoShift
Definition: SystShifts.h:115
std::string training_data
Base class for the various types of spectrum loader.
const Cut kIsTrueSig
::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
void getFlatWeightedFittingSpectra()
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
const Var kRecoHADE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return-1.0;if(sr->vtx.elastic.fuzzyk.npng< 1) return-1.0;const double CVNha_CalE=sr->slc.calE *CalibrationBugCorrectionFactor(sr->hdr);return std::max(CVNha_CalE-kRecoEME(sr), 0.);})
Definition: NueEnergy2018.h:18