Functions | Variables
efficiency.C File Reference
#include "CAFAna/Cuts/Cuts.h"
#include "3FlavorAna/Cuts/NumuCuts2017.h"
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/Loaders.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/Var.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Prediction/PredictionNoExtrap.h"
#include "CAFAna/Systs/Systs.h"
#include "3FlavorAna/Systs/NumuSysts.h"
#include "3FlavorAna/Vars/Binnings.h"
#include "3FlavorAna/Vars/NumuVars.h"
#include "CAFAna/Vars/GenieWeights.h"
#include "CAFAna/Vars/PPFXWeights.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Analysis/Calcs.h"
#include "CAFAna/Analysis/Plots.h"
#include "CAFAna/Analysis/Style.h"
#include "CAFAna/Vars/HistAxes.h"
#include "OscLib/OscCalcPMNSOpt.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TGraph.h"
#include "TGraphAsymmErrors.h"
#include "TH1.h"
#include "TH2.h"
#include "TMath.h"
#include "TGaxis.h"
#include "TMultiGraph.h"
#include "TLegend.h"
#include "TLatex.h"
#include "TStyle.h"
#include "THStack.h"
#include "TPaveText.h"
#include "TList.h"
#include "TAttLine.h"
#include "TAttMarker.h"
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <sstream>
#include <string>
#include <fstream>
#include <iomanip>

Go to the source code of this file.

Functions

void efficiency ()
 

Variables

const double pot = 6e20
 

Function Documentation

void efficiency ( )

Definition at line 58 of file efficiency.C.

References ana::bins, Plot::bins, demo5::c1, calc, test_canvas::colours, caf::Proxy< caf::SRIDBranch >::contain, om::cout, cut, Selection::cut, update_sam_good_runs_metadata::cuts, allTimeWatchdog::endl, Plot::fname, Selection::fname, plot_validation_datamc::fname, ana::Loaders::Go(), compareCafs::histName, MECModelEnuComparisons::i, calib::j, ana::kBeam, kBlue, ana::kCCE, caf::kCoh, caf::kDIS, caf::kFARDET, kGreen, ana::kIsNumuCC(), ana::Loaders::kMC, caf::kMEC, ana::Loaders::kNonSwap, ana::kNoShift, kNumPlots, ana::kNumuCCEOptimisedBinning, ana::kNumuContainFD2017, ana::kNumuCosmicRej2017, ana::kNumuPID2017, ana::kNumuQuality, kOrange, ana::kPPFXFluxCVWgt, caf::kQE, kRed, caf::kRes, ana::kStandardSpillCuts, ana::kTrueE, ana::kXSecCVWgt2017, Plot::label, label, MECModelEnuComparisons::leg, loaders, caf::Proxy< caf::StandardRecord >::mc, caf::Proxy< caf::SRContain >::missE, submit_nova_art::mode, caf::Proxy< caf::SRTruthBranch >::nnu, caf::Proxy< caf::SRTruthBranch >::nu, plots, pot, ana::IPrediction::PredictUnoscillated(), ana::ResetOscCalcToDefault(), caf::Proxy< caf::StandardRecord >::sel, ana::Loaders::SetLoaderPath(), ana::Loaders::SetSpillCut(), sr, string, ana::Spectrum::ToTH1(), PandAna.Demos.tute_pid_validation::var, and Plot::var.

Referenced by remid::ReMIdTrain::analyze(), slicer::SlicerAna::analyze(), ComputeXSec1D(), ComputeXSec3D(), ComputeXSecENu(), ana::ICrossSectionAnalysis::CrossSection(), ana::CutOptimization::Efficiency(), ana::nueccinc::NueCCIncCrossSectionAnalysis::getSelectedSignalPrediction1D(), ana::nueccinc::NueCCIncCrossSectionAnalysis::getSelectedSignalPrediction2D(), ana::nueccinc::NueCCIncCrossSectionAnalysis::getTrueSignalPrediction1D(), ana::nueccinc::NueCCIncCrossSectionAnalysis::getTrueSignalPrediction2D(), cheat::BackTracker::HitCollectionEfficiency(), murem::FindMREParent::produce(), and cheat::BackTracker::SlicesToMCTruthsTable().

