LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
lar_pandora::PFParticleValidation Class Reference

PFParticleValidation class. More...

Inheritance diagram for lar_pandora::PFParticleValidation:
art::EDAnalyzer art::EventObserverBase art::Consumer art::EngineCreator

Classes

class  MatchingDetails
 MatchingDetails class. More...
 
class  SimpleMatchedPfo
 SimpleMatchedPfo class. More...
 
class  SimpleMCPrimary
 SimpleMCPrimary class. More...
 

Public Types

using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 

Public Member Functions

 PFParticleValidation (fhicl::ParameterSet const &pset)
 Constructor. More...
 
virtual ~PFParticleValidation ()
 Destructor. More...
 
void beginJob ()
 
void endJob ()
 
void analyze (const art::Event &evt)
 
void reconfigure (fhicl::ParameterSet const &pset)
 
std::string workerType () const
 
bool modifiesEvent () const
 
void registerProducts (MasterProductRegistry &, ProductDescriptions &, ModuleDescription const &)
 
std::string const & processName () const
 
bool wantAllEvents () const
 
bool wantEvent (Event const &e)
 
fhicl::ParameterSetID selectorConfig () const
 
art::Handle< art::TriggerResultsgetTriggerResults (Event const &e) const
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > consumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > consumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< T > mayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< T > mayConsumeView (InputTag const &it)
 
base_engine_tcreateEngine (seed_t seed)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make)
 
base_engine_tcreateEngine (seed_t seed, std::string const &kind_of_engine_to_make, label_t const &engine_label)
 
seed_t get_seed_value (fhicl::ParameterSet const &pset, char const key[]="seed", seed_t const implicit_seed=-1)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

CurrentProcessingContext const * currentContext () const
 
detail::CachedProducts & cachedProducts ()
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Types

typedef std::vector< SimpleMCPrimarySimpleMCPrimaryList
 
typedef std::vector< SimpleMatchedPfoSimpleMatchedPfoList
 
typedef std::map< int, MatchingDetailsMatchingDetailsMap
 
typedef std::map< SimpleMCPrimary, SimpleMatchedPfoListMCPrimaryMatchingMap
 
typedef std::map< art::Ptr< recob::PFParticle >, HitVectorPFParticleToMatchedHits
 
typedef std::map< art::Ptr< simb::MCParticle >, PFParticleToMatchedHitsMCParticleMatchingMap
 
typedef std::set< int > IntSet
 

Private Member Functions

void GetMCParticleMatchingMap (const PFParticlesToHits &recoParticlesToHits, const MCParticlesToHits &trueParticlesToHits, const HitsToMCParticles &hitsToTrueParticles, MCParticleMatchingMap &mcParticleMatchingMap) const
 Performing matching between true and reconstructed particles. More...
 
void GetSimpleMCPrimaryList (const art::Event &evt, const MCParticlesToHits &mcParticlesToHits, const HitsToMCParticles &hitsToMCParticles, const MCParticleMatchingMap &mcParticleMatchingMap, SimpleMCPrimaryList &simpleMCPrimaryList) const
 Extract details of each mc primary (ordered by number of true hits) More...
 
void GetMCPrimaryMatchingMap (const SimpleMCPrimaryList &simpleMCPrimaryList, const MCParticleMatchingMap &mcParticleMatchingMap, const PFParticlesToHits &pfParticlesToHits, MCPrimaryMatchingMap &mcPrimaryMatchingMap) const
 Obtain a sorted list of matched pfos for each mc primary. More...
 
bool IsNeutrinoInduced (const art::Ptr< simb::MCParticle > pMCParticle, const MCParticlesToMCTruth &artMCParticlesToMCTruth) const
 Whether a mc particle is neutrino induced. More...
 
void GetMCTruth (const art::Event &evt, MCTruthVector &mcTruthVector) const
 Obtain a vector of mc truth. More...
 
void GetRecoNeutrinos (const art::Event &evt, PFParticleVector &recoNeutrinoVector) const
 Obtain a vector of reco neutrinos. More...
 
void PrintAllOutput (const MCTruthVector &mcTruthVector, const PFParticleVector &recoNeutrinoVector, const MCPrimaryMatchingMap &mcPrimaryMatchingMap) const
 Print all the raw matching output to screen. More...
 
void PerformMatching (const MCPrimaryMatchingMap &mcPrimaryMatchingMap, MatchingDetailsMap &matchingDetailsMap) const
 Apply a well-defined matching procedure to the comprehensive matches in the provided mc primary matching map. More...
 
bool GetStrongestPfoMatch (const MCPrimaryMatchingMap &mcPrimaryMatchingMap, IntSet &usedMCIds, IntSet &usedPfoIds, MatchingDetailsMap &matchingDetailsMap) const
 Get the strongest pfo match (most matched hits) between an available mc primary and an available pfo. More...
 
void GetRemainingPfoMatches (const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const IntSet &usedPfoIds, MatchingDetailsMap &matchingDetailsMap) const
 Get the best matches for any pfos left-over after the strong matching procedure. More...
 
void PrintMatchingOutput (const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const MatchingDetailsMap &matchingDetailsMap) const
 Print the results of the matching procedure. More...
 
bool IsGoodMCPrimary (const SimpleMCPrimary &simpleMCPrimary) const
 Whether a provided mc primary passes selection, based on number of "good" hits. More...
 
bool HasMatch (const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfoList &simpleMatchedPfoList, const MatchingDetailsMap &matchingDetailsMap) const
 Whether a provided mc primary has a match, of any quality (use simple matched pfo list and information in matching details map) More...
 
bool IsGoodMatch (const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfo &simpleMatchedPfo) const
 Whether a provided mc primary and pfo are deemed to be a good match. More...
 
unsigned int CountHitsByType (const geo::View_t view, const HitVector &hitVector) const
 Count the number of hits, in a provided vector, of a specified view. More...
 

Static Private Member Functions

static bool SortSimpleMCPrimaries (const SimpleMCPrimary &lhs, const SimpleMCPrimary &rhs)
 Sort simple mc primaries by number of mc hits. More...
 
static bool SortSimpleMatchedPfos (const SimpleMatchedPfo &lhs, const SimpleMatchedPfo &rhs)
 Sort simple matched pfos by number of matched hits. More...
 

Private Attributes

std::string m_hitfinderLabel
 The name/label of the hit producer module. More...
 
std::string m_particleLabel
 The name/label of the particle producer module. More...
 
std::string m_geantModuleLabel
 The name/label of the geant module. More...
 
std::string m_backtrackerLabel
 The name/label of the back-tracker module. More...
 
bool m_printAllToScreen
 Whether to print all/raw matching details to screen. More...
 
bool m_printMatchingToScreen
 Whether to print matching output to screen. More...
 
bool m_neutrinoInducedOnly
 Whether to consider only mc particles that were neutrino induced. More...
 
int m_matchingMinPrimaryHits
 The minimum number of good mc primary hits used in matching scheme. More...
 
int m_matchingMinHitsForGoodView
 The minimum number of good mc primary hits in given view to declare view to be good. More...
 
int m_matchingMinPrimaryGoodViews
 The minimum number of good views for a mc primary. More...
 
bool m_useSmallPrimaries
 Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits. More...
 
int m_matchingMinSharedHits
 The minimum number of shared hits used in matching scheme. More...
 
float m_matchingMinCompleteness
 The minimum particle completeness to declare a match. More...
 
float m_matchingMinPurity
 The minimum particle purity to declare a match. More...
 

Detailed Description

PFParticleValidation class.

Definition at line 23 of file PFParticleValidation_module.cc.

Member Typedef Documentation

typedef std::set<int> lar_pandora::PFParticleValidation::IntSet
private

Definition at line 203 of file PFParticleValidation_module.cc.

Definition at line 39 of file EDAnalyzer.h.

Definition at line 38 of file EDAnalyzer.h.

Constructor & Destructor Documentation

lar_pandora::PFParticleValidation::PFParticleValidation ( fhicl::ParameterSet const &  pset)

Constructor.

Parameters
pset

Definition at line 335 of file PFParticleValidation_module.cc.

References reconfigure().

335  :
336  art::EDAnalyzer(pset)
337 {
338  this->reconfigure(pset);
339 }
void reconfigure(fhicl::ParameterSet const &pset)
lar_pandora::PFParticleValidation::~PFParticleValidation ( )
virtual

Destructor.

Definition at line 343 of file PFParticleValidation_module.cc.

344 {
345 }

Member Function Documentation

void lar_pandora::PFParticleValidation::analyze ( const art::Event evt)

