Classes | Functions
numu_cut_flow.C File Reference
#include "CAFAna/Cuts/Cuts.h"
#include "CAFAna/Cuts/NumuCuts.h"
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Systs/Systs.h"
#include "CAFAna/Systs/NumuSysts.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Analysis/Plots.h"
#include "CAFAna/Vars/HistAxes.h"
#include "CAFAna/Core/OscillatableSpectrum.h"
#include "OscLib/IOscCalc.h"
#include "OscLib/OscCalcDumb.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TGraph.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 <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <sstream>
#include <string>
#include <fstream>
#include <iomanip>
#include <stdexcept>

Go to the source code of this file.

Classes

class  CanMan
 
struct  Sample
 
class  CutLevel
 
class  CutFlow
 

Functions

void addSame (std::string &opt)
 
void numu_cut_flow ()
 

Function Documentation

void addSame ( std::string opt)

Definition at line 85 of file numu_cut_flow.C.

Referenced by CutFlow::Draw(), and CutFlow::DrawEfficiency().

86 {
87  if (opt.find("same") == std::string::npos &&
88  opt.find("SAME") == std::string::npos)
89  opt += " SAME ";
90 
91 }
void numu_cut_flow ( )

Definition at line 271 of file numu_cut_flow.C.

References ana::AutoPlaceLegend(), calc, caf::SRIDBranch::contain, ana::SpectrumLoader::Go(), kBlue, kGreen, ana::kIsNumuCC(), ana::kNumuCCAxis, ana::kNumuContainFD, ana::kNumuNCRej, ana::kNumuQuality, kRed, ana::kStandardSpillCuts, MECModelEnuComparisons::leg, caf::StandardRecord::mc, caf::SRContain::missE, CanMan::NewCan(), caf::SRTruthBranch::nnu, caf::SRTruthBranch::nu, ana::OscillatableSpectrum::Oscillated(), make_root_from_grid_output::remid, CanMan::SaveCans(), caf::StandardRecord::sel, ana::SpectrumLoaderBase::SetSpillCut(), ana::Binning::Simple(), sr, and ana::Spectrum::ToTH1().

