Functions | Variables
test_xsecanalysis.C File Reference
#include "StandardRecord/Proxy/SRProxy.h"
#include "3FlavorAna/Cuts/NumuCuts2017.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Core/Utilities.h"
#include "CAFAna/XSec/CrossSectionAnalysis.h"
#include "CAFAna/XSec/TrivialBkgdEstimator.h"
#include "CAFAna/Vars/Vars.h"
#include "TVector3.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TH1.h"
#include "TH2.h"
#include "3FlavorAna/Vars/NumuVars.h"
#include <cmath>
#include <iostream>

Go to the source code of this file.

Functions

void test_xsecanalysis (bool makePlots=false)
 

Variables

const NuTruthVar kTrueMuE_NT ([](const caf::SRNeutrinoProxy *sr){if(sr->pdg!=14) return float(-1);if(!sr->iscc) return float(-1);if(sr->prim.size()==0) return float(-1);return float(sr->prim[0].p.T());})
 
const Var kTrueMuE = VarFromNuTruthVar(kTrueMuE_NT, -1)
 
const NuTruthCut kIsNuMuCC_NT ([](const caf::SRNeutrinoProxy *sr){if(sr->pdg!=14) return false;return bool(sr->iscc);})
 
const Cut kIsNuMuCC = CutFromNuTruthCut(kIsNuMuCC_NT)
 
const Cut kIsFiducial ([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;TVector3 vtx(sr->vtx.elastic.vtx);if(vtx[0] > 100) return false;if(vtx[1] > 100) return false;if(vtx[2]< 100||vtx[2] > 1000) return false;return true;})
 

Function Documentation

void test_xsecanalysis ( bool  makePlots = false)

Definition at line 69 of file test_xsecanalysis.C.

References allInOneTrainingPlots::axis, MakeMiniprodValidationCuts::f, ana::kIsFiducial, kIsNuMuCC_NT, ana::kIterative, ana::kMuE, ana::kNumuCutND2017, ana::kStandardSpillCuts, kTrueMuE_NT, ana::CrossSectionAnalysis::LoadFrom(), makePlots(), confusionMatrixTree::out, ana::CrossSectionAnalysis::PlotEfficiency(), ana::CrossSectionAnalysis::PlotFluxEstimate(), ana::CrossSectionAnalysis::PlotRecoToTrueMatrix(), ana::CrossSectionAnalysis::PlotUnfoldedSignal(), ana::CrossSectionAnalysis::Result(), ana::CrossSectionAnalysis::SaveTo(), ana::SpectrumLoaderBase::SetSpillCut(), ana::Binning::Simple(), string, and xsec.

