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

#include <PFParticleVarExtractor.h>

Inheritance diagram for VLN::PFParticleVarExtractor:
VLN::VarExtractorBase

Public Member Functions

 PFParticleVarExtractor (const std::string &prefix, calo::CalorimetryAlg &algCalorimetry, const std::string &labelPFPModule, const std::string &labelPFPTrack, const std::string &labelPFPShower, unsigned int plane=2)
 
 ~PFParticleVarExtractor ()=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 Member Functions

void extractShowerVars (const art::Event &evt, const art::Ptr< recob::PFParticle > &particle, VarDict &vars)
 
void extractTrackVars (const art::Event &evt, const art::Ptr< recob::PFParticle > &particle, VarDict &vars)
 
void extractBasicVars (const art::Event &evt, const std::vector< art::Ptr< recob::Hit >> &hits, VarDict &vars)
 

Private Attributes

calo::CalorimetryAlgalgCalorimetry
 
std::string labelPFPModule
 
std::string labelPFPTrack
 
std::string labelPFPShower
 
unsigned int plane
 

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 9 of file PFParticleVarExtractor.h.

Constructor & Destructor Documentation

VLN::PFParticleVarExtractor::PFParticleVarExtractor ( const std::string prefix,
calo::CalorimetryAlg algCalorimetry,
const std::string labelPFPModule,
const std::string labelPFPTrack,
const std::string labelPFPShower,
unsigned int  plane = 2 
)

Definition at line 29 of file PFParticleVarExtractor.cxx.

37  algCalorimetry(algCalorimetry),
41  plane(plane)
42 { }
calo::CalorimetryAlg & algCalorimetry
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::PFParticleVarExtractor::~PFParticleVarExtractor ( )
default

Member Function Documentation

void VLN::PFParticleVarExtractor::extractBasicVars ( const art::Event evt,
const std::vector< art::Ptr< recob::Hit >> &  hits,
VarDict vars 
)
private

Definition at line 105 of file PFParticleVarExtractor.cxx.

110 {
111  const auto chargeCalE = calcHitsChargeCalE(
112  hits, evt, algCalorimetry, plane
113  );
114 
115  appendToVectorVar(vars, "nHit", hits.size());
116  appendToVectorVar(vars, "charge", chargeCalE.first);
117  appendToVectorVar(vars, "calE", chargeCalE.second);
118 }
calo::CalorimetryAlg & algCalorimetry
std::pair< double, double > calcHitsChargeCalE(const std::vector< art::Ptr< recob::Hit >> &hits, const art::Event &evt, calo::CalorimetryAlg &algCalorimetry, unsigned int plane)
Definition: utils.cxx:10
void appendToVectorVar(VarDict &vars, const std::string &name, double value) const
void VLN::PFParticleVarExtractor::extractShowerVars ( const art::Event evt,
const art::Ptr< recob::PFParticle > &  particle,
VarDict vars 
)
private

Definition at line 73 of file PFParticleVarExtractor.cxx.

78 {
80  particle, evt, labelPFPModule, labelPFPShower
81  );
82  auto start = shower->ShowerStart();
83  auto dir = shower->Direction();
84  auto energy = shower->Energy();
85 
86  appendToVectorVar(vars, "is_shower", 1);
87  appendToVectorVar(vars, "length", shower->Length());
88  appendToVectorVar(vars, "start.x", start.x());
89  appendToVectorVar(vars, "start.y", start.y());
90  appendToVectorVar(vars, "start.z", start.z());
91  appendToVectorVar(vars, "dir.x", dir.x());
92  appendToVectorVar(vars, "dir.y", dir.y());
93  appendToVectorVar(vars, "dir.z", dir.z());
95  vars, "energy", (energy.size() < plane + 1) ? 0 : energy[plane]
96  );
97 
98  const auto hits = dune_ana::DUNEAnaShowerUtils::GetHits(
100  );
101 
102  extractBasicVars(evt, hits, vars);
103 }
string dir
static art::Ptr< recob::Shower > GetShower(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &showerLabel)
Get the shower associated to this particle. Should only be called if IsShower method succeeds...
void appendToVectorVar(VarDict &vars, const std::string &name, double value) const
void extractBasicVars(const art::Event &evt, const std::vector< art::Ptr< recob::Hit >> &hits, VarDict &vars)
static std::vector< art::Ptr< recob::Hit > > GetHits(const art::Ptr< recob::Shower > &pShower, const art::Event &evt, const std::string &label)
Get the hits associated with the shower.
void VLN::PFParticleVarExtractor::extractTrackVars ( const art::Event evt,
const art::Ptr< recob::PFParticle > &  particle,
VarDict vars 
)
private

