Functions | Variables
ExampleCode.C File Reference
#include "StandardRecord/Proxy/SRProxy.h"
#include "CAFAna/Core/Loaders.h"
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Core/Spectrum.h"
#include "CAFAna/Core/SpectrumLoader.h"
#include "CAFAna/Core/EventList.h"
#include "CAFAna/Core/Utilities.h"
#include "CAFAna/Analysis/Prod5Loaders.h"
#include "CAFAna/Cuts/Cuts.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Vars/Vars.h"
#include "CAFAna/Prediction/PredictionNoExtrap.h"
#include "CAFAna/Prediction/PredictionGenerator.h"
#include "3FlavorAna/Vars/NueVarsExtra.h"
#include "3FlavorAna/Vars/NumuVarsExtra.h"
#include "3FlavorAna/Cuts/NueCuts2020.h"
#include "3FlavorAna/Cuts/NumuCuts2020.h"
#include "NuXAna/Cuts/NusCuts20.h"
#include "NuXAna/Cuts/NusCuts.h"
#include "NuXAna/Vars/NusVars.h"
#include "NuXAna/Vars/NusVarsTemp.h"
#include "TMVA/Reader.h"
#include "TMVA/IMethod.h"
#include "TString.h"
#include "NuXAna/macros/Nus20/Selection/PredictionHandler.h"
#include "NuXAna/macros/Nus20/Selection/Structs.h"
#include "TFile.h"
#include "TCanvas.h"
#include "TH1.h"
#include "TH2.h"
#include <cassert>

Go to the source code of this file.

Functions

void addVars (PredictionHandler *predH, std::string det)
 
void ExampleCode (TString opt)
 

Variables

const ana::Binning kPartPtpBins = ana::Binning::Simple(50 , 0 , 1 )
 
std::vector< VarContainervarsFD
 
std::vector< VarContainervarsND
 
std::vector< CutContainercutsFD
 
std::vector< CutContainercutsND
 

Function Documentation

void addVars ( PredictionHandler predH,
std::string  det 
)

Definition at line 184 of file ExampleCode.C.

References PredictionHandler::AddVar(), om::cout, update_sam_good_runs_metadata::cuts, cutsFD, cutsND, allTimeWatchdog::endl, ana::kNoShift, ana::kUnweighted, string, vars, varsFD, and varsND.

Referenced by ExampleCode().

184  {
185 
186  std::vector<VarContainer> vars;
187  std::vector<CutContainer> cuts;
188 
189  if (det == "nd"){
190  vars = varsND;
191  cuts = cutsND;
192  }
193  else if (det == "fd"){
194  vars = varsFD;
195  cuts = cutsFD;
196  }
197  else {
198  throw std::logic_error("options for detector are nd or fd");
199  }
200 
201  for (size_t iCut = 0; iCut < cuts.size(); ++iCut){
202 
203  ana::Cut fullCut = cuts.at(iCut).cut;
204  std::string fullName = cuts.at(iCut).name;
205 
206  for (size_t iVar = 0; iVar < vars.size(); ++iVar){
207 
208  std::cout << vars.at(iVar).name+fullName << std::endl;
209 
210  predH->AddVar((vars.at(iVar).name+fullName).c_str(),
211  vars.at(iVar).label.c_str(),
212  vars.at(iVar).var,
213  vars.at(iVar).bins,
214  fullCut,
215  kNoShift,
216  kUnweighted,
217  cuts.at(iCut).cutdata);
218  }
219  }
220 }
std::vector< VarContainer > varsFD
Definition: ExampleCode.C:55
virtual void AddVar(std::string name, HistAxis axis, Cut cuts, SystShifts shift, Var weight, bool cutdata=true)=0
const std::map< std::pair< std::string, std::string >, Variable > vars
std::vector< CutContainer > cutsFD
Definition: ExampleCode.C:65
const SystShifts kNoShift
Definition: SystShifts.cxx:22
OStream cout
Definition: OStream.cxx:6
std::vector< VarContainer > varsND
Definition: ExampleCode.C:59
std::vector< CutContainer > cutsND
Definition: ExampleCode.C:69
const Var kUnweighted
The simplest possible Var, always 1. Used as a default weight.
Definition: Var.h:96
enum BeamMode string
void ExampleCode ( TString  opt)

Definition at line 80 of file ExampleCode.C.

References FDPredictionHandler::AddCosmics(), FDPredictionHandler::AddData(), PredictionHandler::AddData(), FDPredictionHandler::AddLoaders(), PredictionHandler::AddLoaders(), addVars(), ana::assert(), om::cout, allTimeWatchdog::endl, plot_xsec_2d::fileOut, ana::SpectrumLoader::Go(), ana::Loaders::Go(), ana::kCosmic, kFHC, ana::kFullCAF, ana::kNusConcat, ana::kStandardSpillCuts, ana::kStandardSpillCuts_FD_Prod4MotivatedDQ, FDPredictionHandler::Save(), NDPredictionHandler::Save(), ana::Loaders::SetSpillCut(), ana::SpectrumLoaderBase::SetSpillCut(), and string.

80  {
81 
82  bool isCaf = opt.Contains("caf" , TString::kIgnoreCase);
83  bool isConcat = opt.Contains("concat", TString::kIgnoreCase);
84  assert(isCaf or isConcat);
85 
86  bool isND = opt.Contains("nd" , TString::kIgnoreCase);
87  bool isFD = opt.Contains("fd" , TString::kIgnoreCase);
88  bool isFDData = opt.Contains("fddata" , TString::kIgnoreCase);
89  bool isNDData = opt.Contains("nddata" , TString::kIgnoreCase);
90 
91  bool isCosmic = opt.Contains("cos" , TString::kIgnoreCase);
92  bool isSysts = opt.Contains("syst" , TString::kIgnoreCase);
93 
94  // ----------------------
95  // set up loaders
96  // ----------------------
97  // - prod5Nom loaders to take advantage of using both nonswap and swap files
98  // - FD data loader (obviously not useful right now)
99  // - ND data loader. Set to be ND burner Set
100  // - cosmic loader for cosmics files at the far detector
101 
102  // placeholders...
103  std::string kFDDataFHCNus20Concat = "";
104  std::string kFDDataFHCNus20CAF = "";
105  std::string kFDCosmicFHCProd5 = "prod_sumdecaf_R19-11-18-prod5reco.i_fd_cosmic_fhc_full_v1_goodruns_nus2020";
106  std::string kNDBurnerData = "nux_burner_prod_caf_R19-11-18-prod5reco.d.f.h_nd_numi_fhc_period235910_v1_goodruns";
107 
108  Loaders* loadersMC = new Prod5NomLoaders(
111  loadersMC->SetSpillCut(kStandardSpillCuts);
112 
113  SpectrumLoader* loadersFDData = nullptr;
114  if (isFDData) {
115  const std::string dataDef =
116  isConcat? kFDDataFHCNus20Concat : kFDDataFHCNus20CAF;
117  loadersFDData = new SpectrumLoader(dataDef);
118  loadersFDData->SetSpillCut(kStandardSpillCuts);
119  }
120 
121  SpectrumLoader* loadersNDData = nullptr;
122  if (isNDData) {
123  loadersNDData = new SpectrumLoader(kNDBurnerData);
124  loadersNDData->SetSpillCut(kStandardSpillCuts);
125  }
126 
127  SpectrumLoader* loadersCosmic = nullptr;
128  if (isCosmic){
129  loadersCosmic = new SpectrumLoader(kFDCosmicFHCProd5, kCosmic);
130  loadersCosmic->SetSpillCut(kStandardSpillCuts_FD_Prod4MotivatedDQ); // uses good runs list from prod4
131  }
132 
133  // --------------------------
134  // setup prediction handler
135  // --------------------------
136  // Need one prediction handler for the FD, one for the ND
137  // Set to use noextrap as default in the fd, decomp in the nd
138 
139  FDPredictionHandler fdPredH("NoExtrap");
140  fdPredH.AddLoaders(loadersMC);
141  if (isFDData)
142  fdPredH.AddData(loadersFDData);
143  if (isCosmic)
144  fdPredH.AddCosmics(loadersCosmic);
145 
146  NDPredictionHandler ndPredH("Decomp");
147  ndPredH.AddLoaders(loadersMC);
148  if (isNDData)
149  ndPredH.AddData(loadersNDData);
150 
151  if (isFD)
152  addVars(&fdPredH, "fd");
153 
154  if (isND)
155  addVars(&ndPredH, "nd");
156 
157  //--------------------------
158  // GO GO GO
159  // -------------------------
160 
161  loadersMC->Go();
162  if (isFDData)
163  loadersFDData->Go();
164  if (isNDData)
165  loadersNDData->Go();
166  if (isCosmic)
167  loadersCosmic->Go();
168 
169  std::cout << "got all spectra" << std::endl;
170 
171  // setup output file
172  std::string fileOutName = "SelectionSpectr_Unosc.root";
173  TFile* fileOut = new TFile(fileOutName.c_str(), "RECREATE");
174 
175  if (isFD)
176  fdPredH.Save(fileOut);
177  if (isND)
178  ndPredH.Save(fileOut);
179 
180  fileOut->Close();
181 
182 }
const SpillCut kStandardSpillCuts_FD_Prod4MotivatedDQ
Definition: SpillCuts.h:69
Collection of SpectrumLoaders for many configurations.
Definition: Loaders.h:23
void addVars(PredictionHandler *predH, std::string det)
Definition: ExampleCode.C:184
void SetSpillCut(const SpillCut &cut)
void Go()
Call Go() on all the loaders.
Definition: Loaders.cxx:162
void SetSpillCut(const SpillCut &cut)
Definition: Loaders.cxx:121
For nominal spectra and reweighting systs (xsec/flux)
Definition: Prod5Loaders.h:101
Class to handle ND predictions.
virtual void Go() override
Load all the registered spectra.
OStream cout
Definition: OStream.cxx:6
Collaborates with Spectrum and OscillatableSpectrum to fill spectra from CAF files.
assert(nhit_max >=nhit_nbins)
const SpillCut kStandardSpillCuts
Apply this unless you&#39;re doing something special.
Definition: SpillCuts.h:49
Class to handle FD predictions.
enum BeamMode string

Variable Documentation

std::vector<CutContainer> cutsFD
Initial value:
{
CutContainer(kNus20FDCuts, "FullSelection")
}
const Cut kNus20FDCuts
Definition: NusCuts20.h:174

Definition at line 65 of file ExampleCode.C.

Referenced by addVars().

std::vector<CutContainer> cutsND
Initial value:
{
CutContainer(kNus20NDCuts, "FullSelection")
}
const Cut kNus20NDCuts
Definition: NusCuts20.h:102

Definition at line 69 of file ExampleCode.C.

Referenced by addVars().

const ana::Binning kPartPtpBins = ana::Binning::Simple(50 , 0 , 1 )

Definition at line 53 of file ExampleCode.C.

std::vector<VarContainer> varsFD
Initial value:
= {
VarContainer(ana::kPartPtp, "kPartPtp", "Tranverse Momentum Fraction", kPartPtpBins) ,
}
const Var kPartPtp([](const caf::SRProxy *sr){if(std::isnan(1.*sr->sel.nuecosrej.partptp)|| std::isinf(1.*sr->sel.nuecosrej.partptp)) return-5.f;return float(sr->sel.nuecosrej.partptp);})
Definition: NusVars.h:74
const ana::Binning kPartPtpBins
Definition: ExampleCode.C:53

Definition at line 55 of file ExampleCode.C.

Referenced by addVars().

std::vector<VarContainer> varsND
Initial value:
= {
VarContainer(ana::kPartPtp, "kPartPtp", "Tranverse Momentum Fraction", kPartPtpBins) ,
}
const Var kPartPtp([](const caf::SRProxy *sr){if(std::isnan(1.*sr->sel.nuecosrej.partptp)|| std::isinf(1.*sr->sel.nuecosrej.partptp)) return-5.f;return float(sr->sel.nuecosrej.partptp);})
Definition: NusVars.h:74
const ana::Binning kPartPtpBins
Definition: ExampleCode.C:53

Definition at line 59 of file ExampleCode.C.

Referenced by addVars().