Functions
GetHistsFD.C File Reference
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/Loaders.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Core/Var.h"
#include "CAFAna/Cuts/Cuts.h"
#include "CAFAna/Cuts/NumuCuts.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Vars/GenieWeights.h"
#include "CAFAna/Vars/NumuVars.h"
#include "CAFAna/Vars/PPFXWeights.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "TStyle.h"

Go to the source code of this file.

Functions

void GetHistsFD ()
 

Function Documentation

void GetHistsFD ( )

Definition at line 29 of file GetHistsFD.C.

References ana::Binning::Custom(), cut, energy, caf::StandardRecord::energy, MakeMiniprodValidationCuts::f, ana::SpectrumLoader::Go(), make_syst_table_plots::h, MECModelEnuComparisons::i, kCut, ana::kHadCalE, ana::kHadEnergyBinning, ana::kIsNumuCC(), ana::kNoShift, ana::kNumuFD, ana::kStandardSpillCuts, ana::kTrkLength, ana::kTrueE, ana::kTrueHadE, ana::kTrueMuonE, ana::kTuftsWeightCC, demo0::loader, caf::StandardRecord::mc, caf::SRTruthBranch::nnu, caf::SRTruthBranch::nu, Plot2D(), POT, ana::SpectrumLoaderBase::SetSpillCut(), ana::Binning::Simple(), SIMPLEVAR, sr, string, and ana::Spectrum::ToTH2().