70 {
71  if (!makePlots){
72  // Set up spectrum loaders - for an ND analysis, you need to have ND
73  // data and MC
74 
75  // Faster to copy a file to working directory for testing
76  // cp /pnfs/nova/production/caf/R17-11-14-prod4reco.d/genie/nd/000105/10565/neardet_genie_nonswap_genierw_fhc_v08_2157_r00010565_s07_c003_R17-11-14-prod4reco.d_v1_20170322_204739_sim.caf.root .
77  std::string test_file = "/pnfs/nova/production/caf/R17-11-14-prod4reco.d/genie/nd/000105/10565/neardet_genie_nonswap_genierw_fhc_v08_2157_r00010565_s07_c003_R17-11-14-prod4reco.d_v1_20170322_204739_sim.caf.root";
78  SpectrumLoader lMC(test_file);
79  SpectrumLoader lDa(test_file); // In-n-Out test, use MC fake-data until you're ready for data
80  lMC.SetSpillCut(kStandardSpillCuts);
81  lDa.SetSpillCut(kStandardSpillCuts);
82 
83  // For estimating data - you need an axis in your reco'd variable
84  HistAxis axis("Muon Energy [GeV]",Binning::Simple(20,0,5),kMuE);
85  // For evaluating the GENIE xsec, you need an axis in the true variable
86  NuTruthHistAxis axisNuTruth("Muon Energy [GeV]",Binning::Simple(20,0,5),
87  kTrueMuE_NT);
88  Binning EBins = Binning::Simple(40,0,10); // For estimating flux
89  Cut sel = kNumuCutND2017 && kIsFiducial; // Analysis cuts
90 
91  // You need some way to estimate your background. For a real analysis,
92  // the specifics will be different, so put thought into the procedure.
93  // For an in-n-out test, this class will return the MC bkgd estimate.
94  TrivialBkgdEstimator *bkgdest =
95  new TrivialBkgdEstimator(lMC, axis, sel, {!kIsNuMuCC});
96 
97  // Analysis will have a fiducial volume, need to define for flux estimate
98  TVector3 fidMin(-100,-100,100);
99  TVector3 fidMax(100,100,1000);
100 
101  // Unfolding won't matter for an in-n-out test, but in a real analysis,
102  // studying this will be important
103  double unfoldReg = 2;
104  UnfoldMethod_t unfoldType = kIterative;
105 
106  // And we're ready to make the xsec class
107  // Pretty simple, no SystShifts / MC weighting. Real analysis will likely
108  // include these
109  CrossSectionAnalysis xsec(lMC, lDa, axis, axisNuTruth, EBins,
110  sel, kIsNuMuCC_NT, bkgdest, fidMin, fidMax,
111  unfoldReg, unfoldType);
112 
113  // Save to a file to analyize
114  TFile *out = new TFile("out_xsectest.root","recreate");
115  xsec.SaveTo(out, "xsec");
116  out->Close();
117 
118  }
119  else {
120  TFile *f = TFile::Open("out_xsectest.root");
121  f->cd("xsec");
122 
123  // Load from your file
125  CrossSectionAnalysis::LoadFrom(f, "xsec").release();
126 
127  // Now we can start plotting
128  new TCanvas();
129  xsec->Result()->Draw("hist");
130 
131  new TCanvas();
132  xsec->PlotEfficiency()->Draw("hist");
133 
134  new TCanvas();
135  xsec->PlotFluxEstimate()->Draw("hist");
136 
137  new TCanvas();
138  xsec->PlotUnfoldedSignal()->Draw();
139 
140  new TCanvas();
141  xsec->PlotRecoToTrueMatrix()->Draw("colz");
142 
143  }
144 
145 }
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
void makePlots()
Definition: makePlots.C:17
std::unique_ptr< T > LoadFrom(TDirectory *dir, const std::string &label)
Definition: LoadFromFile.h:17
const NuTruthCut kIsNuMuCC_NT([](const caf::SRNeutrinoProxy *sr){if(sr->pdg!=14) return false;return bool(sr->iscc);})
const NuTruthVar kTrueMuE_NT([](const caf::SRNeutrinoProxy *sr){if(sr->pdg!=14) return float(-1);if(!sr->iscc) return float(-1);if(sr->prim.size()==0) return float(-1);return float(sr->prim[0].p.T());})
const Cut kNumuCutND2017
Definition: NumuCuts2017.h:41
const Cut kIsFiducial([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;TVector3 vtx(sr->vtx.elastic.vtx);if(vtx[0] > 100) return false;if(vtx[1] > 100) return false;if(vtx[2]< 100||vtx[2] > 1000) return false;return true;})
Double_t xsec[nknots]
Definition: testXsec.C:47
UnfoldMethod_t
Enumerator for unfolding methods. TODO: Allow swapping to RooUnfold, TUnfold, etc?
const Cut kIsNuMuCC
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
Generic organizational class for a cross section analysis.
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const Var kMuE
Definition: NumuVars.h:22
Just return the MC prediction for the background.
enum BeamMode string

Variable Documentation

const Cut kIsFiducial([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;TVector3 vtx(sr->vtx.elastic.vtx);if(vtx[0] > 100) return false;if(vtx[1] > 100) return false;if(vtx[2]< 100||vtx[2] > 1000) return false;return true;})
const Cut kIsNuMuCC = CutFromNuTruthCut(kIsNuMuCC_NT)

Definition at line 56 of file test_xsecanalysis.C.

Referenced by NuMu2020_TrimCAFs().

const NuTruthCut kIsNuMuCC_NT([](const caf::SRNeutrinoProxy *sr){if(sr->pdg!=14) return false;return bool(sr->iscc);})

Referenced by test_xsecanalysis().

const Var kTrueMuE = VarFromNuTruthVar(kTrueMuE_NT, -1)

Definition at line 49 of file test_xsecanalysis.C.

const NuTruthVar kTrueMuE_NT([](const caf::SRNeutrinoProxy *sr){if(sr->pdg!=14) return float(-1); if(!sr->iscc) return float(-1); if(sr->prim.size()==0) return float(-1);return float(sr->prim[0].p.T());})

Referenced by test_xsecanalysis().