CutFlow_Data.C
Go to the documentation of this file.
1 #include "CAFAna/Cuts/Cuts.h"
6 
8 #include "CAFAna/Core/Spectrum.h"
10 
11 #include "CAFAna/Vars/Vars.h"
14 
17 
18 using namespace ana;
19 
20 #include "TStyle.h"
21 #include "TCanvas.h"
22 #include "TH1.h"
23 #include "TLegend.h"
24 #include "TLatex.h"
25 
26 #include <fstream>
27 
28 struct Plot {
33 };
34 
36 {
37  // --- Set my loader.
38  SpectrumLoader loader( "prod_restrictedcaf_R17-03-01-prod3reco.k_fd_numi_fhc_full_v1_goodruns" );
39  //SpectrumLoader loader( "/pnfs/nova/production/R17-03-01-prod3reco.k/numi/fd/numu_contain_sa_2017/prod_sumrestricteddecaf*.root" );
41 
42  // --- Define my cuts and their names.
43  std::vector<Cut> TieredCuts;
44  std::vector<std::string> CutNames;
45  CutNames.emplace_back("NoCut"); TieredCuts.emplace_back(kNumu2017Veto && kNoCut);
46  CutNames.emplace_back("Quality"); TieredCuts.emplace_back(kNumu2017Veto && kNumuQuality);
47  CutNames.emplace_back("Containment"); TieredCuts.emplace_back(kNumu2017Veto && kNumuQuality && kNumuContainFD2017);
48  CutNames.emplace_back("Cosmic_Rej"); TieredCuts.emplace_back(kNumu2017Veto && kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2017);
49  CutNames.emplace_back("Particle_ID"); TieredCuts.emplace_back(kNumu2017Veto && kNumuQuality && kNumuContainFD2017 && kNumuCosmicRej2017 && kNumuPID2017 );
50 
51  size_t NCuts = TieredCuts.size();
52 
53  // --- Define my objects.
54  Plot plot = {"CC Energy [GeV]", "NuMuCCEnergy", kNumuCCEOptimisedBinning, kCCE};
55  Spectrum* Cosmics[NCuts];
56  Spectrum* BeamNus[NCuts];
57 
58  // --- Set my objects.
59  for(size_t cut = 0; cut < NCuts; ++cut) {
60  const Cut Cut_Cosm = TieredCuts[cut] && kInTimingSideband;
61  const Cut Cut_Beam = TieredCuts[cut] && kInBeamSpill;
62  Cosmics[cut] = new Spectrum( plot.label, plot.bins, loader, plot.var, Cut_Cosm, kNoShift, kTimingSidebandWeight );
63  BeamNus[cut] = new Spectrum( plot.label, plot.bins, loader, plot.var, Cut_Beam, kNoShift, kUnweighted );
64  }
65 
66  // --- Set the loader off!
67  loader.Go();
68 
69  // --- Define an outfile.
70  std::string OutName = "DataCutFlow.root";
71  TFile *OutFile = new TFile(OutName.c_str(), "RECREATE");
72  OutFile -> cd();
73  for(size_t cut = 0; cut < NCuts; ++cut){
74  Cosmics[cut] -> SaveTo( OutFile, TString(CutNames[cut])+TString("_Cosmics") ) ;
75  BeamNus[cut] -> SaveTo( OutFile, TString(CutNames[cut])+TString("_BeamNus") ) ;
76  }
77 } // End of function
size_t NCuts
Definition: MakeCutFlow.C:50
void CutFlow_Data()
Definition: CutFlow_Data.C:35
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
void SaveTo(const osc::IOscCalc &x, TDirectory *dir, const std::string &name)
std::string label
Definition: CutFlow_Data.C:29
std::vector< double > Spectrum
Definition: Constants.h:746
void SetSpillCut(const SpillCut &cut)
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:39
const Cut kInTimingSideband([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return(kInTimingSideband_before(sr)|| kInTimingSideband_after(sr));else return(kInTimingSideband_before(sr)|| kInTimingSideband_afterA(sr)|| kInTimingSideband_afterB(sr));}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_after.Livetime(spill));else return(kInTimingSideband_before.Livetime(spill)+ kInTimingSideband_afterA.Livetime(spill)+ kInTimingSideband_afterB.Livetime(spill));}, [](const caf::SRSpillProxy *spill){return 0;})
Definition: TimingCuts.h:12
const Cut kNumu2017Veto([](const caf::SRProxy *sr){return sr->sel.veto.keep;})
cosmic veto cut for FD
Definition: NumuCuts2017.h:30
====================================================================== ///
Definition: CutFlow_Data.C:28
const Cut kNumuContainFD2017
Definition: NumuCuts2017.h:21
const Var kCCE
Definition: NumuVars.h:21
virtual void Go() override
Load all the registered spectra.
loader
Definition: demo0.py:10
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:22
std::string fname
Definition: CutFlow_Data.C:30
const Cut cut
Definition: exporter_fd.C:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
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
const Cut kInBeamSpill([](const caf::SRProxy *sr){if(sr->spill.run > util::kLastBadTimingRun) return kInBeamSpill_main(sr);else return kInBeamSpill_main(sr)||kInBeamSpill_shifted(sr);}, [](const caf::SRSpillProxy *spill){if(spill->run > util::kLastBadTimingRun) return kInBeamSpill_main.Livetime(spill);else return kInBeamSpill_main.Livetime(spill)+kInBeamSpill_shifted.Livetime(spill);}, [](const caf::SRSpillProxy *spill) -> double{return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:8
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
TFile * OutFile
Binning bins
Definition: CutFlow_Data.C:31
const Cut kNumuQuality
Definition: NumuCuts.h:18
Var var
Definition: CutFlow_Data.C:32
const Var kUnweighted
Definition: Var.h:14
c cd(1)
const Cut kNoCut
Definition: Cut.h:13
static bool plot
std::vector< std::string > CutNames
Definition: MakeCutFlow.C:49
enum BeamMode string