LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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 121 of file LArPandoraHelper.h.

Member Enumeration Documentation

DaughterMode enumeration.

Enumerator
kIgnoreDaughters 
kUseDaughters 
kAddDaughters 

Definition at line 126 of file LArPandoraHelper.h.

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

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 889 of file LArPandoraHelper.cxx.

References recob::Hit::Channel(), sim::SimChannel::Channel(), recob::Hit::PeakTimeMinusRMS(), recob::Hit::PeakTimePlusRMS(), and sim::SimChannel::TrackIDEs().

Referenced by lar_pandora::PFParticleCosmicAna::analyze(), lar_pandora::PFParticleValidation::analyze(), lar_pandora::PFParticleMonitoring::analyze(), BuildMCParticleHitMaps(), and lar_pandora::LArPandora::CreatePandoraInput().

893  {
894  auto const clock_data =
896 
897  SimChannelMap simChannelMap;
898 
899  for (SimChannelVector::const_iterator iter = simChannelVector.begin(),
900  iterEnd = simChannelVector.end();
901  iter != iterEnd;
902  ++iter) {
903  const art::Ptr<sim::SimChannel> simChannel = *iter;
904  simChannelMap.insert(SimChannelMap::value_type(simChannel->Channel(), simChannel));
905  }
906 
907  for (HitVector::const_iterator iter = hitVector.begin(), iterEnd = hitVector.end();
908  iter != iterEnd;
909  ++iter) {
910  const art::Ptr<recob::Hit> hit = *iter;
911 
912  SimChannelMap::const_iterator sIter = simChannelMap.find(hit->Channel());
913  if (simChannelMap.end() == sIter) continue; // Hit has no truth information [continue]
914 
915  // ATTN: Need to convert TDCtick (integer) to TDC (unsigned integer) before passing to simChannel
916  const raw::TDCtick_t start_tick(clock_data.TPCTick2TDC(hit->PeakTimeMinusRMS()));
917  const raw::TDCtick_t end_tick(clock_data.TPCTick2TDC(hit->PeakTimePlusRMS()));
918  const unsigned int start_tdc((start_tick < 0) ? 0 : start_tick);
919  const unsigned int end_tdc(end_tick);
920 
921  if (start_tdc > end_tdc) continue; // Hit undershoots the readout window [continue]
922 
923  const art::Ptr<sim::SimChannel> simChannel = sIter->second;
924  const TrackIDEVector trackCollection(simChannel->TrackIDEs(start_tdc, end_tdc));
925 
926  if (trackCollection.empty()) continue; // Hit has no truth information [continue]
927 
928  for (unsigned int iTrack = 0, iTrackEnd = trackCollection.size(); iTrack < iTrackEnd;
929  ++iTrack) {
930  const sim::TrackIDE trackIDE = trackCollection.at(iTrack);
931  hitsToTrackIDEs[hit].push_back(trackIDE);
932  }
933  }
934  }
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:217
std::vector< sim::TrackIDE > TrackIDEVector
float PeakTimeMinusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:290
Detector simulation of raw signals on wires.
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
Definition: SimChannel.h:323
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:285
Ionization energy from a Geant4 track.
Definition: SimChannel.h:26
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:268
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 938 of file LArPandoraHelper.cxx.

References util::abs(), e, sim::TrackIDE::energyFrac, f, GetFinalStateMCParticle(), IsVisible(), kAddDaughters, kIgnoreDaughters, sim::TrackIDE::trackID, and simb::MCParticle::TrackId().

943  {
944  // Build mapping between particles and track IDs for parent/daughter navigation
945  MCParticleMap particleMap;
946 
947  for (MCTruthToMCParticles::const_iterator iter1 = truthToParticles.begin(),
948  iterEnd1 = truthToParticles.end();
949  iter1 != iterEnd1;
950  ++iter1) {
951  const MCParticleVector& particleVector = iter1->second;
952  for (MCParticleVector::const_iterator iter2 = particleVector.begin(),
953  iterEnd2 = particleVector.end();
954  iter2 != iterEnd2;
955  ++iter2) {
956  const art::Ptr<simb::MCParticle> particle = *iter2;
957  particleMap[particle->TrackId()] = particle;
958  }
959  }
960 
961  // Loop over hits and build mapping between reconstructed hits and true particles
962  for (HitsToTrackIDEs::const_iterator iter1 = hitsToTrackIDEs.begin(),
963  iterEnd1 = hitsToTrackIDEs.end();
964  iter1 != iterEnd1;
965  ++iter1) {
966  const art::Ptr<recob::Hit> hit = iter1->first;
967  const TrackIDEVector& trackCollection = iter1->second;
968 
969  int bestTrackID(-1);
970  float bestEnergyFrac(0.f);
971 
972  for (TrackIDEVector::const_iterator iter2 = trackCollection.begin(),
973  iterEnd2 = trackCollection.end();
974  iter2 != iterEnd2;
975  ++iter2) {
976  const sim::TrackIDE& trackIDE = *iter2;
977  const int trackID(std::abs(trackIDE.trackID)); // TODO: Find out why std::abs is needed
978  const float energyFrac(trackIDE.energyFrac);
979 
980  if (energyFrac > bestEnergyFrac) {
981  bestEnergyFrac = energyFrac;
982  bestTrackID = trackID;
983  }
984  }
985 
986  if (bestTrackID >= 0) {
987  MCParticleMap::const_iterator iter3 = particleMap.find(bestTrackID);
988  if (particleMap.end() == iter3)
989  throw cet::exception("LArPandora") << " PandoraCollector::BuildMCParticleHitMaps --- "
990  "Found a track ID without an MC Particle ";
991 
992  try {
993  const art::Ptr<simb::MCParticle> thisParticle = iter3->second;
994  const art::Ptr<simb::MCParticle> primaryParticle(
995  LArPandoraHelper::GetFinalStateMCParticle(particleMap, thisParticle));
996  const art::Ptr<simb::MCParticle> selectedParticle(
997  (kAddDaughters == daughterMode) ? primaryParticle : thisParticle);
998 
999  if ((kIgnoreDaughters == daughterMode) && (selectedParticle != primaryParticle)) continue;
1000 
1001  if (!(LArPandoraHelper::IsVisible(selectedParticle))) continue;
1002 
1003  particlesToHits[selectedParticle].push_back(hit);
1004  hitsToParticles[hit] = selectedParticle;
1005  }
1006  catch (cet::exception& e) {
1007  }
1008  }
1009  }
1010  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
intermediate_table::const_iterator const_iterator
int TrackId() const
Definition: MCParticle.h:211
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
TFile f
Definition: plotHisto.C:6
static bool IsVisible(const art::Ptr< simb::MCParticle > particle)
Determine whether a particle is visible (i.e. long-lived charged particle)
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:28
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:27
Float_t e
Definition: plot.C:35
Ionization energy from a Geant4 track.
Definition: SimChannel.h:26
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...
Definition: fwd.h:26
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 1014 of file LArPandoraHelper.cxx.

References BuildMCParticleHitMaps(), CollectMCParticles(), and CollectSimChannels().

1020  {
1021  SimChannelVector simChannelVector;
1022  MCTruthToMCParticles truthToParticles;
1023  MCParticlesToMCTruth particlesToTruth;
1024  HitsToTrackIDEs hitsToTrackIDEs;
1025 
1026  bool areSimChannelsValid(false);
1027  LArPandoraHelper::CollectSimChannels(evt, label, simChannelVector, areSimChannelsValid);
1028 
1029  LArPandoraHelper::CollectMCParticles(evt, label, truthToParticles, particlesToTruth);
1030  LArPandoraHelper::BuildMCParticleHitMaps(evt, hitVector, simChannelVector, hitsToTrackIDEs);
1032  hitsToTrackIDEs, truthToParticles, particlesToHits, hitsToParticles, daughterMode);
1033  }
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 1037 of file LArPandoraHelper.cxx.

