LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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)
 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 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)
 

Detailed Description

LArPandoraHelper class.

Definition at line 93 of file LArPandoraHelper.h.

Member Enumeration Documentation

DaughterMode enumeration.

Enumerator
kIgnoreDaughters 
kUseDaughters 
kAddDaughters 

Definition at line 99 of file LArPandoraHelper.h.

100  {
101  kIgnoreDaughters = 0, // Only use parent particles
102  kUseDaughters = 1, // Use both parent and daughter partcles
103  kAddDaughters = 2 // Absorb daughter particles into parent particles
104  };

Member Function Documentation

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

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

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

Definition at line 857 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::PFParticleValidation::analyze(), lar_pandora::PFParticleCosmicAna::analyze(), lar_pandora::PFParticleMonitoring::analyze(), BuildMCParticleHitMaps(), and lar_pandora::LArPandora::CreatePandoraInput().

859 {
860  auto const* ts = lar::providerFrom<detinfo::DetectorClocksService>();
861 
862  SimChannelMap simChannelMap;
863 
864  for (SimChannelVector::const_iterator iter = simChannelVector.begin(), iterEnd = simChannelVector.end(); iter != iterEnd; ++iter)
865  {
866  const art::Ptr<sim::SimChannel> simChannel = *iter;
867  simChannelMap.insert(SimChannelMap::value_type(simChannel->Channel(), simChannel));
868  }
869 
870  for (HitVector::const_iterator iter = hitVector.begin(), iterEnd = hitVector.end(); iter != iterEnd; ++iter)
871  {
872  const art::Ptr<recob::Hit> hit = *iter;
873 
874  SimChannelMap::const_iterator sIter = simChannelMap.find(hit->Channel());
875  if (simChannelMap.end() == sIter)
876  continue; // Hit has no truth information [continue]
877 
878  // ATTN: Need to convert TDCtick (integer) to TDC (unsigned integer) before passing to simChannel
879  const raw::TDCtick_t start_tick(ts->TPCTick2TDC(hit->PeakTimeMinusRMS()));
880  const raw::TDCtick_t end_tick(ts->TPCTick2TDC(hit->PeakTimePlusRMS()));
881  const unsigned int start_tdc((start_tick < 0) ? 0 : start_tick);
882  const unsigned int end_tdc(end_tick);
883 
884  if (start_tdc > end_tdc)
885  continue; // Hit undershoots the readout window [continue]
886 
887  const art::Ptr<sim::SimChannel> simChannel = sIter->second;
888  const TrackIDEVector trackCollection(simChannel->TrackIDEs(start_tdc, end_tdc));
889 
890  if (trackCollection.empty())
891  continue; // Hit has no truth information [continue]
892 
893  for (unsigned int iTrack = 0, iTrackEnd = trackCollection.size(); iTrack < iTrackEnd; ++iTrack)
894  {
895  const sim::TrackIDE trackIDE = trackCollection.at(iTrack);
896  hitsToTrackIDEs[hit].push_back(trackIDE);
897  }
898  }
899 }
std::vector< sim::TrackIDE > TrackIDEVector
std::map< int, art::Ptr< sim::SimChannel > > SimChannelMap
int TDCtick_t
Type representing a TDC tick.
Definition: RawTypes.h:24
intermediate_table::const_iterator const_iterator
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:244
float PeakTimeMinusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:240
Detector simulation of raw signals on wires.
raw::ChannelID_t Channel() const
Returns the readout channel this object describes.
Definition: SimChannel.h:332
float PeakTimePlusRMS(float sigmas=+1.) const
Returns a time sigmas RMS away from the peak time.
Definition: Hit.h:237
Ionization energy from a Geant4 track.
Definition: SimChannel.h:28
raw::ChannelID_t Channel() const
ID of the readout channel the hit was extracted from.
Definition: Hit.h:231
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 903 of file LArPandoraHelper.cxx.

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

905 {
906  // Build mapping between particles and track IDs for parent/daughter navigation
907  MCParticleMap particleMap;
908 
909  for (MCTruthToMCParticles::const_iterator iter1 = truthToParticles.begin(), iterEnd1 = truthToParticles.end(); iter1 != iterEnd1; ++iter1)
910  {
911  const MCParticleVector &particleVector = iter1->second;
912  for (MCParticleVector::const_iterator iter2 = particleVector.begin(), iterEnd2 = particleVector.end(); iter2 != iterEnd2; ++iter2)
913  {
914  const art::Ptr<simb::MCParticle> particle = *iter2;
915  particleMap[particle->TrackId()] = particle;
916  }
917  }
918 
919  // Loop over hits and build mapping between reconstructed hits and true particles
920  for (HitsToTrackIDEs::const_iterator iter1 = hitsToTrackIDEs.begin(), iterEnd1 = hitsToTrackIDEs.end(); iter1 != iterEnd1; ++iter1)
921  {
922  const art::Ptr<recob::Hit> hit = iter1->first;
923  const TrackIDEVector &trackCollection = iter1->second;
924 
925  int bestTrackID(-1);
926  float bestEnergyFrac(0.f);
927 
928  for (TrackIDEVector::const_iterator iter2 = trackCollection.begin(), iterEnd2 = trackCollection.end(); iter2 != iterEnd2; ++iter2)
929  {
930  const sim::TrackIDE &trackIDE = *iter2;
931  const int trackID(std::abs(trackIDE.trackID)); // TODO: Find out why std::abs is needed
932  const float energyFrac(trackIDE.energyFrac);
933 
934  if (energyFrac > bestEnergyFrac)
935  {
936  bestEnergyFrac = energyFrac;
937  bestTrackID = trackID;
938  }
939  }
940 
941  if (bestTrackID >= 0)
942  {
943  MCParticleMap::const_iterator iter3 = particleMap.find(bestTrackID);
944  if (particleMap.end() == iter3)
945  throw cet::exception("LArPandora") << " PandoraCollector::BuildMCParticleHitMaps --- Found a track ID without an MC Particle ";
946 
947  try
948  {
949  const art::Ptr<simb::MCParticle> thisParticle = iter3->second;
950  const art::Ptr<simb::MCParticle> primaryParticle(LArPandoraHelper::GetFinalStateMCParticle(particleMap, thisParticle));
951  const art::Ptr<simb::MCParticle> selectedParticle((kAddDaughters == daughterMode) ? primaryParticle : thisParticle);
952 
953  if ((kIgnoreDaughters == daughterMode) && (selectedParticle != primaryParticle))
954  continue;
955 
956  if (!(LArPandoraHelper::IsVisible(selectedParticle)))
957  continue;
958 
959  particlesToHits[selectedParticle].push_back(hit);
960  hitsToParticles[hit] = selectedParticle;
961  }
962  catch (cet::exception &e)
963  {
964  }
965  }
966  }
967 }
std::vector< sim::TrackIDE > TrackIDEVector
std::map< int, art::Ptr< simb::MCParticle > > MCParticleMap
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
int TrackId() const
Definition: MCParticle.h:214
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)
intermediate_table::const_iterator const_iterator
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:30
Detector simulation of raw signals on wires.
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:29
Float_t e
Definition: plot.C:34
Ionization energy from a Geant4 track.
Definition: SimChannel.h:28
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:25
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 971 of file LArPandoraHelper.cxx.

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