Definition at line 381 of file PFParticleValidation_module.cc.

References lar_pandora::LArPandoraHelper::BuildMCParticleHitMaps(), lar_pandora::LArPandoraHelper::BuildPFParticleHitMaps(), lar_pandora::LArPandoraHelper::CollectHits(), GetMCParticleMatchingMap(), GetMCPrimaryMatchingMap(), GetMCTruth(), GetRecoNeutrinos(), GetSimpleMCPrimaryList(), lar_pandora::LArPandoraHelper::kAddDaughters, m_backtrackerLabel, m_geantModuleLabel, m_hitfinderLabel, m_particleLabel, m_printAllToScreen, m_printMatchingToScreen, PerformMatching(), PrintAllOutput(), and PrintMatchingOutput().

382 {
383  HitVector hitVector;
385 
386  PFParticlesToHits pfParticlesToHits;
387  HitsToPFParticles hitsToPfParticles;
389 
390  MCParticlesToHits mcParticlesToHits;
391  HitsToMCParticles hitsToMCParticles;
392 
394  mcParticlesToHits, hitsToMCParticles, LArPandoraHelper::kAddDaughters);
395 
396  if (hitsToMCParticles.empty())
397  {
398  if (m_backtrackerLabel.empty())
399  throw cet::exception("LArPandora") << " PFParticleValidation::analyze - no sim channels found, backtracker module must be set in FHiCL " << std::endl;
400 
402  mcParticlesToHits, hitsToMCParticles, LArPandoraHelper::kAddDaughters);
403  }
404 
405  MCParticleMatchingMap mcParticleMatchingMap;
406  this->GetMCParticleMatchingMap(pfParticlesToHits, mcParticlesToHits, hitsToMCParticles, mcParticleMatchingMap);
407 
408  SimpleMCPrimaryList simpleMCPrimaryList;
409  this->GetSimpleMCPrimaryList(evt, mcParticlesToHits, hitsToMCParticles, mcParticleMatchingMap, simpleMCPrimaryList);
410 
411  MCPrimaryMatchingMap mcPrimaryMatchingMap;
412  this->GetMCPrimaryMatchingMap(simpleMCPrimaryList, mcParticleMatchingMap, pfParticlesToHits, mcPrimaryMatchingMap);
413 
414  MCTruthVector mcTruthVector;
415  this->GetMCTruth(evt, mcTruthVector);
416 
417  PFParticleVector recoNeutrinoVector;
418  this->GetRecoNeutrinos(evt, recoNeutrinoVector);
419 
420  if (m_printAllToScreen)
421  this->PrintAllOutput(mcTruthVector, recoNeutrinoVector, mcPrimaryMatchingMap);
422 
424  {
425  MatchingDetailsMap matchingDetailsMap;
426  this->PerformMatching(mcPrimaryMatchingMap, matchingDetailsMap);
427  this->PrintMatchingOutput(mcPrimaryMatchingMap, matchingDetailsMap);
428  }
429 }
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 GetMCParticleMatchingMap(const PFParticlesToHits &recoParticlesToHits, const MCParticlesToHits &trueParticlesToHits, const HitsToMCParticles &hitsToTrueParticles, MCParticleMatchingMap &mcParticleMatchingMap) const
Performing matching between true and reconstructed particles.
void PrintMatchingOutput(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const MatchingDetailsMap &matchingDetailsMap) const
Print the results of the matching procedure.
void PerformMatching(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, MatchingDetailsMap &matchingDetailsMap) const
Apply a well-defined matching procedure to the comprehensive matches in the provided mc primary match...
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
std::map< SimpleMCPrimary, SimpleMatchedPfoList > MCPrimaryMatchingMap
void GetRecoNeutrinos(const art::Event &evt, PFParticleVector &recoNeutrinoVector) const
Obtain a vector of reco neutrinos.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
void GetSimpleMCPrimaryList(const art::Event &evt, const MCParticlesToHits &mcParticlesToHits, const HitsToMCParticles &hitsToMCParticles, const MCParticleMatchingMap &mcParticleMatchingMap, SimpleMCPrimaryList &simpleMCPrimaryList) const
Extract details of each mc primary (ordered by number of true hits)
std::map< int, MatchingDetails > MatchingDetailsMap
void PrintAllOutput(const MCTruthVector &mcTruthVector, const PFParticleVector &recoNeutrinoVector, const MCPrimaryMatchingMap &mcPrimaryMatchingMap) const
Print all the raw matching output to screen.
std::string m_particleLabel
The name/label of the particle producer module.
std::vector< art::Ptr< simb::MCTruth > > MCTruthVector
static void BuildMCParticleHitMaps(const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
std::vector< SimpleMCPrimary > SimpleMCPrimaryList
bool m_printMatchingToScreen
Whether to print matching output to screen.
void GetMCTruth(const art::Event &evt, MCTruthVector &mcTruthVector) const
Obtain a vector of mc truth.
bool m_printAllToScreen
Whether to print all/raw matching details to screen.
std::string m_backtrackerLabel
The name/label of the back-tracker module.
std::vector< art::Ptr< recob::Hit > > HitVector
static void CollectHits(const art::Event &evt, const std::string &label, HitVector &hitVector)
Collect the reconstructed Hits from the ART event record.
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
std::map< art::Ptr< simb::MCParticle >, PFParticleToMatchedHits > MCParticleMatchingMap
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
void GetMCPrimaryMatchingMap(const SimpleMCPrimaryList &simpleMCPrimaryList, const MCParticleMatchingMap &mcParticleMatchingMap, const PFParticlesToHits &pfParticlesToHits, MCPrimaryMatchingMap &mcPrimaryMatchingMap) const
Obtain a sorted list of matched pfos for each mc primary.
std::string m_geantModuleLabel
The name/label of the geant module.
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
std::string m_hitfinderLabel
The name/label of the hit producer module.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::PFParticleValidation::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 369 of file PFParticleValidation_module.cc.

370 {
371 }
detail::CachedProducts& art::EventObserverBase::cachedProducts ( )
inlineprotectedinherited

Definition at line 79 of file EventObserverBase.h.

References art::EventObserverBase::selectors_.

Referenced by art::EDAnalyzer::doEvent(), and art::OutputModule::doWriteEvent().

80  {
81  return selectors_;
82  }
detail::CachedProducts selectors_
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 147 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

148 {
149  if (!moduleContext_)
150  return ProductToken<T>::invalid();
151 
152  consumables_[BT].emplace_back(ConsumableType::Product,
153  TypeID{typeid(T)},
154  it.label(),
155  it.instance(),
156  it.process());
157  return ProductToken<T>{it};
158 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 162 of file Consumer.h.

163 {
164  if (!moduleContext_)
165  return;
166 
167  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
168 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 172 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

173 {
174  if (!moduleContext_)
175  return ViewToken<T>::invalid();
176 
177  consumables_[BT].emplace_back(ConsumableType::ViewElement,
178  TypeID{typeid(T)},
179  it.label(),
180  it.instance(),
181  it.process());
182  return ViewToken<T>{it};
183 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
unsigned int lar_pandora::PFParticleValidation::CountHitsByType ( const geo::View_t  view,
const HitVector hitVector 
) const
private

Count the number of hits, in a provided vector, of a specified view.

Parameters
viewthe view
hitVectorthe hit vector
Returns
the number of hits of the specified view

Definition at line 856 of file PFParticleValidation_module.cc.

Referenced by GetMCPrimaryMatchingMap(), and GetSimpleMCPrimaryList().

857 {
858  unsigned int nHitsOfSpecifiedType(0);
859 
860  for (const art::Ptr<recob::Hit> pHit : hitVector)
861  {
862  if (view == pHit->View())
863  ++nHitsOfSpecifiedType;
864  }
865 
866  return nHitsOfSpecifiedType;
867 }
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make 
)
inherited

Definition at line 32 of file EngineCreator.cc.

References art::EngineCreator::rng().

34 {
35  return rng()->createEngine(
36  placeholder_schedule_id(), seed, kind_of_engine_to_make);
37 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
EngineCreator::base_engine_t & EngineCreator::createEngine ( seed_t  seed,
std::string const &  kind_of_engine_to_make,
label_t const &  engine_label 
)
inherited

Definition at line 40 of file EngineCreator.cc.

References art::EngineCreator::rng().

43 {
44  return rng()->createEngine(
45  placeholder_schedule_id(), seed, kind_of_engine_to_make, engine_label);
46 }
long seed
Definition: chem4.cc:68
static art::ServiceHandle< art::RandomNumberGenerator > & rng()
CurrentProcessingContext const * art::EDAnalyzer::currentContext ( ) const
protectedinherited

Definition at line 114 of file EDAnalyzer.cc.

References art::EDAnalyzer::current_context_.

Referenced by art::EDAnalyzer::workerType().

115  {
116  return current_context_.get();
117  }
CPC_exempt_ptr current_context_
Definition: EDAnalyzer.h:179
void lar_pandora::PFParticleValidation::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 375 of file PFParticleValidation_module.cc.

376 {
377 }
EngineCreator::seed_t EngineCreator::get_seed_value ( fhicl::ParameterSet const &  pset,
char const  key[] = "seed",
seed_t const  implicit_seed = -1 
)
inherited

Definition at line 49 of file EngineCreator.cc.

References fhicl::ParameterSet::get().

Referenced by art::MixFilter< T >::initEngine_().

52 {
53  auto const& explicit_seeds = pset.get<std::vector<int>>(key, {});
54  return explicit_seeds.empty() ? implicit_seed : explicit_seeds.front();
55 }
void lar_pandora::PFParticleValidation::GetMCParticleMatchingMap ( const PFParticlesToHits recoParticlesToHits,
const MCParticlesToHits trueParticlesToHits,
const HitsToMCParticles hitsToTrueParticles,
MCParticleMatchingMap mcParticleMatchingMap 
) const
private

Performing matching between true and reconstructed particles.

Parameters
recoParticlesToHitsthe mapping from reconstructed particles to hits
trueParticlesToHitsthe mapping from true particles to hits
hitsToTrueParticlesthe mapping from hits to true particles
mcParticleMatchingMapthe output matches between all reconstructed and true particles

Definition at line 433 of file PFParticleValidation_module.cc.

Referenced by analyze().

435 {
436  // Create a placeholder entry for all mc particles with >0 hits
437  for (const MCParticlesToHits::value_type &mcParticleToHitsEntry : mcParticlesToHits)
438  {
439  if (!mcParticleToHitsEntry.second.empty())
440  (void) mcParticleMatchingMap.insert(MCParticleMatchingMap::value_type(mcParticleToHitsEntry.first, PFParticleToMatchedHits()));
441  }
442 
443  // Store true to reco matching details
444  for (const PFParticlesToHits::value_type &recoParticleToHits : pfParticlesToHits)
445  {
446  const art::Ptr<recob::PFParticle> pRecoParticle(recoParticleToHits.first);
447  const HitVector &hitVector(recoParticleToHits.second);
448 
449  for (const art::Ptr<recob::Hit> pHit : hitVector)
450  {
451  HitsToMCParticles::const_iterator mcParticleIter = hitsToMCParticles.find(pHit);
452 
453  if (hitsToMCParticles.end() == mcParticleIter)
454  continue;
455 
456  const art::Ptr<simb::MCParticle> pTrueParticle = mcParticleIter->second;
457  mcParticleMatchingMap[pTrueParticle][pRecoParticle].push_back(pHit);
458  }
459  }
460 }
intermediate_table::const_iterator const_iterator
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticleToMatchedHits
std::vector< art::Ptr< recob::Hit > > HitVector
void lar_pandora::PFParticleValidation::GetMCPrimaryMatchingMap ( const SimpleMCPrimaryList simpleMCPrimaryList,
const MCParticleMatchingMap mcParticleMatchingMap,
const PFParticlesToHits pfParticlesToHits,
MCPrimaryMatchingMap mcPrimaryMatchingMap 
) const
private

Obtain a sorted list of matched pfos for each mc primary.

Parameters
simpleMCPrimaryListthe simple mc primary list
mcToFullPfoMatchingMapthe mc to full pfo matching map
pfoToHitListMapthe pfo to hit list map
mcPrimaryMatchingMapto receive the populated mc primary matching map

Definition at line 525 of file PFParticleValidation_module.cc.

References CountHitsByType(), art::Ptr< T >::get(), lar_pandora::LArPandoraHelper::IsNeutrino(), geo::kU, geo::kV, geo::kW, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_id, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsTotal, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsU, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsV, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsW, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsTotal, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsU, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsV, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsW, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_pAddress, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_parentId, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_pdgCode, recob::PFParticle::Parent(), recob::PFParticle::PdgCode(), recob::PFParticle::Self(), and SortSimpleMatchedPfos().

Referenced by analyze().

527 {
528  for (const SimpleMCPrimary &simpleMCPrimary : simpleMCPrimaryList)
529  {
530  SimpleMatchedPfoList simpleMatchedPfoList;
531  MCParticleMatchingMap::const_iterator matchedPfoIter = mcParticleMatchingMap.end();
532 
533  // ATTN Nasty workaround I
534  for (MCParticleMatchingMap::const_iterator iter = mcParticleMatchingMap.begin(), iterEnd = mcParticleMatchingMap.end(); iter != iterEnd; ++iter)
535  {
536  if (simpleMCPrimary.m_pAddress == iter->first.get())
537  {
538  matchedPfoIter = iter;
539  break;
540  };
541  }
542 
543  if (mcParticleMatchingMap.end() != matchedPfoIter)
544  {
545  for (const PFParticleToMatchedHits::value_type &contribution : matchedPfoIter->second)
546  {
547  const art::Ptr<recob::PFParticle> pMatchedPfo(contribution.first);
548  const HitVector &matchedHitVector(contribution.second);
549 
550  SimpleMatchedPfo simpleMatchedPfo;
551  simpleMatchedPfo.m_pAddress = pMatchedPfo.get();
552  simpleMatchedPfo.m_id = pMatchedPfo->Self();
553 
554  // ATTN Assume pfos have either zero or one parents. Ignore parent neutrino.
555  PFParticlesToHits::const_iterator parentPfoIter = pfParticlesToHits.end();
556 
557  // ATTN Nasty workaround II, bad place for another loop.
558  for (PFParticlesToHits::const_iterator iter = pfParticlesToHits.begin(), iterEnd = pfParticlesToHits.end(); iter != iterEnd; ++iter)
559  {
560  if (pMatchedPfo->Parent() == iter->first->Self())
561  {
562  parentPfoIter = iter;
563  break;
564  };
565  }
566 
567  if ((pfParticlesToHits.end() != parentPfoIter) && !LArPandoraHelper::IsNeutrino(parentPfoIter->first))
568  simpleMatchedPfo.m_parentId = parentPfoIter->first->Self();
569 
570  simpleMatchedPfo.m_pdgCode = pMatchedPfo->PdgCode();
571  simpleMatchedPfo.m_nMatchedHitsTotal = matchedHitVector.size();
572  simpleMatchedPfo.m_nMatchedHitsU = this->CountHitsByType(geo::kU, matchedHitVector);
573  simpleMatchedPfo.m_nMatchedHitsV = this->CountHitsByType(geo::kV, matchedHitVector);
574  simpleMatchedPfo.m_nMatchedHitsW = this->CountHitsByType(geo::kW, matchedHitVector);
575 
576  PFParticlesToHits::const_iterator pfoHitsIter = pfParticlesToHits.find(pMatchedPfo);
577 
578  if (pfParticlesToHits.end() == pfoHitsIter)
579  throw cet::exception("LArPandora") << " PFParticleValidation::analyze --- Presence of PFParticle in map mandatory.";
580 
581  const HitVector &pfoHitVector(pfoHitsIter->second);
582 
583  simpleMatchedPfo.m_nPfoHitsTotal = pfoHitVector.size();
584  simpleMatchedPfo.m_nPfoHitsU = this->CountHitsByType(geo::kU, pfoHitVector);
585  simpleMatchedPfo.m_nPfoHitsV = this->CountHitsByType(geo::kV, pfoHitVector);
586  simpleMatchedPfo.m_nPfoHitsW = this->CountHitsByType(geo::kW, pfoHitVector);
587 
588  simpleMatchedPfoList.push_back(simpleMatchedPfo);
589  }
590  }
591 
592  // Store the ordered vectors of matched pfo details
593  std::sort(simpleMatchedPfoList.begin(), simpleMatchedPfoList.end(), PFParticleValidation::SortSimpleMatchedPfos);
594 
595  if (!mcPrimaryMatchingMap.insert(MCPrimaryMatchingMap::value_type(simpleMCPrimary, simpleMatchedPfoList)).second)
596  throw cet::exception("LArPandora") << " PFParticleValidation::analyze --- Double-counting MC primaries.";
597  }
598 }
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
Planes which measure V.
Definition: geo_types.h:77
Planes which measure U.
Definition: geo_types.h:76
intermediate_table::const_iterator const_iterator
std::vector< SimpleMatchedPfo > SimpleMatchedPfoList
static bool SortSimpleMatchedPfos(const SimpleMatchedPfo &lhs, const SimpleMatchedPfo &rhs)
Sort simple matched pfos by number of matched hits.
std::vector< art::Ptr< recob::Hit > > HitVector
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:78
unsigned int CountHitsByType(const geo::View_t view, const HitVector &hitVector) const
Count the number of hits, in a provided vector, of a specified view.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
void lar_pandora::PFParticleValidation::GetMCTruth ( const art::Event evt,
MCTruthVector mcTruthVector 
) const
private

Obtain a vector of mc truth.

Parameters
evtthe event
mcNeutrinoVectorto receive the populated vector of mc truth

Definition at line 602 of file PFParticleValidation_module.cc.

References lar_pandora::LArPandoraHelper::CollectMCParticles(), m_geantModuleLabel, and simb::MCTruth::NeutrinoSet().

Referenced by analyze().

603 {
604  MCTruthToMCParticles artMCTruthToMCParticles;
605  MCParticlesToMCTruth artMCParticlesToMCTruth;
606  LArPandoraHelper::CollectMCParticles(evt, m_geantModuleLabel, artMCTruthToMCParticles, artMCParticlesToMCTruth);
607 
608  for (const auto &mapEntry : artMCTruthToMCParticles)
609  {
610  const art::Ptr<simb::MCTruth> truth = mapEntry.first;
611 
612  if (!truth->NeutrinoSet())
613  continue;
614 
615  if (mcTruthVector.end() == std::find(mcTruthVector.begin(), mcTruthVector.end(), truth))
616  mcTruthVector.push_back(truth);
617  }
618 }
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
bool NeutrinoSet() const
Definition: MCTruth.h:75
std::string m_geantModuleLabel
The name/label of the geant module.
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::PFParticleValidation::GetRecoNeutrinos ( const art::Event evt,
PFParticleVector recoNeutrinoVector 
) const
private

Obtain a vector of reco neutrinos.

Parameters
evtthe event
recoNeutrinoVectorto receive the populated vector of reco neutrinos

Definition at line 622 of file PFParticleValidation_module.cc.

References lar_pandora::LArPandoraHelper::CollectPFParticles(), m_particleLabel, and lar_pandora::LArPandoraHelper::SelectNeutrinoPFParticles().

Referenced by analyze().

623 {
624  PFParticleVector allPFParticles;
626  LArPandoraHelper::SelectNeutrinoPFParticles(allPFParticles, recoNeutrinoVector);
627 }
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::string m_particleLabel
The name/label of the particle producer module.
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
static void SelectNeutrinoPFParticles(const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
Select reconstructed neutrino particles from a list of all reconstructed particles.
void lar_pandora::PFParticleValidation::GetRemainingPfoMatches ( const MCPrimaryMatchingMap mcPrimaryMatchingMap,
const IntSet usedPfoIds,
MatchingDetailsMap matchingDetailsMap 
) const
private

Get the best matches for any pfos left-over after the strong matching procedure.

Parameters
mcPrimaryMatchingMapthe input/raw mc primary matching map
usedPfoIdsthe list of pfo ids with an existing match
matchingDetailsMapthe matching details map, to be populated

Definition at line 731 of file PFParticleValidation_module.cc.

References IsGoodMCPrimary(), lar_pandora::PFParticleValidation::MatchingDetails::m_completeness, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_id, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_id, lar_pandora::PFParticleValidation::MatchingDetails::m_matchedPrimaryId, lar_pandora::PFParticleValidation::MatchingDetails::m_nMatchedHits, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsTotal, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal, and m_useSmallPrimaries.

Referenced by PerformMatching().

733 {
734  for (const MCPrimaryMatchingMap::value_type &mapValue : mcPrimaryMatchingMap)
735  {
736  const SimpleMCPrimary &simpleMCPrimary(mapValue.first);
737 
738  if (!m_useSmallPrimaries && !this->IsGoodMCPrimary(simpleMCPrimary))
739  continue;
740 
741  for (const SimpleMatchedPfo &simpleMatchedPfo : mapValue.second)
742  {
743  if (usedPfoIds.count(simpleMatchedPfo.m_id))
744  continue;
745 
746  MatchingDetails &matchingDetails(matchingDetailsMap[simpleMatchedPfo.m_id]);
747 
748  if (simpleMatchedPfo.m_nMatchedHitsTotal > matchingDetails.m_nMatchedHits)
749  {
750  matchingDetails.m_matchedPrimaryId = simpleMCPrimary.m_id;
751  matchingDetails.m_nMatchedHits = simpleMatchedPfo.m_nMatchedHitsTotal;
752  matchingDetails.m_completeness = static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMCPrimary.m_nMCHitsTotal);
753  }
754  }
755  }
756 }
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
bool IsGoodMCPrimary(const SimpleMCPrimary &simpleMCPrimary) const
Whether a provided mc primary passes selection, based on number of "good" hits.
void lar_pandora::PFParticleValidation::GetSimpleMCPrimaryList ( const art::Event evt,
const MCParticlesToHits mcParticlesToHits,
const HitsToMCParticles hitsToMCParticles,
const MCParticleMatchingMap mcParticleMatchingMap,
SimpleMCPrimaryList simpleMCPrimaryList 
) const
private

Extract details of each mc primary (ordered by number of true hits)

Parameters
evtthe event
mcParticlesToHitsthe mc primary to hits map
hitsToMCParticlesthe hits to mc particles map
mcParticleMatchingMapthe mc to particle to pf particle matching map (to record number of matched pf particles)
simpleMCPrimaryListto receive the populated simple mc primary list

Definition at line 464 of file PFParticleValidation_module.cc.

References lar_pandora::LArPandoraHelper::CollectMCParticles(), CountHitsByType(), simb::MCParticle::E(), art::Ptr< T >::get(), IsNeutrinoInduced(), geo::kU, geo::kV, geo::kW, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_energy, m_geantModuleLabel, m_neutrinoInducedOnly, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMatchedPfos, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsU, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsV, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsW, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_pAddress, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_pdgCode, simb::MCParticle::PdgCode(), and SortSimpleMCPrimaries().

Referenced by analyze().

466 {
467  MCTruthToMCParticles artMCTruthToMCParticles;
468  MCParticlesToMCTruth artMCParticlesToMCTruth;
469  LArPandoraHelper::CollectMCParticles(evt, m_geantModuleLabel, artMCTruthToMCParticles, artMCParticlesToMCTruth);
470 
471  for (const MCParticlesToHits::value_type &mapEntry : mcParticlesToHits)
472  {
473  const art::Ptr<simb::MCParticle> pMCPrimary(mapEntry.first);
474 
475  if (m_neutrinoInducedOnly && !this->IsNeutrinoInduced(pMCPrimary, artMCParticlesToMCTruth))
476  continue;
477 
478  SimpleMCPrimary simpleMCPrimary;
479  // ATTN simpleMCPrimary.m_id assigned later, after sorting
480  simpleMCPrimary.m_pAddress = pMCPrimary.get();
481  simpleMCPrimary.m_pdgCode = pMCPrimary->PdgCode();
482  simpleMCPrimary.m_energy = pMCPrimary->E();
483 
484  MCParticlesToHits::const_iterator trueHitsIter = mcParticlesToHits.find(pMCPrimary);
485 
486  if (mcParticlesToHits.end() != trueHitsIter)
487  {
488  const HitVector &hitVector(trueHitsIter->second);
489  simpleMCPrimary.m_nMCHitsTotal = hitVector.size();
490  simpleMCPrimary.m_nMCHitsU = this->CountHitsByType(geo::kU, hitVector);
491  simpleMCPrimary.m_nMCHitsV = this->CountHitsByType(geo::kV, hitVector);
492  simpleMCPrimary.m_nMCHitsW = this->CountHitsByType(geo::kW, hitVector);
493  }
494 
495  MCParticleMatchingMap::const_iterator matchedPfoIter = mcParticleMatchingMap.find(pMCPrimary);
496 
497  if (mcParticleMatchingMap.end() != matchedPfoIter)
498  simpleMCPrimary.m_nMatchedPfos = matchedPfoIter->second.size();
499 
500  simpleMCPrimaryList.push_back(simpleMCPrimary);
501  }
502 
503  std::sort(simpleMCPrimaryList.begin(), simpleMCPrimaryList.end(), PFParticleValidation::SortSimpleMCPrimaries);
504 
505  int mcPrimaryId(0);
506  for (SimpleMCPrimary &simpleMCPrimary : simpleMCPrimaryList)
507  simpleMCPrimary.m_id = mcPrimaryId++;
508 }
bool IsNeutrinoInduced(const art::Ptr< simb::MCParticle > pMCParticle, const MCParticlesToMCTruth &artMCParticlesToMCTruth) const
Whether a mc particle is neutrino induced.
Planes which measure V.
Definition: geo_types.h:77
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
bool m_neutrinoInducedOnly
Whether to consider only mc particles that were neutrino induced.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
Planes which measure U.
Definition: geo_types.h:76
intermediate_table::const_iterator const_iterator
std::vector< art::Ptr< recob::Hit > > HitVector
static bool SortSimpleMCPrimaries(const SimpleMCPrimary &lhs, const SimpleMCPrimary &rhs)
Sort simple mc primaries by number of mc hits.
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:78
std::string m_geantModuleLabel
The name/label of the geant module.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
unsigned int CountHitsByType(const geo::View_t view, const HitVector &hitVector) const
Count the number of hits, in a provided vector, of a specified view.
Definition: fwd.h:25
bool lar_pandora::PFParticleValidation::GetStrongestPfoMatch ( const MCPrimaryMatchingMap mcPrimaryMatchingMap,
IntSet usedMCIds,
IntSet usedPfoIds,
MatchingDetailsMap matchingDetailsMap 
) const
private

Get the strongest pfo match (most matched hits) between an available mc primary and an available pfo.

Parameters
mcPrimaryMatchingMapthe input/raw mc primary matching map
usedMCIdsthe list of mc primary ids with an existing match
usedPfoIdsthe list of pfo ids with an existing match
matchingDetailsMapthe matching details map, to be populated

Definition at line 684 of file PFParticleValidation_module.cc.

References IsGoodMatch(), IsGoodMCPrimary(), lar_pandora::PFParticleValidation::MatchingDetails::m_completeness, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_id, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_id, lar_pandora::PFParticleValidation::MatchingDetails::m_matchedPrimaryId, lar_pandora::PFParticleValidation::MatchingDetails::m_nMatchedHits, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsTotal, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal, and m_useSmallPrimaries.

Referenced by PerformMatching().

686 {
687  int bestPfoMatchId(-1);
688  MatchingDetails bestMatchingDetails;
689 
690  for (const MCPrimaryMatchingMap::value_type &mapValue : mcPrimaryMatchingMap)
691  {
692  const SimpleMCPrimary &simpleMCPrimary(mapValue.first);
693 
694  if (!m_useSmallPrimaries && !this->IsGoodMCPrimary(simpleMCPrimary))
695  continue;
696 
697  if (usedMCIds.count(simpleMCPrimary.m_id))
698  continue;
699 
700  for (const SimpleMatchedPfo &simpleMatchedPfo : mapValue.second)
701  {
702  if (usedPfoIds.count(simpleMatchedPfo.m_id))
703  continue;
704 
705  if (!this->IsGoodMatch(simpleMCPrimary, simpleMatchedPfo))
706  continue;
707 
708  if (simpleMatchedPfo.m_nMatchedHitsTotal > bestMatchingDetails.m_nMatchedHits)
709  {
710  bestPfoMatchId = simpleMatchedPfo.m_id;
711  bestMatchingDetails.m_matchedPrimaryId = simpleMCPrimary.m_id;
712  bestMatchingDetails.m_nMatchedHits = simpleMatchedPfo.m_nMatchedHitsTotal;
713  bestMatchingDetails.m_completeness = static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMCPrimary.m_nMCHitsTotal);
714  }
715  }
716  }
717 
718  if (bestPfoMatchId > -1)
719  {
720  matchingDetailsMap[bestPfoMatchId] = bestMatchingDetails;
721  usedMCIds.insert(bestMatchingDetails.m_matchedPrimaryId);
722  usedPfoIds.insert(bestPfoMatchId);
723  return true;
724  }
725 
726  return false;
727 }
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
bool IsGoodMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfo &simpleMatchedPfo) const
Whether a provided mc primary and pfo are deemed to be a good match.
bool IsGoodMCPrimary(const SimpleMCPrimary &simpleMCPrimary) const
Whether a provided mc primary passes selection, based on number of "good" hits.
art::Handle<art::TriggerResults> art::EventObserverBase::getTriggerResults ( Event const &  e) const
inlineinherited

Definition at line 61 of file EventObserverBase.h.

References art::detail::CachedProducts::getOneTriggerResults(), and art::EventObserverBase::selectors_.

Referenced by art::OutputModule::doWriteEvent().

62  {
64  }
detail::CachedProducts selectors_
art::Handle< art::TriggerResults > getOneTriggerResults(Event const &) const
Float_t e
Definition: plot.C:34
bool lar_pandora::PFParticleValidation::HasMatch ( const SimpleMCPrimary simpleMCPrimary,
const SimpleMatchedPfoList simpleMatchedPfoList,
const MatchingDetailsMap matchingDetailsMap 
) const
private

Whether a provided mc primary has a match, of any quality (use simple matched pfo list and information in matching details map)

Parameters
simpleMCPrimarythe simple mc primary
simpleMatchedPfoListthe list of simple matched pfos
matchingDetailsMapthe matching details map
Returns
boolean

Definition at line 832 of file PFParticleValidation_module.cc.

References lar_pandora::PFParticleValidation::SimpleMCPrimary::m_id.

Referenced by PrintMatchingOutput().

834 {
835  for (const SimpleMatchedPfo &simpleMatchedPfo : simpleMatchedPfoList)
836  {
837  if (matchingDetailsMap.count(simpleMatchedPfo.m_id) && (simpleMCPrimary.m_id == matchingDetailsMap.at(simpleMatchedPfo.m_id).m_matchedPrimaryId))
838  return true;
839  }
840 
841  return false;
842 }
bool lar_pandora::PFParticleValidation::IsGoodMatch ( const SimpleMCPrimary simpleMCPrimary,
const SimpleMatchedPfo simpleMatchedPfo 
) const
private

Whether a provided mc primary and pfo are deemed to be a good match.

Parameters
simpleMCPrimarythe simple mc primary
simpleMatchedPfothe simple matched pfo
Returns
boolean

Definition at line 846 of file PFParticleValidation_module.cc.

References m_matchingMinCompleteness, m_matchingMinPurity, m_matchingMinSharedHits, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsTotal, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal, and lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsTotal.

Referenced by GetStrongestPfoMatch(), and PrintMatchingOutput().

847 {
848  const float purity((simpleMatchedPfo.m_nPfoHitsTotal > 0) ? static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMatchedPfo.m_nPfoHitsTotal) : 0.f);
849  const float completeness((simpleMCPrimary.m_nMCHitsTotal > 0) ? static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMCPrimary.m_nMCHitsTotal) : 0.f);
850 
851  return ((simpleMatchedPfo.m_nMatchedHitsTotal >= m_matchingMinSharedHits) && (purity >= m_matchingMinPurity) && (completeness >= m_matchingMinCompleteness));
852 }
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
float m_matchingMinPurity
The minimum particle purity to declare a match.
int m_matchingMinSharedHits
The minimum number of shared hits used in matching scheme.
bool lar_pandora::PFParticleValidation::IsGoodMCPrimary ( const SimpleMCPrimary simpleMCPrimary) const
private