References sim::TrackIDE::energy, sim::TrackIDE::energyFrac, art::FindManyP< ProdB, Data >::get(), art::ProductRetriever::getByLabel(), art::Handle< T >::isValid(), art::Ptr< T >::key(), sim::TrackIDE::trackID, and simb::MCParticle::TrackId().

1041  {
1042  // Start by getting the collection of Hits
1044  evt.getByLabel(hitLabel, theHits);
1045 
1046  if (!theHits.isValid()) {
1047  mf::LogDebug("LArPandora") << " Failed to find hits... " << std::endl;
1048  return;
1049  }
1050 
1051  HitVector hitVector;
1052 
1053  for (unsigned int i = 0; i < theHits->size(); ++i) {
1054  const art::Ptr<recob::Hit> hit(theHits, i);
1055  hitVector.push_back(hit);
1056  }
1057 
1058  // Now get the associations between Hits and MCParticles
1059  std::vector<anab::BackTrackerHitMatchingData const*> backtrackerVector;
1060 
1061  MCParticleVector particleVector;
1062 
1064  theHits, evt, backtrackLabel);
1065 
1066  if (!particles_per_hit.isValid()) {
1067  mf::LogDebug("LArPandora") << " Failed to find reco-truth matching... " << std::endl;
1068  return;
1069  }
1070 
1071  // Now loop over the hits and build a collection of IDEs
1072  for (HitVector::const_iterator iter = hitVector.begin(), iterEnd = hitVector.end();
1073  iter != iterEnd;
1074  ++iter) {
1075  const art::Ptr<recob::Hit> hit = *iter;
1076 
1077  particleVector.clear();
1078  backtrackerVector.clear();
1079  particles_per_hit.get(hit.key(), particleVector, backtrackerVector);
1080 
1081  for (unsigned int j = 0; j < particleVector.size(); ++j) {
1082  const art::Ptr<simb::MCParticle> particle = particleVector[j];
1083 
1084  sim::TrackIDE trackIDE;
1085  trackIDE.trackID = particle->TrackId();
1086  trackIDE.energy = backtrackerVector[j]->energy;
1087  trackIDE.energyFrac = backtrackerVector[j]->ideFraction;
1088 
1089  hitsToTrackIDEs[hit].push_back(trackIDE);
1090  }
1091  }
1092  }
intermediate_table::const_iterator const_iterator
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:29
int TrackId() const
Definition: MCParticle.h:211
bool isValid() const noexcept
Definition: Handle.h:203
key_type key() const noexcept
Definition: Ptr.h:166
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:28
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:27
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Ionization energy from a Geant4 track.
Definition: SimChannel.h:26
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 1096 of file LArPandoraHelper.cxx.

References BuildMCParticleHitMaps(), and CollectMCParticles().

1103  {
1104  MCTruthToMCParticles truthToParticles;
1105  MCParticlesToMCTruth particlesToTruth;
1106  HitsToTrackIDEs hitsToTrackIDEs;
1107 
1108  LArPandoraHelper::CollectMCParticles(evt, truthLabel, truthToParticles, particlesToTruth);
1109  LArPandoraHelper::BuildMCParticleHitMaps(evt, hitLabel, backtrackLabel, hitsToTrackIDEs);
1111  hitsToTrackIDEs, truthToParticles, particlesToHits, hitsToParticles, daughterMode);
1112  }
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 1151 of file LArPandoraHelper.cxx.

References simb::MCParticle::TrackId().

Referenced by lar_pandora::PFParticleMonitoring::analyze().

1153  {
1154  for (MCParticleVector::const_iterator iter = particleVector.begin(),
1155  iterEnd = particleVector.end();
1156  iter != iterEnd;
1157  ++iter) {
1158  const art::Ptr<simb::MCParticle> particle = *iter;
1159  particleMap[particle->TrackId()] = particle;
1160  particleMap[particle->TrackId()] = particle;
1161  }
1162  }
intermediate_table::const_iterator const_iterator
int TrackId() const
Definition: MCParticle.h:211
Definition: fwd.h:26
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 507 of file LArPandoraHelper.cxx.

References GetFinalStatePFParticle(), IsFinalState(), kAddDaughters, kIgnoreDaughters, and recob::PFParticle::Self().

Referenced by lar_pandora::PFParticleCosmicAna::analyze(), lar_pandora::PFParticleValidation::analyze(), lar_pandora::PFParticleAnalysis::analyze(), lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::PFParticleHitDumper::analyze(), and BuildPFParticleHitMaps().

