Public Types | Static Public Member Functions | List of all members
lar_pandora::LArPandoraHelper Class Reference

LArPandoraHelper class. More...

#include <LArPandoraHelper.h>

Public Types

enum  DaughterMode { kIgnoreDaughters = 0, kUseDaughters = 1, kAddDaughters = 2 }
 DaughterMode enumeration. More...
 

Static Public Member Functions

static void CollectWires (const art::Event &evt, const std::string &label, WireVector &wireVector)
 Collect the reconstructed wires from the ART event record. More...
 
static void CollectHits (const art::Event &evt, const std::string &label, HitVector &hitVector)
 Collect the reconstructed Hits from the ART event record. More...
 
static void CollectPFParticles (const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
 Collect the reconstructed PFParticles from the ART event record. More...
 
static void CollectSpacePoints (const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits)
 Collect the reconstructed SpacePoints and associated hits from the ART event record. More...
 
static void CollectSpacePoints (const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits, HitsToSpacePoints &hitsToSpacePoints)
 Collect the reconstructed SpacePoints and associated hits from the ART event record. More...
 
static void CollectClusters (const art::Event &evt, const std::string &label, ClusterVector &clusterVector, ClustersToHits &clustersToHits)
 Collect the reconstructed Clusters and associated hits from the ART event record. More...
 
static void CollectPFParticles (const art::Event &evt, const std::string &label, PFParticleVector &particleVector, PFParticlesToSpacePoints &particlesToSpacePoints)
 Collect the reconstructed PFParticles and associated SpacePoints from the ART event record. More...
 
static void CollectPFParticles (const art::Event &evt, const std::string &label, PFParticleVector &particleVector, PFParticlesToClusters &particlesToClusters)
 Collect the reconstructed PFParticles and associated Clusters from the ART event record. More...
 
static void CollectPFParticleMetadata (const art::Event &evt, const std::string &label, PFParticleVector &particleVector, PFParticlesToMetadata &particlesToMetadata)
 Collect the reconstructed PFParticle Metadata from the ART event record. More...
 
static void CollectShowers (const art::Event &evt, const std::string &label, ShowerVector &showerVector, PFParticlesToShowers &particlesToShowers)
 Collect the reconstructed PFParticles and associated Showers from the ART event record. More...
 
static void CollectShowers (const art::Event &evt, const std::string &label, ShowerVector &showerVector, ShowersToHits &showersToHits)
 Collect the reconstructed Showers and associated Hits from the ART event record. More...
 
static void CollectTracks (const art::Event &evt, const std::string &label, TrackVector &trackVector, PFParticlesToTracks &particlesToTracks)
 Collect the reconstructed PFParticles and associated Tracks from the ART event record. More...
 
static void CollectTracks (const art::Event &evt, const std::string &label, TrackVector &trackVector, TracksToHits &tracksToHits)
 Collect the reconstructed Tracks and associated Hits from the ART event record. More...
 
static void CollectSeeds (const art::Event &evt, const std::string &label, SeedVector &seedVector, PFParticlesToSeeds &particlesToSeeds)
 Collect the reconstructed PFParticles and associated Seeds from the ART event record. More...
 
static void CollectSeeds (const art::Event &evt, const std::string &label, SeedVector &seedVector, SeedsToHits &seedsToHits)
 Collect the reconstructed Seeds and associated Hits from the ART event record. More...
 
static void CollectVertices (const art::Event &evt, const std::string &label, VertexVector &vertexVector, PFParticlesToVertices &particlesToVertices)
 Collect the reconstructed PFParticles and associated Vertices from the ART event record. More...
 
static void BuildPFParticleHitMaps (const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
 Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps. More...
 
static void BuildPFParticleHitMaps (const PFParticleVector &particleVector, const PFParticlesToClusters &particlesToClusters, const ClustersToHits &clustersToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
 Build mapping between PFParticles and Hits using PFParticle/Cluster/Hit maps. More...
 
static void BuildPFParticleHitMaps (const art::Event &evt, const std::string &label_pfpart, const std::string &label_mid, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters, const bool useClusters=true)
 Build mapping between PFParticles and Hits starting from ART event record. More...
 
static void BuildPFParticleHitMaps (const art::Event &evt, const std::string &label, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters, const bool useClusters=true)
 Build mapping between PFParticles and Hits starting from ART event record. More...
 
static void CollectCosmicTags (const art::Event &evt, const std::string &label, CosmicTagVector &cosmicTagVector, TracksToCosmicTags &tracksToCosmicTags)
 Collect a vector of cosmic tags from the ART event record. More...
 
static void CollectT0s (const art::Event &evt, const std::string &label, T0Vector &t0Vector, PFParticlesToT0s &particlesToT0s)
 Collect a vector of T0s from the ART event record. More...
 
static void CollectSimChannels (const art::Event &evt, const std::string &label, SimChannelVector &simChannelVector, bool &areSimChannelsValid)
 Collect a vector of SimChannel objects from the ART event record. More...
 
static void CollectMCParticles (const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
 Collect a vector of MCParticle objects from the ART event record. More...
 
static void CollectGeneratorMCParticles (const art::Event &evt, const std::string &label, RawMCParticleVector &particleVector)
 Collect a vector of MCParticle objects from the generator in the ART event record. ATTN: This function is needed as accessing generator (opposed to Geant4) level MCParticles requires use of MCTruth block. More...
 
static void CollectMCParticles (const art::Event &evt, const std::string &label, MCTruthToMCParticles &truthToParticles, MCParticlesToMCTruth &particlesToTruth)
 Collect truth information from the ART event record. More...
 
static void BuildMCParticleHitMaps (const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
 Collect the links from reconstructed hits to their true energy deposits. More...
 
static void BuildMCParticleHitMaps (const HitsToTrackIDEs &hitsToTrackIDEs, const MCTruthToMCParticles &truthToParticles, MCParticlesToHits &particlesToHits, HitsToMCParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
 Build mapping between Hits and MCParticles, starting from Hit/TrackIDE/MCParticle information. More...
 
static void BuildMCParticleHitMaps (const art::Event &evt, const std::string &label, const HitVector &hitVector, MCParticlesToHits &particlesToHits, HitsToMCParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
 Build mapping between Hits and MCParticles, starting from ART event record. More...
 
static void BuildMCParticleHitMaps (const art::Event &evt, const std::string &hitLabel, const std::string &backtrackLabel, HitsToTrackIDEs &hitsToTrackIDEs)
 Get mapping between hits and true energy deposits using back-tracker information. More...
 
static void BuildMCParticleHitMaps (const art::Event &evt, const std::string &truthLabel, const std::string &hitLabel, const std::string &backtrackLabel, MCParticlesToHits &particlesToHits, HitsToMCParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
 Build mapping between Hits and MCParticles, starting from Hit/TrackIDE/MCParticle information. More...
 
template<typename T >
static void GetAssociatedHits (const art::Event &evt, const std::string &label, const std::vector< art::Ptr< T >> &inputVector, HitVector &associatedHits, const pandora::IntVector *const indexVector=nullptr)
 Get all hits associated with input clusters. More...
 
static void SelectNeutrinoPFParticles (const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
 Select reconstructed neutrino particles from a list of all reconstructed particles. More...
 
static void SelectFinalStatePFParticles (const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
 Select final-state reconstructed particles from a list of all reconstructed particles. More...
 
static void BuildMCParticleMap (const MCParticleVector &particleVector, MCParticleMap &particleMap)
 Build particle maps for true particles. More...
 
static void BuildPFParticleMap (const PFParticleVector &particleVector, PFParticleMap &particleMap)
 Build particle maps for reconstructed particles. More...
 
static art::Ptr< recob::PFParticleGetParentPFParticle (const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
 Return the top-level parent particle by navigating up the chain of parent/daughter associations. More...
 
static art::Ptr< recob::PFParticleGetFinalStatePFParticle (const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
 Return the final-state parent particle by navigating up the chain of parent/daughter associations. More...
 
static art::Ptr< simb::MCParticleGetParentMCParticle (const MCParticleMap &particleMap, const art::Ptr< simb::MCParticle > daughterParticle)
 Return the top-level parent particle by navigating up the chain of parent/daughter associations. More...
 
static art::Ptr< simb::MCParticleGetFinalStateMCParticle (const MCParticleMap &particleMap, const art::Ptr< simb::MCParticle > daughterParticle)
 Return the final-state parent particle by navigating up the chain of parent/daughter associations. More...
 
static art::Ptr< recob::TrackGetPrimaryTrack (const PFParticlesToTracks &particlesToTracks, const art::Ptr< recob::PFParticle > particle)
 Return the primary track associated with a PFParticle. More...
 
static int GetGeneration (const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
 Return the generation of this particle (first generation if primary) More...
 
static int GetParentNeutrino (const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
 Return the parent neutrino PDG code (or zero for cosmics) for a given reconstructed particle. More...
 
static bool IsFinalState (const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
 Determine whether a particle has been reconstructed as a final-state particle. More...
 
static bool IsNeutrino (const art::Ptr< recob::PFParticle > particle)
 Determine whether a particle has been reconstructed as a neutrino. More...
 
static bool IsTrack (const art::Ptr< recob::PFParticle > particle)
 Determine whether a particle has been reconstructed as track-like. More...
 
static bool IsShower (const art::Ptr< recob::PFParticle > particle)
 Determine whether a particle has been reconstructed as shower-like. More...
 
static bool IsVisible (const art::Ptr< simb::MCParticle > particle)
 Determine whether a particle is visible (i.e. long-lived charged particle) More...
 
static larpandoraobj::PFParticleMetadata GetPFParticleMetadata (const pandora::ParticleFlowObject *const pPfo)
 Get metadata associated to a PFO. More...
 

Detailed Description

LArPandoraHelper class.

Definition at line 119 of file LArPandoraHelper.h.

Member Enumeration Documentation

DaughterMode enumeration.

Enumerator
kIgnoreDaughters 
kUseDaughters 
kAddDaughters 

Definition at line 124 of file LArPandoraHelper.h.

124  {
125  kIgnoreDaughters = 0, // Only use parent particles
126  kUseDaughters = 1, // Use both parent and daughter partcles
127  kAddDaughters = 2 // Absorb daughter particles into parent particles
128  };

Member Function Documentation

void lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps ( const art::Event evt,
const HitVector hitVector,
const SimChannelVector simChannelVector,
HitsToTrackIDEs hitsToTrackIDEs 
)
static

Collect the links from reconstructed hits to their true energy deposits.

Parameters
evtthe art event containers
hitVectorthe input vector of reconstructed hits
simChannelVectorthe input vector of SimChannels
hitsToTrackIDEsthe out map from hits to true energy deposits

Definition at line 916 of file LArPandoraHelper.cxx.

920  {
921  auto const clock_data =
923 
924  SimChannelMap simChannelMap;
925 
926  for (SimChannelVector::const_iterator iter = simChannelVector.begin(),
927  iterEnd = simChannelVector.end();
928  iter != iterEnd;
929  ++iter) {
930  const art::Ptr<sim::SimChannel> simChannel = *iter;
931  simChannelMap.insert(SimChannelMap::value_type(simChannel->Channel(), simChannel));
932  }
933 
934  for (HitVector::const_iterator iter = hitVector.begin(), iterEnd = hitVector.end();
935  iter != iterEnd;
936  ++iter) {
937  const art::Ptr<recob::Hit> hit = *iter;
938 
939  SimChannelMap::const_iterator sIter = simChannelMap.find(hit->Channel());
940  if (simChannelMap.end() == sIter) continue; // Hit has no truth information [continue]
941 
942  // ATTN: Need to convert TDCtick (integer) to TDC (unsigned integer) before passing to simChannel
943  const raw::TDCtick_t start_tick(clock_data.TPCTick2TDC(hit->PeakTimeMinusRMS()));
944  const raw::TDCtick_t end_tick(clock_data.TPCTick2TDC(hit->PeakTimePlusRMS()));
945  const unsigned int start_tdc((start_tick < 0) ? 0 : start_tick);
946  const unsigned int end_tdc(end_tick);
947 
948  if (start_tdc > end_tdc) continue; // Hit undershoots the readout window [continue]
949 
950  const art::Ptr<sim::SimChannel> simChannel = sIter->second;
951  const TrackIDEVector trackCollection(simChannel->TrackIDEs(start_tdc, end_tdc));
952 
953  if (trackCollection.empty()) continue; // Hit has no truth information [continue]
954 
955  for (unsigned int iTrack = 0, iTrackEnd = trackCollection.size(); iTrack < iTrackEnd;
956  ++iTrack) {
957  const sim::TrackIDE trackIDE = trackCollection.at(iTrack);
958  hitsToTrackIDEs[hit].push_back(trackIDE);
959  }
960  }
961  }
std::map< int, art::Ptr< sim::SimChannel > > SimChannelMap
intermediate_table::const_iterator const_iterator
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:25
std::vector< sim::TrackIDE > TrackIDEs(TDC_t startTDC, TDC_t endTDC) const
Returns energies collected for each track within a time interval.
Definition: SimChannel.cxx:246
std::vector< sim::TrackIDE > TrackIDEVector
float PeakTimeMinusRMS(float sigmas=+1.) const
Definition: Hit.h:239
Detector simulation of raw signals on wires.
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
Definition: SimChannel.h:329
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:236
Ionization energy from a Geant4 track.
Definition: SimChannel.h:25
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:230
void lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps ( const HitsToTrackIDEs hitsToTrackIDEs,
const MCTruthToMCParticles truthToParticles,
MCParticlesToHits particlesToHits,
HitsToMCParticles hitsToParticles,
const DaughterMode  daughterMode = kUseDaughters 
)
static

Build mapping between Hits and MCParticles, starting from Hit/TrackIDE/MCParticle information.

Parameters
hitsToTrackIDEsthe input map from hits to true energy deposits
truthToParticlesthe input map of truth information
particlesToHitsthe mapping between true particles and reconstructed hits
hitsToParticlesthe mapping between reconstructed hits and true particles
daughterModetreatment of daughter particles in construction of maps

Definition at line 966 of file LArPandoraHelper.cxx.

971  {
972  // Build mapping between particles and track IDs for parent/daughter navigation
973  MCParticleMap particleMap;
974 
975  for (MCTruthToMCParticles::const_iterator iter1 = truthToParticles.begin(),
976  iterEnd1 = truthToParticles.end();
977  iter1 != iterEnd1;
978  ++iter1) {
979  const MCParticleVector& particleVector = iter1->second;
980  for (MCParticleVector::const_iterator iter2 = particleVector.begin(),
981  iterEnd2 = particleVector.end();
982  iter2 != iterEnd2;
983  ++iter2) {
984  const art::Ptr<simb::MCParticle> particle = *iter2;
985  particleMap[particle->TrackId()] = particle;
986  }
987  }
988 
989  // Loop over hits and build mapping between reconstructed hits and true particles
990  for (HitsToTrackIDEs::const_iterator iter1 = hitsToTrackIDEs.begin(),
991  iterEnd1 = hitsToTrackIDEs.end();
992  iter1 != iterEnd1;
993  ++iter1) {
994  const art::Ptr<recob::Hit> hit = iter1->first;
995  const TrackIDEVector& trackCollection = iter1->second;
996 
997  int bestTrackID(-1);
998  float bestEnergyFrac(0.f);
999 
1000  for (TrackIDEVector::const_iterator iter2 = trackCollection.begin(),
1001  iterEnd2 = trackCollection.end();
1002  iter2 != iterEnd2;
1003  ++iter2) {
1004  const sim::TrackIDE& trackIDE = *iter2;
1005  const int trackID(std::abs(trackIDE.trackID)); // TODO: Find out why std::abs is needed
1006  const float energyFrac(trackIDE.energyFrac);
1007 
1008  if (energyFrac > bestEnergyFrac) {
1009  bestEnergyFrac = energyFrac;
1010  bestTrackID = trackID;
1011  }
1012  }
1013 
1014  if (bestTrackID >= 0) {
1015  MCParticleMap::const_iterator iter3 = particleMap.find(bestTrackID);
1016  if (particleMap.end() == iter3)
1017  throw cet::exception("LArPandora") << " PandoraCollector::BuildMCParticleHitMaps --- "
1018  "Found a track ID without an MC Particle ";
1019 
1020  try {
1021  const art::Ptr<simb::MCParticle> thisParticle = iter3->second;
1022  const art::Ptr<simb::MCParticle> primaryParticle(
1023  LArPandoraHelper::GetFinalStateMCParticle(particleMap, thisParticle));
1024  const art::Ptr<simb::MCParticle> selectedParticle(
1025  (kAddDaughters == daughterMode) ? primaryParticle : thisParticle);
1026 
1027  if ((kIgnoreDaughters == daughterMode) && (selectedParticle != primaryParticle)) continue;
1028 
1029  if (!(LArPandoraHelper::IsVisible(selectedParticle))) continue;
1030 
1031  particlesToHits[selectedParticle].push_back(hit);
1032  hitsToParticles[hit] = selectedParticle;
1033  }
1034  catch (cet::exception& e) {
1035  }
1036  }
1037  }
1038  }
intermediate_table::const_iterator const_iterator
int TrackId() const
Definition: MCParticle.h:210
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
T abs(T value)
static bool IsVisible(const art::Ptr< simb::MCParticle > particle)
Determine whether a particle is visible (i.e. long-lived charged particle)
const double e
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:27
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
std::vector< sim::TrackIDE > TrackIDEVector
Detector simulation of raw signals on wires.
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:26
Ionization energy from a Geant4 track.
Definition: SimChannel.h:25
static art::Ptr< simb::MCParticle > GetFinalStateMCParticle(const MCParticleMap &particleMap, const art::Ptr< simb::MCParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps ( const art::Event evt,
const std::string label,
const HitVector hitVector,
MCParticlesToHits particlesToHits,
HitsToMCParticles hitsToParticles,
const DaughterMode  daughterMode = kUseDaughters 
)
static

Build mapping between Hits and MCParticles, starting from ART event record.

Parameters
evtthe ART event record
labelthe label for the truth information in the event
hitVectorthe input vector of reconstructed hits
particlesToHitsthe output mapping between true particles and reconstructed hits
hitsToParticlesthe output mapping between reconstructed hits and true particles
daughterModetreatment of daughter particles in construction of maps

Definition at line 1043 of file LArPandoraHelper.cxx.

1049  {
1050  SimChannelVector simChannelVector;
1051  MCTruthToMCParticles truthToParticles;
1052  MCParticlesToMCTruth particlesToTruth;
1053  HitsToTrackIDEs hitsToTrackIDEs;
1054 
1055  bool areSimChannelsValid(false);
1056  LArPandoraHelper::CollectSimChannels(evt, label, simChannelVector, areSimChannelsValid);
1057 
1058  LArPandoraHelper::CollectMCParticles(evt, label, truthToParticles, particlesToTruth);
1059  LArPandoraHelper::BuildMCParticleHitMaps(evt, hitVector, simChannelVector, hitsToTrackIDEs);
1061  hitsToTrackIDEs, truthToParticles, particlesToHits, hitsToParticles, daughterMode);
1062  }
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
std::map< art::Ptr< recob::Hit >, TrackIDEVector > HitsToTrackIDEs
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
static void CollectSimChannels(const art::Event &evt, const std::string &label, SimChannelVector &simChannelVector, bool &areSimChannelsValid)
Collect a vector of SimChannel objects from the ART event record.
std::vector< art::Ptr< sim::SimChannel > > SimChannelVector
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
void lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps ( const art::Event evt,
const std::string hitLabel,
const std::string backtrackLabel,
HitsToTrackIDEs hitsToTrackIDEs 
)
static

Get mapping between hits and true energy deposits using back-tracker information.

Parameters
evtthe event record
hitLabelthe label of the collection of hits
backtrackLabelthe label of the collection of back-tracker information
hitsToTrackIDEsthe output map between hits and true energy deposits

Definition at line 1067 of file LArPandoraHelper.cxx.

1071  {
1072  // Start by getting the collection of Hits
1074  evt.getByLabel(hitLabel, theHits);
1075 
1076  if (!theHits.isValid()) {
1077  mf::LogDebug("LArPandora") << " Failed to find hits... " << std::endl;
1078  return;
1079  }
1080 
1081  HitVector hitVector;
1082 
1083  for (unsigned int i = 0; i < theHits->size(); ++i) {
1084  const art::Ptr<recob::Hit> hit(theHits, i);
1085  hitVector.push_back(hit);
1086  }
1087 
1088  // Now get the associations between Hits and MCParticles
1089  std::vector<anab::BackTrackerHitMatchingData const*> backtrackerVector;
1090 
1091  MCParticleVector particleVector;
1092 
1093  art::FindManyP<simb::MCParticle, anab::BackTrackerHitMatchingData> particles_per_hit(
1094  theHits, evt, backtrackLabel);
1095 
1096  if (!particles_per_hit.isValid()) {
1097  mf::LogDebug("LArPandora") << " Failed to find reco-truth matching... " << std::endl;
1098  return;
1099  }
1100 
1101  // Now loop over the hits and build a collection of IDEs
1102  for (HitVector::const_iterator iter = hitVector.begin(), iterEnd = hitVector.end();
1103  iter != iterEnd;
1104  ++iter) {
1105  const art::Ptr<recob::Hit> hit = *iter;
1106 
1107  particleVector.clear();
1108  backtrackerVector.clear();
1109  particles_per_hit.get(hit.key(), particleVector, backtrackerVector);
1110 
1111  for (unsigned int j = 0; j < particleVector.size(); ++j) {
1112  const art::Ptr<simb::MCParticle> particle = particleVector[j];
1113 
1114  sim::TrackIDE trackIDE;
1115  trackIDE.trackID = particle->TrackId();
1116  trackIDE.energy = backtrackerVector[j]->energy;
1117  trackIDE.energyFrac = backtrackerVector[j]->ideFraction;
1118 
1119  hitsToTrackIDEs[hit].push_back(trackIDE);
1120  }
1121  }
1122  }
intermediate_table::const_iterator const_iterator
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:28
int TrackId() const
Definition: MCParticle.h:210
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
key_type key() const noexcept
Definition: Ptr.h:216
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:27
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
Detector simulation of raw signals on wires.
std::vector< art::Ptr< recob::Hit > > HitVector
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:26
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Ionization energy from a Geant4 track.
Definition: SimChannel.h:25
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps ( const art::Event evt,
const std::string truthLabel,
const std::string hitLabel,
const std::string backtrackLabel,
MCParticlesToHits particlesToHits,
HitsToMCParticles hitsToParticles,
const DaughterMode  daughterMode = kUseDaughters 
)
static

Build mapping between Hits and MCParticles, starting from Hit/TrackIDE/MCParticle information.

Parameters
evtthe event record
truthLabelthe label describing the G4 truth information
hitLabelthe label describing the hit collection
backtrackLabelthe label describing the back-tracker information
particlesToHitsthe mapping between true particles and reconstructed hits
hitsToParticlesthe mapping between reconstructed hits and true particles
daughterModetreatment of daughter particles in construction of maps

Definition at line 1127 of file LArPandoraHelper.cxx.

1134  {
1135  MCTruthToMCParticles truthToParticles;
1136  MCParticlesToMCTruth particlesToTruth;
1137  HitsToTrackIDEs hitsToTrackIDEs;
1138 
1139  LArPandoraHelper::CollectMCParticles(evt, truthLabel, truthToParticles, particlesToTruth);
1140  LArPandoraHelper::BuildMCParticleHitMaps(evt, hitLabel, backtrackLabel, hitsToTrackIDEs);
1142  hitsToTrackIDEs, truthToParticles, particlesToHits, hitsToParticles, daughterMode);
1143  }
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
std::map< art::Ptr< recob::Hit >, TrackIDEVector > HitsToTrackIDEs
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
void lar_pandora::LArPandoraHelper::BuildMCParticleMap ( const MCParticleVector particleVector,
MCParticleMap particleMap 
)
static

Build particle maps for true particles.

Parameters
particleVectorthe input vector of true particles
particleMapthe output mapping between true particle and true track ID

Definition at line 1184 of file LArPandoraHelper.cxx.

1186  {
1187  for (MCParticleVector::const_iterator iter = particleVector.begin(),
1188  iterEnd = particleVector.end();
1189  iter != iterEnd;
1190  ++iter) {
1191  const art::Ptr<simb::MCParticle> particle = *iter;
1192  particleMap[particle->TrackId()] = particle;
1193  particleMap[particle->TrackId()] = particle;
1194  }
1195  }
intermediate_table::const_iterator const_iterator
int TrackId() const
Definition: MCParticle.h:210
void lar_pandora::LArPandoraHelper::BuildPFParticleHitMaps ( const PFParticleVector particleVector,
const PFParticlesToSpacePoints particlesToSpacePoints,
const SpacePointsToHits spacePointsToHits,
PFParticlesToHits particlesToHits,
HitsToPFParticles hitsToParticles,
const DaughterMode  daughterMode = kUseDaughters 
)
static

Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.

Parameters
particleVectorthe input vector of PFParticle objects
particlesToSpacePointsthe input map from PFParticle to SpacePoint objects
spacePointsToHitsthe input map from SpacePoint to Hit objects
particlesToHitsthe output map from PFParticle to Hit objects
hitsToParticlesthe output map from Hit to PFParticle objects
daughterModetreatment of daughter particles in construction of maps

Definition at line 523 of file LArPandoraHelper.cxx.

529  {
530  // Build mapping from particle to particle ID for parent/daughter navigation
531  PFParticleMap particleMap;
532 
533  for (PFParticleVector::const_iterator iter1 = particleVector.begin(),
534  iterEnd1 = particleVector.end();
535  iter1 != iterEnd1;
536  ++iter1) {
537  const art::Ptr<recob::PFParticle> particle = *iter1;
538  particleMap[particle->Self()] = particle;
539  }
540 
541  // Loop over hits and build mapping between reconstructed final-state particles and reconstructed hits
542  for (PFParticlesToSpacePoints::const_iterator iter1 = particlesToSpacePoints.begin(),
543  iterEnd1 = particlesToSpacePoints.end();
544  iter1 != iterEnd1;
545  ++iter1) {
546  const art::Ptr<recob::PFParticle> thisParticle = iter1->first;
547  const art::Ptr<recob::PFParticle> particle(
548  (kAddDaughters == daughterMode) ?
549  LArPandoraHelper::GetFinalStatePFParticle(particleMap, thisParticle) :
550  thisParticle);
551 
552  if ((kIgnoreDaughters == daughterMode) &&
553  !LArPandoraHelper::IsFinalState(particleMap, particle))
554  continue;
555 
556  const SpacePointVector& spacePointVector = iter1->second;
557 
558  for (SpacePointVector::const_iterator iter2 = spacePointVector.begin(),
559  iterEnd2 = spacePointVector.end();
560  iter2 != iterEnd2;
561  ++iter2) {
562  const art::Ptr<recob::SpacePoint> spacepoint = *iter2;
563 
564  SpacePointsToHits::const_iterator iter3 = spacePointsToHits.find(spacepoint);
565  if (spacePointsToHits.end() == iter3)
566  throw cet::exception("LArPandora") << " PandoraCollector::BuildPFParticleHitMaps --- "
567  "Found a space point without an associated hit ";
568 
569  const art::Ptr<recob::Hit> hit = iter3->second;
570 
571  particlesToHits[particle].push_back(hit);
572  hitsToParticles[hit] = particle;
573  }
574  }
575  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
static art::Ptr< recob::PFParticle > GetFinalStatePFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
intermediate_table::const_iterator const_iterator
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
Detector simulation of raw signals on wires.
static bool IsFinalState(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Determine whether a particle has been reconstructed as a final-state particle.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraHelper::BuildPFParticleHitMaps ( const PFParticleVector particleVector,
const PFParticlesToClusters particlesToClusters,
const ClustersToHits clustersToHits,
PFParticlesToHits particlesToHits,
HitsToPFParticles hitsToParticles,
const DaughterMode  daughterMode = kUseDaughters 
)
static

Build mapping between PFParticles and Hits using PFParticle/Cluster/Hit maps.

Parameters
particleVectorthe input vector of PFParticle objects
particlesToClustersthe input map from PFParticle to Cluster objects
clustersToHitsthe input map from Cluster to Hit objects
particlesToHitsthe output map from PFParticle to Hit objects
hitsToParticlesthe output map from Hit to PFParticle objects
daughterModetreatment of daughter particles in construction of maps

Definition at line 580 of file LArPandoraHelper.cxx.

586  {
587  // Build mapping from particle to particle ID for parent/daughter navigation
588  PFParticleMap particleMap;
589 
590  for (PFParticleVector::const_iterator iter1 = particleVector.begin(),
591  iterEnd1 = particleVector.end();
592  iter1 != iterEnd1;
593  ++iter1) {
594  const art::Ptr<recob::PFParticle> particle = *iter1;
595  particleMap[particle->Self()] = particle;
596  }
597 
598  // Loop over hits and build mapping between reconstructed final-state particles and reconstructed hits
599  for (PFParticlesToClusters::const_iterator iter1 = particlesToClusters.begin(),
600  iterEnd1 = particlesToClusters.end();
601  iter1 != iterEnd1;
602  ++iter1) {
603  const art::Ptr<recob::PFParticle> thisParticle = iter1->first;
604  const art::Ptr<recob::PFParticle> particle(
605  (kAddDaughters == daughterMode) ?
606  LArPandoraHelper::GetFinalStatePFParticle(particleMap, thisParticle) :
607  thisParticle);
608 
609  if ((kIgnoreDaughters == daughterMode) &&
610  !LArPandoraHelper::IsFinalState(particleMap, particle))
611  continue;
612 
613  const ClusterVector& clusterVector = iter1->second;
614  for (ClusterVector::const_iterator iter2 = clusterVector.begin(),
615  iterEnd2 = clusterVector.end();
616  iter2 != iterEnd2;
617  ++iter2) {
618  const art::Ptr<recob::Cluster> cluster = *iter2;
619 
620  ClustersToHits::const_iterator iter3 = clustersToHits.find(cluster);
621  if (clustersToHits.end() == iter3)
622  throw cet::exception("LArPandora") << " PandoraCollector::BuildPFParticleHitMaps --- "
623  "Found a space point without an associated hit ";
624 
625  const HitVector& hitVector = iter3->second;
626  for (HitVector::const_iterator iter4 = hitVector.begin(), iterEnd4 = hitVector.end();
627  iter4 != iterEnd4;
628  ++iter4) {
629  const art::Ptr<recob::Hit> hit = *iter4;
630 
631  particlesToHits[particle].push_back(hit);
632  hitsToParticles[hit] = particle;
633  }
634  }
635  }
636  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
static art::Ptr< recob::PFParticle > GetFinalStatePFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
intermediate_table::const_iterator const_iterator
Cluster finding and building.
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
Detector simulation of raw signals on wires.
std::vector< art::Ptr< recob::Hit > > HitVector
std::vector< art::Ptr< recob::Cluster > > ClusterVector
static bool IsFinalState(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Determine whether a particle has been reconstructed as a final-state particle.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::LArPandoraHelper::BuildPFParticleHitMaps ( const art::Event evt,
const std::string label_pfpart,
const std::string label_mid,
PFParticlesToHits particlesToHits,
HitsToPFParticles hitsToParticles,
const DaughterMode  daughterMode = kUseDaughters,
const bool  useClusters = true 
)
static

Build mapping between PFParticles and Hits starting from ART event record.

Parameters
evtthe ART event record
label_pfpartthe label for the PFParticle list in the event
label_spacethe label for the Intermediate list in the event
particlesToHitsoutput map from PFParticle to Hit objects
hitsToParticlesoutput map from Hit to PFParticle objects
daughterModetreatment of daughter particles in construction of maps
useClusterschoice of intermediate object (true for Clusters, false for SpacePoints)

Definition at line 655 of file LArPandoraHelper.cxx.

662  {
663  // Use intermediate clusters
664  if (useClusters) {
665  PFParticleVector particleVector;
666  PFParticlesToClusters particlesToClusters;
667 
668  ClusterVector clusterVector;
669  ClustersToHits clustersToHits;
670 
671  LArPandoraHelper::CollectPFParticles(evt, label_pfpart, particleVector, particlesToClusters);
672  LArPandoraHelper::CollectClusters(evt, label_middle, clusterVector, clustersToHits);
673 
675  particlesToClusters,
676  clustersToHits,
677  particlesToHits,
678  hitsToParticles,
679  daughterMode);
680  }
681 
682  // Use intermediate space points
683  else {
684  PFParticleVector particleVector;
685  PFParticlesToSpacePoints particlesToSpacePoints;
686 
687  SpacePointVector spacePointVector;
688  SpacePointsToHits spacePointsToHits;
689 
691  evt, label_pfpart, particleVector, particlesToSpacePoints);
692  LArPandoraHelper::CollectSpacePoints(evt, label_middle, spacePointVector, spacePointsToHits);
693 
695  particlesToSpacePoints,
696  spacePointsToHits,
697  particlesToHits,
698  hitsToParticles,
699  daughterMode);
700  }
701  }
static void BuildPFParticleHitMaps(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.
static void CollectClusters(const art::Event &evt, const std::string &label, ClusterVector &clusterVector, ClustersToHits &clustersToHits)
Collect the reconstructed Clusters and associated hits from the ART event record. ...
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
static void CollectSpacePoints(const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits)
Collect the reconstructed SpacePoints and associated hits from the ART event record.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< recob::Cluster >, HitVector > ClustersToHits
std::vector< art::Ptr< recob::SpacePoint > > SpacePointVector
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::map< art::Ptr< recob::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
void lar_pandora::LArPandoraHelper::BuildPFParticleHitMaps ( const art::Event evt,
const std::string label,
PFParticlesToHits particlesToHits,
HitsToPFParticles hitsToParticles,
const DaughterMode  daughterMode = kUseDaughters,
const bool  useClusters = true 
)
static

Build mapping between PFParticles and Hits starting from ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
particlesToHitsoutput map from PFParticle to Hit objects
hitsToParticlesoutput map from Hit to PFParticle objects
daughterModetreatment of daughter particles in construction of maps
useClusterschoice of intermediate object (true for Clusters, false for SpacePoints)

Definition at line 641 of file LArPandoraHelper.cxx.

647  {
649  evt, label, label, particlesToHits, hitsToParticles, daughterMode, useClusters);
650  }
static void BuildPFParticleHitMaps(const PFParticleVector &particleVector, const PFParticlesToSpacePoints &particlesToSpacePoints, const SpacePointsToHits &spacePointsToHits, PFParticlesToHits &particlesToHits, HitsToPFParticles &hitsToParticles, const DaughterMode daughterMode=kUseDaughters)
Build mapping between PFParticles and Hits using PFParticle/SpacePoint/Hit maps.
void lar_pandora::LArPandoraHelper::BuildPFParticleMap ( const PFParticleVector particleVector,
PFParticleMap particleMap 
)
static

Build particle maps for reconstructed particles.

Parameters
particleVectorthe input vector of reconstructed particles
particleMapthe output mapping between reconstructed particles and particle ID

Definition at line 1200 of file LArPandoraHelper.cxx.

1202  {
1203  for (PFParticleVector::const_iterator iter = particleVector.begin(),
1204  iterEnd = particleVector.end();
1205  iter != iterEnd;
1206  ++iter) {
1207  const art::Ptr<recob::PFParticle> particle = *iter;
1208  particleMap[particle->Self()] = particle;
1209  }
1210  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
intermediate_table::const_iterator const_iterator
void lar_pandora::LArPandoraHelper::CollectClusters ( const art::Event evt,
const std::string label,
ClusterVector clusterVector,
ClustersToHits clustersToHits 
)
static

Collect the reconstructed Clusters and associated hits from the ART event record.

Parameters
evtthe ART event record
labelthe label for the SpacePoint list in the event
clusterVectorthe output vector of Cluster objects
clustersToHitsthe output map from Cluster to Hit objects

Definition at line 164 of file LArPandoraHelper.cxx.

168  {
170  evt.getByLabel(label, theClusters);
171 
172  if (!theClusters.isValid()) {
173  mf::LogDebug("LArPandora") << " Failed to find clusters... " << std::endl;
174  return;
175  }
176  else {
177  mf::LogDebug("LArPandora") << " Found: " << theClusters->size() << " Clusters " << std::endl;
178  }
179 
180  art::FindManyP<recob::Hit> theHitAssns(theClusters, evt, label);
181  for (unsigned int i = 0; i < theClusters->size(); ++i) {
182  const art::Ptr<recob::Cluster> cluster(theClusters, i);
183  clusterVector.push_back(cluster);
184 
185  const std::vector<art::Ptr<recob::Hit>> hits = theHitAssns.at(i);
186  for (unsigned int j = 0; j < hits.size(); ++j) {
187  const art::Ptr<recob::Hit> hit = hits.at(j);
188  clustersToHits[cluster].push_back(hit);
189  }
190  }
191  }
void cluster(In first, In last, Out result, Pred *pred)
Definition: NNClusters.h:41
Cluster finding and building.
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
Detector simulation of raw signals on wires.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectCosmicTags ( const art::Event evt,
const std::string label,
CosmicTagVector cosmicTagVector,
TracksToCosmicTags tracksToCosmicTags 
)
static

Collect a vector of cosmic tags from the ART event record.

Parameters
evtthe ART event record
labelthe label for the cosmic tag information in the event
cosmicTagVectoroutput vector of CosmicTag objects
tracksToCosmicTagsoutput map from tracks to cosmic tags

Definition at line 751 of file LArPandoraHelper.cxx.

755  {
757  evt.getByLabel(label, theCosmicTags);
758 
759  if (theCosmicTags.isValid()) {
760  art::FindOneP<recob::Track> theCosmicAssns(
761  theCosmicTags, evt, label); // We assume there is one tag per algorithm
762  for (unsigned int i = 0; i < theCosmicTags->size(); ++i) {
763  const art::Ptr<anab::CosmicTag> cosmicTag(theCosmicTags, i);
764  const art::Ptr<recob::Track> track = theCosmicAssns.at(i);
765  tracksToCosmicTags[track].push_back(
766  cosmicTag); // We assume there could be multiple algorithms
767  cosmicTagVector.push_back(cosmicTag);
768  }
769  }
770  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
Definition: fwd.h:31
void lar_pandora::LArPandoraHelper::CollectGeneratorMCParticles ( const art::Event evt,
const std::string label,
RawMCParticleVector particleVector 
)
static

Collect a vector of MCParticle objects from the generator in the ART event record. ATTN: This function is needed as accessing generator (opposed to Geant4) level MCParticles requires use of MCTruth block.

Parameters
evtthe ART event record
labelthe label for the truth information in the generator
particleVectorthe output vector of MCParticle objects

Definition at line 855 of file LArPandoraHelper.cxx.

858  {
860  evt.getByLabel(label, mcTruthBlocks);
861 
862  if (!mcTruthBlocks.isValid()) {
863  mf::LogDebug("LArPandora") << " Failed to find MC truth blocks from generator... "
864  << std::endl;
865  return;
866  }
867  else {
868  mf::LogDebug("LArPandora") << " Found: " << mcTruthBlocks->size() << " MC truth blocks "
869  << std::endl;
870  }
871 
872  if (mcTruthBlocks->size() != 1)
873  throw cet::exception("LArPandora") << " PandoraCollector::CollectGeneratorMCParticles --- "
874  "Unexpected number of MC truth blocks ";
875 
876  const art::Ptr<simb::MCTruth> mcTruth(mcTruthBlocks, 0);
877 
878  for (int i = 0; i < mcTruth->NParticles(); ++i) {
879  particleVector.push_back(mcTruth->GetParticle(i));
880  }
881  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectHits ( const art::Event evt,
const std::string label,
HitVector hitVector 
)
static

Collect the reconstructed Hits from the ART event record.

Parameters
evtthe ART event record
labelthe label for the Hit list in the event
hitVectorthe ouput vector of Hit objects

Definition at line 71 of file LArPandoraHelper.cxx.

74  {
76  evt.getByLabel(label, theHits);
77 
78  if (!theHits.isValid()) {
79  mf::LogDebug("LArPandora") << " Failed to find hits... " << std::endl;
80  return;
81  }
82  else {
83  mf::LogDebug("LArPandora") << " Found: " << theHits->size() << " Hits " << std::endl;
84  }
85 
86  for (unsigned int i = 0; i < theHits->size(); ++i) {
87  const art::Ptr<recob::Hit> hit(theHits, i);
88  hitVector.push_back(hit);
89  }
90  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
Detector simulation of raw signals on wires.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectMCParticles ( const art::Event evt,
const std::string label,
MCParticleVector particleVector 
)
static

Collect a vector of MCParticle objects from the ART event record.

Parameters
evtthe ART event record
labelthe label for the truth information in the event
particleVectorthe output vector of MCParticle objects

Definition at line 830 of file LArPandoraHelper.cxx.

833  {
835  evt.getByLabel(label, theParticles);
836 
837  if (!theParticles.isValid()) {
838  mf::LogDebug("LArPandora") << " Failed to find MC particles... " << std::endl;
839  return;
840  }
841  else {
842  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " MC particles "
843  << std::endl;
844  }
845 
846  for (unsigned int i = 0; i < theParticles->size(); ++i) {
847  const art::Ptr<simb::MCParticle> particle(theParticles, i);
848  particleVector.push_back(particle);
849  }
850  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectMCParticles ( const art::Event evt,
const std::string label,
MCTruthToMCParticles truthToParticles,
MCParticlesToMCTruth particlesToTruth 
)
static

Collect truth information from the ART event record.

Parameters
evtthe ART event record
labelthe label for the truth information in the event
truthToParticlesoutput map from MCTruth to MCParticle objects
particlesToTruthoutput map from MCParticle to MCTruth objects

Definition at line 886 of file LArPandoraHelper.cxx.

890  {
892  evt.getByLabel(label, theParticles);
893 
894  if (!theParticles.isValid()) {
895  mf::LogDebug("LArPandora") << " Failed to find MC particles... " << std::endl;
896  return;
897  }
898  else {
899  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " MC particles "
900  << std::endl;
901  }
902 
903  art::FindOneP<simb::MCTruth> theTruthAssns(theParticles, evt, label);
904 
905  for (unsigned int i = 0, iEnd = theParticles->size(); i < iEnd; ++i) {
906  const art::Ptr<simb::MCParticle> particle(theParticles, i);
907  const art::Ptr<simb::MCTruth> truth(theTruthAssns.at(i));
908  truthToParticles[truth].push_back(particle);
909  particlesToTruth[particle] = truth;
910  }
911  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectPFParticleMetadata ( const art::Event evt,
const std::string label,
PFParticleVector particleVector,
PFParticlesToMetadata particlesToMetadata 
)
static

Collect the reconstructed PFParticle Metadata from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
particleVectorthe output vector of PFParticle objects
particlesToSpacePointsthe output map from PFParticle to PFParticleMetadata objects

Definition at line 262 of file LArPandoraHelper.cxx.

266  {
268  evt.getByLabel(label, theParticles);
269 
270  if (!theParticles.isValid()) {
271  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
272  return;
273  }
274  else {
275  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles "
276  << std::endl;
277  }
278 
279  art::FindManyP<larpandoraobj::PFParticleMetadata> theMetadataAssns(theParticles, evt, label);
280  for (unsigned int i = 0; i < theParticles->size(); ++i) {
281  const art::Ptr<recob::PFParticle> particle(theParticles, i);
282  particleVector.push_back(particle);
283 
284  const std::vector<art::Ptr<larpandoraobj::PFParticleMetadata>> pfParticleMetadataList =
285  theMetadataAssns.at(i);
286  for (unsigned int j = 0; j < pfParticleMetadataList.size(); ++j) {
287  const art::Ptr<larpandoraobj::PFParticleMetadata> pfParticleMetadata =
288  pfParticleMetadataList.at(j);
289  particlesToMetadata[particle].push_back(pfParticleMetadata);
290  }
291  }
292  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectPFParticles ( const art::Event evt,
const std::string label,
PFParticleVector particleVector 
)
static

Collect the reconstructed PFParticles from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
particleVectorthe output vector of PFParticle objects

Definition at line 95 of file LArPandoraHelper.cxx.

98  {
100  evt.getByLabel(label, theParticles);
101 
102  if (!theParticles.isValid()) {
103  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
104  return;
105  }
106  else {
107  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles "
108  << std::endl;
109  }
110 
111  for (unsigned int i = 0; i < theParticles->size(); ++i) {
112  const art::Ptr<recob::PFParticle> particle(theParticles, i);
113  particleVector.push_back(particle);
114  }
115  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectPFParticles ( const art::Event evt,
const std::string label,
PFParticleVector particleVector,
PFParticlesToSpacePoints particlesToSpacePoints 
)
static

Collect the reconstructed PFParticles and associated SpacePoints from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
particleVectorthe output vector of PFParticle objects
particlesToSpacePointsthe output map from PFParticle to SpacePoint objects

Definition at line 196 of file LArPandoraHelper.cxx.

200  {
202  evt.getByLabel(label, theParticles);
203 
204  if (!theParticles.isValid()) {
205  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
206  return;
207  }
208  else {
209  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles "
210  << std::endl;
211  }
212 
213  art::FindManyP<recob::SpacePoint> theSpacePointAssns(theParticles, evt, label);
214  for (unsigned int i = 0; i < theParticles->size(); ++i) {
215  const art::Ptr<recob::PFParticle> particle(theParticles, i);
216  particleVector.push_back(particle);
217 
218  const std::vector<art::Ptr<recob::SpacePoint>> spacepoints = theSpacePointAssns.at(i);
219  for (unsigned int j = 0; j < spacepoints.size(); ++j) {
220  const art::Ptr<recob::SpacePoint> spacepoint = spacepoints.at(j);
221  particlesToSpacePoints[particle].push_back(spacepoint);
222  }
223  }
224  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
static void lar_pandora::LArPandoraHelper::CollectPFParticles ( const art::Event evt,
const std::string label,
PFParticleVector particleVector,
PFParticlesToClusters particlesToClusters 
)
static

Collect the reconstructed PFParticles and associated Clusters from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
particleVectorthe output vector of PFParticle objects
particlesToClustersthe output map from PFParticle to Cluster objects
void lar_pandora::LArPandoraHelper::CollectSeeds ( const art::Event evt,
const std::string label,
SeedVector seedVector,
PFParticlesToSeeds particlesToSeeds 
)
static

Collect the reconstructed PFParticles and associated Seeds from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
seedVectorthe output vector of Seed objects
particlesToSeedsthe output map from PFParticle to Seed objects

Definition at line 425 of file LArPandoraHelper.cxx.

429  {
431  evt.getByLabel(label, theSeeds);
432 
433  if (!theSeeds.isValid()) {
434  mf::LogDebug("LArPandora") << " Failed to find seeds... " << std::endl;
435  return;
436  }
437  else {
438  mf::LogDebug("LArPandora") << " Found: " << theSeeds->size() << " Seeds " << std::endl;
439  }
440 
441  art::FindManyP<recob::PFParticle> theSeedAssns(theSeeds, evt, label);
442  for (unsigned int i = 0; i < theSeeds->size(); ++i) {
443  const art::Ptr<recob::Seed> seed(theSeeds, i);
444  seedVector.push_back(seed);
445 
446  const std::vector<art::Ptr<recob::PFParticle>> particles = theSeedAssns.at(i);
447  for (unsigned int j = 0; j < particles.size(); ++j) {
448  const art::Ptr<recob::PFParticle> particle = particles.at(j);
449  particlesToSeeds[particle].push_back(seed);
450  }
451  }
452  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:31
QTextStream & endl(QTextStream &s)
static void lar_pandora::LArPandoraHelper::CollectSeeds ( const art::Event evt,
const std::string label,
SeedVector seedVector,
SeedsToHits seedsToHits 
)
static

Collect the reconstructed Seeds and associated Hits from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
seedVectorthe output vector of Seed objects
seedsToHitsthe output map from Seed to Hit objects
void lar_pandora::LArPandoraHelper::CollectShowers ( const art::Event evt,
const std::string label,
ShowerVector showerVector,
PFParticlesToShowers particlesToShowers 
)
static

Collect the reconstructed PFParticles and associated Showers from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
showerVectorthe output vector of Shower objects
particlesToShowersthe output map from PFParticle to Shower objects

Definition at line 297 of file LArPandoraHelper.cxx.

301  {
303  evt.getByLabel(label, theShowers);
304 
305  if (!theShowers.isValid()) {
306  mf::LogDebug("LArPandora") << " Failed to find showers... " << std::endl;
307  return;
308  }
309  else {
310  mf::LogDebug("LArPandora") << " Found: " << theShowers->size() << " Showers " << std::endl;
311  }
312 
313  art::FindManyP<recob::PFParticle> theShowerAssns(theShowers, evt, label);
314  for (unsigned int i = 0; i < theShowers->size(); ++i) {
315  const art::Ptr<recob::Shower> shower(theShowers, i);
316  showerVector.push_back(shower);
317 
318  const std::vector<art::Ptr<recob::PFParticle>> particles = theShowerAssns.at(i);
319  for (unsigned int j = 0; j < particles.size(); ++j) {
320  const art::Ptr<recob::PFParticle> particle = particles.at(j);
321  particlesToShowers[particle].push_back(shower);
322  }
323  }
324  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
static void lar_pandora::LArPandoraHelper::CollectShowers ( const art::Event evt,
const std::string label,
ShowerVector showerVector,
ShowersToHits showersToHits 
)
static

Collect the reconstructed Showers and associated Hits from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
showerVectorthe output vector of Shower objects
showersToHitsthe output map from Shower to Hit objects
void lar_pandora::LArPandoraHelper::CollectSimChannels ( const art::Event evt,
const std::string label,
SimChannelVector simChannelVector,
bool areSimChannelsValid 
)
static

Collect a vector of SimChannel objects from the ART event record.

Parameters
evtthe ART event record
labelthe label for the truth information in the event
simChannelVectoroutput vector of SimChannel objects
areSimChannelsValidboolean parameter indicating if the sim channel collection exists

Definition at line 802 of file LArPandoraHelper.cxx.

806  {
808  evt.getByLabel(label, theSimChannels);
809 
810  if (!theSimChannels.isValid()) {
811  mf::LogDebug("LArPandora") << " Failed to find sim channels... " << std::endl;
812  areSimChannelsValid = false;
813  return;
814  }
815  else {
816  mf::LogDebug("LArPandora") << " Found: " << theSimChannels->size() << " SimChannels "
817  << std::endl;
818  areSimChannelsValid = true;
819  }
820 
821  for (unsigned int i = 0; i < theSimChannels->size(); ++i) {
822  const art::Ptr<sim::SimChannel> channel(theSimChannels, i);
823  simChannelVector.push_back(channel);
824  }
825  }
uint8_t channel
Definition: CRTFragment.hh:201
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectSpacePoints ( const art::Event evt,
const std::string label,
SpacePointVector spacePointVector,
SpacePointsToHits spacePointsToHits 
)
static

Collect the reconstructed SpacePoints and associated hits from the ART event record.

Parameters
evtthe ART event record
labelthe label for the SpacePoint list in the event
spacePointVectorthe output vector of SpacePoint objects
spacePointsToHitsthe output map from SpacePoint to Hit objects

Definition at line 120 of file LArPandoraHelper.cxx.

124  {
125  HitsToSpacePoints hitsToSpacePoints;
127  evt, label, spacePointVector, spacePointsToHits, hitsToSpacePoints);
128  }
static void CollectSpacePoints(const art::Event &evt, const std::string &label, SpacePointVector &spacePointVector, SpacePointsToHits &spacePointsToHits)
Collect the reconstructed SpacePoints and associated hits from the ART event record.
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::SpacePoint > > HitsToSpacePoints
void lar_pandora::LArPandoraHelper::CollectSpacePoints ( const art::Event evt,
const std::string label,
SpacePointVector spacePointVector,
SpacePointsToHits spacePointsToHits,
HitsToSpacePoints hitsToSpacePoints 
)
static

Collect the reconstructed SpacePoints and associated hits from the ART event record.

Parameters
evtthe ART event record
labelthe label for the SpacePoint list in the event
spacePointVectorthe output vector of SpacePoint objects
spacePointsToHitsthe output map from SpacePoint to Hit objects
hitsToSpacePointsthe output map from Hit to SpacePoint objects

Definition at line 133 of file LArPandoraHelper.cxx.

138  {
140  evt.getByLabel(label, theSpacePoints);
141 
142  if (!theSpacePoints.isValid()) {
143  mf::LogDebug("LArPandora") << " Failed to find spacepoints... " << std::endl;
144  return;
145  }
146  else {
147  mf::LogDebug("LArPandora") << " Found: " << theSpacePoints->size() << " SpacePoints "
148  << std::endl;
149  }
150 
151  art::FindOneP<recob::Hit> theHitAssns(theSpacePoints, evt, label);
152  for (unsigned int i = 0; i < theSpacePoints->size(); ++i) {
153  const art::Ptr<recob::SpacePoint> spacepoint(theSpacePoints, i);
154  spacePointVector.push_back(spacepoint);
155  const art::Ptr<recob::Hit> hit = theHitAssns.at(i);
156  spacePointsToHits[spacepoint] = hit;
157  hitsToSpacePoints[hit] = spacepoint;
158  }
159  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
Detector simulation of raw signals on wires.
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
void lar_pandora::LArPandoraHelper::CollectT0s ( const art::Event evt,
const std::string label,
T0Vector t0Vector,
PFParticlesToT0s particlesToT0s 
)
static

Collect a vector of T0s from the ART event record.

Parameters
evtthe ART event record
labelthe label for the T0 information in the event
t0Vectoroutput vector of T0 objects
particlesToT0soutput map from PParticles to T0s

Definition at line 775 of file LArPandoraHelper.cxx.

779  {
781  evt.getByLabel(label, theT0s);
782 
783  if (theT0s.isValid()) {
784  art::FindManyP<recob::PFParticle> theAssns(theT0s, evt, label);
785  for (unsigned int i = 0; i < theT0s->size(); ++i) {
786  const art::Ptr<anab::T0> theT0(theT0s, i);
787  t0Vector.push_back(theT0);
788 
789  const std::vector<art::Ptr<recob::PFParticle>> particles = theAssns.at(i);
790  for (unsigned int j = 0; j < particles.size(); ++j) {
791  const art::Ptr<recob::PFParticle> theParticle = particles.at(j);
792  particlesToT0s[theParticle].push_back(
793  theT0); // We assume there could be multiple T0s per PFParticle
794  }
795  }
796  }
797  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
Definition: fwd.h:31
void lar_pandora::LArPandoraHelper::CollectTracks ( const art::Event evt,
const std::string label,
TrackVector trackVector,
PFParticlesToTracks particlesToTracks 
)
static

Collect the reconstructed PFParticles and associated Tracks from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
trackVectorthe output vector of Track objects
particlesToTracksthe output map from PFParticle to Track objects

Definition at line 329 of file LArPandoraHelper.cxx.

333  {
335  evt.getByLabel(label, theTracks);
336 
337  if (!theTracks.isValid()) {
338  mf::LogDebug("LArPandora") << " Failed to find tracks... " << std::endl;
339  return;
340  }
341  else {
342  mf::LogDebug("LArPandora") << " Found: " << theTracks->size() << " Tracks " << std::endl;
343  }
344 
345  art::FindManyP<recob::PFParticle> theTrackAssns(theTracks, evt, label);
346  for (unsigned int i = 0; i < theTracks->size(); ++i) {
347  const art::Ptr<recob::Track> track(theTracks, i);
348  trackVector.push_back(track);
349 
350  const std::vector<art::Ptr<recob::PFParticle>> particles = theTrackAssns.at(i);
351  for (unsigned int j = 0; j < particles.size(); ++j) {
352  const art::Ptr<recob::PFParticle> particle = particles.at(j);
353  particlesToTracks[particle].push_back(track);
354  }
355  }
356  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
static void lar_pandora::LArPandoraHelper::CollectTracks ( const art::Event evt,
const std::string label,
TrackVector trackVector,
TracksToHits tracksToHits 
)
static

Collect the reconstructed Tracks and associated Hits from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
trackVectorthe output vector of Track objects
tracksToHitsthe output map from Track to Hit objects
void lar_pandora::LArPandoraHelper::CollectVertices ( const art::Event evt,
const std::string label,
VertexVector vertexVector,
PFParticlesToVertices particlesToVertices 
)
static

Collect the reconstructed PFParticles and associated Vertices from the ART event record.

Parameters
evtthe ART event record
labelthe label for the PFParticle list in the event
vertexVectorthe output vector of Vertex objects
particlesToVerticesthe output map from PFParticle to Vertex objects

Definition at line 491 of file LArPandoraHelper.cxx.

495  {
497  evt.getByLabel(label, theVertices);
498 
499  if (!theVertices.isValid()) {
500  mf::LogDebug("LArPandora") << " Failed to find vertices... " << std::endl;
501  return;
502  }
503  else {
504  mf::LogDebug("LArPandora") << " Found: " << theVertices->size() << " Vertices " << std::endl;
505  }
506 
507  art::FindManyP<recob::PFParticle> theVerticesAssns(theVertices, evt, label);
508  for (unsigned int i = 0; i < theVertices->size(); ++i) {
509  const art::Ptr<recob::Vertex> vertex(theVertices, i);
510  vertexVector.push_back(vertex);
511 
512  const std::vector<art::Ptr<recob::PFParticle>> particles = theVerticesAssns.at(i);
513  for (unsigned int j = 0; j < particles.size(); ++j) {
514  const art::Ptr<recob::PFParticle> particle = particles.at(j);
515  particlesToVertices[particle].push_back(vertex);
516  }
517  }
518  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
vertex reconstruction
void lar_pandora::LArPandoraHelper::CollectWires ( const art::Event evt,
const std::string label,
WireVector wireVector 
)
static

Collect the reconstructed wires from the ART event record.

Parameters
evtthe ART event record
labelthe label for the Wire list in the event
wireVectorthe ouput vector of Wire objects

Definition at line 47 of file LArPandoraHelper.cxx.

50  {
52  evt.getByLabel(label, theWires);
53 
54  if (!theWires.isValid()) {
55  mf::LogDebug("LArPandora") << " Failed to find wires... " << std::endl;
56  return;
57  }
58  else {
59  mf::LogDebug("LArPandora") << " Found: " << theWires->size() << " Wires " << std::endl;
60  }
61 
62  for (unsigned int i = 0; i < theWires->size(); ++i) {
63  const art::Ptr<recob::Wire> wire(theWires, i);
64  wireVector.push_back(wire);
65  }
66  }
bool isValid() const noexcept
Definition: Handle.h:191
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
QTextStream & endl(QTextStream &s)
template<typename T >
template void lar_pandora::LArPandoraHelper::GetAssociatedHits ( const art::Event evt,
const std::string label,
const std::vector< art::Ptr< T >> &  inputVector,
HitVector associatedHits,
const pandora::IntVector *const  indexVector = nullptr 
)
static

Get all hits associated with input clusters.

Parameters
evtthe event containing the hits
labelthe label of the collection producing PFParticles
inputvector input of T (clusters, spacepoints)
associatedHitsoutput hits associated with T
indexVectorvector of spacepoint indices reflecting trajectory points sorting order

Definition at line 1149 of file LArPandoraHelper.cxx.

1154  {
1155 
1157  evt.getByLabel(label, handle);
1158  art::FindManyP<recob::Hit> hitAssoc(handle, evt, label);
1159 
1160  if (indexVector != nullptr) {
1161  if (inputVector.size() != indexVector->size())
1162  throw cet::exception("LArPandora") << " PandoraHelper::GetAssociatedHits --- trying to use "
1163  "an index vector not matching input vector";
1164 
1165  // If indexVector is filled, sort hits according to trajectory points order
1166  for (int index : (*indexVector)) {
1167  const art::Ptr<T>& element = inputVector.at(index);
1168  const HitVector& hits = hitAssoc.at(element.key());
1169  associatedHits.insert(associatedHits.end(), hits.begin(), hits.end());
1170  }
1171  }
1172  else {
1173  // If indexVector is empty just loop through inputSpacePoints
1174  for (const art::Ptr<T>& element : inputVector) {
1175  const HitVector& hits = hitAssoc.at(element.key());
1176  associatedHits.insert(associatedHits.end(), hits.begin(), hits.end());
1177  }
1178  }
1179  }
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: DataViewImpl.h:633
key_type key() const noexcept
Definition: Ptr.h:216
std::vector< art::Ptr< recob::Hit > > HitVector
Definition: fwd.h:31
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::Ptr< simb::MCParticle > lar_pandora::LArPandoraHelper::GetFinalStateMCParticle ( const MCParticleMap particleMap,
const art::Ptr< simb::MCParticle daughterParticle 
)
static

Return the final-state parent particle by navigating up the chain of parent/daughter associations.

Parameters
particleMapthe mapping between true particle and true track ID
daughterParticlethe input MC particle
Returns
the final-state parent particle

Definition at line 1314 of file LArPandoraHelper.cxx.

1316  {
1317  // Navigate upward through MC daughter/parent links - collect this particle and all its parents
1318  MCParticleVector mcVector;
1319 
1320  int trackID(inputParticle->TrackId());
1321 
1322  while (1) {
1323  MCParticleMap::const_iterator pIter = particleMap.find(trackID);
1324  if (particleMap.end() == pIter) break; // Can't find MC Particle for this track ID [break]
1325 
1326  const art::Ptr<simb::MCParticle> particle = pIter->second;
1327  mcVector.push_back(particle);
1328 
1329  trackID = particle->Mother();
1330  }
1331 
1332  // Navigate downward through MC parent/daughter links - return the first long-lived charged particle
1333  for (MCParticleVector::const_reverse_iterator iter = mcVector.rbegin(),
1334  iterEnd = mcVector.rend();
1335  iter != iterEnd;
1336  ++iter) {
1337  const art::Ptr<simb::MCParticle> nextParticle = *iter;
1338 
1339  if (LArPandoraHelper::IsVisible(nextParticle)) return nextParticle;
1340  }
1341 
1342  throw cet::exception("LArPandora"); // need to catch this exception
1343  }
int Mother() const
Definition: MCParticle.h:213
intermediate_table::const_iterator const_iterator
static bool IsVisible(const art::Ptr< simb::MCParticle > particle)
Determine whether a particle is visible (i.e. long-lived charged particle)
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::Ptr< recob::PFParticle > lar_pandora::LArPandoraHelper::GetFinalStatePFParticle ( const PFParticleMap particleMap,
const art::Ptr< recob::PFParticle daughterParticle 
)
static

Return the final-state parent particle by navigating up the chain of parent/daughter associations.

Parameters
particleMapthe mapping between reconstructed particle and particle ID
daughterParticlethe input PF particle
Returns
the final-state parent particle

Definition at line 1247 of file LArPandoraHelper.cxx.

1249  {
1250  // Navigate upward through PFO daughter/parent links - return the top-level non-neutrino PF Particle
1251  int primaryTrackID(inputParticle->Self());
1252 
1253  if (!inputParticle->IsPrimary()) {
1254  int parentTrackID(inputParticle->Parent());
1255 
1256  while (1) {
1257  PFParticleMap::const_iterator pIter1 = particleMap.find(parentTrackID);
1258  if (particleMap.end() == pIter1)
1259  throw cet::exception("LArPandora") << " PandoraCollector::GetFinalStatePFParticle --- "
1260  "Found a PFParticle without a particle ID ";
1261 
1262  const art::Ptr<recob::PFParticle> parentParticle = pIter1->second;
1263  if (LArPandoraHelper::IsNeutrino(parentParticle)) break;
1264 
1265  primaryTrackID = parentTrackID;
1266 
1267  if (parentParticle->IsPrimary()) break;
1268 
1269  parentTrackID = parentParticle->Parent();
1270  }
1271  }
1272 
1273  PFParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1274  if (particleMap.end() == pIter2)
1275  throw cet::exception("LArPandora") << " PandoraCollector::GetFinalStatePFParticle --- Found "
1276  "a PFParticle without a particle ID ";
1277 
1278  const art::Ptr<recob::PFParticle> outputParticle = pIter2->second;
1279  return outputParticle;
1280  }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int lar_pandora::LArPandoraHelper::GetGeneration ( const PFParticleMap particleMap,
const art::Ptr< recob::PFParticle daughterParticle 
)
static

Return the generation of this particle (first generation if primary)

Parameters
particleMapthe mapping between reconstructed particle and particle ID
daughterParticlethe input daughter particle
Returns
the nth generation in the particle hierarchy

Definition at line 1368 of file LArPandoraHelper.cxx.

1370  {
1371  // Navigate upward through PFO daughter/parent links - return the top-level PF Particle
1372  int nGenerations(0);
1373  int primaryTrackID(inputParticle->Self());
1374 
1375  while (1) {
1376  PFParticleMap::const_iterator pIter = particleMap.find(primaryTrackID);
1377  if (particleMap.end() == pIter)
1378  throw cet::exception("LArPandora")
1379  << " PandoraCollector::GetGeneration --- Found a PFParticle without a particle ID ";
1380 
1381  ++nGenerations;
1382 
1383  const art::Ptr<recob::PFParticle> primaryParticle = pIter->second;
1384  if (primaryParticle->IsPrimary()) break;
1385 
1386  primaryTrackID = primaryParticle->Parent();
1387  }
1388 
1389  return nGenerations;
1390  }
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::Ptr< simb::MCParticle > lar_pandora::LArPandoraHelper::GetParentMCParticle ( const MCParticleMap particleMap,
const art::Ptr< simb::MCParticle daughterParticle 
)
static

Return the top-level parent particle by navigating up the chain of parent/daughter associations.

Parameters
particleMapthe mapping between true particle and true track ID
daughterParticlethe input MC particle
Returns
the top-level parent particle

Definition at line 1285 of file LArPandoraHelper.cxx.

1287  {
1288  // Navigate upward through MC daughter/parent links - return the top-level MC particle
1289  int primaryTrackID(inputParticle->TrackId());
1290  int parentTrackID(inputParticle->Mother());
1291 
1292  while (1) {
1293  MCParticleMap::const_iterator pIter1 = particleMap.find(parentTrackID);
1294  if (particleMap.end() == pIter1) break; // Can't find MC Particle for this track ID [break]
1295 
1296  const art::Ptr<simb::MCParticle> particle = pIter1->second;
1297 
1298  primaryTrackID = parentTrackID;
1299  parentTrackID = particle->Mother();
1300  }
1301 
1302  MCParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1303  if (particleMap.end() == pIter2)
1304  throw cet::exception("LArPandora")
1305  << " PandoraCollector::GetParentMCParticle --- Found a track ID without a MC particle ";
1306 
1307  const art::Ptr<simb::MCParticle> outputParticle = pIter2->second;
1308  return outputParticle;
1309  }
int Mother() const
Definition: MCParticle.h:213
intermediate_table::const_iterator const_iterator
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int lar_pandora::LArPandoraHelper::GetParentNeutrino ( const PFParticleMap particleMap,
const art::Ptr< recob::PFParticle daughterParticle 
)
static

Return the parent neutrino PDG code (or zero for cosmics) for a given reconstructed particle.

Parameters
particleMapthe mapping between reconstructed particle and particle ID
daughterParticlethe input daughter particle
Returns
the PDG code of the parent neutrinos (or zero for cosmics)

Definition at line 1395 of file LArPandoraHelper.cxx.

1397  {
1398  art::Ptr<recob::PFParticle> parentParticle =
1399  LArPandoraHelper::GetParentPFParticle(particleMap, daughterParticle);
1400 
1401  if (LArPandoraHelper::IsNeutrino(parentParticle)) return parentParticle->PdgCode();
1402 
1403  if (parentParticle->IsPrimary()) return 0;
1404 
1405  const int parentID(parentParticle->Parent());
1406 
1407  PFParticleMap::const_iterator pIter = particleMap.find(parentID);
1408  if (particleMap.end() == pIter)
1409  throw cet::exception("LArPandora")
1410  << " PandoraCollector::GetParentNeutrino --- Found a PFParticle without a particle ID ";
1411 
1412  const art::Ptr<recob::PFParticle> neutrinoParticle = pIter->second;
1413  return neutrinoParticle->PdgCode();
1414  }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
intermediate_table::const_iterator const_iterator
static art::Ptr< recob::PFParticle > GetParentPFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the top-level parent particle by navigating up the chain of parent/daughter associations...
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::Ptr< recob::PFParticle > lar_pandora::LArPandoraHelper::GetParentPFParticle ( const PFParticleMap particleMap,
const art::Ptr< recob::PFParticle daughterParticle 
)
static

Return the top-level parent particle by navigating up the chain of parent/daughter associations.

Parameters
particleMapthe mapping between reconstructed particle and particle ID
daughterParticlethe input PF particle
Returns
the top-level parent particle

Definition at line 1215 of file LArPandoraHelper.cxx.

1217  {
1218  // Navigate upward through PFO daughter/parent links - return the top-level PF Particle
1219  int primaryTrackID(inputParticle->Self());
1220 
1221  if (!inputParticle->IsPrimary()) {
1222  while (1) {
1223  PFParticleMap::const_iterator pIter1 = particleMap.find(primaryTrackID);
1224  if (particleMap.end() == pIter1)
1225  throw cet::exception("LArPandora") << " PandoraCollector::GetParentPFParticle --- Found "
1226  "a PFParticle without a particle ID ";
1227 
1228  const art::Ptr<recob::PFParticle> primaryParticle = pIter1->second;
1229  if (primaryParticle->IsPrimary()) break;
1230 
1231  primaryTrackID = primaryParticle->Parent();
1232  }
1233  }
1234 
1235  PFParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1236  if (particleMap.end() == pIter2)
1237  throw cet::exception("LArPandora")
1238  << " PandoraCollector::GetParentPFParticle --- Found a PFParticle without a particle ID ";
1239 
1240  const art::Ptr<recob::PFParticle> outputParticle = pIter2->second;
1241  return outputParticle;
1242  }
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
larpandoraobj::PFParticleMetadata lar_pandora::LArPandoraHelper::GetPFParticleMetadata ( const pandora::ParticleFlowObject *const  pPfo)
static

Get metadata associated to a PFO.

Parameters
pPfoinput ParticleFlowObject
Returns
larpandoraobj::PFParticleMetadata

Definition at line 1498 of file LArPandoraHelper.cxx.

1499  {
1500  return larpandoraobj::PFParticleMetadata(pPfo->GetPropertiesMap());
1501  }
Metadata associated to PFParticles.
art::Ptr< recob::Track > lar_pandora::LArPandoraHelper::GetPrimaryTrack ( const PFParticlesToTracks particlesToTracks,
const art::Ptr< recob::PFParticle particle 
)
static

Return the primary track associated with a PFParticle.

Parameters
particlesToTracksthe mapping between particles and tracks
particlethe input particle

Definition at line 1348 of file LArPandoraHelper.cxx.

1350  {
1351  PFParticlesToTracks::const_iterator tIter = particlesToTracks.find(particle);
1352 
1353  if (particlesToTracks.end() == tIter || tIter->second.empty())
1354  throw cet::exception("LArPandora")
1355  << " PandoraCollector::GetPrimaryTrack --- Failed to find associated track ";
1356 
1357  if (tIter->second.size() != 1)
1358  throw cet::exception("LArPandora")
1359  << " PandoraCollector::GetPrimaryTrack --- Found more than one associated track ";
1360 
1361  const art::Ptr<recob::Track> primaryTrack = *(tIter->second.begin());
1362  return primaryTrack;
1363  }
intermediate_table::const_iterator const_iterator
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool lar_pandora::LArPandoraHelper::IsFinalState ( const PFParticleMap particleMap,
const art::Ptr< recob::PFParticle daughterParticle 
)
static

Determine whether a particle has been reconstructed as a final-state particle.

Parameters
particleMapthe mapping between reconstructed particle and particle ID
daughterParticlethe input daughter particle
Returns
true/false

Definition at line 1419 of file LArPandoraHelper.cxx.

1421  {
1422  if (LArPandoraHelper::IsNeutrino(daughterParticle)) return false;
1423 
1424  if (daughterParticle->IsPrimary()) return true;
1425 
1426  const int parentID(daughterParticle->Parent());
1427 
1428  PFParticleMap::const_iterator pIter = particleMap.find(parentID);
1429  if (particleMap.end() == pIter)
1430  throw cet::exception("LArPandora")
1431  << " PandoraCollector::IsFinalState --- Found a PFParticle without a particle ID ";
1432 
1433  const art::Ptr<recob::PFParticle> parentParticle = pIter->second;
1434 
1435  if (LArPandoraHelper::IsNeutrino(parentParticle)) return true;
1436 
1437  return false;
1438  }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool lar_pandora::LArPandoraHelper::IsNeutrino ( const art::Ptr< recob::PFParticle particle)
static

Determine whether a particle has been reconstructed as a neutrino.

Parameters
particlethe input particle
Returns
true/false

Definition at line 1443 of file LArPandoraHelper.cxx.

1444  {
1445  const int pdg(particle->PdgCode());
1446 
1447  // electron, muon, tau (use Pandora PDG tables)
1448  return ((pandora::NU_E == std::abs(pdg)) || (pandora::NU_MU == std::abs(pdg)) ||
1449  (pandora::NU_TAU == std::abs(pdg)));
1450  }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
T abs(T value)
bool lar_pandora::LArPandoraHelper::IsShower ( const art::Ptr< recob::PFParticle particle)
static

Determine whether a particle has been reconstructed as shower-like.

Parameters
particlethe input particle
Returns
true/false

Definition at line 1467 of file LArPandoraHelper.cxx.

1468  {
1469  const int pdg(particle->PdgCode());
1470 
1471  // electron, photon (use Pandora PDG tables)
1472  return ((pandora::E_MINUS == std::abs(pdg)) || (pandora::PHOTON == std::abs(pdg)));
1473  }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
T abs(T value)
bool lar_pandora::LArPandoraHelper::IsTrack ( const art::Ptr< recob::PFParticle particle)
static

Determine whether a particle has been reconstructed as track-like.

Parameters
particlethe input particle
Returns
true/false

Definition at line 1455 of file LArPandoraHelper.cxx.

1456  {
1457  const int pdg(particle->PdgCode());
1458 
1459  // muon, pion, proton, kaon (use Pandora PDG tables)
1460  return ((pandora::MU_MINUS == std::abs(pdg)) || (pandora::PI_PLUS == std::abs(pdg)) ||
1461  (pandora::PROTON == std::abs(pdg)) || (pandora::K_PLUS == std::abs(pdg)));
1462  }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
T abs(T value)
bool lar_pandora::LArPandoraHelper::IsVisible ( const art::Ptr< simb::MCParticle particle)
static

Determine whether a particle is visible (i.e. long-lived charged particle)

Parameters
particlethe input mc particle
Returns
true/false

Definition at line 1478 of file LArPandoraHelper.cxx.

1479  {
1480  // Include long-lived charged particles
1481  const int pdg(particle->PdgCode());
1482 
1483  if ((pandora::E_MINUS == std::abs(pdg)) || (pandora::MU_MINUS == std::abs(pdg)) ||
1484  (pandora::PROTON == std::abs(pdg)) || (pandora::PI_PLUS == std::abs(pdg)) ||
1485  (pandora::K_PLUS == std::abs(pdg)) || (pandora::SIGMA_MINUS == std::abs(pdg)) ||
1486  (pandora::SIGMA_PLUS == std::abs(pdg)) || (pandora::HYPERON_MINUS == std::abs(pdg)) ||
1487  (pandora::PHOTON == std::abs(pdg)) || (pandora::NEUTRON == std::abs(pdg)))
1488  return true;
1489 
1490  // TODO: What about ions, neutrons, photons? (Have included neutrons and photons for now)
1491 
1492  return false;
1493  }
int PdgCode() const
Definition: MCParticle.h:212
T abs(T value)
void lar_pandora::LArPandoraHelper::SelectFinalStatePFParticles ( const PFParticleVector inputParticles,
PFParticleVector outputParticles 
)
static

Select final-state reconstructed particles from a list of all reconstructed particles.

Parameters
inputParticlesthe input vector of all particles (it has to be all of them!)
outputParticlesthe output vector of final-state particles

Definition at line 722 of file LArPandoraHelper.cxx.

724  {
725  // Build mapping from particle to particle ID for parent/daughter navigation
726  PFParticleMap particleMap;
727 
728  for (PFParticleVector::const_iterator iter = inputParticles.begin(),
729  iterEnd = inputParticles.end();
730  iter != iterEnd;
731  ++iter) {
732  const art::Ptr<recob::PFParticle> particle = *iter;
733  particleMap[particle->Self()] = particle;
734  }
735 
736  // Select final-state particles
737  for (PFParticleVector::const_iterator iter = inputParticles.begin(),
738  iterEnd = inputParticles.end();
739  iter != iterEnd;
740  ++iter) {
741  const art::Ptr<recob::PFParticle> particle = *iter;
742 
743  if (LArPandoraHelper::IsFinalState(particleMap, particle))
744  outputParticles.push_back(particle);
745  }
746  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
intermediate_table::const_iterator const_iterator
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
static bool IsFinalState(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Determine whether a particle has been reconstructed as a final-state particle.
void lar_pandora::LArPandoraHelper::SelectNeutrinoPFParticles ( const PFParticleVector inputParticles,
PFParticleVector outputParticles 
)
static

Select reconstructed neutrino particles from a list of all reconstructed particles.

Parameters
inputParticlesthe input vector of all particles (it has to be all of them!)
outputParticlesthe output vector of final-state particles

Definition at line 706 of file LArPandoraHelper.cxx.

708  {
709  for (PFParticleVector::const_iterator iter = inputParticles.begin(),
710  iterEnd = inputParticles.end();
711  iter != iterEnd;
712  ++iter) {
713  const art::Ptr<recob::PFParticle> particle = *iter;
714 
715  if (LArPandoraHelper::IsNeutrino(particle)) outputParticles.push_back(particle);
716  }
717  }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
intermediate_table::const_iterator const_iterator

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