Whether a provided mc primary passes selection, based on number of "good" hits.

Parameters
simpleMCPrimarythe simple mc primary
Returns
boolean

Definition at line 814 of file PFParticleValidation_module.cc.

References m_matchingMinHitsForGoodView, m_matchingMinPrimaryGoodViews, m_matchingMinPrimaryHits, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsU, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsV, and lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsW.

Referenced by GetRemainingPfoMatches(), GetStrongestPfoMatch(), and PrintMatchingOutput().

815 {
816  if (simpleMCPrimary.m_nMCHitsTotal < m_matchingMinPrimaryHits)
817  return false;
818 
819  int nGoodViews(0);
820  if (simpleMCPrimary.m_nMCHitsU >= m_matchingMinHitsForGoodView) ++nGoodViews;
821  if (simpleMCPrimary.m_nMCHitsV >= m_matchingMinHitsForGoodView) ++nGoodViews;
822  if (simpleMCPrimary.m_nMCHitsW >= m_matchingMinHitsForGoodView) ++nGoodViews;
823 
824  if (nGoodViews < m_matchingMinPrimaryGoodViews)
825  return false;
826 
827  return true;
828 }
int m_matchingMinPrimaryHits
The minimum number of good mc primary hits used in matching scheme.
int m_matchingMinPrimaryGoodViews
The minimum number of good views for a mc primary.
int m_matchingMinHitsForGoodView
The minimum number of good mc primary hits in given view to declare view to be good.
bool lar_pandora::PFParticleValidation::IsNeutrinoInduced ( const art::Ptr< simb::MCParticle pMCParticle,
const MCParticlesToMCTruth artMCParticlesToMCTruth 
) const
private

Whether a mc particle is neutrino induced.

Parameters
pMCParticleaddress of the mc particle
artMCParticlesToMCTruththe mapping from mc particles to mc truth
Returns
boolean

Definition at line 512 of file PFParticleValidation_module.cc.

References simb::kBeamNeutrino, and simb::MCTruth::Origin().

Referenced by GetSimpleMCPrimaryList().

513 {
514  MCParticlesToMCTruth::const_iterator iter = artMCParticlesToMCTruth.find(pMCParticle);
515 
516  if (artMCParticlesToMCTruth.end() == iter)
517  return false;
518 
519  const art::Ptr<simb::MCTruth> pMCTruth = iter->second;
520  return (simb::kBeamNeutrino == pMCTruth->Origin());
521 }
simb::Origin_t Origin() const
Definition: MCTruth.h:71
intermediate_table::const_iterator const_iterator
Beam neutrinos.
Definition: MCTruth.h:21
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 190 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

191 {
192  if (!moduleContext_)
193  return ProductToken<T>::invalid();
194 
195  consumables_[BT].emplace_back(ConsumableType::Product,
196  TypeID{typeid(T)},
197  it.label(),
198  it.instance(),
199  it.process());
200  return ProductToken<T>{it};
201 }
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 205 of file Consumer.h.