514  {
515  // Build mapping from particle to particle ID for parent/daughter navigation
516  PFParticleMap particleMap;
517 
518  for (PFParticleVector::const_iterator iter1 = particleVector.begin(),
519  iterEnd1 = particleVector.end();
520  iter1 != iterEnd1;
521  ++iter1) {
522  const art::Ptr<recob::PFParticle> particle = *iter1;
523  particleMap[particle->Self()] = particle;
524  }
525 
526  // Loop over hits and build mapping between reconstructed final-state particles and reconstructed hits
527  for (PFParticlesToSpacePoints::const_iterator iter1 = particlesToSpacePoints.begin(),
528  iterEnd1 = particlesToSpacePoints.end();
529  iter1 != iterEnd1;
530  ++iter1) {
531  const art::Ptr<recob::PFParticle> thisParticle = iter1->first;
532  const art::Ptr<recob::PFParticle> particle(
533  (kAddDaughters == daughterMode) ?
534  LArPandoraHelper::GetFinalStatePFParticle(particleMap, thisParticle) :
535  thisParticle);
536 
537  if ((kIgnoreDaughters == daughterMode) &&
538  !LArPandoraHelper::IsFinalState(particleMap, particle))
539  continue;
540 
541  const SpacePointVector& spacePointVector = iter1->second;
542 
543  for (SpacePointVector::const_iterator iter2 = spacePointVector.begin(),
544  iterEnd2 = spacePointVector.end();
545  iter2 != iterEnd2;
546  ++iter2) {
547  const art::Ptr<recob::SpacePoint> spacepoint = *iter2;
548 
549  SpacePointsToHits::const_iterator iter3 = spacePointsToHits.find(spacepoint);
550  if (spacePointsToHits.end() == iter3)
551  throw cet::exception("LArPandora") << " PandoraCollector::BuildPFParticleHitMaps --- "
552  "Found a space point without an associated hit ";
553 
554  const art::Ptr<recob::Hit> hit = iter3->second;
555 
556  particlesToHits[particle].push_back(hit);
557  hitsToParticles[hit] = particle;
558  }
559  }
560  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:88
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 564 of file LArPandoraHelper.cxx.

References GetFinalStatePFParticle(), IsFinalState(), kAddDaughters, kIgnoreDaughters, and recob::PFParticle::Self().

570  {
571  // Build mapping from particle to particle ID for parent/daughter navigation
572  PFParticleMap particleMap;
573 
574  for (PFParticleVector::const_iterator iter1 = particleVector.begin(),
575  iterEnd1 = particleVector.end();
576  iter1 != iterEnd1;
577  ++iter1) {
578  const art::Ptr<recob::PFParticle> particle = *iter1;
579  particleMap[particle->Self()] = particle;
580  }
581 
582  // Loop over hits and build mapping between reconstructed final-state particles and reconstructed hits
583  for (PFParticlesToClusters::const_iterator iter1 = particlesToClusters.begin(),
584  iterEnd1 = particlesToClusters.end();
585  iter1 != iterEnd1;
586  ++iter1) {
587  const art::Ptr<recob::PFParticle> thisParticle = iter1->first;
588  const art::Ptr<recob::PFParticle> particle(
589  (kAddDaughters == daughterMode) ?
590  LArPandoraHelper::GetFinalStatePFParticle(particleMap, thisParticle) :
591  thisParticle);
592 
593  if ((kIgnoreDaughters == daughterMode) &&
594  !LArPandoraHelper::IsFinalState(particleMap, particle))
595  continue;
596 
597  const ClusterVector& clusterVector = iter1->second;
598  for (ClusterVector::const_iterator iter2 = clusterVector.begin(),
599  iterEnd2 = clusterVector.end();
600  iter2 != iterEnd2;
601  ++iter2) {
602  const art::Ptr<recob::Cluster> cluster = *iter2;
603 
604  ClustersToHits::const_iterator iter3 = clustersToHits.find(cluster);
605  if (clustersToHits.end() == iter3)
606  throw cet::exception("LArPandora") << " PandoraCollector::BuildPFParticleHitMaps --- "
607  "Found a space point without an associated hit ";
608 
609  const HitVector& hitVector = iter3->second;
610  for (HitVector::const_iterator iter4 = hitVector.begin(), iterEnd4 = hitVector.end();
611  iter4 != iterEnd4;
612  ++iter4) {
613  const art::Ptr<recob::Hit> hit = *iter4;
614 
615  particlesToHits[particle].push_back(hit);
616  hitsToParticles[hit] = particle;
617  }
618  }
619  }
620  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:88
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 637 of file LArPandoraHelper.cxx.

References BuildPFParticleHitMaps(), CollectClusters(), CollectPFParticles(), and CollectSpacePoints().

644  {
645  // Use intermediate clusters
646  if (useClusters) {
647  PFParticleVector particleVector;
648  PFParticlesToClusters particlesToClusters;
649 
650  ClusterVector clusterVector;
651  ClustersToHits clustersToHits;
652 
653  LArPandoraHelper::CollectPFParticles(evt, label_pfpart, particleVector, particlesToClusters);
654  LArPandoraHelper::CollectClusters(evt, label_middle, clusterVector, clustersToHits);
655 
657  particlesToClusters,
658  clustersToHits,
659  particlesToHits,
660  hitsToParticles,
661  daughterMode);
662  }
663 
664  // Use intermediate space points
665  else {
666  PFParticleVector particleVector;
667  PFParticlesToSpacePoints particlesToSpacePoints;
668 
669  SpacePointVector spacePointVector;
670  SpacePointsToHits spacePointsToHits;
671 
673  evt, label_pfpart, particleVector, particlesToSpacePoints);
674  LArPandoraHelper::CollectSpacePoints(evt, label_middle, spacePointVector, spacePointsToHits);
675 
677  particlesToSpacePoints,
678  spacePointsToHits,
679  particlesToHits,
680  hitsToParticles,
681  daughterMode);
682  }
683  }
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 624 of file LArPandoraHelper.cxx.

References BuildPFParticleHitMaps().

630  {
632  evt, label, label, particlesToHits, hitsToParticles, daughterMode, useClusters);
633  }
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 1166 of file LArPandoraHelper.cxx.

References recob::PFParticle::Self().

Referenced by lar_pandora::PFParticleAnalysis::analyze(), and lar_pandora::PFParticleMonitoring::analyze().

1168  {
1169  for (PFParticleVector::const_iterator iter = particleVector.begin(),
1170  iterEnd = particleVector.end();
1171  iter != iterEnd;
1172  ++iter) {
1173  const art::Ptr<recob::PFParticle> particle = *iter;
1174  particleMap[particle->Self()] = particle;
1175  }
1176  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:88
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 159 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), hits(), and art::Handle< T >::isValid().

Referenced by BuildPFParticleHitMaps().

163  {
165  evt.getByLabel(label, theClusters);
166 
167  if (!theClusters.isValid()) {
168  mf::LogDebug("LArPandora") << " Failed to find clusters... " << std::endl;
169  return;
170  }
171  else {
172  mf::LogDebug("LArPandora") << " Found: " << theClusters->size() << " Clusters " << std::endl;
173  }
174 
175  art::FindManyP<recob::Hit> theHitAssns(theClusters, evt, label);
176  for (unsigned int i = 0; i < theClusters->size(); ++i) {
177  const art::Ptr<recob::Cluster> cluster(theClusters, i);
178  clusterVector.push_back(cluster);
179 
180  const std::vector<art::Ptr<recob::Hit>> hits = theHitAssns.at(i);
181  for (unsigned int j = 0; j < hits.size(); ++j) {
182  const art::Ptr<recob::Hit> hit = hits.at(j);
183  clustersToHits[cluster].push_back(hit);
184  }
185  }
186  }
Cluster finding and building.
bool isValid() const noexcept
Definition: Handle.h:203
void hits()
Definition: readHits.C:15
Detector simulation of raw signals on wires.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 730 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), art::Handle< T >::isValid(), and track.