Definition at line 44 of file PFParticleVarExtractor.cxx.

49 {
51  particle, evt, labelPFPModule, labelPFPTrack
52  );
53  auto start = track->Start();
54  auto dir = track->StartDirection();
55 
56  appendToVectorVar(vars, "is_shower", 0);
57  appendToVectorVar(vars, "length", track->Length());
58  appendToVectorVar(vars, "start.x", start.x());
59  appendToVectorVar(vars, "start.y", start.y());
60  appendToVectorVar(vars, "start.z", start.z());
61  appendToVectorVar(vars, "dir.x", dir.x());
62  appendToVectorVar(vars, "dir.y", dir.y());
63  appendToVectorVar(vars, "dir.z", dir.z());
64  appendToVectorVar(vars, "energy", track->StartMomentum());
65 
66  const auto hits = dune_ana::DUNEAnaTrackUtils::GetHits(
67  track, evt, labelPFPTrack
68  );
69 
70  extractBasicVars(evt, hits, vars);
71 }
static art::Ptr< recob::Track > GetTrack(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &trackLabel)
Get the track associated to this particle. Should only be called if IsTrack method succeeds...
string dir
static std::vector< art::Ptr< recob::Hit > > GetHits(const art::Ptr< recob::Track > &pTrack, const art::Event &evt, const std::string &label)
Get the hits associated with the track.
void appendToVectorVar(VarDict &vars, const std::string &name, double value) const
void extractBasicVars(const art::Event &evt, const std::vector< art::Ptr< recob::Hit >> &hits, VarDict &vars)
void VLN::PFParticleVarExtractor::extractVars ( const art::Event evt,
VarDict vars 
)
overrideprotectedvirtual

Implements VLN::VarExtractorBase.

Definition at line 120 of file PFParticleVarExtractor.cxx.

121 {
122  const std::vector<art::Ptr<recob::PFParticle>> particles
124 
125  for (const auto &particle : particles)
126  {
127  const bool isTrack = dune_ana::DUNEAnaPFParticleUtils::IsTrack(
128  particle, evt, labelPFPModule, labelPFPTrack
129  );
130 
131  const bool isShower = dune_ana::DUNEAnaPFParticleUtils::IsShower(
132  particle, evt, labelPFPModule, labelPFPShower
133  );
134 
135  if (isTrack == isShower) {
136  /* TODO: Maybe handle this condition somehow? */
137  continue;
138  }
139 
140  if (isShower) {
141  extractShowerVars(evt, particle, vars);
142  }
143  else if (isTrack) {
144  extractTrackVars(evt, particle, vars);
145  }
146  }
147 }
static bool IsShower(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &showerLabel)
Check if this particle has an associated shower.
void extractShowerVars(const art::Event &evt, const art::Ptr< recob::PFParticle > &particle, VarDict &vars)
void extractTrackVars(const art::Event &evt, const art::Ptr< recob::PFParticle > &particle, VarDict &vars)
static bool IsTrack(const art::Ptr< recob::PFParticle > &pParticle, const art::Event &evt, const std::string &pParticleLabel, const std::string &trackLabel)
Check if this particle has an associated track.
static std::vector< art::Ptr< recob::PFParticle > > GetPFParticles(const art::Event &evt, const std::string &label)
Get the particles from the event.

Member Data Documentation

calo::CalorimetryAlg& VLN::PFParticleVarExtractor::algCalorimetry
private

Definition at line 46 of file PFParticleVarExtractor.h.

std::string VLN::PFParticleVarExtractor::labelPFPModule
private

Definition at line 47 of file PFParticleVarExtractor.h.

std::string VLN::PFParticleVarExtractor::labelPFPShower
private

Definition at line 49 of file PFParticleVarExtractor.h.

std::string VLN::PFParticleVarExtractor::labelPFPTrack
private

Definition at line 48 of file PFParticleVarExtractor.h.

unsigned int VLN::PFParticleVarExtractor::plane
private

Definition at line 50 of file PFParticleVarExtractor.h.


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