EventMCVarExtractor.cxx
Go to the documentation of this file.
1 #include "EventMCVarExtractor.h"
2 
4 
5 namespace VLN {
6 
7 static const std::vector<std::string> SCALAR_VARS({
8  "isCC", "pdg", "mode", "lepPdg", "nuE", "lepE", "hadE"
9 });
10 
11 static const std::vector<std::string> VECTOR_VARS({});
12 
14  const std::string &prefix, const std::string &labelGenerator
15 )
17  labelGenerator(labelGenerator)
18 { }
19 
21 {
22  std::vector<art::Ptr<simb::MCTruth>> mcTruth;
23 
24  auto mcTruth_h = evt.getHandle<std::vector<simb::MCTruth>>(labelGenerator);
25  if (!mcTruth_h) {
26  return;
27  }
28 
29  art::fill_ptr_vector(mcTruth, mcTruth_h);
30  if (mcTruth.empty()) {
31  return;
32  }
33 
34  const auto &nuInt = mcTruth[0]->GetNeutrino();
35 
36  setScalarVar(vars, "isCC", (nuInt.CCNC() == 0));
37  setScalarVar(vars, "pdg", nuInt.Nu().PdgCode());
38  setScalarVar(vars, "mode", nuInt.Mode());
39  setScalarVar(vars, "lepPdg", nuInt.Lepton().PdgCode());
40 
41  const double nuE = nuInt.Nu().E();
42  const double lepE = nuInt.Lepton().Momentum().T();
43 
44  setScalarVar(vars, "nuE", nuE);
45  setScalarVar(vars, "lepE", lepE);
46  setScalarVar(vars, "hadE", nuE - lepE);
47 }
48 
49 }
50 
static const std::vector< std::string > VECTOR_VARS({})
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
std::string string
Definition: nybbler.cc:12
void extractVars(const art::Event &evt, VarDict &vars) override
EventMCVarExtractor(const std::string &prefix, const std::string &labelGenerator="generator")
Definition: VarDict.h:8
static const std::vector< std::string > SCALAR_VARS({"run","subRun","event"})
Definition: utils.cxx:6
void setScalarVar(VarDict &vars, const std::string &name, double value) const
TCEvent evt
Definition: DataStructs.cxx:7
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297