206 {
207  if (!moduleContext_)
208  return;
209 
210  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
211 }
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 215 of file Consumer.h.

References art::InputTag::instance(), art::InputTag::label(), and art::InputTag::process().

216 {
217  if (!moduleContext_)
218  return ViewToken<T>::invalid();
219 
220  consumables_[BT].emplace_back(ConsumableType::ViewElement,
221  TypeID{typeid(T)},
222  it.label(),
223  it.instance(),
224  it.process());
225  return ViewToken<T>{it};
226 }
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
bool art::EventObserverBase::modifiesEvent ( ) const
inlineinherited

Definition at line 25 of file EventObserverBase.h.

26  {
27  return false;
28  }
void lar_pandora::PFParticleValidation::PerformMatching ( const MCPrimaryMatchingMap mcPrimaryMatchingMap,
MatchingDetailsMap matchingDetailsMap 
) const
private

Apply a well-defined matching procedure to the comprehensive matches in the provided mc primary matching map.

Parameters
mcPrimaryMatchingMapthe input/raw mc primary matching map
matchingDetailsMapthe matching details map, to be populated

Definition at line 672 of file PFParticleValidation_module.cc.

References GetRemainingPfoMatches(), and GetStrongestPfoMatch().

Referenced by analyze().

673 {
674  // Get best matches, one-by-one, until no more strong matches possible
675  IntSet usedMCIds, usedPfoIds;
676  while (GetStrongestPfoMatch(mcPrimaryMatchingMap, usedMCIds, usedPfoIds, matchingDetailsMap)) {}
677 
678  // Assign any remaining pfos to primaries, based on number of matched hits
679  GetRemainingPfoMatches(mcPrimaryMatchingMap, usedPfoIds, matchingDetailsMap);
680 }
bool GetStrongestPfoMatch(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, IntSet &usedMCIds, IntSet &usedPfoIds, MatchingDetailsMap &matchingDetailsMap) const
Get the strongest pfo match (most matched hits) between an available mc primary and an available pfo...
void GetRemainingPfoMatches(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const IntSet &usedPfoIds, MatchingDetailsMap &matchingDetailsMap) const
Get the best matches for any pfos left-over after the strong matching procedure.
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited

Definition at line 89 of file Consumer.cc.

References fhicl::ParameterSet::get_if_present().

Referenced by art::EDProducer::doBeginJob(), art::EDFilter::doBeginJob(), and art::EDAnalyzer::doBeginJob().

90 {
91  if (!moduleContext_)
92  return;
93 
94  pset.get_if_present("errorOnMissingConsumes", requireConsumes_);
95  for (auto& consumablesPerBranch : consumables_) {
96  cet::sort_all(consumablesPerBranch);
97  }
98 }
bool requireConsumes_
Definition: Consumer.h:137
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
void lar_pandora::PFParticleValidation::PrintAllOutput ( const MCTruthVector mcTruthVector,
const PFParticleVector recoNeutrinoVector,
const MCPrimaryMatchingMap mcPrimaryMatchingMap 
) const
private

Print all the raw matching output to screen.

Parameters
mcTruthVectorthe mc truth vector
recoNeutrinoVectorthe reco neutrino vector
mcPrimaryMatchingMapthe input/raw mc primary matching map

Definition at line 631 of file PFParticleValidation_module.cc.

References lar_pandora::PFParticleValidation::SimpleMCPrimary::m_id, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_id, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsTotal, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsU, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsV, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsW, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsU, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsV, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsW, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsTotal, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsU, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsV, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsW, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_parentId, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_pdgCode, and lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_pdgCode.

Referenced by analyze().

633 {
634  std::cout << "---RAW-MATCHING-OUTPUT--------------------------------------------------------------------------" << std::endl;
635 
636  for (const art::Ptr<simb::MCTruth> pMCTruth : mcTruthVector)
637  {
638  std::cout << "MCNeutrino, PDG " << pMCTruth->GetNeutrino().Nu().PdgCode() << ", InteractionType " << pMCTruth->GetNeutrino().InteractionType() << std::endl;
639  }
640 
641  for (const art::Ptr<recob::PFParticle> pPfo : recoNeutrinoVector)
642  {
643  std::cout << "RecoNeutrino, PDG " << pPfo->PdgCode() << ", nDaughters " << pPfo->NumDaughters() << std::endl;
644  }
645 
646  for (const MCPrimaryMatchingMap::value_type &mapValue : mcPrimaryMatchingMap)
647  {
648  const SimpleMCPrimary &simpleMCPrimary(mapValue.first);
649 
650  std::cout << std::endl << "Primary " << simpleMCPrimary.m_id << ", PDG " << simpleMCPrimary.m_pdgCode << ", nMCHits " << simpleMCPrimary.m_nMCHitsTotal
651  << " (" << simpleMCPrimary.m_nMCHitsU << ", " << simpleMCPrimary.m_nMCHitsV << ", " << simpleMCPrimary.m_nMCHitsW << ")" << std::endl;
652 
653  for (const SimpleMatchedPfo &simpleMatchedPfo : mapValue.second)
654  {
655  std::cout << "-MatchedPfo " << simpleMatchedPfo.m_id;
656 
657  if (simpleMatchedPfo.m_parentId >= 0)
658  std::cout << ", ParentPfo " << simpleMatchedPfo.m_parentId;
659 
660  std::cout << ", PDG " << simpleMatchedPfo.m_pdgCode << ", nMatchedHits " << simpleMatchedPfo.m_nMatchedHitsTotal
661  << " (" << simpleMatchedPfo.m_nMatchedHitsU << ", " << simpleMatchedPfo.m_nMatchedHitsV << ", " << simpleMatchedPfo.m_nMatchedHitsW << ")"
662  << ", nPfoHits " << simpleMatchedPfo.m_nPfoHitsTotal << " (" << simpleMatchedPfo.m_nPfoHitsU << ", " << simpleMatchedPfo.m_nPfoHitsV << ", "
663  << simpleMatchedPfo.m_nPfoHitsW << ")" << std::endl;
664  }
665  }
666 
667  std::cout << "------------------------------------------------------------------------------------------------" << std::endl;
668 }
void lar_pandora::PFParticleValidation::PrintMatchingOutput ( const MCPrimaryMatchingMap mcPrimaryMatchingMap,
const MatchingDetailsMap matchingDetailsMap 
) const
private

Print the results of the matching procedure.

Parameters
mcPrimaryMatchingMapthe input/raw mc primary matching map
matchingDetailsMapthe matching details map

Definition at line 760 of file PFParticleValidation_module.cc.

