Public Member Functions | Protected Member Functions | Private Attributes | List of all members
VLN::EventMCVarExtractor Class Reference

#include <EventMCVarExtractor.h>

Inheritance diagram for VLN::EventMCVarExtractor:
VLN::VarExtractorBase

Public Member Functions

 EventMCVarExtractor (const std::string &prefix, const std::string &labelGenerator="generator")
 
 ~EventMCVarExtractor ()=default
 
- Public Member Functions inherited from VLN::VarExtractorBase
 VarExtractorBase (const std::string &prefix, const std::vector< std::string > &scalarVars, const std::vector< std::string > &vectorVars)
 
virtual ~VarExtractorBase ()=default
 
virtual void extract (const art::Event &evt, VarDict &vars)
 

Protected Member Functions

void extractVars (const art::Event &evt, VarDict &vars) override
 
- Protected Member Functions inherited from VLN::VarExtractorBase
void setScalarVar (VarDict &vars, const std::string &name, double value) const
 
void appendToVectorVar (VarDict &vars, const std::string &name, double value) const
 
void initScalarVars (VarDict &vars, const std::vector< std::string > &names) const
 
void initVectorVars (VarDict &vars, const std::vector< std::string > &names) const
 

Private Attributes

std::string labelGenerator
 

Additional Inherited Members

- Protected Attributes inherited from VLN::VarExtractorBase
std::string prefix
 
std::vector< std::stringscalarVars
 
std::vector< std::stringvectorVars
 

Detailed Description

Definition at line 8 of file EventMCVarExtractor.h.

Constructor & Destructor Documentation

VLN::EventMCVarExtractor::EventMCVarExtractor ( const std::string prefix,
const std::string labelGenerator = "generator" 
)
explicit

Definition at line 13 of file EventMCVarExtractor.cxx.

18 { }
static const std::vector< std::string > VECTOR_VARS({})
static const std::vector< std::string > SCALAR_VARS({"run","subRun","event"})
VarExtractorBase(const std::string &prefix, const std::vector< std::string > &scalarVars, const std::vector< std::string > &vectorVars)
VLN::EventMCVarExtractor::~EventMCVarExtractor ( )
default

Member Function Documentation

void VLN::EventMCVarExtractor::extractVars ( const art::Event evt,
VarDict vars 
)
overrideprotectedvirtual

Implements VLN::VarExtractorBase.

Definition at line 20 of file EventMCVarExtractor.cxx.

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 }
Handle< PROD > getHandle(SelectorBase const &) const
Definition: DataViewImpl.h:382
void setScalarVar(VarDict &vars, const std::string &name, double value) const
void fill_ptr_vector(std::vector< Ptr< T >> &ptrs, H const &h)
Definition: Ptr.h:297

Member Data Documentation

std::string VLN::EventMCVarExtractor::labelGenerator
private

Definition at line 21 of file EventMCVarExtractor.h.


The documentation for this class was generated from the following files: