nue_nd_cutflow_table.C
Go to the documentation of this file.
2 
3 #include "CAFAna/Cuts/Cuts.h"
8 
9 #include <iomanip>
10 #include <iostream>
11 #include <deque>
12 
13 using namespace ana;
14 
16 {
17  const double Na = a.Integral(1e20);
18  const double Nb = b.Integral(1e20);
19 
20  if(Na > Nb) return "";
21 
22  return TString::Format("%.02lf\\%%", 100*Na/Nb).Data();
23 }
24 
26 {
28 }
29 
31  const std::string& label,
32  PredictionNoExtrap* mcDenom1, PredictionNoExtrap* mcDenom2,
33  Spectrum* dataDenom1, Spectrum* dataDenom2)
34 {
36 
37  std::cout << label
38  << " & " << std::lround(mc->PredictUnoscillated().Integral(data->POT()))
39  << " & " << Efficiency(mc, mcDenom1)
40  << " & " << Efficiency(mc, mcDenom2)
41  << " & " << std::lround(mc->PredictComponent(&noosc,
44  Sign::kBoth).Integral(data->POT()))
45  << " & " << std::lround(mc->PredictComponent(&noosc,
48  Sign::kBoth).Integral(data->POT()))
49  << " & " << std::lround(mc->PredictComponent(&noosc,
52  Sign::kBoth).Integral(data->POT()))
53  << " & " << std::lround(data->Integral(data->POT()))
54  << " & " << Efficiency(*data, *dataDenom1)
55  << " & " << Efficiency(*data, *dataDenom2)
56  << " \\\\" << std::endl;
57 }
58 
59 std::vector<Cut> MakeCutSequence(std::deque<Cut> cuts)
60 {
61  std::vector<Cut> ret = {cuts.front()};
62  cuts.pop_front();
63  for(Cut& cut: cuts){
64  ret.push_back(ret.back() && cut);
65  }
66  return ret;
67 }
68 
70 {
71  const std::string fnameMC = "prod_caf_S15-05-22_nd_genie_fhc_nonswap";
72  const std::string fnameData = "prod_caf_S15-05-22a_nd_numi_goodruns";
73 
74  SpectrumLoader loaderMC(fnameMC);
75  loaderMC.SetSpillCut(kStandardDQCuts);
76  SpectrumLoader loaderData(fnameData);
77  loaderData.SetSpillCut(kStandardSpillCuts);
78 
79  std::vector<Cut> cuts = MakeCutSequence({kNoCut,
88 
89  Cut fullPresel = cuts.back();
90 
91  cuts.push_back(fullPresel && kNueFirstAnaLEMOpt);
92  cuts.push_back(fullPresel && kNueFirstAnaLIDOpt);
93 
94  const std::vector<std::string> labels = {"No cut",
95  "Data quality",
96  "Reconstruction",
97  "Fiducial",
98  "Containment",
99  "Front planes",
100  "Slice hits and $E_{\\rm cal}$",
101  "Shower length",
102  "Gap",
103  "LEM",
104  "LID"};
105  assert(labels.size() == cuts.size());
106 
107  const HistAxis axis("", Binning::Simple(1, 0, 1), kUnweighted);
108 
109  std::vector<Spectrum*> data;
110  std::vector<PredictionNoExtrap*> mc;
111  for(unsigned int i = 0; i < cuts.size(); ++i){
112  data.push_back(new Spectrum(loaderData, axis, cuts[i]));
113  mc.push_back(new PredictionNoExtrap(loaderMC, kNullLoader, kNullLoader,
114  "", Binning::Simple(1, 0, 1), kUnweighted, cuts[i]));
115  }
116 
117  loaderMC.Go();
118  loaderData.Go();
119 
120 
121  std::cout << "\\begin{tabular}{r|rrr|rrr|rrr}" << std::endl;
122  std::cout << "& \\multicolumn{1}{c}{Total MC} & \\multicolumn{2}{c|}{Efficiency} & \\multicolumn{1}{c}{$\\nu_{\\mu}$ CC} & \\multicolumn{1}{c}{$\\nu_{e}$ CC} & \\multicolumn{1}{c|}{NC} & \\multicolumn{1}{c}{Data} & \\multicolumn{2}{c}{Efficiency} \\\\" << std::endl;
123  std::cout << "\\hline" << std::endl;
124  for(unsigned int i = 0; i < cuts.size(); ++i){
125  GetSpectra(mc[i], data[i], labels[i], mc[0], mc[8], data[0], data[8]);
126  if(i == 8) std::cout << "\\hline" << std::endl;
127  }
128  std::cout << "\\end{tabular}" << std::endl;
129 }
const Cut kNueNDFirstAnaRecoQuality([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;if(sr->vtx.elastic.fuzzyk.npng==0) return false;if(sr->vtx.elastic.fuzzyk.nshwlid==0) return false;return true;})
Minimum ND reconstruction requirements from docdb-12943.
const Cut kNueFirstAnaLIDOpt([](const caf::SRProxy *sr){return(sr->sel.lid.ann > 0.95);})
From Tian&#39;s docdb 12673 optimized lid cut.
const Cut kNueNDFirstAnaEnergy
Pass neutrinos through unchanged.
const Cut kNueNDFirstAnaHits([](const caf::SRProxy *sr){if(sr->slc.nhit<=20||sr->slc.nhit >=200) return false;return true;})
Minimum cell hit requirement, docdb-12943.
void nue_nd_cutflow_table()
Oscillation analysis framework, runs over CAF files outside of ART.
Spectrum PredictComponent(osc::IOscCalculator *calc, Flavors::Flavors_t flav, Current::Current_t curr, Sign::Sign_t sign) const override
std::vector< Cut > MakeCutSequence(std::deque< Cut > cuts)
const int Na
(&#39;beam &#39;)
Definition: IPrediction.h:15
const Cut kNueNDFirstAnaGap([](const caf::SRProxy *sr){assert(sr->vtx.elastic.fuzzyk.nshwlid > 0 &&"Must apply DQ cuts");if(sr->vtx.elastic.fuzzyk.png[0].shwlid.gap > 100.0) return false;return true;})
Remove large gaps between shower and vertex (reco failure), docdb-12943.
virtual Spectrum PredictUnoscillated() const
Definition: IPrediction.cxx:82
const Cut kNueNDFirstAnaProngLength([](const caf::SRProxy *sr){assert(sr->vtx.elastic.IsValid &&"Must apply DQ cuts");if(sr->vtx.elastic.fuzzyk.npng==0) return false;if(sr->vtx.elastic.fuzzyk.png[0].len<=140.0||sr->vtx.elastic.fuzzyk.png[0].len >=500.0) return false;return true;})
longest 3d fuzzk prong, docdb-12943
const Cut kNueNDFrontPlanesCut
No hits in the first 5 planes of the detector, doc 12879.
void SetSpillCut(const SpillCut &cut)
double Integral(double exposure, double *err=0, EExposureType expotype=kPOT) const
Return total number of events scaled to pot.
Definition: Spectrum.cxx:742
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
const Cut kNueFirstAnaLEMOpt([](const caf::SRProxy *sr){return(sr->sel.lem.pid > 0.80);})
From Tian&#39;s docdb 12673 optimized lem cut.
const char * label
const XML_Char const XML_Char * data
Definition: expat.h:268
Charged-current interactions.
Definition: IPrediction.h:39
const double a
const SpillCut kStandardDQCuts([](const caf::SRSpillProxy *spill){if(spill->dcmedgematchfrac==0 &&spill->fracdcm3hits==0 &&spill->nmissingdcmslg==0) return bool(spill->isgoodspill); if(spill->det==caf::kNEARDET && (spill->fracdcm3hits > 0.45|| spill->nmissingdcms > 0)) return false; if(spill->eventincomplete) return false; if(spill->det==caf::kFARDET && spill->nmissingdcmslg > 0) return false; if(spill->det==caf::kFARDET && !spill->ismc && spill->dcmedgematchfrac<=0.2) return false;return true;})
Cut out events with a noisy detector or with parts missing.
Definition: SpillCuts.h:12
virtual void Go() override
Load all the registered spectra.
osc::NoOscillations noosc
Definition: NueSystFuncs.h:44
double POT() const
Definition: Spectrum.h:263
OStream cout
Definition: OStream.cxx:6
std::pair< Spectrum *, Spectrum * > Efficiency(SpectrumLoaderBase &loader, const NuTruthHistAxis &axis, const Cut &seln, const NuTruthCut &truthSeln, const SystShifts &shift, const NuTruthVar &weight)
Definition: Efficiency.cxx:10
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut cut
Definition: exporter_fd.C:30
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Cut kNueNDFirstAnaFiducial([](const caf::SRProxy *sr){assert(sr->vtx.elastic.IsValid &&"Must apply DQ cuts");if(sr->vtx.elastic.vtx.X()< -140.0) return false;if(sr->vtx.elastic.vtx.X() > 140.0) return false;if(sr->vtx.elastic.vtx.Y()< -140.0) return false;if(sr->vtx.elastic.vtx.Y() > 140.0) return false;if(sr->vtx.elastic.vtx.Z()< 100.0) return false;if(sr->vtx.elastic.vtx.Z() > 700.0) return false;return true;})
ND vertex containment from docdb-12943.
const hit & b
Definition: hits.cxx:21
Neutral-current interactions.
Definition: IPrediction.h:40
Both neutrinos and antineutrinos.
Definition: IPrediction.h:52
const int Nb
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:28
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
Prediction that just uses FD MC, with no extrapolation.
All neutrinos, any flavor.
Definition: IPrediction.h:26
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:100
const Cut kNoCut
The simplest possible cut: pass everything, used as a default.
Definition: Cut.h:117
static NullLoader kNullLoader
Dummy loader that doesn&#39;t load any files.
const Cut kNueNDFirstAnaDQ([](const caf::SRProxy *sr){if(sr->sel.nuecosrej.hitsperplane >=8) return false;return true;})
Cut on ND data quality from docdb-12943.
const Cut kNueNDFirstAnaContain([](const caf::SRProxy *sr){for(unsigned int ix=0;ix< sr->vtx.elastic.fuzzyk.nshwlid;++ix){TVector3 start=sr->vtx.elastic.fuzzyk.png[ix].shwlid.start;TVector3 stop=sr->vtx.elastic.fuzzyk.png[ix].shwlid.stop;if(std::min(start.X(), stop.X())< -180.0) return false;if(std::max(start.X(), stop.X()) > 180.0) return false;if(std::min(start.Y(), stop.Y())< -180.0) return false;if(std::max(start.Y(), stop.Y()) > 180.0) return false;if(std::min(start.Z(), stop.Z())< 25.0) return false;if(std::max(start.Z(), stop.Z()) > 1225.0) return false;}return true;})
Loose containtment on start and end of all showers, docdb-12943.
void GetSpectra(PredictionNoExtrap *mc, Spectrum *data, const std::string &label, PredictionNoExtrap *mcDenom1, PredictionNoExtrap *mcDenom2, Spectrum *dataDenom1, Spectrum *dataDenom2)