973 {
974  SimChannelVector simChannelVector;
975  MCTruthToMCParticles truthToParticles;
976  MCParticlesToMCTruth particlesToTruth;
977  HitsToTrackIDEs hitsToTrackIDEs;
978 
979  LArPandoraHelper::CollectSimChannels(evt, label, simChannelVector);
980  LArPandoraHelper::CollectMCParticles(evt, label, truthToParticles, particlesToTruth);
981  LArPandoraHelper::BuildMCParticleHitMaps(hitVector, simChannelVector, hitsToTrackIDEs);
982  LArPandoraHelper::BuildMCParticleHitMaps(hitsToTrackIDEs, truthToParticles, particlesToHits, hitsToParticles, daughterMode);
983 }
std::map< art::Ptr< recob::Hit >, TrackIDEVector > HitsToTrackIDEs
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
std::vector< art::Ptr< sim::SimChannel > > SimChannelVector
static void BuildMCParticleHitMaps(const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
static void CollectSimChannels(const art::Event &evt, const std::string &label, SimChannelVector &simChannelVector)
Collect a vector of SimChannel objects from the ART event record.
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 987 of file LArPandoraHelper.cxx.

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

989 {
990  // Start by getting the collection of Hits
992  evt.getByLabel(hitLabel, theHits);
993 
994  if (!theHits.isValid())
995  {
996  mf::LogDebug("LArPandora") << " Failed to find hits... " << std::endl;
997  return;
998  }
999 
1000  HitVector hitVector;
1001 
1002  for (unsigned int i = 0; i < theHits->size(); ++i)
1003  {
1004  const art::Ptr<recob::Hit> hit(theHits, i);
1005  hitVector.push_back(hit);
1006  }
1007 
1008  // Now get the associations between Hits and MCParticles
1009  std::vector<anab::BackTrackerHitMatchingData const*> backtrackerVector;
1010 
1011  MCParticleVector particleVector;
1012 
1013  art::FindManyP<simb::MCParticle, anab::BackTrackerHitMatchingData> particles_per_hit(theHits, evt, backtrackLabel);
1014 
1015  if (!particles_per_hit.isValid())
1016  {
1017  mf::LogDebug("LArPandora") << " Failed to find reco-truth matching... " << std::endl;
1018  return;
1019  }
1020 
1021  // Now loop over the hits and build a collection of IDEs
1022  for (HitVector::const_iterator iter = hitVector.begin(), iterEnd = hitVector.end(); iter != iterEnd; ++iter)
1023  {
1024  const art::Ptr<recob::Hit> hit = *iter;
1025 
1026  particleVector.clear(); backtrackerVector.clear();
1027  particles_per_hit.get(hit.key(), particleVector, backtrackerVector);
1028 
1029  for (unsigned int j = 0; j < particleVector.size(); ++j)
1030  {
1031  const art::Ptr<simb::MCParticle> particle = particleVector[j];
1032 
1033  sim::TrackIDE trackIDE;
1034  trackIDE.trackID = particle->TrackId();
1035  trackIDE.energy = backtrackerVector[j]->energy;
1036  trackIDE.energyFrac = backtrackerVector[j]->ideFraction;
1037 
1038  hitsToTrackIDEs[hit].push_back(trackIDE);
1039  }
1040  }
1041 }
key_type key() const
Definition: Ptr.h:356
float energy
energy from the particle with this trackID [MeV]
Definition: SimChannel.h:31
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
int TrackId() const
Definition: MCParticle.h:214
bool isValid() const
Definition: Handle.h:190
intermediate_table::const_iterator const_iterator
float energyFrac
fraction of hit energy from the particle with this trackID
Definition: SimChannel.h:30
std::vector< art::Ptr< recob::Hit > > HitVector
Detector simulation of raw signals on wires.
int trackID
Geant4 supplied trackID.
Definition: SimChannel.h:29
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Ionization energy from a Geant4 track.
Definition: SimChannel.h:28
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 1045 of file LArPandoraHelper.cxx.

References BuildMCParticleHitMaps(), and CollectMCParticles().

1047 {
1048  MCTruthToMCParticles truthToParticles;
1049  MCParticlesToMCTruth particlesToTruth;
1050  HitsToTrackIDEs hitsToTrackIDEs;
1051 
1052  LArPandoraHelper::CollectMCParticles(evt, truthLabel, truthToParticles, particlesToTruth);
1053  LArPandoraHelper::BuildMCParticleHitMaps(evt, hitLabel, backtrackLabel, hitsToTrackIDEs);
1054  LArPandoraHelper::BuildMCParticleHitMaps(hitsToTrackIDEs, truthToParticles, particlesToHits, hitsToParticles, daughterMode);
1055 }
std::map< art::Ptr< recob::Hit >, TrackIDEVector > HitsToTrackIDEs
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
static void BuildMCParticleHitMaps(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 1094 of file LArPandoraHelper.cxx.

References simb::MCParticle::TrackId().

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

1095 {
1096  for (MCParticleVector::const_iterator iter = particleVector.begin(), iterEnd = particleVector.end(); iter != iterEnd; ++iter)
1097  {
1098  const art::Ptr<simb::MCParticle> particle = *iter;
1099  particleMap[particle->TrackId()] = particle;
1100  particleMap[particle->TrackId()] = particle;
1101  }
1102 }
int TrackId() const
Definition: MCParticle.h:214
intermediate_table::const_iterator const_iterator
Definition: fwd.h:25
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 519 of file LArPandoraHelper.cxx.

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

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

522 {
523  // Build mapping from particle to particle ID for parent/daughter navigation
524  PFParticleMap particleMap;
525 
526  for (PFParticleVector::const_iterator iter1 = particleVector.begin(), iterEnd1 = particleVector.end(); iter1 != iterEnd1; ++iter1)
527  {
528  const art::Ptr<recob::PFParticle> particle = *iter1;
529  particleMap[particle->Self()] = particle;
530  }
531 
532  // Loop over hits and build mapping between reconstructed final-state particles and reconstructed hits
533  for (PFParticlesToSpacePoints::const_iterator iter1 = particlesToSpacePoints.begin(), iterEnd1 = particlesToSpacePoints.end();
534  iter1 != iterEnd1; ++iter1)
535  {
536  const art::Ptr<recob::PFParticle> thisParticle = iter1->first;
537  const art::Ptr<recob::PFParticle> particle((kAddDaughters == daughterMode) ?
538  LArPandoraHelper::GetFinalStatePFParticle(particleMap, thisParticle) : thisParticle);
539 
540  if ((kIgnoreDaughters == daughterMode) && !LArPandoraHelper::IsFinalState(particleMap, particle))
541  continue;
542 
543  const SpacePointVector &spacePointVector = iter1->second;
544 
545  for (SpacePointVector::const_iterator iter2 = spacePointVector.begin(), iterEnd2 = spacePointVector.end(); iter2 != iterEnd2; ++iter2)
546  {
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 --- Found a space point without an associated hit ";
552 
553  const art::Ptr<recob::Hit> hit = iter3->second;
554 
555  particlesToHits[particle].push_back(hit);
556  hitsToParticles[hit] = particle;
557  }
558  }
559 }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
static art::Ptr< recob::PFParticle > GetFinalStatePFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
intermediate_table::const_iterator const_iterator
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 563 of file LArPandoraHelper.cxx.

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

566 {
567  // Build mapping from particle to particle ID for parent/daughter navigation
568  PFParticleMap particleMap;
569 
570  for (PFParticleVector::const_iterator iter1 = particleVector.begin(), iterEnd1 = particleVector.end(); iter1 != iterEnd1; ++iter1)
571  {
572  const art::Ptr<recob::PFParticle> particle = *iter1;
573  particleMap[particle->Self()] = particle;
574  }
575 
576  // Loop over hits and build mapping between reconstructed final-state particles and reconstructed hits
577  for (PFParticlesToClusters::const_iterator iter1 = particlesToClusters.begin(), iterEnd1 = particlesToClusters.end();
578  iter1 != iterEnd1; ++iter1)
579  {
580  const art::Ptr<recob::PFParticle> thisParticle = iter1->first;
581  const art::Ptr<recob::PFParticle> particle((kAddDaughters == daughterMode) ?
582  LArPandoraHelper::GetFinalStatePFParticle(particleMap, thisParticle) : thisParticle);
583 
584  if ((kIgnoreDaughters == daughterMode) && !LArPandoraHelper::IsFinalState(particleMap, particle))
585  continue;
586 
587  const ClusterVector &clusterVector = iter1->second;
588  for (ClusterVector::const_iterator iter2 = clusterVector.begin(), iterEnd2 = clusterVector.end(); iter2 != iterEnd2; ++iter2)
589  {
590  const art::Ptr<recob::Cluster> cluster = *iter2;
591 
592  ClustersToHits::const_iterator iter3 = clustersToHits.find(cluster);
593  if (clustersToHits.end() == iter3)
594  throw cet::exception("LArPandora") << " PandoraCollector::BuildPFParticleHitMaps --- Found a space point without an associated hit ";
595 
596  const HitVector &hitVector = iter3->second;
597  for (HitVector::const_iterator iter4 = hitVector.begin(), iterEnd4 = hitVector.end(); iter4 != iterEnd4; ++iter4)
598  {
599  const art::Ptr<recob::Hit> hit = *iter4;
600 
601  particlesToHits[particle].push_back(hit);
602  hitsToParticles[hit] = particle;
603  }
604  }
605  }
606 }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
static art::Ptr< recob::PFParticle > GetFinalStatePFParticle(const PFParticleMap &particleMap, const art::Ptr< recob::PFParticle > daughterParticle)
Return the final-state parent particle by navigating up the chain of parent/daughter associations...
Cluster finding and building.
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
intermediate_table::const_iterator const_iterator
std::vector< art::Ptr< recob::Hit > > HitVector
Detector simulation of raw signals on wires.
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 618 of file LArPandoraHelper.cxx.

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

620 {
621  // Use intermediate clusters
622  if (useClusters)
623  {
624  PFParticleVector particleVector;
625  PFParticlesToClusters particlesToClusters;
626 
627  ClusterVector clusterVector;
628  ClustersToHits clustersToHits;
629 
630  LArPandoraHelper::CollectPFParticles(evt, label_pfpart, particleVector, particlesToClusters);
631  LArPandoraHelper::CollectClusters(evt, label_middle, clusterVector, clustersToHits);
632 
633  LArPandoraHelper::BuildPFParticleHitMaps(particleVector, particlesToClusters, clustersToHits,
634  particlesToHits, hitsToParticles, daughterMode);
635  }
636 
637  // Use intermediate space points
638  else
639  {
640  PFParticleVector particleVector;
641  PFParticlesToSpacePoints particlesToSpacePoints;
642 
643  SpacePointVector spacePointVector;
644  SpacePointsToHits spacePointsToHits;
645 
646  LArPandoraHelper::CollectPFParticles(evt, label_pfpart, particleVector, particlesToSpacePoints);
647  LArPandoraHelper::CollectSpacePoints(evt, label_middle, spacePointVector, spacePointsToHits);
648 
649  LArPandoraHelper::BuildPFParticleHitMaps(particleVector, particlesToSpacePoints, spacePointsToHits,
650  particlesToHits, hitsToParticles, daughterMode);
651  }
652 }
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::SpacePoint >, art::Ptr< recob::Hit > > SpacePointsToHits
std::map< art::Ptr< recob::PFParticle >, ClusterVector > PFParticlesToClusters
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
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::Cluster >, HitVector > ClustersToHits
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::SpacePoint > > SpacePointVector
std::vector< art::Ptr< recob::Cluster > > ClusterVector
std::map< art::Ptr< recob::PFParticle >, SpacePointVector > PFParticlesToSpacePoints
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 610 of file LArPandoraHelper.cxx.

References BuildPFParticleHitMaps().

612 {
613  return LArPandoraHelper::BuildPFParticleHitMaps(evt, label, label, particlesToHits, hitsToParticles, daughterMode, useClusters);
614 }
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 1106 of file LArPandoraHelper.cxx.

References recob::PFParticle::Self().

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

1107 {
1108  for (PFParticleVector::const_iterator iter = particleVector.begin(), iterEnd = particleVector.end(); iter != iterEnd; ++iter)
1109  {
1110  const art::Ptr<recob::PFParticle> particle = *iter;
1111  particleMap[particle->Self()] = particle;
1112  }
1113 }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
intermediate_table::const_iterator const_iterator
void lar_pandora::LArPandoraHelper::CollectClusters ( const art::Event evt,
const std::string &  label,
ClusterVector clusterVector,
ClustersToHits clustersToHits 
)
static

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

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

Definition at line 157 of file LArPandoraHelper.cxx.

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

Referenced by BuildPFParticleHitMaps().

159 {
161  evt.getByLabel(label, theClusters);
162 
163  if (!theClusters.isValid())
164  {
165  mf::LogDebug("LArPandora") << " Failed to find clusters... " << std::endl;
166  return;
167  }
168  else
169  {
170  mf::LogDebug("LArPandora") << " Found: " << theClusters->size() << " Clusters " << std::endl;
171  }
172 
173  art::FindManyP<recob::Hit> theHitAssns(theClusters, evt, label);
174  for (unsigned int i = 0; i < theClusters->size(); ++i)
175  {
176  const art::Ptr<recob::Cluster> cluster(theClusters, i);
177  clusterVector.push_back(cluster);
178 
179  const std::vector< art::Ptr<recob::Hit> > hits = theHitAssns.at(i);
180  for (unsigned int j=0; j<hits.size(); ++j)
181  {
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
Definition: Handle.h:190
void hits()
Definition: readHits.C:15
Detector simulation of raw signals on wires.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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 692 of file LArPandoraHelper.cxx.

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

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

694 {
696  evt.getByLabel(label, theCosmicTags);
697 
698  if (theCosmicTags.isValid())
699  {
700  art::FindOneP<recob::Track> theCosmicAssns(theCosmicTags, evt, label); // We assume there is one tag per algorithm
701  for (unsigned int i = 0; i < theCosmicTags->size(); ++i)
702  {
703  const art::Ptr<anab::CosmicTag> cosmicTag(theCosmicTags, i);
704  const art::Ptr<recob::Track> track = theCosmicAssns.at(i);
705  tracksToCosmicTags[track].push_back(cosmicTag); // We assume there could be multiple algorithms
706  cosmicTagVector.push_back(cosmicTag);
707  }
708  }
709 }
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Float_t track
Definition: plot.C:34
Definition: fwd.h:25
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 792 of file LArPandoraHelper.cxx.

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

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

793 {
794  if (evt.isRealData())
795  throw cet::exception("LArPandora") << " PandoraCollector::CollectGeneratorMCParticles --- Trying to access MC truth from real data ";
796 
798  evt.getByLabel(label, mcTruthBlocks);
799 
800  if (!mcTruthBlocks.isValid())
801  {
802  mf::LogDebug("LArPandora") << " Failed to find MC truth blocks from generator... " << std::endl;
803  return;
804  }
805  else
806  {
807  mf::LogDebug("LArPandora") << " Found: " << mcTruthBlocks->size() << " MC truth blocks " << std::endl;
808  }
809 
810  if (mcTruthBlocks->size() != 1)
811  throw cet::exception("LArPandora") << " PandoraCollector::CollectGeneratorMCParticles --- Unexpected number of MC truth blocks ";
812 
813  const art::Ptr<simb::MCTruth> mcTruth(mcTruthBlocks, 0);
814 
815  for (int i = 0; i < mcTruth->NParticles(); ++i)
816  {
817  particleVector.push_back(mcTruth->GetParticle(i));
818  }
819 }
bool isRealData() const
Definition: Event.h:83
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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 71 of file LArPandoraHelper.cxx.

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

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

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

References art::DataViewImpl::getByLabel(), art::Event::isRealData(), 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().

766 {
767  if (evt.isRealData())
768  throw cet::exception("LArPandora") << " PandoraCollector::CollectMCParticles --- Trying to access MC truth from real data ";
769 
771  evt.getByLabel(label, theParticles);
772 
773  if (!theParticles.isValid())
774  {
775  mf::LogDebug("LArPandora") << " Failed to find MC particles... " << std::endl;
776  return;
777  }
778  else
779  {
780  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " MC particles " << std::endl;
781  }
782 
783  for (unsigned int i = 0; i < theParticles->size(); ++i)
784  {
785  const art::Ptr<simb::MCParticle> particle(theParticles, i);
786  particleVector.push_back(particle);
787  }
788 }
bool isRealData() const
Definition: Event.h:83
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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 824 of file LArPandoraHelper.cxx.

References art::DataViewImpl::getByLabel(), art::Event::isRealData(), and art::Handle< T >::isValid().

826 {
827  if (evt.isRealData())
828  throw cet::exception("LArPandora") << " PandoraCollector::CollectMCParticles --- Trying to access MC truth from real data ";
829 
831  evt.getByLabel(label, theParticles);
832 
833  if (!theParticles.isValid())
834  {
835  mf::LogDebug("LArPandora") << " Failed to find MC particles... " << std::endl;
836  return;
837  }
838  else
839  {
840  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " MC particles " << std::endl;
841  }
842 
843  art::FindOneP<simb::MCTruth> theTruthAssns(theParticles, evt, label);
844 
845  for (unsigned int i = 0, iEnd = theParticles->size(); i < iEnd; ++i)
846  {
847  const art::Ptr<simb::MCParticle> particle(theParticles, i);
848  const art::Ptr<simb::MCTruth> truth(theTruthAssns.at(i));
849  truthToParticles[truth].push_back(particle);
850  particlesToTruth[particle] = truth;
851  }
852 }
bool isRealData() const
Definition: Event.h:83
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:25
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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 256 of file LArPandoraHelper.cxx.

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

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

References art::DataViewImpl::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(), 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  {
102  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
103  return;
104  }
105  else
106  {
107  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles " << std::endl;
108  }
109 
110  for (unsigned int i = 0; i < theParticles->size(); ++i)
111  {
112  const art::Ptr<recob::PFParticle> particle(theParticles, i);
113  particleVector.push_back(particle);
114  }
115 }
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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 art::DataViewImpl::getByLabel(), and art::Handle< T >::isValid().

192 {
194  evt.getByLabel(label, theParticles);
195 
196  if (!theParticles.isValid())
197  {
198  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
199  return;
200  }
201  else
202  {
203  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles " << std::endl;
204  }
205 
206  art::FindManyP<recob::SpacePoint> theSpacePointAssns(theParticles, evt, label);
207  for (unsigned int i = 0; i < theParticles->size(); ++i)
208  {
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  {
215  const art::Ptr<recob::SpacePoint> spacepoint = spacepoints.at(j);
216  particlesToSpacePoints[particle].push_back(spacepoint);
217  }
218  }
219 }
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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

Definition at line 223 of file LArPandoraHelper.cxx.

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

225 {
227  evt.getByLabel(label, theParticles);
228 
229  if (!theParticles.isValid())
230  {
231  mf::LogDebug("LArPandora") << " Failed to find particles... " << std::endl;
232  return;
233  }
234  else
235  {
236  mf::LogDebug("LArPandora") << " Found: " << theParticles->size() << " PFParticles " << std::endl;
237  }
238 
239  art::FindManyP<recob::Cluster> theClusterAssns(theParticles, evt, label);
240  for (unsigned int i = 0; i < theParticles->size(); ++i)
241  {
242  const art::Ptr<recob::PFParticle> particle(theParticles, i);
243  particleVector.push_back(particle);
244 
245  const std::vector< art::Ptr<recob::Cluster> > clusters = theClusterAssns.at(i);
246  for (unsigned int j=0; j<clusters.size(); ++j)
247  {
248  const art::Ptr<recob::Cluster> cluster = clusters.at(j);
249  particlesToClusters[particle].push_back(cluster);
250  }
251  }
252 }
Cluster finding and building.
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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 419 of file LArPandoraHelper.cxx.

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

421 {
423  evt.getByLabel(label, theSeeds);
424 
425  if (!theSeeds.isValid())
426  {
427  mf::LogDebug("LArPandora") << " Failed to find seeds... " << std::endl;
428  return;
429  }
430  else
431  {
432  mf::LogDebug("LArPandora") << " Found: " << theSeeds->size() << " Seeds " << std::endl;
433  }
434 
435  art::FindManyP<recob::PFParticle> theSeedAssns(theSeeds, evt, label);
436  for (unsigned int i = 0; i < theSeeds->size(); ++i)
437  {
438  const art::Ptr<recob::Seed> seed(theSeeds, i);
439  seedVector.push_back(seed);
440 
441  const std::vector< art::Ptr<recob::PFParticle> > particles = theSeedAssns.at(i);
442  for (unsigned int j=0; j<particles.size(); ++j)
443  {
444  const art::Ptr<recob::PFParticle> particle = particles.at(j);
445  particlesToSeeds[particle].push_back(seed);
446  }
447  }
448 }
bool isValid() const
Definition: Handle.h:190
long seed
Definition: chem4.cc:68
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:25
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 289 of file LArPandoraHelper.cxx.

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

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

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

Definition at line 387 of file LArPandoraHelper.cxx.

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

388 {
390  evt.getByLabel(label, theShowers);
391 
392  if (!theShowers.isValid())
393  {
394  mf::LogDebug("LArPandora") << " Failed to find showers... " << std::endl;
395  return;
396  }
397  else
398  {
399  mf::LogDebug("LArPandora") << " Found: " << theShowers->size() << " Showers " << std::endl;
400  }
401 
402  art::FindManyP<recob::Hit> theHitAssns(theShowers, evt, label);
403  for (unsigned int i = 0; i < theShowers->size(); ++i)
404  {
405  const art::Ptr<recob::Shower> shower(theShowers, i);
406  showerVector.push_back(shower);
407 
408  const std::vector< art::Ptr<recob::Hit> > hits = theHitAssns.at(i);
409  for (unsigned int j=0; j<hits.size(); ++j)
410  {
411  const art::Ptr<recob::Hit> hit = hits.at(j);
412  showersToHits[shower].push_back(hit);
413  }
414  }
415 }
bool isValid() const
Definition: Handle.h:190
void hits()
Definition: readHits.C:15
Detector simulation of raw signals on wires.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
void lar_pandora::LArPandoraHelper::CollectSimChannels ( const art::Event evt,
const std::string &  label,
SimChannelVector simChannelVector 
)
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

Definition at line 738 of file LArPandoraHelper.cxx.

References art::DataViewImpl::getByLabel(), art::Event::isRealData(), and art::Handle< T >::isValid().

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

739 {
740  if (evt.isRealData())
741  throw cet::exception("LArPandora") << " PandoraCollector::CollectSimChannels --- Trying to access MC truth from real data ";
742 
744  evt.getByLabel(label, theSimChannels);
745 
746  if (!theSimChannels.isValid())
747  {
748  mf::LogDebug("LArPandora") << " Failed to find sim channels... " << std::endl;
749  return;
750  }
751  else
752  {
753  mf::LogDebug("LArPandora") << " Found: " << theSimChannels->size() << " SimChannels " << std::endl;
754  }
755 
756  for (unsigned int i = 0; i < theSimChannels->size(); ++i)
757  {
758  const art::Ptr<sim::SimChannel> channel(theSimChannels, i);
759  simChannelVector.push_back(channel);
760  }
761 }
bool isRealData() const
Definition: Event.h:83
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
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 119 of file LArPandoraHelper.cxx.

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

121 {
122  HitsToSpacePoints hitsToSpacePoints;
123  return LArPandoraHelper::CollectSpacePoints(evt, label, spacePointVector, spacePointsToHits, hitsToSpacePoints);
124 }
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 128 of file LArPandoraHelper.cxx.

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

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

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

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

714 {
716  evt.getByLabel(label, theT0s);
717 
718  if (theT0s.isValid())
719  {
720  art::FindManyP<recob::PFParticle> theAssns(theT0s, evt, label);
721  for (unsigned int i = 0; i < theT0s->size(); ++i)
722  {
723  const art::Ptr<anab::T0> theT0(theT0s, i);
724  t0Vector.push_back(theT0);
725 
726  const std::vector< art::Ptr<recob::PFParticle> > particles = theAssns.at(i);
727  for (unsigned int j=0; j<particles.size(); ++j)
728  {
729  const art::Ptr<recob::PFParticle> theParticle = particles.at(j);
730  particlesToT0s[theParticle].push_back(theT0); // We assume there could be multiple T0s per PFParticle
731  }
732  }
733  }
734 }
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
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 322 of file LArPandoraHelper.cxx.

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

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

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

Definition at line 355 of file LArPandoraHelper.cxx.

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

356 {
358  evt.getByLabel(label, theTracks);
359 
360  if (!theTracks.isValid())
361  {
362  mf::LogDebug("LArPandora") << " Failed to find tracks... " << std::endl;
363  return;
364  }
365  else
366  {
367  mf::LogDebug("LArPandora") << " Found: " << theTracks->size() << " Tracks " << std::endl;
368  }
369 
370  art::FindManyP<recob::Hit> theHitAssns(theTracks, evt, label);
371  for (unsigned int i = 0; i < theTracks->size(); ++i)
372  {
373  const art::Ptr<recob::Track> track(theTracks, i);
374  trackVector.push_back(track);
375 
376  const std::vector< art::Ptr<recob::Hit> > hits = theHitAssns.at(i);
377  for (unsigned int j=0; j<hits.size(); ++j)
378  {
379  const art::Ptr<recob::Hit> hit = hits.at(j);
380  tracksToHits[track].push_back(hit);
381  }
382  }
383 }
bool isValid() const
Definition: Handle.h:190
void hits()
Definition: readHits.C:15
Detector simulation of raw signals on wires.
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Float_t track
Definition: plot.C:34
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 486 of file LArPandoraHelper.cxx.

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

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

488 {
490  evt.getByLabel(label, theVertices);
491 
492  if (!theVertices.isValid())
493  {
494  mf::LogDebug("LArPandora") << " Failed to find vertices... " << std::endl;
495  return;
496  }
497  else
498  {
499  mf::LogDebug("LArPandora") << " Found: " << theVertices->size() << " Vertices " << std::endl;
500  }
501 
502  art::FindManyP<recob::PFParticle> theVerticesAssns(theVertices, evt, label);
503  for (unsigned int i = 0; i < theVertices->size(); ++i)
504  {
505  const art::Ptr<recob::Vertex> vertex(theVertices, i);
506  vertexVector.push_back(vertex);
507 
508  const std::vector< art::Ptr<recob::PFParticle> > particles = theVerticesAssns.at(i);
509  for (unsigned int j=0; j<particles.size(); ++j)
510  {
511  const art::Ptr<recob::PFParticle> particle = particles.at(j);
512  particlesToVertices[particle].push_back(vertex);
513  }
514  }
515 }
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
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::DataViewImpl::getByLabel(), and art::Handle< T >::isValid().

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

48 {
50  evt.getByLabel(label, theWires);
51 
52  if (!theWires.isValid())
53  {
54  mf::LogDebug("LArPandora") << " Failed to find wires... " << std::endl;
55  return;
56  }
57  else
58  {
59  mf::LogDebug("LArPandora") << " Found: " << theWires->size() << " Wires " << std::endl;
60  }
61 
62  for (unsigned int i = 0; i < theWires->size(); ++i)
63  {
64  const art::Ptr<recob::Wire> wire(theWires, i);
65  wireVector.push_back(wire);
66  }
67 }
bool isValid() const
Definition: Handle.h:190
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
MaybeLogger_< ELseverityLevel::ELsev_success, false > LogDebug
Definition: fwd.h:25
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 1060 of file LArPandoraHelper.cxx.

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

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

1062 {
1063 
1064  art::Handle<std::vector<T> > handle;
1065  evt.getByLabel(label, handle);
1066  art::FindManyP<recob::Hit> hitAssoc(handle, evt, label);
1067 
1068  if (indexVector != nullptr)
1069  {
1070  if (inputVector.size() != indexVector->size())
1071  throw cet::exception("LArPandora") << " PandoraHelper::GetAssociatedHits --- trying to use an index vector not matching input vector";
1072 
1073  // If indexVector is filled, sort hits according to trajectory points order
1074  for (int index : (*indexVector))
1075  {
1076  const art::Ptr<T> &element = inputVector.at(index);
1077  const HitVector &hits = hitAssoc.at(element.key());
1078  associatedHits.insert(associatedHits.end(), hits.begin(), hits.end());
1079  }
1080  }
1081  else
1082  {
1083  // If indexVector is empty just loop through inputSpacePoints
1084  for (const art::Ptr<T> &element : inputVector)
1085  {
1086  const HitVector &hits = hitAssoc.at(element.key());
1087  associatedHits.insert(associatedHits.end(), hits.begin(), hits.end());
1088  }
1089  }
1090 }
key_type key() const
Definition: Ptr.h:356
void hits()
Definition: readHits.C:15
std::vector< art::Ptr< recob::Hit > > HitVector
bool getByLabel(std::string const &label, std::string const &productInstanceName, Handle< PROD > &result) const
Definition: DataViewImpl.h:344
Definition: fwd.h:25
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 1214 of file LArPandoraHelper.cxx.

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

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

1215 {
1216  // Navigate upward through MC daughter/parent links - collect this particle and all its parents
1217  MCParticleVector mcVector;
1218 
1219  int trackID(inputParticle->TrackId());
1220 
1221  while(1)
1222  {
1223  MCParticleMap::const_iterator pIter = particleMap.find(trackID);
1224  if (particleMap.end() == pIter)
1225  break; // Can't find MC Particle for this track ID [break]
1226 
1227  const art::Ptr<simb::MCParticle> particle = pIter->second;
1228  mcVector.push_back(particle);
1229 
1230  trackID = particle->Mother();
1231  }
1232 
1233  // Navigate downward through MC parent/daughter links - return the first long-lived charged particle
1234  for (MCParticleVector::const_reverse_iterator iter = mcVector.rbegin(), iterEnd = mcVector.rend(); iter != iterEnd; ++iter)
1235  {
1236  const art::Ptr<simb::MCParticle> nextParticle = *iter;
1237 
1238  if (LArPandoraHelper::IsVisible(nextParticle))
1239  return nextParticle;
1240  }
1241 
1242  throw cet::exception("LArPandora"); // need to catch this exception
1243 }
int Mother() const
Definition: MCParticle.h:217
std::vector< art::Ptr< simb::MCParticle > > MCParticleVector
static bool IsVisible(const art::Ptr< simb::MCParticle > particle)
Determine whether a particle is visible (i.e. long-lived charged particle)
intermediate_table::const_iterator const_iterator
Definition: fwd.h:25
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 1148 of file LArPandoraHelper.cxx.

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

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

1149 {
1150  // Navigate upward through PFO daughter/parent links - return the top-level non-neutrino PF Particle
1151  int primaryTrackID(inputParticle->Self());
1152 
1153  if (!inputParticle->IsPrimary())
1154  {
1155  int parentTrackID(inputParticle->Parent());
1156 
1157  while(1)
1158  {
1159  PFParticleMap::const_iterator pIter1 = particleMap.find(parentTrackID);
1160  if (particleMap.end() == pIter1)
1161  throw cet::exception("LArPandora") << " PandoraCollector::GetFinalStatePFParticle --- Found a PFParticle without a particle ID ";
1162 
1163  const art::Ptr<recob::PFParticle> parentParticle = pIter1->second;
1164  if (LArPandoraHelper::IsNeutrino(parentParticle))
1165  break;
1166 
1167  primaryTrackID = parentTrackID;
1168 
1169  if (parentParticle->IsPrimary())
1170  break;
1171 
1172  parentTrackID = parentParticle->Parent();
1173  }
1174  }
1175 
1176  PFParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1177  if (particleMap.end() == pIter2)
1178  throw cet::exception("LArPandora") << " PandoraCollector::GetFinalStatePFParticle --- Found a PFParticle without a particle ID ";
1179 
1180  const art::Ptr<recob::PFParticle> outputParticle = pIter2->second;
1181  return outputParticle;
1182 }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
int lar_pandora::LArPandoraHelper::GetGeneration ( const PFParticleMap particleMap,
const art::Ptr< recob::PFParticle daughterParticle 
)
static

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

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

Definition at line 1263 of file LArPandoraHelper.cxx.

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

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

1264 {
1265  // Navigate upward through PFO daughter/parent links - return the top-level PF Particle
1266  int nGenerations(0);
1267  int primaryTrackID(inputParticle->Self());
1268 
1269  while(1)
1270  {
1271  PFParticleMap::const_iterator pIter = particleMap.find(primaryTrackID);
1272  if (particleMap.end() == pIter)
1273  throw cet::exception("LArPandora") << " PandoraCollector::GetGeneration --- Found a PFParticle without a particle ID ";
1274 
1275  ++nGenerations;
1276 
1277  const art::Ptr<recob::PFParticle> primaryParticle = pIter->second;
1278  if (primaryParticle->IsPrimary())
1279  break;
1280 
1281  primaryTrackID = primaryParticle->Parent();
1282  }
1283 
1284  return nGenerations;
1285 }
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::Ptr< simb::MCParticle > lar_pandora::LArPandoraHelper::GetParentMCParticle ( const MCParticleMap particleMap,
const art::Ptr< simb::MCParticle daughterParticle 
)
static

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

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

Definition at line 1186 of file LArPandoraHelper.cxx.

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

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

1187 {
1188  // Navigate upward through MC daughter/parent links - return the top-level MC particle
1189  int primaryTrackID(inputParticle->TrackId());
1190  int parentTrackID(inputParticle->Mother());
1191 
1192  while(1)
1193  {
1194  MCParticleMap::const_iterator pIter1 = particleMap.find(parentTrackID);
1195  if (particleMap.end() == pIter1)
1196  break; // Can't find MC Particle for this track ID [break]
1197 
1198  const art::Ptr<simb::MCParticle> particle = pIter1->second;
1199 
1200  primaryTrackID = parentTrackID;
1201  parentTrackID = particle->Mother();
1202  }
1203 
1204  MCParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1205  if (particleMap.end() == pIter2)
1206  throw cet::exception("LArPandora") << " PandoraCollector::GetParentMCParticle --- Found a track ID without a MC particle ";
1207 
1208  const art::Ptr<simb::MCParticle> outputParticle = pIter2->second;
1209  return outputParticle;
1210 }
int Mother() const
Definition: MCParticle.h:217
intermediate_table::const_iterator const_iterator
Definition: fwd.h:25
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 1289 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().

1290 {
1291  art::Ptr<recob::PFParticle> parentParticle = LArPandoraHelper::GetParentPFParticle(particleMap, daughterParticle);
1292 
1293  if (LArPandoraHelper::IsNeutrino(parentParticle))
1294  return parentParticle->PdgCode();
1295 
1296  if (parentParticle->IsPrimary())
1297  return 0;
1298 
1299  const int parentID(parentParticle->Parent());
1300 
1301  PFParticleMap::const_iterator pIter = particleMap.find(parentID);
1302  if (particleMap.end() == pIter)
1303  throw cet::exception("LArPandora") << " PandoraCollector::GetParentNeutrino --- Found a PFParticle without a particle ID ";
1304 
1305  const art::Ptr<recob::PFParticle> neutrinoParticle = pIter->second;
1306  return neutrinoParticle->PdgCode();
1307 }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
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...
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
art::Ptr< 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 1117 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().

1118 {
1119  // Navigate upward through PFO daughter/parent links - return the top-level PF Particle
1120  int primaryTrackID(inputParticle->Self());
1121 
1122  if (!inputParticle->IsPrimary())
1123  {
1124  while(1)
1125  {
1126  PFParticleMap::const_iterator pIter1 = particleMap.find(primaryTrackID);
1127  if (particleMap.end() == pIter1)
1128  throw cet::exception("LArPandora") << " PandoraCollector::GetParentPFParticle --- Found a PFParticle without a particle ID ";
1129 
1130  const art::Ptr<recob::PFParticle> primaryParticle = pIter1->second;
1131  if (primaryParticle->IsPrimary())
1132  break;
1133 
1134  primaryTrackID = primaryParticle->Parent();
1135  }
1136  }
1137 
1138  PFParticleMap::const_iterator pIter2 = particleMap.find(primaryTrackID);
1139  if (particleMap.end() == pIter2)
1140  throw cet::exception("LArPandora") << " PandoraCollector::GetParentPFParticle --- Found a PFParticle without a particle ID ";
1141 
1142  const art::Ptr<recob::PFParticle> outputParticle = pIter2->second;
1143  return outputParticle;
1144 }
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
larpandoraobj::PFParticleMetadata lar_pandora::LArPandoraHelper::GetPFParticleMetadata ( const pandora::ParticleFlowObject *const  pPfo)
static

Definition at line 1384 of file LArPandoraHelper.cxx.

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

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

1385 {
1386  return larpandoraobj::PFParticleMetadata(pPfo->GetPropertiesMap());
1387 }
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 1247 of file LArPandoraHelper.cxx.

1248 {
1249  PFParticlesToTracks::const_iterator tIter = particlesToTracks.find(particle);
1250 
1251  if (particlesToTracks.end() == tIter || tIter->second.empty())
1252  throw cet::exception("LArPandora") << " PandoraCollector::GetPrimaryTrack --- Failed to find associated track ";
1253 
1254  if (tIter->second.size() != 1)
1255  throw cet::exception("LArPandora") << " PandoraCollector::GetPrimaryTrack --- Found more than one associated track ";
1256 
1257  const art::Ptr<recob::Track> primaryTrack = *(tIter->second.begin());
1258  return primaryTrack;
1259 }
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 1311 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().

1312 {
1313  if (LArPandoraHelper::IsNeutrino(daughterParticle))
1314  return false;
1315 
1316  if (daughterParticle->IsPrimary())
1317  return true;
1318 
1319  const int parentID(daughterParticle->Parent());
1320 
1321  PFParticleMap::const_iterator pIter = particleMap.find(parentID);
1322  if (particleMap.end() == pIter)
1323  throw cet::exception("LArPandora") << " PandoraCollector::IsFinalState --- Found a PFParticle without a particle ID ";
1324 
1325  const art::Ptr<recob::PFParticle> parentParticle = pIter->second;
1326 
1327  if (LArPandoraHelper::IsNeutrino(parentParticle))
1328  return true;
1329 
1330  return false;
1331 }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
intermediate_table::const_iterator const_iterator
size_t Parent() const
Definition: PFParticle.h:96
bool IsPrimary() const
Returns whether the particle is the root of the flow.
Definition: PFParticle.h:86
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
bool lar_pandora::LArPandoraHelper::IsNeutrino ( const art::Ptr< recob::PFParticle particle)
static

Determine whether a particle has been reconstructed as a neutrino.

Parameters
particlethe input particle
Returns
true/false

Definition at line 1335 of file LArPandoraHelper.cxx.

References recob::PFParticle::PdgCode().

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

1336 {
1337  const int pdg(particle->PdgCode());
1338 
1339  // electron, muon, tau (use Pandora PDG tables)
1340  return ((pandora::NU_E == std::abs(pdg)) || (pandora::NU_MU == std::abs(pdg)) || (pandora::NU_TAU == std::abs(pdg)));
1341 }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
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 1356 of file LArPandoraHelper.cxx.

References recob::PFParticle::PdgCode().

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

1357 {
1358  const int pdg(particle->PdgCode());
1359 
1360  // electron, photon (use Pandora PDG tables)
1361  return ((pandora::E_MINUS == std::abs(pdg)) || (pandora::PHOTON == std::abs(pdg)));
1362 }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
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 1345 of file LArPandoraHelper.cxx.

References recob::PFParticle::PdgCode().

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

1346 {
1347  const int pdg(particle->PdgCode());
1348 
1349  // muon, pion, proton, kaon (use Pandora PDG tables)
1350  return ((pandora::MU_MINUS == std::abs(pdg)) || (pandora::PI_PLUS == std::abs(pdg)) || (pandora::PROTON == std::abs(pdg)) ||
1351  (pandora::K_PLUS == std::abs(pdg)));
1352 }
int PdgCode() const
Return the type of particle as a PDG ID.
Definition: PFParticle.h:83
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 1366 of file LArPandoraHelper.cxx.

References simb::MCParticle::PdgCode().

Referenced by BuildMCParticleHitMaps(), and GetFinalStateMCParticle().

1367 {
1368  // Include long-lived charged particles
1369  const int pdg(particle->PdgCode());
1370 
1371  if ((pandora::E_MINUS == std::abs(pdg)) || (pandora::MU_MINUS == std::abs(pdg)) || (pandora::PROTON == std::abs(pdg)) ||
1372  (pandora::PI_PLUS == std::abs(pdg)) || (pandora::K_PLUS == std::abs(pdg)) ||
1373  (pandora::SIGMA_MINUS == std::abs(pdg)) || (pandora::SIGMA_PLUS == std::abs(pdg)) || (pandora::HYPERON_MINUS == std::abs(pdg)) ||
1374  (pandora::PHOTON == std::abs(pdg)) || (pandora::NEUTRON == std::abs(pdg)))
1375  return true;
1376 
1377  // TODO: What about ions, neutrons, photons? (Have included neutrons and photons for now)
1378 
1379  return false;
1380 }
int PdgCode() const
Definition: MCParticle.h:216
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 669 of file LArPandoraHelper.cxx.

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

670 {
671  // Build mapping from particle to particle ID for parent/daughter navigation
672  PFParticleMap particleMap;
673 
674  for (PFParticleVector::const_iterator iter = inputParticles.begin(), iterEnd = inputParticles.end(); iter != iterEnd; ++iter)
675  {
676  const art::Ptr<recob::PFParticle> particle = *iter;
677  particleMap[particle->Self()] = particle;
678  }
679 
680  // Select final-state particles
681  for (PFParticleVector::const_iterator iter = inputParticles.begin(), iterEnd = inputParticles.end(); iter != iterEnd; ++iter)
682  {
683  const art::Ptr<recob::PFParticle> particle = *iter;
684 
685  if (LArPandoraHelper::IsFinalState(particleMap, particle))
686  outputParticles.push_back(particle);
687  }
688 }
size_t Self() const
Returns the index of this particle.
Definition: PFParticle.h:92
std::map< int, art::Ptr< recob::PFParticle > > PFParticleMap
intermediate_table::const_iterator const_iterator
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 656 of file LArPandoraHelper.cxx.

References IsNeutrino().

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

657 {
658  for (PFParticleVector::const_iterator iter = inputParticles.begin(), iterEnd = inputParticles.end(); iter != iterEnd; ++iter)
659  {
660  const art::Ptr<recob::PFParticle> particle = *iter;
661 
662  if (LArPandoraHelper::IsNeutrino(particle))
663  outputParticles.push_back(particle);
664  }
665 }
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: