fd_data_mc.C
Go to the documentation of this file.
6 #include "CAFAna/Core/Spectrum.h"
10 #include "CAFAna/Vars/Vars.h"
11 #include "CAFAna/Decomp/IDecomp.h"
13 
14 using namespace ana;
15 
19 
20 #include "TCanvas.h"
21 #include "TFile.h"
22 #include "TH1.h"
23 #include "TLegend.h"
24 #include "TPad.h"
25 
26 void fd_data_mc()
27 {
28  //choose your samweb datasets or concat files:
29  SpectrumLoader loaderData("/pnfs/nova/persistent/production/concat/R16-03-03-prod2reco.f/*/prod_restricteddecaf_R16-03-03-prod2reco.f_fd_numi_fhc_*_nue_contain_v1_goodruns_prod2-snapshot/*.root");
30  SpectrumLoader loader("/pnfs/nova/persistent/production/concat/R16-03-03-prod2reco.f/*/*nonswap*_nue_con*.root");
31  SpectrumLoader loaderSwap("/pnfs/nova/persistent/production/concat/R16-03-03-prod2reco.f/*/*fluxswap*_nue_con*.root");
32  SpectrumLoader loaderTauSwap("/pnfs/nova/persistent/production/concat/R16-03-03-prod2reco.f/*/*tau*_nue_con*.root");
33 
34  loaderData.SetSpillCut(kStandardSpillCuts);
36  loaderSwap.SetSpillCut(kStandardSpillCuts);
37  loaderTauSwap.SetSpillCut(kStandardSpillCuts);
38 
39  //which variables do you want to look at?
41  defs.push_back({"2d",{"",Binning::Simple(1,0,1),kUnweighted}});
42  const int kNumVars = defs.size();
43 
44  //which cut combinations do you want to look at?
45  const int kNumSels = 9;
46  const Cut sels[kNumSels] = {kNoCut, kNueSecondAnaFullPresel, kNueSecondAnaFullPresel&&kNueSecondAnaLEMSb,kNueSecondAnaFullPresel&&kNueSecondAnaLIDSb, kNueSecondAnaFullPresel&&kNueSecondAnaCVNSb,kNueSecondAnaFullPresel&&kNueSecondAnaCVNeSsb,kNueSecondAnaFullPresel&&kNueSecondAnaLIDSsb,kNueSecondAnaFullPresel&&kNueSecondAnaLEMSsb,kNueSecondAnaFullPresel&&(kNueSecondAnaCVNeSsb || kNueSecondAnaLIDSsb || kNueSecondAnaLEMSsb)};
47  const std::string selNames[kNumSels] = {"nocut", "presel", "lem", "lid", "cvne","cvneloose","lidloose","lemloose","allloose"};
48 
50  Spectrum* cosm[kNumSels][kNumVars];
51  IPrediction* preds[kNumSels][kNumVars];
52 
53  //loop over the selectors and variables to create a full selection
54  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
55  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
56  if(varIdx < (kNumVars-1)){
57  const HistAxis& axis = defs[varIdx].axis;
58  spects[selIdx][varIdx] = new Spectrum(loaderData, axis, sels[selIdx]&&kInBeamSpill, kNoShift, kTuftsWeightCC);
59  cosm[selIdx][varIdx] = new Spectrum(loaderData, axis, sels[selIdx]&&kInTimingSideband, kNoShift, kTuftsWeightCC);
60  preds[selIdx][varIdx] = new PredictionNoExtrap(loader, loaderSwap, loaderTauSwap,
61  axis.label, axis.bins, axis.var,
62  sels[selIdx], kNoShift, kTuftsWeightCC);
63  }
64  //sneak in a 2d spectrum
65  else{
66  spects[selIdx][varIdx] = new Spectrum("(Slice - Shower) calorimetric energy (GeV);cos#theta",loaderData,Binning::Simple(30, 0, 3), kHadCalE, Binning::Simple(25, 0, +1), kCosTheta, sels[selIdx]&&kInBeamSpill, kNoShift, kTuftsWeightCC);
67  cosm[selIdx][varIdx] = new Spectrum("(Slice - Shower) calorimetric energy (GeV);cos#theta",loaderData,Binning::Simple(30, 0, 3), kHadCalE, Binning::Simple(25, 0, +1), kCosTheta, sels[selIdx]&&kInTimingSideband, kNoShift, kTuftsWeightCC);
68  }
69 
70  }
71  }
72 
73  loader.Go();
74  loaderSwap.Go();
75  loaderTauSwap.Go();
76  loaderData.Go();
77 
78 
79 
80  TFile* fout = new TFile("secondana_fd_data_mc.root", "RECREATE");
81  for(int selIdx = 0; selIdx < kNumSels; ++selIdx){
82  TDirectory* d = fout->mkdir(selNames[selIdx].c_str());
83  for(int varIdx = 0; varIdx < kNumVars; ++varIdx){
84  const char* name = defs[varIdx].name.c_str();
85  spects[selIdx][varIdx]->SaveTo(d->mkdir(TString::Format("spect_%s", name)));
86  cosm[selIdx][varIdx]->SaveTo(d->mkdir(TString::Format("cosm_%s", name)));
87  if(varIdx<kNumVars-1) preds[selIdx][varIdx]->SaveTo(d->mkdir(TString::Format("pred_%s", name)));
88  }
89  }
90 }
const XML_Char * name
Definition: expat.h:151
const int kNumVars
Definition: vars.h:14
Oscillation analysis framework, runs over CAF files outside of ART.
virtual void SaveTo(TDirectory *dir) const
const Cut kNueSecondAnaLEMSb([](const caf::SRProxy *sr){return(sr->sel.lem.pid > 0.8);})
const Cut kNueSecondAnaCVNSb([](const caf::SRProxy *sr){return(sr->sel.cvn.nueid > 0.95);})
HistAxis axis
Definition: NuePlotLists.h:13
void SetSpillCut(const SpillCut &cut)
const Var kHadCalE([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return float(sr->slc.calE);if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return float(sr->slc.calE);return((sr->slc.calE- sr->vtx.elastic.fuzzyk.png[0].shwlid.calE));})
Definition: NueVarsExtra.h:40
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
void fd_data_mc()
Definition: fd_data_mc.C:26
const Cut kNueSecondAnaCVNeSsb([](const caf::SRProxy *sr){return(sr->sel.cvn.nueid > 0.75);})
const Cut sels[kNumSels]
Definition: vars.h:44
Float_t d
Definition: plot.C:236
virtual void Go() override
Load all the registered spectra.
const HistDef defs[kNumVars]
Definition: vars.h:15
loader
Definition: demo0.py:10
const int kNumSels
Definition: vars.h:43
std::string name
Definition: NuePlotLists.h:12
const SystShifts kNoShift
Definition: SystShifts.h:112
std::vector< HistDef > getAllNueSecondAnaFDHistDef()
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
const Cut kNueSecondAnaLIDSb([](const caf::SRProxy *sr){return(sr->sel.lid.ann > 0.95);})
const Var kTuftsWeightCC
Definition: XsecTunes.h:32
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
const Cut kInTimingSideband([](const caf::SRProxy *sr){const double t=sr->slc.meantime;if(t< 1000 *util::kMinTimingSidebandBeforeMicroSec|| t > 1000 *util::kMaxTimingSidebandAfterMicroSec) return false;if(t > 1000 *util::kMaxTimingSidebandBeforeMicroSec && t< 1000 *util::kMinTimingSidebandAfterMicroSec) return false;if(sr->spill.run<=util::kLastBadTimingRun && t > 1000 *util::kMaxTimingSidebandBeforeShiftedWindowMicroSec && t< 1000 *util::kMinTimingSidebandAfterShiftedWindowMicroSec) return false; return true;}, [](const caf::SRSpillProxy *spill){if(spill->run<=util::kLastBadTimingRun) return 1e-6 *util::kTimingSidebandBadPeriodMicroSec;else return 1e-6 *util::kTimingSidebandMicroSec;}, [](const caf::SRSpillProxy *spill){return 0;})
Definition: TimingCuts.h:13
const Cut kNueSecondAnaFullPresel
Full FD nue preselection cuts for Second Analysis.
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
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
void spects(osc::IOscCalculatorAdjustable *calc, IPrediction *predFHC, IPrediction *predRHC)
Definition: sensitivity.C:100
Prediction that just uses FD MC, with no extrapolation.
const Cut kInBeamSpill([](const caf::SRProxy *sr){const double t=sr->slc.meantime;const int run=sr->spill.run;return util::IsInBeamWindow(run, t);}, [](const caf::SRSpillProxy *spill){if(spill->run<=util::kLastBadTimingRun) return 1e-6 *util::kBeamWindowBadPeriodMicroSec;else return 1e-6 *util::kBeamWindowMicroSec;}, [](const caf::SRSpillProxy *spill){return spill->spillpot;})
Does the event fall inside the window we call the beam spill?
Definition: TimingCuts.h:9
const Var kCosTheta
const std::string selNames[kNumSels]
Definition: vars.h:46
loaderSwap
Definition: demo4.py:9
static Binning Simple(int n, double lo, double hi, const std::vector< std::string > &labels={})
Definition: Binning.cxx:38
const Cut kNueSecondAnaLIDSsb([](const caf::SRProxy *sr){return(sr->sel.lid.ann > 0.63);})
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
const Cut kNueSecondAnaLEMSsb([](const caf::SRProxy *sr){return(sr->sel.lem.pid > 0.47);})
void SaveTo(TDirectory *dir) const
Definition: Spectrum.cxx:1029