272 {
273 
274 
275  Cut truthContain({"sel.contain.missE", "mc.nu.E", "mc.nnu"},
276  [](const caf::StandardRecord* sr)
277  {
278  if(sr->mc.nnu == 0) return false;
279  return sr->sel.contain.missE / sr->mc.nu[0].E < 0.01;
280  });
281 
282  Cut cvn({"sel.cvnnumu.output", "sel.cvnnumu.noutput"},
283  [](const caf::StandardRecord* sr)
284  {
285  if(!sr->sel.cvnnumu.noutput) return false;
286  return sr->sel.cvnnumu.output[0] > 0.35;
287  });
288 
289  Cut cvn2({"sel.cvnnumu.output", "sel.cvnnumu.noutput"},
290  [](const caf::StandardRecord* sr)
291  {
292  if(!sr->sel.cvnnumu.noutput) return false;
293  return sr->sel.cvnnumu.output[0] > 0.5;
294  });
295 
296 
297  Var cvnOut({"sel.cvnnumu.output", "sel.cvnnumu.noutput"},
298  [](const caf::StandardRecord* sr)
299  {
300  if(!sr->sel.cvnnumu.noutput) return -5.f;
301  return sr->sel.cvnnumu.output[0];
302  });
303 
304  HistAxis cvnAxis("; CVN #nu_{#mu};Events", Binning::Simple(40, 0,1), cvnOut);
305 
306  SpectrumLoader nonswap(
307  "/cloud/login/rocco/development/results/2015-10-20_caf_nonswap_numu/fardet_genie_fhc_nonswap_ideal_3000_r01000001_s*");
308  nonswap.SetSpillCut(kStandardSpillCuts);
309  CutFlow remid("remid", nonswap,
310  kNumuCCAxis,
311  {Sample("sig", "Truth Containment",
312  kIsNumuCC && truthContain),
313  Sample("bkg", "Truth Containment",
314  !kIsNumuCC && truthContain)});
315 
316 
317  remid.Reserve(10);
318 
319 
320  remid.AddLevel("quality", "Quality", truthContain && kNumuQuality,
321  kGreen+2);
322  remid.AddLevel("containment", "Containment",
323  truthContain && kNumuQuality && kNumuContainFD, kBlue);
324  remid.AddLevel("NCRej", "CVN Loose",
325  truthContain && kNumuQuality && kNumuContainFD && cvn,
326  kMagenta-3);
327 
328  remid.AddLevel("NCRej", "CVN Tight",
329  truthContain && kNumuQuality && kNumuContainFD && cvn2,
330  kCyan-3);
331  remid.AddLevel("NCRej", "ReMId",
332  truthContain && kNumuQuality && kNumuContainFD && kNumuNCRej,
333  kRed);
334 
335 
336  OscillatableSpectrum cvnSig(nonswap, cvnAxis, kIsNumuCC && truthContain);
337  OscillatableSpectrum cvnBkg(nonswap, cvnAxis, !kIsNumuCC && truthContain);
338 
339 
340 
341  nonswap.Go();
342 
343  CanMan canMan;
344 
346  canMan.NewCan("sig");
347  remid.Draw(3e20, "sig","H", calc, 14, 14);
348 
349  canMan.NewCan("sig_eff");
350  remid.DrawEfficiency(3e20, "sig","H", calc, 14, 14);
351 
352  canMan.NewCan("bkg");
353  remid.Draw(3e20, "bkg","H", calc, 14, 14);
354 
355  canMan.NewCan("bkg_eff");
356  remid.DrawEfficiency(3e20, "bkg","H", calc, 14, 14);
357 
358  canMan.NewCan("cvn_dist");
359  TH1* hSig = cvnSig.Oscillated(calc, 14, 14).ToTH1(3e20);
360  TH1* hBkg = cvnBkg.Oscillated(calc, 14, 14).ToTH1(3e20);
361  hSig->SetLineColor(kRed);
362  hBkg->SetLineColor(kBlue);
363  hSig->Draw("HIST ");
364  hBkg->Draw("HIST SAME");
365 
366  TLegend* leg = AutoPlaceLegend(0.35, 0.15);
367  leg->AddEntry(hSig, "Contained #nu_{#mu} Signal", "l");
368  leg->AddEntry(hBkg, "Contained Background", "l");
369  leg->Draw();
370 
371 
372 
373  delete calc;
374 
375  osc::IOscCalc* calcOsc = new osc::OscCalcDumb();
376  canMan.NewCan("sig_osc");
377  remid.Draw(3e20, "sig","H", calcOsc, 14, 14);
378 
379  canMan.NewCan("sig_eff_osc");
380  remid.DrawEfficiency(3e20, "sig","H", calcOsc, 14, 14);
381 
382  canMan.NewCan("bkg_osc");
383  remid.Draw(3e20, "bkg","H", calcOsc, 14, 14);
384 
385  canMan.NewCan("bkg_eff_osc");
386  remid.DrawEfficiency(3e20, "bkg","H", calcOsc, 14, 14);
387 
388  canMan.NewCan("cvn_dist_osc");
389  TH1* hSigOsc = cvnSig.Oscillated(calcOsc, 14, 14).ToTH1(3e20);
390  TH1* hBkgOsc = cvnBkg.Oscillated(calcOsc, 14, 14).ToTH1(3e20);
391  hSigOsc->SetLineColor(kRed);
392  hBkgOsc->SetLineColor(kBlue);
393  hBkgOsc->Draw("HIST");
394  hSigOsc->Draw("HIST SAME ");
395 
396  TLegend* legOsc = AutoPlaceLegend(0.35, 0.15);
397  legOsc->AddEntry(hSigOsc, "Contained #nu_{#mu} Signal", "l");
398  legOsc->AddEntry(hBkgOsc, "Contained Background", "l");
399  legOsc->Draw();
400 
401  canMan.SaveCans("cvn_plots/", ".pdf");
402 
403 }
Definition: canMan.py:1
enum BeamMode kRed
float missE
sum of energy of particles that leave detector. example cut: missE/trueE > 0.01 is truly uncontained ...
Definition: SRContain.h:21
TCanvas * SaveCans(std::string prefix="", std::string suffix=".pdf")
Definition: numu_cut_flow.C:71
General interface to oscillation calculators.
Definition: StanTypedefs.h:22
const Cut kNumuContainFD([](const caf::SRProxy *sr){ std::pair< int, int > planes=calcFirstLastLivePlane(sr->slc.firstplane, std::bitset< 14 >(sr->hdr.dibmask));int planestofront=sr->slc.firstplane-planes.first;int planestoback=planes.second-sr->slc.lastplane;return( sr->slc.ncellsfromedge > 1 &&planestofront > 1 &&planestoback > 1 &&sr->sel.contain.kalfwdcell > 10 &&sr->sel.contain.kalbakcell > 10 &&sr->sel.contain.cosfwdcell > 0 &&sr->sel.contain.cosbakcell > 0);})
Definition: NumuCuts.h:20
Defines an enumeration for prong classification.
osc::OscCalcDumb calc
_NoOscillations< double > NoOscillations
Definition: IOscCalc.h:67
const HistAxis kNumuCCAxis("Reconstructed Neutrino Energy (GeV)", kNumuEnergyBinning, kCCE)
Definition: HistAxes.h:8
TCanvas * NewCan(std::string name, std::string title)
Definition: numu_cut_flow.C:60
Simple oscillation probability calculator that has no solar term or mass hierarchy or delta so it&#39;s s...
Definition: OscCalcDumb.h:16
caf::StandardRecord * sr
const Cut kNumuNCRej([](const caf::SRProxy *sr){return(sr->sel.remid.pid >0.75);})
Definition: NumuCuts.h:24
short nnu
Number of neutrinos in nu vector (0 or 1)
Definition: SRTruthBranch.h:37
The StandardRecord is the primary top-level object in the Common Analysis File trees.
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
SRIDBranch sel
Selector (PID) branch.
SRTruthBranch mc
Truth branch for MC: energy, flavor, etc.
TLegend * AutoPlaceLegend(double dx, double dy, double yPin)
Create a legend, maximizing distance from all histograms.
Definition: Plots.cxx:717
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
A PID for muons.
Definition: FillPIDs.h:10
const Cut kNumuQuality
Definition: NumuCuts.h:18
Spectrum with true energy information, allowing it to be oscillated
enum BeamMode kGreen
enum BeamMode kBlue
SRContain contain
Output from SRContain (containment related variables)
Definition: SRIDBranch.h:51
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