Namespaces | Functions
fiducial_optimization.C File Reference
#include "CAFAna/XSec/CutOptimization.h"
#include "NDAna/nuebarcc_inc/NuebarCCIncCuts.h"
#include "NDAna/nuebarcc_inc/NuebarCCIncExtra.h"
#include "3FlavorAna/Vars/NueVars.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Analysis/Exposures.h"
#include "CAFAna/Systs/XSecSystLists.h"
#include "CAFAna/Vars/XsecTunes.h"
#include "CAFAna/Vars/PPFXWeights.h"
#include "CAFAna/XSec/GenieMultiverseSyst.h"
#include "CAFAna/XSec/FluxMultiverseSyst.h"
#include "NDAna/muonid/NDXSecMuonPID.h"

Go to the source code of this file.

Namespaces

 nuebarccinc
 

Functions

void load_libs_muonid ()
 
void fiducial_optimization (int axis=0)
 

Function Documentation

void fiducial_optimization ( int  axis = 0)

Definition at line 34 of file fiducial_optimization.C.

References allInOneTrainingPlots::axis, Cut(), ana::CutFromNuTruthCut(), ana::CutOptimization::DefineMultiverseSystematic(), ana::CutOptimization::DefineNominal(), ana::CutOptimization::DefineSystematic(), ana::getAllXsecSysts_2020(), ana::GenieMultiverseParameters::GetSystShifts(), ana::CutOptimization::Go(), nuebarccinc::kCVNNueIDCut, nuebarccinc::kDQ, nuebarccinc::kFrontPlanes, nuebarccinc::kMuonIDProd4Cut, nuebarccinc::kNHits, nuebarccinc::kNuebarCCIncContainmentLoose, nuebarccinc::kNuebarCCIncFiducialLoose, nuebarccinc::kNuebarCCST, nuebarccinc::kNueCCST, ana::kPPFXFluxCVWgt, ana::numubarccpi0::kSignal, ana::kStandardSpillCuts, nuebarccinc::kTrueDetectorST, ana::kVtxX, ana::kVtxY, ana::kVtxZ, ana::kXSecCVWgt2020, load_libs_muonid(), loaders, make_training::optimizer, output, nuebarccinc::PROD5_MC_RHC_CALIB_DOWN, nuebarccinc::PROD5_MC_RHC_CALIB_SHAPE, nuebarccinc::PROD5_MC_RHC_CALIB_UP, nuebarccinc::PROD5_MC_RHC_CHERENKOV, nuebarccinc::PROD5_MC_RHC_LIGHT_DOWN, nuebarccinc::PROD5_MC_RHC_LIGHT_UP, nuebarccinc::PROD5_MC_RHC_NOMINAL, ana::CutOptimization::SaveTo(), and ana::CutOptimization::SetSpillCuts().