59 {
60 
61  std::string fd_nonswap = "prod_caf_R17-03-01-prod3reco.l_fd_genie_nonswap_fhc_nova_v08_full_v1";
62 
64  loaders.SetLoaderPath( fd_nonswap, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap );
65 
67 
70 
71 
72  //// ------ Now the cuts ------ /////
73 
74  const Cut kAny(// Any mode
75  [](const caf::SRProxy* sr)
76  {
77  return (sr->mc.nnu > 0);
78  });
79  const Cut kQE( // QE
80  [](const caf::SRProxy* sr)
81  {
82  return sr->mc.nnu > 0 && sr->mc.nu[0].mode == 0;
83  });
84  const Cut kRes( // Res
85  [](const caf::SRProxy* sr)
86  {
87  return sr->mc.nnu > 0 && sr->mc.nu[0].mode == 1;
88  });
89  const Cut kDIS( // DIS
90  [](const caf::SRProxy* sr)
91  {
92  return sr->mc.nnu > 0 && sr->mc.nu[0].mode == 2;
93  });
94  const Cut kCoh( // Coh
95  [](const caf::SRProxy* sr)
96  {
97  return sr->mc.nnu > 0 && sr->mc.nu[0].mode == 3;
98  });
99  const Cut kMEC( // MEC
100  [](const caf::SRProxy* sr)
101  {
102  return sr->mc.nnu > 0 && sr->mc.nu[0].mode == 10;
103  });
104 
105  const Cut kTruthContainFD( // only approx
106  [](const caf::SRProxy* sr)
107  {
108  return sr->mc.nnu > 0 && sr->mc.nu[0].E > 0 && sr->sel.contain.missE/sr->mc.nu[0].E < 0.01;
109  });
110 
111  struct Modes
112  {
114  Cut cut;
115  };
116 
117  const int kNumModes = 6;
118 
119  Modes modes[kNumModes] = {
120  {"All", kAny},
121  {"QE", kQE},
122  {"Res", kRes},
123  {"DIS", kDIS},
124  {"Coh", kCoh},
125  {"MEC", kMEC}
126  };
127 
128  struct Plot
129  {
132  Binning bins;
133  Var var;
134  };
135 
136  const int kNumPlots = 2;
137 
138  Plot plots[kNumPlots] = {
139  {";Reconstructed Neutrino Energy (GeV);Efficiency", "kCCE", kNumuCCEOptimisedBinning, kCCE},
140  {";True Neutrino Energy (GeV);Efficiency", "kTrueE", kNumuCCEOptimisedBinning, kTrueE}
141  };
142 
143  struct Selection
144  {
147  Cut cut;
148  };
149 
150  const int kNumCuts = 5;
151 
152 
153  const Cut kBasicCut = kIsNumuCC && kTruthContainFD;
154 
155  Selection cuts[kNumCuts] = {
156  {"No cuts","NoCut", kBasicCut},
157  {"Data quality","DQ", kBasicCut && kNumuQuality},
158  {"+ containment","DQ_contain", kBasicCut && kNumuQuality && kNumuContainFD2017},
159  {"+ PIDs","DQ_contain_NCRej", kBasicCut && kNumuQuality && kNumuContainFD2017 && kNumuPID2017},
160  {"+ Cosmic rej.","NumuFD", kBasicCut && kNumuQuality && kNumuContainFD2017 && kNumuPID2017 && kNumuCosmicRej2017}
161  };
162 
163  int colours[kNumCuts] = {kBlack, kBlue, kGreen+2, kOrange-3, kRed};
164 
165  PredictionNoExtrap* sSpect[kNumPlots][kNumCuts][kNumModes];
166 
167  for(int k = 0; k < kNumModes; k++)
168  {
169  Cut mode = modes[k].cut;
170 
171  for(int i = 0; i < kNumPlots; i++)
172  {
173  Plot p = plots[i];
174 
175  for(int j = 0; j < kNumCuts; j++)
176  {
177  Cut cut = cuts[j].cut;
178 
179  sSpect[i][j][k] = new PredictionNoExtrap(loaders, p.label, p.bins, p.var, cut && mode, kNoShift, kPPFXFluxCVWgt * kXSecCVWgt2017 );
180  } // loop over cuts
181  } // loop over plots
182  } // loop over modes
183 
184  loaders.Go();
185 
186  TH1* hHist[kNumPlots][kNumCuts][kNumModes];
187 
188  for(int k = 0; k < kNumModes; k++)
189  {
190  for(int i = 0; i < kNumPlots; i++)
191  {
192  for(int j = 0; j < kNumCuts; j++)
193  {
194  std::string histName = plots[i].fname+"_"+cuts[j].fname;
195 
196  // hHist[i][j][k] = sSpect[i][j][k]->Predict(&calc).ToTH1(pot);
197  hHist[i][j][k] = sSpect[i][j][k]->PredictUnoscillated().ToTH1(pot);
198  hHist[i][j][k]->SetName(histName.c_str());
199 
200  hHist[i][j][k]->SetMarkerColor(colours[j]);
201  hHist[i][j][k]->SetLineColor(colours[j]);
202  } // end loop over cuts
203  } // end loop over plots
204  } // end loop over modes
205 
206  for(int k = 0; k < kNumModes; k++)
207  {
208  for(int i = 0; i < kNumPlots; i++)
209  {
210  std::string canvasName = plots[i].fname+"_"+modes[k].fname;
211  TCanvas* c1 = new TCanvas("",canvasName.c_str());
212 
213  TLegend* leg = new TLegend(0.65,0.18,0.85,0.40);
214  leg->SetFillColor(10);
215  leg->SetLineWidth(0);
216  leg->SetLineColor(10);
217 
218  for (int j = 1; j < kNumCuts; j++)
219  {
220  hHist[i][j][k]->Divide(hHist[i][0][k]);
221 
222  std::cout << modes[k].fname.c_str() << " "
223  << plots[i].fname.c_str() << " "
224  << cuts[j].fname.c_str() << " : "
225  << hHist[i][j][k]->Integral() << std::endl;
226 
227  if(j == 1) hHist[i][j][k]->Draw("hist");
228  else hHist[i][j][k]->Draw("hist same");
229  leg->AddEntry(hHist[i][j][k], cuts[j].label.c_str(), "l");
230  } // loop over cuts
231 
232  leg->Draw();
233  c1->SaveAs(("eff/"+canvasName+".pdf").c_str());
234  c1->SaveAs(("eff/"+canvasName+".root").c_str());
235  } // loop over plots
236  } // loop over modes
237 
238 }
enum BeamMode kOrange
enum BeamMode kRed
Far Detector at Ash River.
Definition: SREnums.h:11
Represent the binning of a Spectrum&#39;s x-axis.
Definition: Binning.h:16
void ResetOscCalcToDefault(osc::IOscCalcAdjustable *calc)
Reset calculator to default assumptions for all parameters.
Definition: Calcs.cxx:23
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
TH1D * ToTH1(double exposure, Color_t col=kBlack, Style_t style=kSolid, EExposureType expotype=kPOT, EBinType bintype=kBinContent) const
Histogram made from this Spectrum, scaled to some exposure.
Definition: Spectrum.cxx:148
std::string label
Definition: CutFlow_Data.C:29
std::string fname
Definition: getTimePeak.C:84
const double pot
Definition: efficiency.C:54
caf::Proxy< caf::SRContain > contain
Definition: SRProxy.h:1250
const char * p
Definition: xmltok.h:285
Proxy for caf::StandardRecord.
Definition: SRProxy.h:2125
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
caf::Proxy< std::vector< caf::SRNeutrino > > nu
Definition: SRProxy.h:617
const Color_t kMC
virtual Spectrum PredictUnoscillated() const
Definition: IPrediction.cxx:33
caf::Proxy< short int > nnu
Definition: SRProxy.h:616
osc::OscCalcDumb calc
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
const char * label
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
const Var kTrueE([](const caf::SRProxy *sr){assert(sr->mc.nnu==1);return sr->mc.nu[0].E;})
Definition: Vars.cxx:85
====================================================================== ///
Definition: CutFlow_Data.C:28
const Cut kNumuContainFD2017
Definition: NumuCuts2017.h:21
const int kNumPlots
Definition: GetSpectra.h:1
const std::vector< Plot > plots
Optimized version of OscCalcPMNS.
Definition: StanTypedefs.h:31
const Var kCCE
Definition: NumuVars.h:21
caf::StandardRecord * sr
const double j
Definition: BetheBloch.cxx:29
const Binning bins
const Cut kNumuPID2017([](const caf::SRProxy *sr){return(sr->sel.remid.pid > 0.5 &&sr->sel.cvn.numuid > 0.5);})
Definition: NumuCuts2017.h:27
const Cut kNumuCosmicRej2017([](const caf::SRProxy *sr){return(sr->sel.cosrej.anglekal > 0.5 && sr->sel.cosrej.numucontpid2020 > 0.5 && sr->slc.nhit< 400);})
Definition: NumuCuts2017.h:24
const SystShifts kNoShift
Definition: SystShifts.cxx:21
OStream cout
Definition: OStream.cxx:6
caf::Proxy< float > missE
Definition: SRProxy.h:826
caf::Proxy< caf::SRTruthBranch > mc
Definition: SRProxy.h:2137
std::string fname
Definition: CutFlow_Data.C:30
const Cut cut
Definition: exporter_fd.C:30
std::vector< Loaders * > loaders
Definition: syst_header.h:386
const Binning kNumuCCEOptimisedBinning
Optimised binning for numuCCE from L. Vinton. See docdb 16332. This was close to &#39;custC&#39; in that talk...
Definition: Binnings.cxx:28
c1
Definition: demo5.py:24
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Binning bins
Definition: CutFlow_Data.C:31
Prediction that just uses FD MC, with no extrapolation.
caf::Proxy< caf::SRIDBranch > sel
Definition: SRProxy.h:2140
const Cut kNumuQuality
Definition: NumuCuts.h:18
const Var kXSecCVWgt2017
Definition: XsecTunes.h:37
Var var
Definition: CutFlow_Data.C:32
enum BeamMode kGreen
enum BeamMode kBlue
void SetLoaderPath(const std::string &path, caf::Det_t det, DataMC datamc, DataSource src=kBeam, SwappingConfig swap=kNonSwap)
Configure loader via wildcard path.
Definition: Loaders.cxx:25
enum BeamMode string

Variable Documentation

const double pot = 6e20

Definition at line 54 of file efficiency.C.

Referenced by efficiency().