30 {
31 
32  std::string fd_nonswap = "/pnfs/nova/persistent/production/concat/R16-03-03-prod2reco.f/epoch*/prod_decaf_R16-03-03-prod2reco.f_fd_genie_nonswap_fhc_nova_v08_epoch*_numu_contain_v1_prod2-snapshot.root";
33  SpectrumLoader loader(fd_nonswap);
34  loader.SetSpillCut(kStandardSpillCuts);
35 
36  struct Plot2D
37  {
39  std::string labelx;
40  Binning binsx;
41  Var varx;
42  std::string labely;
43  Binning binsy;
44  Var vary;
45  Cut cut;
46  };
47 
48  const Cut kTrueEbelow5({"mc.nnu","mc.nu.E"},
49  [](const caf::StandardRecord* sr)
50  {
51  if (sr->mc.nnu < 1) return false;
52  else return (sr->mc.nu[0].E <= 5.0);
53  });
54 
55  const Cut kHasTrueMuon({"energy.numusimp.mc.truegoodmuon","energy.numusimp.mc.truemuonE"},
56  [](const caf::StandardRecord* sr)
57  {
58  if (sr->energy.numusimp.mc.truegoodmuon < 1) return false;
59  else return (sr->energy.numusimp.mc.truemuonE > 0);
60  });
61 
62  const Cut kCut = kTrueEbelow5 && kIsNumuCC && kHasTrueMuon && kNumuFD;
63 
64  //// ------ Now the binnings and variables ------ /////
65 
66  const Binning kMuonEnergyBinning = Binning::Simple(150,0,5);
67  const Binning kHadEnergyBinning = Binning::Simple(150,0,5);
68  const Binning kRToverTBinning = Binning::Simple(150, -1.0, 1.0);
69  const Binning kTrackLengthBinning = Binning::Simple(150, 0, 15);
70 
71  std::vector<double> hadronBins;
72  double hadronAxis = 0.0;
73  for(int i = 0; i < 116; ++i){
74  hadronBins.push_back(hadronAxis);
75  if (hadronAxis < 1.0){hadronAxis = hadronAxis + 0.01;}
76  else if (hadronAxis < 1.5){hadronAxis = hadronAxis + 0.05;}
77  else {hadronAxis = hadronAxis + 0.1;}
78  }
79 
80  const Binning kHadEBinning = Binning::Custom(hadronBins);
81 
82  const Var kTrueHadE = kTrueE - kTrueMuonE;
83 
84  const Var kHadE1 = SIMPLEVAR(energy.numusimp.hadtrkE);
85  const Var kHadE2 = SIMPLEVAR(energy.numusimp.hadcalE);
86  const Var kHadCalE = kHadE1 + kHadE2;
87 
88  const int kNumPlots2D = 2;
89 
90  Plot2D plots2D[kNumPlots2D] = {
91 
92  {"MuonE_hist","Reco muon track length (m)", kTrackLengthBinning, kTrkLength, "True muon energy (GeV)" , kMuonEnergyBinning, kTrueMuonE, kCut},
93 
94  {"HadE_hist","Visible hadronic energy (GeV)", kHadEBinning, kHadCalE, "True hadronic energy (GeV)" , kHadEnergyBinning, kTrueHadE, kCut}
95  };
96 
97  Spectrum* sSpect2D[kNumPlots2D];
98 
99  for(int i = 0; i < kNumPlots2D; i++)
100  {
101  Plot2D p = plots2D[i];
102  // sSpect2D[i] = new Spectrum(p.labelx, p.labely, loader, p.binsx, p.varx, p.binsy, p.vary, p.cut, kNoShift, kTuftsWeightCC * kPPFXFluxCVWgt ); // for miniproduction
103  sSpect2D[i] = new Spectrum(p.labelx, p.labely, loader, p.binsx, p.varx, p.binsy, p.vary, p.cut, kNoShift, kTuftsWeightCC );
104  } // loop over 1D plots
105 
106  loader.Go();
107 
108  TFile f("2DPlotsForFittingFD.root","RECREATE");
109 
110  for(int i = 0; i < kNumPlots2D; i++)
111  {
112  Plot2D p = plots2D[i];
113  TH2* h = sSpect2D[i]->ToTH2(sSpect2D[i]->POT());
114  h->SetName(p.name.c_str());
115  h->Write();
116  } // loop over 1D plots
117 
118 }
const Var kHadCalE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(-1);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(sr->slc.calE);return float(sr->slc.calE- sr->vtx.elastic.fuzzyk.png[0].shwlid.calE);})
const XML_Char * name
Definition: expat.h:151
TH2 * ToTH2(double exposure, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Spectrum must be 2D to obtain TH2.
Definition: Spectrum.cxx:165
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
const char * p
Definition: xmltok.h:285
const Var kTrueHadE
void Plot2D(TH1 *total, std::map< std::string, TH1 * > systs, std::vector< std::string > to_plot, std::string basename)
const Cut kNumuFD
Definition: NumuCuts.h:53
const Var kTrkLength([](const caf::SRProxy *sr){if(sr->trk.kalman.ntracks< 1) return-5.f;return sr->trk.kalman.tracks[0].len/100;})
Definition: NumuVars.h:65
#define SIMPLEVAR(CAFNAME)
For Vars where literally all you need is a single CAF variable.
Definition: Var.h:88
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:40
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
const Binning kHadEnergyBinning
double energy
Definition: plottest35.C:25
caf::StandardRecord * sr
loader
Definition: demo0.py:10
short nnu
Number of neutrinos in nu vector (0 or 1)
Definition: SRTruthBranch.h:37
std::vector< float > Spectrum
Definition: Constants.h:728
const SystShifts kNoShift
Definition: SystShifts.cxx:22
std::vector< double > POT
The StandardRecord is the primary top-level object in the Common Analysis File trees.
const Cut cut
Definition: exporter_fd.C:30
const Var kTuftsWeightCC
Definition: XsecTunes.h:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Var kTrueMuonE([](const caf::SRProxy *sr){if(sr->mc.nnu==0) return 0.f;if(sr->mc.nu[0].prim.empty()) return 0.f;if(std::abs(sr->mc.nu[0].prim[0].pdg)!=13) return 0.f;return float(sr->mc.nu[0].prim[0].p.E);})
Definition: NumuVars.h:107
const Cut kCut
Definition: VarsAndCuts.h:36
SRTruthBranch mc
Truth branch for MC: energy, flavor, etc.
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
SREnergyBranch energy
Energy estimator branch.
std::vector< SRNeutrino > nu
implemented as a vector to maintain mc.nu structure, i.e. not a pointer, but with 0 or 1 entries...
Definition: SRTruthBranch.h:25
enum BeamMode string