35 {
37 
38  // axis = 0, 1, 2 for x, y, z respectively
39  std::map<TString, SpectrumLoader *> loaders;
40  loaders["kNominal"] = new SpectrumLoader(nuebarccinc::PROD5_MC_RHC_NOMINAL );
41  loaders["kCalibNeg"] = new SpectrumLoader(nuebarccinc::PROD5_MC_RHC_CALIB_DOWN );
42  loaders["kCalibPos"] = new SpectrumLoader(nuebarccinc::PROD5_MC_RHC_CALIB_UP );
43  loaders["kCalibShape"] = new SpectrumLoader(nuebarccinc::PROD5_MC_RHC_CALIB_SHAPE);
44  loaders["kLightUpCalibDown"] = new SpectrumLoader(nuebarccinc::PROD5_MC_RHC_LIGHT_UP );
45  loaders["kLightDownCalibUp"] = new SpectrumLoader(nuebarccinc::PROD5_MC_RHC_LIGHT_DOWN );
46  loaders["kCherenkov"] = new SpectrumLoader(nuebarccinc::PROD5_MC_RHC_CHERENKOV );
47 
48 
49  std::vector<std::string> opti_labels = {"fiducial_vtx_x", "fiducial_vtx_y", "fiducial_vtx_z"};
50  // define a hist axis to optimize
51  std::vector<const HistAxis *> opti_axes = {new HistAxis("Vertex in X Direction (cm)",
52  Binning::Simple(40, -200, 200),
53  kVtxX),
54  new HistAxis("Vertex in Y Direction (cm)",
55  Binning::Simple(40, -200, 200),
56  kVtxY),
57  new HistAxis("Vertex in Z Direction (cm)",
58  Binning::Simple(80, 0, 1200),
59  kVtxZ)};
60  // Define selection and signal cuts
63  // This demo is for fiducial cut optimization so the selection
64  // should be all preselection minus fiducial constraints
65  const Cut * kSelection = new Cut(nuebarccinc::kDQ &&
72 
73 
74  // central value weight to be applied to all samples
75  const Var * kCVWeight = new Var(kPPFXFluxCVWgt * kXSecCVWgt2020);
76 
77  // nominal definition
78  SystematicDef * sNominal =
79  new SystematicDef("sNominal",
80  loaders["kNominal"],
81  opti_axes[axis],
82  kCVWeight);
83 
84  // systematic definitions
85  SystematicDef * sLightlevelUpDown =
86  new SystematicDef("sLightlevelUpDown",
87  loaders["kLightUpCalibDown"],
88  loaders["kLightDownCalibUp"],
89  opti_axes[axis],
90  kCVWeight);
91  SystematicDef * sCalibPosNeg =
92  new SystematicDef("sCalibPosNeg",
93  loaders["kCalibPos"],
94  loaders["kCalibNeg"],
95  opti_axes[axis],
96  kCVWeight);
97  SystematicDef * sCalibShape =
98  new SystematicDef("sCalibShape",
99  loaders["kCalibShape"],
100  opti_axes[axis],
101  kCVWeight);
102  SystematicDef * sCherenkov =
103  new SystematicDef("sCherenkov",
104  loaders["kCherenkov"],
105  opti_axes[axis],
106  kCVWeight);
107 
108  // Setup the genie multiverses
109  // We take flux uncertainty to be constant, so no need for PPFX universe
110  GenieMultiverseParameters genie_multiverse(300, getAllXsecSysts_2020());
111  std::vector<SystShifts> genie_shifts = genie_multiverse.GetSystShifts();
112 
113  SystematicDef * sGenieMultiverse =
114  new SystematicDef("sGenieMultiverse",
115  loaders["kNominal"],
116  opti_axes[axis],
117  kCVWeight);
118 
119  // create the optimizer.
121  optimizer = new CutOptimization(opti_axes[axis],
122  kSignal,
123  kSelection);
124  optimizer->DefineNominal(sNominal);
125  optimizer->DefineSystematic(sLightlevelUpDown);
126  optimizer->DefineSystematic(sCalibPosNeg );
127  optimizer->DefineSystematic(sCalibShape );
128  optimizer->DefineSystematic(sCherenkov );
129  optimizer->DefineMultiverseSystematic(sGenieMultiverse, genie_shifts);
130  // optionally set spill cuts for all loaders
131  optimizer->SetSpillCuts(kStandardSpillCuts);
132 
133 
134  // Let the loaders go
135  optimizer->Go();
136 
137  // save to file
138  TFile * output = new TFile(("fiducial_optimization_" + opti_labels[axis] + ".root").c_str(), "recreate");
139  optimizer->SaveTo(output, opti_labels[axis].c_str());
140  output->Close();
141 
142 }
ofstream output
const ana::Cut kCVNNueIDCut
const ana::NuTruthCut kNuebarCCST([](const caf::SRNeutrinoProxy *truth){return(truth->iscc && truth->pdg==-12 && truth->pdgorig==-12);})
_HistAxis< Var > HistAxis
Definition: HistAxis.h:103
const ana::Var kNHits([](const caf::SRProxy *sr){return sr->slc.nhit;})
const Var kPPFXFluxCVWgt
Definition: PPFXWeights.h:16
const ana::Cut kFrontPlanes
const std::string PROD5_MC_RHC_LIGHT_UP
const ana::NuTruthCut kTrueDetectorST([](const caf::SRNeutrinoProxy *sr){return(sr->vtx.X()< tvtxmax.X()&&sr->vtx.X() > tvtxmin.X()&&sr->vtx.Y() > tvtxmin.Y()&&sr->vtx.Y()< tvtxmax.Y()&&sr->vtx.Z() > tvtxmin.Z()&&sr->vtx.Z()< tvtxmax.Z());})
const ana::NuTruthCut kNueCCST([](const caf::SRNeutrinoProxy *truth){return(truth->iscc && truth->pdg==12 && truth->pdgorig==12);})
const std::string PROD5_MC_RHC_CALIB_DOWN
GenericSystematicDef< caf::SRProxy > SystematicDef
const Var kVtxX
const std::string PROD5_MC_RHC_LIGHT_DOWN
void DefineNominal(SystematicDef *nominal)
_Var< caf::SRProxy > Var
Representation of a variable to be retrieved from a caf::StandardRecord object.
Definition: Var.h:74
std::vector< const ISyst * > getAllXsecSysts_2020()
void Cut(double x)
Definition: plot_outliers.C:1
const ana::Cut kNuebarCCIncContainmentLoose([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;if(sr->vtx.elastic.fuzzyk.nshwlid< 1) return false;TVector3 start=sr->vtx.elastic.fuzzyk.png[0].shwlid.start;TVector3 stop=sr->vtx.elastic.fuzzyk.png[0].shwlid.stop;for(uint ix=0;ix< sr->vtx.elastic.fuzzyk.nshwlid;ix++){TVector3 start_muoncatcher=sr->vtx.elastic.fuzzyk.png[ix].shwlid.start;TVector3 stop_muoncatcher=sr->vtx.elastic.fuzzyk.png[ix].shwlid.stop;if(std::max(start_muoncatcher.Z(), stop_muoncatcher.Z()) > 1250.0) return false;}if(sr->sel.nuecosrej.distallpngtop< 30) return false;if(sr->sel.nuecosrej.distallpngbottom< 10) return false;if(sr->sel.nuecosrej.distallpngeast< 30) return false;if(sr->sel.nuecosrej.distallpngwest< 10) return false;if(sr->sel.nuecosrej.distallpngfront< 100) return false;return true;})
const std::string PROD5_MC_RHC_NOMINAL
void SaveTo(TDirectory *dir, const std::string &name) const
void DefineMultiverseSystematic(SystematicDef *syst, std::vector< Var > mv_weights)
const std::string PROD5_MC_RHC_CALIB_UP
const std::string PROD5_MC_RHC_CALIB_SHAPE
void SetSpillCuts(const SpillCut &)
const std::string PROD5_MC_RHC_CHERENKOV
const Var kVtxY
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
void DefineSystematic(SystematicDef *syst)
std::vector< Loaders * > loaders
Definition: syst_header.h:386
const Var kVtxZ
const ana::Cut kDQ([](const caf::SRProxy *sr){if(sr->sel.nuecosrej.hitsperplane >=8) return false;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;if(sr->vtx.elastic.fuzzyk.png[0].shwlid.nhitx<=5||sr->vtx.elastic.fuzzyk.png[0].shwlid.nhity<=5) return false;if(sr->vtx.elastic.fuzzyk.png[0].shwlid.gap > 100) return false; if(sr->vtx.elastic.fuzzyk.nshwlid >=2){if((sr->vtx.elastic.fuzzyk.png[0].shwlid.dir). Dot(sr->vtx.elastic.fuzzyk.png[1].shwlid.dir)< -0.95) return false;}float xyhitdiff=abs(sr->vtx.elastic.fuzzyk.png[0].shwlid.nhitx-sr->vtx.elastic.fuzzyk.png[0].shwlid.nhity);float xyhitsum=sr->vtx.elastic.fuzzyk.png[0].shwlid.nhitx+sr->vtx.elastic.fuzzyk.png[0].shwlid.nhity;if(xyhitdiff/xyhitsum >=0.4) return false;float nhitall=0.0;for(unsigned int j=0;j< sr->vtx.elastic.fuzzyk.nshwlid;j++){nhitall+=sr->vtx.elastic.fuzzyk.png[j].shwlid.nhit;}if(nhitall/sr->slc.nhit<=0.7) return false;return true;})
const ana::Cut kMuonIDProd4Cut
Definition: datamc.C:28
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
const ana::Cut kNuebarCCIncFiducialLoose([](const caf::SRProxy *sr){if(!sr->vtx.elastic.IsValid) return false;if(sr->vtx.elastic.vtx.X()< -165.0) return false;if(sr->vtx.elastic.vtx.X() > 165.0) return false;if(sr->vtx.elastic.vtx.Y()< -165.0) return false;if(sr->vtx.elastic.vtx.Y() > 165.0) return false;if(sr->vtx.elastic.vtx.Z()< 100.0) return false;if(sr->vtx.elastic.vtx.Z() > 1000.0) return false;return true;})
Cut CutFromNuTruthCut(const NuTruthCut &stc)
Definition: Cut.cxx:7
void load_libs_muonid()
const Var kXSecCVWgt2020
Definition: XsecTunes.h:105
void load_libs_muonid ( )

Definition at line 27 of file fiducial_optimization.C.

References exit(), and runNovaSAM::ret.

Referenced by fiducial_optimization().

28 {
29  const int ret = gSystem->Load("libNDAnamuonid");
30  if(ret != 0) exit(1);
31 }
exit(0)