References HasMatch(), if(), IsGoodMatch(), IsGoodMCPrimary(), lar_pandora::PFParticleValidation::SimpleMCPrimary::m_id, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_id, m_matchingMinCompleteness, m_matchingMinHitsForGoodView, m_matchingMinPrimaryGoodViews, m_matchingMinPrimaryHits, m_matchingMinPurity, m_matchingMinSharedHits, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsTotal, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsU, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsV, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsW, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsU, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsV, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsW, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsTotal, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsU, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsV, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsW, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_parentId, lar_pandora::PFParticleValidation::SimpleMCPrimary::m_pdgCode, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_pdgCode, and m_useSmallPrimaries.

Referenced by analyze().

761 {
762  std::cout << "---PROCESSED-MATCHING-OUTPUT--------------------------------------------------------------------" << std::endl;
763  std::cout << "MinPrimaryGoodHits " << m_matchingMinPrimaryHits << ", MinHitsForGoodView " << m_matchingMinHitsForGoodView << ", MinPrimaryGoodViews " << m_matchingMinPrimaryGoodViews << std::endl;
764  std::cout << "UseSmallPrimaries " << m_useSmallPrimaries << ", MinSharedHits " << m_matchingMinSharedHits << ", MinCompleteness " << m_matchingMinCompleteness << ", MinPurity " << m_matchingMinPurity << std::endl;
765 
766  bool isCorrect(true), isCalculable(false);
767 
768  for (const MCPrimaryMatchingMap::value_type &mapValue : mcPrimaryMatchingMap)
769  {
770  const SimpleMCPrimary &simpleMCPrimary(mapValue.first);
771  const bool hasMatch(this->HasMatch(simpleMCPrimary, mapValue.second, matchingDetailsMap));
772  const bool isTargetPrimary(this->IsGoodMCPrimary(simpleMCPrimary) && (2112 != simpleMCPrimary.m_pdgCode));
773 
774  if (!hasMatch && !isTargetPrimary)
775  continue;
776 
777  std::cout << std::endl << (!isTargetPrimary ? "(Non target) " : "")
778  << "Primary " << simpleMCPrimary.m_id << ", PDG " << simpleMCPrimary.m_pdgCode << ", nMCHits " << simpleMCPrimary.m_nMCHitsTotal
779  << " (" << simpleMCPrimary.m_nMCHitsU << ", " << simpleMCPrimary.m_nMCHitsV << ", " << simpleMCPrimary.m_nMCHitsW << ")" << std::endl;
780 
781  if (2112 != simpleMCPrimary.m_pdgCode)
782  isCalculable = true;
783 
784  unsigned int nMatches(0);
785 
786  for (const SimpleMatchedPfo &simpleMatchedPfo : mapValue.second)
787  {
788  if (matchingDetailsMap.count(simpleMatchedPfo.m_id) && (simpleMCPrimary.m_id == matchingDetailsMap.at(simpleMatchedPfo.m_id).m_matchedPrimaryId))
789  {
790  const bool isGoodMatch(this->IsGoodMatch(simpleMCPrimary, simpleMatchedPfo));
791 
792  if (isGoodMatch) ++nMatches;
793  std::cout << "-" << (!isGoodMatch ? "(Below threshold) " : "") << "MatchedPfo " << simpleMatchedPfo.m_id;
794 
795  if (simpleMatchedPfo.m_parentId >= 0) std::cout << ", ParentPfo " << simpleMatchedPfo.m_parentId;
796 
797  std::cout << ", PDG " << simpleMatchedPfo.m_pdgCode << ", nMatchedHits " << simpleMatchedPfo.m_nMatchedHitsTotal
798  << " (" << simpleMatchedPfo.m_nMatchedHitsU << ", " << simpleMatchedPfo.m_nMatchedHitsV << ", " << simpleMatchedPfo.m_nMatchedHitsW << ")"
799  << ", nPfoHits " << simpleMatchedPfo.m_nPfoHitsTotal
800  << " (" << simpleMatchedPfo.m_nPfoHitsU << ", " << simpleMatchedPfo.m_nPfoHitsV << ", " << simpleMatchedPfo.m_nPfoHitsW << ")" << std::endl;
801  }
802  }
803 
804  if (isTargetPrimary && (1 != nMatches))
805  isCorrect = false;
806  }
807 
808  std::cout << std::endl << "Is correct? " << (isCorrect && isCalculable) << std::endl;
809  std::cout << "------------------------------------------------------------------------------------------------" << std::endl;
810 }
bool HasMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfoList &simpleMatchedPfoList, const MatchingDetailsMap &matchingDetailsMap) const
Whether a provided mc primary has a match, of any quality (use simple matched pfo list and informatio...
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
int m_matchingMinPrimaryHits
The minimum number of good mc primary hits used in matching scheme.
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
if(nlines<=0)
bool IsGoodMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfo &simpleMatchedPfo) const
Whether a provided mc primary and pfo are deemed to be a good match.
float m_matchingMinPurity
The minimum particle purity to declare a match.
int m_matchingMinSharedHits
The minimum number of shared hits used in matching scheme.
int m_matchingMinPrimaryGoodViews
The minimum number of good views for a mc primary.
bool IsGoodMCPrimary(const SimpleMCPrimary &simpleMCPrimary) const
Whether a provided mc primary passes selection, based on number of "good" hits.
int m_matchingMinHitsForGoodView
The minimum number of good mc primary hits in given view to declare view to be good.
std::string const& art::EventObserverBase::processName ( ) const
inlineinherited
void lar_pandora::PFParticleValidation::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 349 of file PFParticleValidation_module.cc.

References fhicl::ParameterSet::get(), m_backtrackerLabel, m_geantModuleLabel, m_hitfinderLabel, m_matchingMinCompleteness, m_matchingMinHitsForGoodView, m_matchingMinPrimaryGoodViews, m_matchingMinPrimaryHits, m_matchingMinPurity, m_matchingMinSharedHits, m_neutrinoInducedOnly, m_particleLabel, m_printAllToScreen, m_printMatchingToScreen, and m_useSmallPrimaries.

Referenced by PFParticleValidation().

350 {
351  m_particleLabel = pset.get<std::string>("PFParticleModule", "pandoraNu");
352  m_hitfinderLabel = pset.get<std::string>("HitFinderModule", "gaushit");
353  m_geantModuleLabel = pset.get<std::string>("GeantModule","largeant");
354  m_backtrackerLabel = pset.get<std::string>("BackTrackerModule","gaushitTruthMatch");
355  m_printAllToScreen = pset.get<bool>("PrintAllToScreen", true);
356  m_printMatchingToScreen = pset.get<bool>("PrintMatchingToScreen", true);
357  m_neutrinoInducedOnly = pset.get<bool>("NeutrinoInducedOnly", true);
358  m_matchingMinPrimaryHits = pset.get<int>("MatchingMinPrimaryHits", 15);
359  m_matchingMinHitsForGoodView = pset.get<int>("MatchingMinHitsForGoodView", 5);
360  m_matchingMinPrimaryGoodViews = pset.get<int>("MatchingMinPrimaryGoodViews", 2);
361  m_useSmallPrimaries = pset.get<bool>("UseSmallPrimaries", true);
362  m_matchingMinSharedHits = pset.get<int>("MatchingMinSharedHits", 5);
363  m_matchingMinCompleteness = pset.get<float>("MatchingMinCompleteness", 0.1f);
364  m_matchingMinPurity = pset.get<float>("MatchingMinPurity", 0.5f);
365 }
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
bool m_neutrinoInducedOnly
Whether to consider only mc particles that were neutrino induced.
int m_matchingMinPrimaryHits
The minimum number of good mc primary hits used in matching scheme.
std::string m_particleLabel
The name/label of the particle producer module.
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
bool m_printMatchingToScreen
Whether to print matching output to screen.
bool m_printAllToScreen
Whether to print all/raw matching details to screen.
float m_matchingMinPurity
The minimum particle purity to declare a match.
std::string m_backtrackerLabel
The name/label of the back-tracker module.
int m_matchingMinSharedHits
The minimum number of shared hits used in matching scheme.
int m_matchingMinPrimaryGoodViews
The minimum number of good views for a mc primary.
int m_matchingMinHitsForGoodView
The minimum number of good mc primary hits in given view to declare view to be good.
std::string m_geantModuleLabel
The name/label of the geant module.
std::string m_hitfinderLabel
The name/label of the hit producer module.
void art::EventObserverBase::registerProducts ( MasterProductRegistry ,
ProductDescriptions ,
ModuleDescription const &   
)
inlineinherited

Definition at line 33 of file EventObserverBase.h.

36  {}
fhicl::ParameterSetID art::EventObserverBase::selectorConfig ( ) const
inlineinherited

Definition at line 56 of file EventObserverBase.h.

References art::EventObserverBase::selector_config_id_.

Referenced by art::RootOutputFile::writeOne().

57  {
58  return selector_config_id_;
59  }
fhicl::ParameterSetID selector_config_id_
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Definition at line 125 of file Consumer.cc.

Referenced by art::EDProducer::doEndJob(), art::EDFilter::doEndJob(), art::EDAnalyzer::doEndJob(), and art::RootOutput::endJob().

126 {
127  if (!moduleContext_)
128  return;
129 
130  // If none of the branches have missing consumes statements, exit early.
131  if (std::all_of(cbegin(missingConsumes_),
132  cend(missingConsumes_),
133  [](auto const& perBranch) { return perBranch.empty(); }))
134  return;
135 
136  constexpr cet::HorizontalRule rule{60};
137  mf::LogPrint log{"MTdiagnostics"};
138  log << '\n'
139  << rule('=') << '\n'
140  << "The following consumes (or mayConsume) statements are missing from\n"
141  << module_context(moduleDescription_) << '\n'
142  << rule('-') << '\n';
143 
144  cet::for_all_with_index(
145  missingConsumes_, [&log](std::size_t const i, auto const& perBranch) {
146  for (auto const& pi : perBranch) {
147  log << " "
148  << assemble_consumes_statement(static_cast<BranchType>(i), pi)
149  << '\n';
150  }
151  });
152  log << rule('=');
153 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
bool lar_pandora::PFParticleValidation::SortSimpleMatchedPfos ( const SimpleMatchedPfo lhs,
const SimpleMatchedPfo rhs 
)
staticprivate

Sort simple matched pfos by number of matched hits.

Parameters
lhsthe left-hand side
rhsthe right-hand side
Returns
boolean

Definition at line 881 of file PFParticleValidation_module.cc.

References lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_id, lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nMatchedHitsTotal, and lar_pandora::PFParticleValidation::SimpleMatchedPfo::m_nPfoHitsTotal.

Referenced by GetMCPrimaryMatchingMap().

882 {
883  if (lhs.m_nMatchedHitsTotal != rhs.m_nMatchedHitsTotal)
884  return (lhs.m_nMatchedHitsTotal > rhs.m_nMatchedHitsTotal);
885 
886  if (lhs.m_nPfoHitsTotal != rhs.m_nPfoHitsTotal)
887  return (lhs.m_nPfoHitsTotal > rhs.m_nPfoHitsTotal);
888 
889  return (lhs.m_id < rhs.m_id);
890 }
bool lar_pandora::PFParticleValidation::SortSimpleMCPrimaries ( const SimpleMCPrimary lhs,
const SimpleMCPrimary rhs 
)
staticprivate

Sort simple mc primaries by number of mc hits.

Parameters
lhsthe left-hand side
rhsthe right-hand side
Returns
boolean

Definition at line 871 of file PFParticleValidation_module.cc.

References lar_pandora::PFParticleValidation::SimpleMCPrimary::m_energy, and lar_pandora::PFParticleValidation::SimpleMCPrimary::m_nMCHitsTotal.

Referenced by GetSimpleMCPrimaryList().

872 {
873  if (lhs.m_nMCHitsTotal != rhs.m_nMCHitsTotal)
874  return (lhs.m_nMCHitsTotal > rhs.m_nMCHitsTotal);
875 
876  return (lhs.m_energy > rhs.m_energy);
877 }
void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited

Definition at line 101 of file Consumer.cc.

References art::errors::ProductRegistrationFailure.

103 {
104  // Early exits if consumes tracking has been disabled or if the
105  // consumed product is an allowed consumable.
106  if (!moduleContext_)
107  return;
108 
109  if (cet::binary_search_all(consumables_[bt], pi))
110  return;
111 
112  if (requireConsumes_) {
114  "Consumer: an error occurred during validation of a "
115  "retrieved product\n\n")
116  << "The following consumes (or mayConsume) statement is missing from\n"
117  << module_context(moduleDescription_) << ":\n\n"
118  << " " << assemble_consumes_statement(bt, pi) << "\n\n";
119  }
120 
121  missingConsumes_[bt].insert(pi);
122 }
cet::exempt_ptr< ModuleDescription const > moduleDescription_
Definition: Consumer.h:140
bool requireConsumes_
Definition: Consumer.h:137
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
constexpr T pi()
Returns the constant pi (up to 35 decimal digits of precision)
ConsumableProducts consumables_
Definition: Consumer.h:138
bool moduleContext_
Definition: Consumer.h:136
ConsumableProductSets missingConsumes_
Definition: Consumer.h:139
bool art::EventObserverBase::wantAllEvents ( ) const
inlineinherited
bool art::EventObserverBase::wantEvent ( Event const &  e)
inlineinherited
std::string art::EDAnalyzer::workerType ( ) const
inlineinherited

Definition at line 109 of file EDAnalyzer.h.

References art::EDAnalyzer::currentContext().

110  {
111  return "WorkerT<EDAnalyzer>";
112  }

Member Data Documentation

std::string lar_pandora::PFParticleValidation::m_backtrackerLabel
private

The name/label of the back-tracker module.

Definition at line 295 of file PFParticleValidation_module.cc.

Referenced by analyze(), and reconfigure().

std::string lar_pandora::PFParticleValidation::m_geantModuleLabel
private

The name/label of the geant module.

Definition at line 294 of file PFParticleValidation_module.cc.

Referenced by analyze(), GetMCTruth(), GetSimpleMCPrimaryList(), and reconfigure().

std::string lar_pandora::PFParticleValidation::m_hitfinderLabel
private

The name/label of the hit producer module.

Definition at line 292 of file PFParticleValidation_module.cc.

Referenced by analyze(), and reconfigure().

float lar_pandora::PFParticleValidation::m_matchingMinCompleteness
private

The minimum particle completeness to declare a match.

Definition at line 308 of file PFParticleValidation_module.cc.

Referenced by IsGoodMatch(), PrintMatchingOutput(), and reconfigure().

int lar_pandora::PFParticleValidation::m_matchingMinHitsForGoodView
private

The minimum number of good mc primary hits in given view to declare view to be good.

Definition at line 303 of file PFParticleValidation_module.cc.

Referenced by IsGoodMCPrimary(), PrintMatchingOutput(), and reconfigure().

int lar_pandora::PFParticleValidation::m_matchingMinPrimaryGoodViews
private

The minimum number of good views for a mc primary.

Definition at line 304 of file PFParticleValidation_module.cc.

Referenced by IsGoodMCPrimary(), PrintMatchingOutput(), and reconfigure().

int lar_pandora::PFParticleValidation::m_matchingMinPrimaryHits
private

The minimum number of good mc primary hits used in matching scheme.

Definition at line 302 of file PFParticleValidation_module.cc.

Referenced by IsGoodMCPrimary(), PrintMatchingOutput(), and reconfigure().

float lar_pandora::PFParticleValidation::m_matchingMinPurity
private

The minimum particle purity to declare a match.

Definition at line 309 of file PFParticleValidation_module.cc.

Referenced by IsGoodMatch(), PrintMatchingOutput(), and reconfigure().

int lar_pandora::PFParticleValidation::m_matchingMinSharedHits
private

The minimum number of shared hits used in matching scheme.

Definition at line 307 of file PFParticleValidation_module.cc.

Referenced by IsGoodMatch(), PrintMatchingOutput(), and reconfigure().

bool lar_pandora::PFParticleValidation::m_neutrinoInducedOnly
private

Whether to consider only mc particles that were neutrino induced.

Definition at line 300 of file PFParticleValidation_module.cc.

Referenced by GetSimpleMCPrimaryList(), and reconfigure().

std::string lar_pandora::PFParticleValidation::m_particleLabel
private

The name/label of the particle producer module.

Definition at line 293 of file PFParticleValidation_module.cc.

Referenced by analyze(), GetRecoNeutrinos(), and reconfigure().

bool lar_pandora::PFParticleValidation::m_printAllToScreen
private

Whether to print all/raw matching details to screen.

Definition at line 297 of file PFParticleValidation_module.cc.

Referenced by analyze(), and reconfigure().

bool lar_pandora::PFParticleValidation::m_printMatchingToScreen
private

Whether to print matching output to screen.

Definition at line 298 of file PFParticleValidation_module.cc.

Referenced by analyze(), and reconfigure().

bool lar_pandora::PFParticleValidation::m_useSmallPrimaries
private

Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.

Definition at line 306 of file PFParticleValidation_module.cc.

Referenced by GetRemainingPfoMatches(), GetStrongestPfoMatch(), PrintMatchingOutput(), and reconfigure().


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