Referenced by lar_pandora::PFParticleCosmicAna::analyze().

734  {
736  evt.getByLabel(label, theCosmicTags);
737 
738  if (theCosmicTags.isValid()) {
739  art::FindOneP<recob::Track> theCosmicAssns(
740  theCosmicTags, evt, label); // We assume there is one tag per algorithm
741  for (unsigned int i = 0; i < theCosmicTags->size(); ++i) {
742  const art::Ptr<anab::CosmicTag> cosmicTag(theCosmicTags, i);
743  const art::Ptr<recob::Track> track = theCosmicAssns.at(i);
744  tracksToCosmicTags[track].push_back(
745  cosmicTag); // We assume there could be multiple algorithms
746  cosmicTagVector.push_back(cosmicTag);
747  }
748  }
749  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Float_t track
Definition: plot.C:35
Definition: fwd.h:26
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 830 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), simb::MCTruth::GetParticle(), art::Handle< T >::isValid(), and simb::MCTruth::NParticles().

Referenced by lar_pandora::LArPandora::CreatePandoraInput().

833  {
835  evt.getByLabel(label, mcTruthBlocks);
836 
837  if (!mcTruthBlocks.isValid()) {
838  mf::LogDebug("LArPandora") << " Failed to find MC truth blocks from generator... "
839  << std::endl;
840  return;
841  }
842  else {
843  mf::LogDebug("LArPandora") << " Found: " << mcTruthBlocks->size() << " MC truth blocks "
844  << std::endl;
845  }
846 
847  if (mcTruthBlocks->size() != 1)
848  throw cet::exception("LArPandora") << " PandoraCollector::CollectGeneratorMCParticles --- "
849  "Unexpected number of MC truth blocks ";
850 
851  const art::Ptr<simb::MCTruth> mcTruth(mcTruthBlocks, 0);
852 
853  for (int i = 0; i < mcTruth->NParticles(); ++i) {
854  particleVector.push_back(mcTruth->GetParticle(i));
855  }
856  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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 70 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by lar_pandora::PFParticleCosmicAna::analyze(), lar_pandora::PFParticleValidation::analyze(), lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::PFParticleHitDumper::analyze(), lar_pandora::LArPandoraHitCollectionToolDefault::CollectHits(), and lar_pandora::LArPandoraOutput::CopyAllHitsToSingleSlice().

73  {
75  evt.getByLabel(label, theHits);
76 
77  if (!theHits.isValid()) {
78  mf::LogDebug("LArPandora") << " Failed to find hits... " << std::endl;
79  return;
80  }
81  else {
82  mf::LogDebug("LArPandora") << " Found: " << theHits->size() << " Hits " << std::endl;
83  }
84 
85  for (unsigned int i = 0; i < theHits->size(); ++i) {
86  const art::Ptr<recob::Hit> hit(theHits, i);
87  hitVector.push_back(hit);
88  }
89  }
bool isValid() const noexcept
Definition: Handle.h:203
Detector simulation of raw signals on wires.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 806 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by lar_pandora::PFParticleCosmicAna::analyze(), lar_pandora::PFParticleMonitoring::analyze(), BuildMCParticleHitMaps(), lar_pandora::LArPandora::CreatePandoraInput(), lar_pandora::PFParticleValidation::GetMCTruth(), and lar_pandora::PFParticleValidation::GetSimpleMCPrimaryList().

809  {
811  evt.getByLabel(label, theParticles);
812 
813  if (!theParticles.isValid()) {
814  mf::LogDebug("LArPandora") << " Failed to find MC particles... " << std::endl;
815  return;
816  }
817  else {
818  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " MC particles "
819  << std::endl;
820  }
821 
822  for (unsigned int i = 0; i < theParticles->size(); ++i) {
823  const art::Ptr<simb::MCParticle> particle(theParticles, i);
824  particleVector.push_back(particle);
825  }
826  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:26
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 860 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

864  {
866  evt.getByLabel(label, theParticles);
867 
868  if (!theParticles.isValid()) {
869  mf::LogDebug("LArPandora") << " Failed to find MC particles... " << std::endl;
870  return;
871  }
872  else {
873  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " MC particles "
874  << std::endl;
875  }
876 
877  art::FindOneP<simb::MCTruth> theTruthAssns(theParticles, evt, label);
878 
879  for (unsigned int i = 0, iEnd = theParticles->size(); i < iEnd; ++i) {
880  const art::Ptr<simb::MCParticle> particle(theParticles, i);
881  const art::Ptr<simb::MCTruth> truth(theTruthAssns.at(i));
882  truthToParticles[truth].push_back(particle);
883  particlesToTruth[particle] = truth;
884  }
885  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:26
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 254 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

258  {
260  evt.getByLabel(label, theParticles);
261 
262  if (!theParticles.isValid()) {
263  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
264  return;
265  }
266  else {
267  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles "
268  << std::endl;
269  }
270 
271  art::FindManyP<larpandoraobj::PFParticleMetadata> theMetadataAssns(theParticles, evt, label);
272  for (unsigned int i = 0; i < theParticles->size(); ++i) {
273  const art::Ptr<recob::PFParticle> particle(theParticles, i);
274  particleVector.push_back(particle);
275 
276  const std::vector<art::Ptr<larpandoraobj::PFParticleMetadata>> pfParticleMetadataList =
277  theMetadataAssns.at(i);
278  for (unsigned int j = 0; j < pfParticleMetadataList.size(); ++j) {
279  const art::Ptr<larpandoraobj::PFParticleMetadata> pfParticleMetadata =
280  pfParticleMetadataList.at(j);
281  particlesToMetadata[particle].push_back(pfParticleMetadata);
282  }
283  }
284  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 93 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by lar_pandora::PFParticleCosmicAna::analyze(), lar_pandora::PFParticleAnalysis::analyze(), lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::PFParticleHitDumper::analyze(), BuildPFParticleHitMaps(), CollectPFParticles(), lar_pandora::PFParticleValidation::GetRecoNeutrinos(), lar_pandora::LArPandoraTrackCreation::produce(), and lar_pandora::LArPandoraShowerCreation::produce().

96  {
98  evt.getByLabel(label, theParticles);
99 
100  if (!theParticles.isValid()) {
101  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
102  return;
103  }
104  else {
105  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles "
106  << std::endl;
107  }
108 
109  for (unsigned int i = 0; i < theParticles->size(); ++i) {
110  const art::Ptr<recob::PFParticle> particle(theParticles, i);
111  particleVector.push_back(particle);
112  }
113  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 190 of file LArPandoraHelper.cxx.

References CollectPFParticles(), tca::evt, art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

194  {
196  evt.getByLabel(label, theParticles);
197 
198  if (!theParticles.isValid()) {
199  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
200  return;
201  }
202  else {
203  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles "
204  << std::endl;
205  }
206 
207  art::FindManyP<recob::SpacePoint> theSpacePointAssns(theParticles, evt, label);
208  for (unsigned int i = 0; i < theParticles->size(); ++i) {
209  const art::Ptr<recob::PFParticle> particle(theParticles, i);
210  particleVector.push_back(particle);
211 
212  const std::vector<art::Ptr<recob::SpacePoint>> spacepoints = theSpacePointAssns.at(i);
213  for (unsigned int j = 0; j < spacepoints.size(); ++j) {
214  const art::Ptr<recob::SpacePoint> spacepoint = spacepoints.at(j);
215  particlesToSpacePoints[particle].push_back(spacepoint);
216  }
217  }
218  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 412 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), art::Handle< T >::isValid(), and seed.

416  {
418  evt.getByLabel(label, theSeeds);
419 
420  if (!theSeeds.isValid()) {
421  mf::LogDebug("LArPandora") << " Failed to find seeds... " << std::endl;
422  return;
423  }
424  else {
425  mf::LogDebug("LArPandora") << " Found: " << theSeeds->size() << " Seeds " << std::endl;
426  }
427 
428  art::FindManyP<recob::PFParticle> theSeedAssns(theSeeds, evt, label);
429  for (unsigned int i = 0; i < theSeeds->size(); ++i) {
430  const art::Ptr<recob::Seed> seed(theSeeds, i);
431  seedVector.push_back(seed);
432 
433  const std::vector<art::Ptr<recob::PFParticle>> particles = theSeedAssns.at(i);
434  for (unsigned int j = 0; j < particles.size(); ++j) {
435  const art::Ptr<recob::PFParticle> particle = particles.at(j);
436  particlesToSeeds[particle].push_back(seed);
437  }
438  }
439  }
bool isValid() const noexcept
Definition: Handle.h:203
long seed
Definition: chem4.cc:67
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:26
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 288 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by lar_pandora::PFParticleAnalysis::analyze(), lar_pandora::PFParticleHitDumper::analyze(), and CollectTracks().

292  {
294  evt.getByLabel(label, theShowers);
295 
296  if (!theShowers.isValid()) {
297  mf::LogDebug("LArPandora") << " Failed to find showers... " << std::endl;
298  return;
299  }
300  else {
301  mf::LogDebug("LArPandora") << " Found: " << theShowers->size() << " Showers " << std::endl;
302  }
303 
304  art::FindManyP<recob::PFParticle> theShowerAssns(theShowers, evt, label);
305  for (unsigned int i = 0; i < theShowers->size(); ++i) {
306  const art::Ptr<recob::Shower> shower(theShowers, i);
307  showerVector.push_back(shower);
308 
309  const std::vector<art::Ptr<recob::PFParticle>> particles = theShowerAssns.at(i);
310  for (unsigned int j = 0; j < particles.size(); ++j) {
311  const art::Ptr<recob::PFParticle> particle = particles.at(j);
312  particlesToShowers[particle].push_back(shower);
313  }
314  }
315  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 779 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by BuildMCParticleHitMaps(), and lar_pandora::LArPandora::CreatePandoraInput().

783  {
785  evt.getByLabel(label, theSimChannels);
786 
787  if (!theSimChannels.isValid()) {
788  mf::LogDebug("LArPandora") << " Failed to find sim channels... " << std::endl;
789  areSimChannelsValid = false;
790  return;
791  }
792  else {
793  mf::LogDebug("LArPandora") << " Found: " << theSimChannels->size() << " SimChannels "
794  << std::endl;
795  areSimChannelsValid = true;
796  }
797 
798  for (unsigned int i = 0; i < theSimChannels->size(); ++i) {
799  const art::Ptr<sim::SimChannel> channel(theSimChannels, i);
800  simChannelVector.push_back(channel);
801  }
802  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 117 of file LArPandoraHelper.cxx.

Referenced by lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::PFParticleHitDumper::analyze(), and BuildPFParticleHitMaps().

121  {
122  HitsToSpacePoints hitsToSpacePoints;
124  evt, label, spacePointVector, spacePointsToHits, hitsToSpacePoints);
125  }
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 129 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

134  {
136  evt.getByLabel(label, theSpacePoints);
137 
138  if (!theSpacePoints.isValid()) {
139  mf::LogDebug("LArPandora") << " Failed to find spacepoints... " << std::endl;
140  return;
141  }
142  else {
143  mf::LogDebug("LArPandora") << " Found: " << theSpacePoints->size() << " SpacePoints "
144  << std::endl;
145  }
146 
147  art::FindOneP<recob::Hit> theHitAssns(theSpacePoints, evt, label);
148  for (unsigned int i = 0; i < theSpacePoints->size(); ++i) {
149  const art::Ptr<recob::SpacePoint> spacepoint(theSpacePoints, i);
150  spacePointVector.push_back(spacepoint);
151  const art::Ptr<recob::Hit> hit = theHitAssns.at(i);
152  spacePointsToHits[spacepoint] = hit;
153  hitsToSpacePoints[hit] = spacepoint;
154  }
155  }
bool isValid() const noexcept
Definition: Handle.h:203
Detector simulation of raw signals on wires.
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 753 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by lar_pandora::PFParticleAnalysis::analyze(), and lar_pandora::PFParticleMonitoring::analyze().

757  {
759  evt.getByLabel(label, theT0s);
760 
761  if (theT0s.isValid()) {
762  art::FindManyP<recob::PFParticle> theAssns(theT0s, evt, label);
763  for (unsigned int i = 0; i < theT0s->size(); ++i) {
764  const art::Ptr<anab::T0> theT0(theT0s, i);
765  t0Vector.push_back(theT0);
766 
767  const std::vector<art::Ptr<recob::PFParticle>> particles = theAssns.at(i);
768  for (unsigned int j = 0; j < particles.size(); ++j) {
769  const art::Ptr<recob::PFParticle> theParticle = particles.at(j);
770  particlesToT0s[theParticle].push_back(
771  theT0); // We assume there could be multiple T0s per PFParticle
772  }
773  }
774  }
775  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: fwd.h:26
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 319 of file LArPandoraHelper.cxx.

References CollectShowers(), art::ProductRetriever::getByLabel(), hits(), art::Handle< T >::isValid(), and track.

Referenced by lar_pandora::PFParticleTrackAna::analyze(), lar_pandora::PFParticleCosmicAna::analyze(), lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::PFParticleAnalysis::analyze(), and lar_pandora::PFParticleHitDumper::analyze().

323  {
325  evt.getByLabel(label, theTracks);
326 
327  if (!theTracks.isValid()) {
328  mf::LogDebug("LArPandora") << " Failed to find tracks... " << std::endl;
329  return;
330  }
331  else {
332  mf::LogDebug("LArPandora") << " Found: " << theTracks->size() << " Tracks " << std::endl;
333  }
334 
335  art::FindManyP<recob::PFParticle> theTrackAssns(theTracks, evt, label);
336  for (unsigned int i = 0; i < theTracks->size(); ++i) {
337  const art::Ptr<recob::Track> track(theTracks, i);
338  trackVector.push_back(track);
339 
340  const std::vector<art::Ptr<recob::PFParticle>> particles = theTrackAssns.at(i);
341  for (unsigned int j = 0; j < particles.size(); ++j) {
342  const art::Ptr<recob::PFParticle> particle = particles.at(j);
343  particlesToTracks[particle].push_back(track);
344  }
345  }
346  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Float_t track
Definition: plot.C:35
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 476 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by lar_pandora::PFParticleAnalysis::analyze(), lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::LArPandoraShowerCreation::produce(), and lar_pandora::LArPandoraTrackCreation::produce().

480  {
482  evt.getByLabel(label, theVertices);
483 
484  if (!theVertices.isValid()) {
485  mf::LogDebug("LArPandora") << " Failed to find vertices... " << std::endl;
486  return;
487  }
488  else {
489  mf::LogDebug("LArPandora") << " Found: " << theVertices->size() << " Vertices " << std::endl;
490  }
491 
492  art::FindManyP<recob::PFParticle> theVerticesAssns(theVertices, evt, label);
493  for (unsigned int i = 0; i < theVertices->size(); ++i) {
494  const art::Ptr<recob::Vertex> vertex(theVertices, i);
495  vertexVector.push_back(vertex);
496 
497  const std::vector<art::Ptr<recob::PFParticle>> particles = theVerticesAssns.at(i);
498  for (unsigned int j = 0; j < particles.size(); ++j) {
499  const art::Ptr<recob::PFParticle> particle = particles.at(j);
500  particlesToVertices[particle].push_back(vertex);
501  }
502  }
503  }
bool isValid() const noexcept
Definition: Handle.h:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:26
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.

References art::ProductRetriever::getByLabel(), and art::Handle< T >::isValid().

Referenced by lar_pandora::PFParticleHitDumper::analyze().

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:203
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:26
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 1117 of file LArPandoraHelper.cxx.

References art::ProductRetriever::getByLabel(), hits(), and art::Ptr< T >::key().

Referenced by GetPFParticleMetadata(), lar_pandora::LArPandoraShowerCreation::produce(), and lar_pandora::LArPandoraTrackCreation::produce().

1122  {
1123 
1125  evt.getByLabel(label, handle);
1126  art::FindManyP<recob::Hit> hitAssoc(handle, evt, label);
1127 
1128  if (indexVector != nullptr) {
1129  if (inputVector.size() != indexVector->size())
1130  throw cet::exception("LArPandora") << " PandoraHelper::GetAssociatedHits --- trying to use "
1131  "an index vector not matching input vector";
1132 
1133  // If indexVector is filled, sort hits according to trajectory points order
1134  for (int index : (*indexVector)) {
1135  const art::Ptr<T>& element = inputVector.at(index);
1136  const HitVector& hits = hitAssoc.at(element.key());
1137  associatedHits.insert(associatedHits.end(), hits.begin(), hits.end());
1138  }
1139  }
1140  else {
1141  // If indexVector is empty just loop through inputSpacePoints
1142  for (const art::Ptr<T>& element : inputVector) {
1143  const HitVector& hits = hitAssoc.at(element.key());
1144  associatedHits.insert(associatedHits.end(), hits.begin(), hits.end());
1145  }
1146  }
1147  }
void hits()
Definition: readHits.C:15
key_type key() const noexcept
Definition: Ptr.h:166
std::vector< art::Ptr< recob::Hit > > HitVector
bool getByLabel(std::string const &label, std::string const &instance, Handle< PROD > &result) const
Definition: fwd.h:26
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 1279 of file LArPandoraHelper.cxx.

References IsVisible(), simb::MCParticle::Mother(), and simb::MCParticle::TrackId().

Referenced by lar_pandora::PFParticleMonitoring::analyze(), and BuildMCParticleHitMaps().

1282  {
1283  // Navigate upward through MC daughter/parent links - collect this particle and all its parents
1284  MCParticleVector mcVector;
1285 
1286  int trackID(inputParticle->TrackId());
1287 
1288  while (1) {
1289  MCParticleMap::const_iterator pIter = particleMap.find(trackID);
1290  if (particleMap.end() == pIter) break; // Can't find MC Particle for this track ID [break]
1291 
1292  const art::Ptr<simb::MCParticle> particle = pIter->second;
1293  mcVector.push_back(particle);
1294 
1295  trackID = particle->Mother();
1296  }
1297 
1298  // Navigate downward through MC parent/daughter links - return the first long-lived charged particle
1299  for (MCParticleVector::const_reverse_iterator iter = mcVector.rbegin(),
1300  iterEnd = mcVector.rend();
1301  iter != iterEnd;
1302  ++iter) {
1303  const art::Ptr<simb::MCParticle> nextParticle = *iter;
1304 
1305  if (LArPandoraHelper::IsVisible(nextParticle)) return nextParticle;
1306  }
1307 
1308  throw cet::exception("LArPandora"); // need to catch this exception
1309  }
int Mother() const
Definition: MCParticle.h:214
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
Definition: fwd.h:26
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 1212 of file LArPandoraHelper.cxx.

References IsNeutrino(), recob::PFParticle::IsPrimary(), recob::PFParticle::Parent(), and recob::PFParticle::Self().

Referenced by lar_pandora::PFParticleMonitoring::analyze(), and BuildPFParticleHitMaps().

1215  {
1216  // Navigate upward through PFO daughter/parent links - return the top-level non-neutrino PF Particle
1217  int primaryTrackID(inputParticle->Self());
1218 
1219  if (!inputParticle->IsPrimary()) {
1220  int parentTrackID(inputParticle->Parent());
1221 
1222  while (1) {
1223  PFParticleMap::const_iterator pIter1 = particleMap.find(parentTrackID);
1224  if (particleMap.end() == pIter1)
1225  throw cet::exception("LArPandora") << " PandoraCollector::GetFinalStatePFParticle --- "
1226  "Found a PFParticle without a particle ID ";
1227 
1228  const art::Ptr<recob::PFParticle> parentParticle = pIter1->second;
1229  if (LArPandoraHelper::IsNeutrino(parentParticle)) break;
1230 
1231  primaryTrackID = parentTrackID;
1232 
1233  if (parentParticle->IsPrimary()) break;
1234 
1235  parentTrackID = parentParticle->Parent();
1236  }
1237  }
1238 
1239  PFParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1240  if (particleMap.end() == pIter2)
1241  throw cet::exception("LArPandora") << " PandoraCollector::GetFinalStatePFParticle --- Found "
1242  "a PFParticle without a particle ID ";
1243 
1244  const art::Ptr<recob::PFParticle> outputParticle = pIter2->second;
1245  return outputParticle;
1246  }
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:92
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:82
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 1333 of file LArPandoraHelper.cxx.

References recob::PFParticle::IsPrimary(), recob::PFParticle::Parent(), and recob::PFParticle::Self().

Referenced by lar_pandora::PFParticleAnalysis::analyze().

1335  {
1336  // Navigate upward through PFO daughter/parent links - return the top-level PF Particle
1337  int nGenerations(0);
1338  int primaryTrackID(inputParticle->Self());
1339 
1340  while (1) {
1341  PFParticleMap::const_iterator pIter = particleMap.find(primaryTrackID);
1342  if (particleMap.end() == pIter)
1343  throw cet::exception("LArPandora")
1344  << " PandoraCollector::GetGeneration --- Found a PFParticle without a particle ID ";
1345 
1346  ++nGenerations;
1347 
1348  const art::Ptr<recob::PFParticle> primaryParticle = pIter->second;
1349  if (primaryParticle->IsPrimary()) break;
1350 
1351  primaryTrackID = primaryParticle->Parent();
1352  }
1353 
1354  return nGenerations;
1355  }
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:92
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:82
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 1250 of file LArPandoraHelper.cxx.

References simb::MCParticle::Mother(), and simb::MCParticle::TrackId().

Referenced by lar_pandora::PFParticleMonitoring::analyze().

1253  {
1254  // Navigate upward through MC daughter/parent links - return the top-level MC particle
1255  int primaryTrackID(inputParticle->TrackId());
1256  int parentTrackID(inputParticle->Mother());
1257 
1258  while (1) {
1259  MCParticleMap::const_iterator pIter1 = particleMap.find(parentTrackID);
1260  if (particleMap.end() == pIter1) break; // Can't find MC Particle for this track ID [break]
1261 
1262  const art::Ptr<simb::MCParticle> particle = pIter1->second;
1263 
1264  primaryTrackID = parentTrackID;
1265  parentTrackID = particle->Mother();
1266  }
1267 
1268  MCParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1269  if (particleMap.end() == pIter2)
1270  throw cet::exception("LArPandora")
1271  << " PandoraCollector::GetParentMCParticle --- Found a track ID without a MC particle ";
1272 
1273  const art::Ptr<simb::MCParticle> outputParticle = pIter2->second;
1274  return outputParticle;
1275  }
int Mother() const
Definition: MCParticle.h:214
intermediate_table::const_iterator const_iterator
Definition: fwd.h:26
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 1359 of file LArPandoraHelper.cxx.

References GetParentPFParticle(), IsNeutrino(), recob::PFParticle::IsPrimary(), recob::PFParticle::Parent(), and recob::PFParticle::PdgCode().

Referenced by lar_pandora::PFParticleAnalysis::analyze(), and lar_pandora::PFParticleMonitoring::analyze().

1361  {
1362  art::Ptr<recob::PFParticle> parentParticle =
1363  LArPandoraHelper::GetParentPFParticle(particleMap, daughterParticle);
1364 
1365  if (LArPandoraHelper::IsNeutrino(parentParticle)) return parentParticle->PdgCode();
1366 
1367  if (parentParticle->IsPrimary()) return 0;
1368 
1369  const int parentID(parentParticle->Parent());
1370 
1371  PFParticleMap::const_iterator pIter = particleMap.find(parentID);
1372  if (particleMap.end() == pIter)
1373  throw cet::exception("LArPandora")
1374  << " PandoraCollector::GetParentNeutrino --- Found a PFParticle without a particle ID ";
1375 
1376  const art::Ptr<recob::PFParticle> neutrinoParticle = pIter->second;
1377  return neutrinoParticle->PdgCode();
1378  }
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:79
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:92
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:82
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 1180 of file LArPandoraHelper.cxx.

References recob::PFParticle::IsPrimary(), recob::PFParticle::Parent(), and recob::PFParticle::Self().

Referenced by lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::PFParticleMonitoring::BuildRecoNeutrinoHitMaps(), lar_pandora::LArPandoraExternalEventBuilding::CollectClearCosmicRays(), lar_pandora::LArPandoraExternalEventBuilding::CollectSlices(), and GetParentNeutrino().

1183  {
1184  // Navigate upward through PFO daughter/parent links - return the top-level PF Particle
1185  int primaryTrackID(inputParticle->Self());
1186 
1187  if (!inputParticle->IsPrimary()) {
1188  while (1) {
1189  PFParticleMap::const_iterator pIter1 = particleMap.find(primaryTrackID);
1190  if (particleMap.end() == pIter1)
1191  throw cet::exception("LArPandora") << " PandoraCollector::GetParentPFParticle --- Found "
1192  "a PFParticle without a particle ID ";
1193 
1194  const art::Ptr<recob::PFParticle> primaryParticle = pIter1->second;
1195  if (primaryParticle->IsPrimary()) break;
1196 
1197  primaryTrackID = primaryParticle->Parent();
1198  }
1199  }
1200 
1201  PFParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1202  if (particleMap.end() == pIter2)
1203  throw cet::exception("LArPandora")
1204  << " PandoraCollector::GetParentPFParticle --- Found a PFParticle without a particle ID ";
1205 
1206  const art::Ptr<recob::PFParticle> outputParticle = pIter2->second;
1207  return outputParticle;
1208  }
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:92
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:82
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 1456 of file LArPandoraHelper.cxx.

References GetAssociatedHits(), and lar::dump::vector().

Referenced by lar_pandora::LArPandoraOutput::BuildParticleMetadata().

1458  {
1459  return larpandoraobj::PFParticleMetadata(pPfo->GetPropertiesMap());
1460  }
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 1313 of file LArPandoraHelper.cxx.

1316  {
1317  PFParticlesToTracks::const_iterator tIter = particlesToTracks.find(particle);
1318 
1319  if (particlesToTracks.end() == tIter || tIter->second.empty())
1320  throw cet::exception("LArPandora")
1321  << " PandoraCollector::GetPrimaryTrack --- Failed to find associated track ";
1322 
1323  if (tIter->second.size() != 1)
1324  throw cet::exception("LArPandora")
1325  << " PandoraCollector::GetPrimaryTrack --- Found more than one associated track ";
1326 
1327  const art::Ptr<recob::Track> primaryTrack = *(tIter->second.begin());
1328  return primaryTrack;
1329  }
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 1382 of file LArPandoraHelper.cxx.

References IsNeutrino(), recob::PFParticle::IsPrimary(), and recob::PFParticle::Parent().

Referenced by lar_pandora::PFParticleAnalysis::analyze(), lar_pandora::PFParticleMonitoring::analyze(), BuildPFParticleHitMaps(), and SelectFinalStatePFParticles().

1384  {
1385  if (LArPandoraHelper::IsNeutrino(daughterParticle)) return false;
1386 
1387  if (daughterParticle->IsPrimary()) return true;
1388 
1389  const int parentID(daughterParticle->Parent());
1390 
1391  PFParticleMap::const_iterator pIter = particleMap.find(parentID);
1392  if (particleMap.end() == pIter)
1393  throw cet::exception("LArPandora")
1394  << " PandoraCollector::IsFinalState --- Found a PFParticle without a particle ID ";
1395 
1396  const art::Ptr<recob::PFParticle> parentParticle = pIter->second;
1397 
1398  if (LArPandoraHelper::IsNeutrino(parentParticle)) return true;
1399 
1400  return false;
1401  }
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:92
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:82
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 1405 of file LArPandoraHelper.cxx.

References util::abs(), and recob::PFParticle::PdgCode().

Referenced by lar_pandora::PFParticleMonitoring::analyze(), lar_pandora::PFParticleMonitoring::BuildRecoNeutrinoHitMaps(), lar_pandora::PFParticleHitDumper::FillReco3D(), GetFinalStatePFParticle(), lar_pandora::PFParticleValidation::GetMCPrimaryMatchingMap(), GetParentNeutrino(), IsFinalState(), and SelectNeutrinoPFParticles().

1406  {
1407  const int pdg(particle->PdgCode());
1408 
1409  // electron, muon, tau (use Pandora PDG tables)
1410  return ((pandora::NU_E == std::abs(pdg)) || (pandora::NU_MU == std::abs(pdg)) ||
1411  (pandora::NU_TAU == std::abs(pdg)));
1412  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:79
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 1427 of file LArPandoraHelper.cxx.

References util::abs(), and recob::PFParticle::PdgCode().

Referenced by lar_pandora::LArPandoraShowerCreation::produce().

1428  {
1429  const int pdg(particle->PdgCode());
1430 
1431  // electron, photon (use Pandora PDG tables)
1432  return ((pandora::E_MINUS == std::abs(pdg)) || (pandora::PHOTON == std::abs(pdg)));
1433  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:79
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 1416 of file LArPandoraHelper.cxx.

References util::abs(), and recob::PFParticle::PdgCode().

Referenced by lar_pandora::PFParticleCosmicAna::FillRecoTree(), and lar_pandora::LArPandoraTrackCreation::produce().

1417  {
1418  const int pdg(particle->PdgCode());
1419 
1420  // muon, pion, proton, kaon (use Pandora PDG tables)
1421  return ((pandora::MU_MINUS == std::abs(pdg)) || (pandora::PI_PLUS == std::abs(pdg)) ||
1422  (pandora::PROTON == std::abs(pdg)) || (pandora::K_PLUS == std::abs(pdg)));
1423  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:79
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 1437 of file LArPandoraHelper.cxx.

References util::abs(), and simb::MCParticle::PdgCode().

Referenced by BuildMCParticleHitMaps(), and GetFinalStateMCParticle().

1438  {
1439  // Include long-lived charged particles
1440  const int pdg(particle->PdgCode());
1441 
1442  if ((pandora::E_MINUS == std::abs(pdg)) || (pandora::MU_MINUS == std::abs(pdg)) ||
1443  (pandora::PROTON == std::abs(pdg)) || (pandora::PI_PLUS == std::abs(pdg)) ||
1444  (pandora::K_PLUS == std::abs(pdg)) || (pandora::SIGMA_MINUS == std::abs(pdg)) ||
1445  (pandora::SIGMA_PLUS == std::abs(pdg)) || (pandora::HYPERON_MINUS == std::abs(pdg)) ||
1446  (pandora::PHOTON == std::abs(pdg)) || (pandora::NEUTRON == std::abs(pdg)))
1447  return true;
1448 
1449  // TODO: What about ions, neutrons, photons? (Have included neutrons and photons for now)
1450 
1451  return false;
1452  }
int PdgCode() const
Definition: MCParticle.h:213
constexpr auto abs(T v)
Returns the absolute value of the argument.
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 702 of file LArPandoraHelper.cxx.

References IsFinalState(), and recob::PFParticle::Self().

704  {
705  // Build mapping from particle to particle ID for parent/daughter navigation
706  PFParticleMap particleMap;
707 
708  for (PFParticleVector::const_iterator iter = inputParticles.begin(),
709  iterEnd = inputParticles.end();
710  iter != iterEnd;
711  ++iter) {
712  const art::Ptr<recob::PFParticle> particle = *iter;
713  particleMap[particle->Self()] = particle;
714  }
715 
716  // Select final-state particles
717  for (PFParticleVector::const_iterator iter = inputParticles.begin(),
718  iterEnd = inputParticles.end();
719  iter != iterEnd;
720  ++iter) {
721  const art::Ptr<recob::PFParticle> particle = *iter;
722 
723  if (LArPandoraHelper::IsFinalState(particleMap, particle))
724  outputParticles.push_back(particle);
725  }
726  }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:88
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 687 of file LArPandoraHelper.cxx.

References IsNeutrino().

Referenced by lar_pandora::PFParticleMonitoring::analyze(), and lar_pandora::PFParticleValidation::GetRecoNeutrinos().

689  {
690  for (PFParticleVector::const_iterator iter = inputParticles.begin(),
691  iterEnd = inputParticles.end();
692  iter != iterEnd;
693  ++iter) {
694  const art::Ptr<recob::PFParticle> particle = *iter;
695 
696  if (LArPandoraHelper::IsNeutrino(particle)) outputParticles.push_back(particle);
697  }
698  }
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: