Classes | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
lar_pandora::PFParticleValidation Class Reference

PFParticleValidation class. More...

Inheritance diagram for lar_pandora::PFParticleValidation:
art::EDAnalyzer art::detail::Analyzer art::detail::LegacyModule art::Observer art::ModuleBase

Classes

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

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)
 
- Public Member Functions inherited from art::EDAnalyzer
 EDAnalyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDAnalyzer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Analyzer
virtual ~Analyzer () noexcept
 
 Analyzer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 Analyzer (Table< Config > const &config)
 
void doBeginJob (SharedResources const &resources)
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Observer
 ~Observer () noexcept
 
 Observer (Observer const &)=delete
 
 Observer (Observer &&)=delete
 
Observeroperator= (Observer const &)=delete
 
Observeroperator= (Observer &&)=delete
 
void registerProducts (ProductDescriptions &, ModuleDescription const &)
 
void fillDescriptions (ModuleDescription const &)
 
fhicl::ParameterSetID selectorConfig () const
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

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...
 

Additional Inherited Members

- Public Types inherited from art::EDAnalyzer
using WorkerType = WorkerT< EDAnalyzer >
 
using ModuleType = EDAnalyzer
 
- Protected Member Functions inherited from art::Observer
std::string const & processName () const
 
bool wantAllEvents () const noexcept
 
bool wantEvent (ScheduleID id, Event const &e) const
 
Handle< TriggerResultsgetTriggerResults (Event const &e) const
 
 Observer (fhicl::ParameterSet const &config)
 
 Observer (std::vector< std::string > const &select_paths, std::vector< std::string > const &reject_paths, fhicl::ParameterSet const &config)
 
- Protected Member Functions inherited from art::ModuleBase
ConsumesCollectorconsumesCollector ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 

Detailed Description

PFParticleValidation class.

Definition at line 24 of file PFParticleValidation_module.cc.

Member Typedef Documentation

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

Definition at line 204 of file PFParticleValidation_module.cc.

Definition at line 121 of file PFParticleValidation_module.cc.

Definition at line 125 of file PFParticleValidation_module.cc.

Definition at line 122 of file PFParticleValidation_module.cc.

Definition at line 124 of file PFParticleValidation_module.cc.

Definition at line 103 of file PFParticleValidation_module.cc.

Definition at line 76 of file PFParticleValidation_module.cc.

Constructor & Destructor Documentation

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

Constructor.

Parameters
pset

Definition at line 336 of file PFParticleValidation_module.cc.

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

Destructor.

Definition at line 344 of file PFParticleValidation_module.cc.

345 {
346 }

Member Function Documentation

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

Definition at line 382 of file PFParticleValidation_module.cc.

383 {
384  HitVector hitVector;
386 
387  PFParticlesToHits pfParticlesToHits;
388  HitsToPFParticles hitsToPfParticles;
390 
391  MCParticlesToHits mcParticlesToHits;
392  HitsToMCParticles hitsToMCParticles;
393 
395  mcParticlesToHits, hitsToMCParticles, LArPandoraHelper::kAddDaughters);
396 
397  if (hitsToMCParticles.empty())
398  {
399  if (m_backtrackerLabel.empty())
400  throw cet::exception("LArPandora") << " PFParticleValidation::analyze - no sim channels found, backtracker module must be set in FHiCL " << std::endl;
401 
403  mcParticlesToHits, hitsToMCParticles, LArPandoraHelper::kAddDaughters);
404  }
405 
406  MCParticleMatchingMap mcParticleMatchingMap;
407  this->GetMCParticleMatchingMap(pfParticlesToHits, mcParticlesToHits, hitsToMCParticles, mcParticleMatchingMap);
408 
409  SimpleMCPrimaryList simpleMCPrimaryList;
410  this->GetSimpleMCPrimaryList(evt, mcParticlesToHits, hitsToMCParticles, mcParticleMatchingMap, simpleMCPrimaryList);
411 
412  MCPrimaryMatchingMap mcPrimaryMatchingMap;
413  this->GetMCPrimaryMatchingMap(simpleMCPrimaryList, mcParticleMatchingMap, pfParticlesToHits, mcPrimaryMatchingMap);
414 
415  MCTruthVector mcTruthVector;
416  this->GetMCTruth(evt, mcTruthVector);
417 
418  PFParticleVector recoNeutrinoVector;
419  this->GetRecoNeutrinos(evt, recoNeutrinoVector);
420 
421  if (m_printAllToScreen)
422  this->PrintAllOutput(mcTruthVector, recoNeutrinoVector, mcPrimaryMatchingMap);
423 
425  {
426  MatchingDetailsMap matchingDetailsMap;
427  this->PerformMatching(mcPrimaryMatchingMap, matchingDetailsMap);
428  this->PrintMatchingOutput(mcPrimaryMatchingMap, matchingDetailsMap);
429  }
430 }
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.
std::vector< art::Ptr< simb::MCTruth > > MCTruthVector
void GetMCParticleMatchingMap(const PFParticlesToHits &recoParticlesToHits, const MCParticlesToHits &trueParticlesToHits, const HitsToMCParticles &hitsToTrueParticles, MCParticleMatchingMap &mcParticleMatchingMap) const
Performing matching between true and reconstructed particles.
std::map< art::Ptr< recob::Hit >, art::Ptr< simb::MCParticle > > HitsToMCParticles
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< SimpleMCPrimary, SimpleMatchedPfoList > MCPrimaryMatchingMap
void GetRecoNeutrinos(const art::Event &evt, PFParticleVector &recoNeutrinoVector) const
Obtain a vector of reco neutrinos.
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< 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.
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
bool m_printAllToScreen
Whether to print all/raw matching details to screen.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::string m_backtrackerLabel
The name/label of the back-tracker module.
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
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< simb::MCParticle >, PFParticleToMatchedHits > MCParticleMatchingMap
std::vector< art::Ptr< recob::Hit > > HitVector
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
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.
static void BuildMCParticleHitMaps(const art::Event &evt, const HitVector &hitVector, const SimChannelVector &simChannelVector, HitsToTrackIDEs &hitsToTrackIDEs)
Collect the links from reconstructed hits to their true energy deposits.
std::string m_hitfinderLabel
The name/label of the hit producer module.
cet::coded_exception< error, detail::translate > exception
Definition: exception.h:33
QTextStream & endl(QTextStream &s)
void lar_pandora::PFParticleValidation::beginJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 370 of file PFParticleValidation_module.cc.

371 {
372 }
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 857 of file PFParticleValidation_module.cc.

858 {
859  unsigned int nHitsOfSpecifiedType(0);
860 
861  for (const art::Ptr<recob::Hit> pHit : hitVector)
862  {
863  if (view == pHit->View())
864  ++nHitsOfSpecifiedType;
865  }
866 
867  return nHitsOfSpecifiedType;
868 }
void lar_pandora::PFParticleValidation::endJob ( )
virtual

Reimplemented from art::EDAnalyzer.

Definition at line 376 of file PFParticleValidation_module.cc.

377 {
378 }
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 434 of file PFParticleValidation_module.cc.

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

528 {
529  for (const SimpleMCPrimary &simpleMCPrimary : simpleMCPrimaryList)
530  {
531  SimpleMatchedPfoList simpleMatchedPfoList;
532  MCParticleMatchingMap::const_iterator matchedPfoIter = mcParticleMatchingMap.end();
533 
534  // ATTN Nasty workaround I
535  for (MCParticleMatchingMap::const_iterator iter = mcParticleMatchingMap.begin(), iterEnd = mcParticleMatchingMap.end(); iter != iterEnd; ++iter)
536  {
537  if (simpleMCPrimary.m_pAddress == iter->first.get())
538  {
539  matchedPfoIter = iter;
540  break;
541  };
542  }
543 
544  if (mcParticleMatchingMap.end() != matchedPfoIter)
545  {
546  for (const PFParticleToMatchedHits::value_type &contribution : matchedPfoIter->second)
547  {
548  const art::Ptr<recob::PFParticle> pMatchedPfo(contribution.first);
549  const HitVector &matchedHitVector(contribution.second);
550 
551  SimpleMatchedPfo simpleMatchedPfo;
552  simpleMatchedPfo.m_pAddress = pMatchedPfo.get();
553  simpleMatchedPfo.m_id = pMatchedPfo->Self();
554 
555  // ATTN Assume pfos have either zero or one parents. Ignore parent neutrino.
556  PFParticlesToHits::const_iterator parentPfoIter = pfParticlesToHits.end();
557 
558  // ATTN Nasty workaround II, bad place for another loop.
559  for (PFParticlesToHits::const_iterator iter = pfParticlesToHits.begin(), iterEnd = pfParticlesToHits.end(); iter != iterEnd; ++iter)
560  {
561  if (pMatchedPfo->Parent() == iter->first->Self())
562  {
563  parentPfoIter = iter;
564  break;
565  };
566  }
567 
568  if ((pfParticlesToHits.end() != parentPfoIter) && !LArPandoraHelper::IsNeutrino(parentPfoIter->first))
569  simpleMatchedPfo.m_parentId = parentPfoIter->first->Self();
570 
571  simpleMatchedPfo.m_pdgCode = pMatchedPfo->PdgCode();
572  simpleMatchedPfo.m_nMatchedHitsTotal = matchedHitVector.size();
573  simpleMatchedPfo.m_nMatchedHitsU = this->CountHitsByType(geo::kU, matchedHitVector);
574  simpleMatchedPfo.m_nMatchedHitsV = this->CountHitsByType(geo::kV, matchedHitVector);
575  simpleMatchedPfo.m_nMatchedHitsW = this->CountHitsByType(geo::kW, matchedHitVector);
576 
577  PFParticlesToHits::const_iterator pfoHitsIter = pfParticlesToHits.find(pMatchedPfo);
578 
579  if (pfParticlesToHits.end() == pfoHitsIter)
580  throw cet::exception("LArPandora") << " PFParticleValidation::analyze --- Presence of PFParticle in map mandatory.";
581 
582  const HitVector &pfoHitVector(pfoHitsIter->second);
583 
584  simpleMatchedPfo.m_nPfoHitsTotal = pfoHitVector.size();
585  simpleMatchedPfo.m_nPfoHitsU = this->CountHitsByType(geo::kU, pfoHitVector);
586  simpleMatchedPfo.m_nPfoHitsV = this->CountHitsByType(geo::kV, pfoHitVector);
587  simpleMatchedPfo.m_nPfoHitsW = this->CountHitsByType(geo::kW, pfoHitVector);
588 
589  simpleMatchedPfoList.push_back(simpleMatchedPfo);
590  }
591  }
592 
593  // Store the ordered vectors of matched pfo details
594  std::sort(simpleMatchedPfoList.begin(), simpleMatchedPfoList.end(), PFParticleValidation::SortSimpleMatchedPfos);
595 
596  if (!mcPrimaryMatchingMap.insert(MCPrimaryMatchingMap::value_type(simpleMCPrimary, simpleMatchedPfoList)).second)
597  throw cet::exception("LArPandora") << " PFParticleValidation::analyze --- Double-counting MC primaries.";
598  }
599 }
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:130
intermediate_table::const_iterator const_iterator
Planes which measure U.
Definition: geo_types.h:129
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:131
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 603 of file PFParticleValidation_module.cc.

604 {
605  MCTruthToMCParticles artMCTruthToMCParticles;
606  MCParticlesToMCTruth artMCParticlesToMCTruth;
607  LArPandoraHelper::CollectMCParticles(evt, m_geantModuleLabel, artMCTruthToMCParticles, artMCParticlesToMCTruth);
608 
609  for (const auto &mapEntry : artMCTruthToMCParticles)
610  {
611  const art::Ptr<simb::MCTruth> truth = mapEntry.first;
612 
613  if (!truth->NeutrinoSet())
614  continue;
615 
616  if (mcTruthVector.end() == std::find(mcTruthVector.begin(), mcTruthVector.end(), truth))
617  mcTruthVector.push_back(truth);
618  }
619 }
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
bool NeutrinoSet() const
Definition: MCTruth.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.
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 623 of file PFParticleValidation_module.cc.

624 {
625  PFParticleVector allPFParticles;
627  LArPandoraHelper::SelectNeutrinoPFParticles(allPFParticles, recoNeutrinoVector);
628 }
std::string m_particleLabel
The name/label of the particle producer module.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
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 732 of file PFParticleValidation_module.cc.

734 {
735  for (const MCPrimaryMatchingMap::value_type &mapValue : mcPrimaryMatchingMap)
736  {
737  const SimpleMCPrimary &simpleMCPrimary(mapValue.first);
738 
739  if (!m_useSmallPrimaries && !this->IsGoodMCPrimary(simpleMCPrimary))
740  continue;
741 
742  for (const SimpleMatchedPfo &simpleMatchedPfo : mapValue.second)
743  {
744  if (usedPfoIds.count(simpleMatchedPfo.m_id))
745  continue;
746 
747  MatchingDetails &matchingDetails(matchingDetailsMap[simpleMatchedPfo.m_id]);
748 
749  if (simpleMatchedPfo.m_nMatchedHitsTotal > matchingDetails.m_nMatchedHits)
750  {
751  matchingDetails.m_matchedPrimaryId = simpleMCPrimary.m_id;
752  matchingDetails.m_nMatchedHits = simpleMatchedPfo.m_nMatchedHitsTotal;
753  matchingDetails.m_completeness = static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMCPrimary.m_nMCHitsTotal);
754  }
755  }
756  }
757 }
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 465 of file PFParticleValidation_module.cc.

467 {
468  MCTruthToMCParticles artMCTruthToMCParticles;
469  MCParticlesToMCTruth artMCParticlesToMCTruth;
470  LArPandoraHelper::CollectMCParticles(evt, m_geantModuleLabel, artMCTruthToMCParticles, artMCParticlesToMCTruth);
471 
472  for (const MCParticlesToHits::value_type &mapEntry : mcParticlesToHits)
473  {
474  const art::Ptr<simb::MCParticle> pMCPrimary(mapEntry.first);
475 
476  if (m_neutrinoInducedOnly && !this->IsNeutrinoInduced(pMCPrimary, artMCParticlesToMCTruth))
477  continue;
478 
479  SimpleMCPrimary simpleMCPrimary;
480  // ATTN simpleMCPrimary.m_id assigned later, after sorting
481  simpleMCPrimary.m_pAddress = pMCPrimary.get();
482  simpleMCPrimary.m_pdgCode = pMCPrimary->PdgCode();
483  simpleMCPrimary.m_energy = pMCPrimary->E();
484 
485  MCParticlesToHits::const_iterator trueHitsIter = mcParticlesToHits.find(pMCPrimary);
486 
487  if (mcParticlesToHits.end() != trueHitsIter)
488  {
489  const HitVector &hitVector(trueHitsIter->second);
490  simpleMCPrimary.m_nMCHitsTotal = hitVector.size();
491  simpleMCPrimary.m_nMCHitsU = this->CountHitsByType(geo::kU, hitVector);
492  simpleMCPrimary.m_nMCHitsV = this->CountHitsByType(geo::kV, hitVector);
493  simpleMCPrimary.m_nMCHitsW = this->CountHitsByType(geo::kW, hitVector);
494  }
495 
496  MCParticleMatchingMap::const_iterator matchedPfoIter = mcParticleMatchingMap.find(pMCPrimary);
497 
498  if (mcParticleMatchingMap.end() != matchedPfoIter)
499  simpleMCPrimary.m_nMatchedPfos = matchedPfoIter->second.size();
500 
501  simpleMCPrimaryList.push_back(simpleMCPrimary);
502  }
503 
504  std::sort(simpleMCPrimaryList.begin(), simpleMCPrimaryList.end(), PFParticleValidation::SortSimpleMCPrimaries);
505 
506  int mcPrimaryId(0);
507  for (SimpleMCPrimary &simpleMCPrimary : simpleMCPrimaryList)
508  simpleMCPrimary.m_id = mcPrimaryId++;
509 }
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:130
bool m_neutrinoInducedOnly
Whether to consider only mc particles that were neutrino induced.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
intermediate_table::const_iterator const_iterator
Planes which measure U.
Definition: geo_types.h:129
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
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:131
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.
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 685 of file PFParticleValidation_module.cc.

687 {
688  int bestPfoMatchId(-1);
689  MatchingDetails bestMatchingDetails;
690 
691  for (const MCPrimaryMatchingMap::value_type &mapValue : mcPrimaryMatchingMap)
692  {
693  const SimpleMCPrimary &simpleMCPrimary(mapValue.first);
694 
695  if (!m_useSmallPrimaries && !this->IsGoodMCPrimary(simpleMCPrimary))
696  continue;
697 
698  if (usedMCIds.count(simpleMCPrimary.m_id))
699  continue;
700 
701  for (const SimpleMatchedPfo &simpleMatchedPfo : mapValue.second)
702  {
703  if (usedPfoIds.count(simpleMatchedPfo.m_id))
704  continue;
705 
706  if (!this->IsGoodMatch(simpleMCPrimary, simpleMatchedPfo))
707  continue;
708 
709  if (simpleMatchedPfo.m_nMatchedHitsTotal > bestMatchingDetails.m_nMatchedHits)
710  {
711  bestPfoMatchId = simpleMatchedPfo.m_id;
712  bestMatchingDetails.m_matchedPrimaryId = simpleMCPrimary.m_id;
713  bestMatchingDetails.m_nMatchedHits = simpleMatchedPfo.m_nMatchedHitsTotal;
714  bestMatchingDetails.m_completeness = static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMCPrimary.m_nMCHitsTotal);
715  }
716  }
717  }
718 
719  if (bestPfoMatchId > -1)
720  {
721  matchingDetailsMap[bestPfoMatchId] = bestMatchingDetails;
722  usedMCIds.insert(bestMatchingDetails.m_matchedPrimaryId);
723  usedPfoIds.insert(bestPfoMatchId);
724  return true;
725  }
726 
727  return false;
728 }
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.
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 833 of file PFParticleValidation_module.cc.

835 {
836  for (const SimpleMatchedPfo &simpleMatchedPfo : simpleMatchedPfoList)
837  {
838  if (matchingDetailsMap.count(simpleMatchedPfo.m_id) && (simpleMCPrimary.m_id == matchingDetailsMap.at(simpleMatchedPfo.m_id).m_matchedPrimaryId))
839  return true;
840  }
841 
842  return false;
843 }
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 847 of file PFParticleValidation_module.cc.

848 {
849  const float purity((simpleMatchedPfo.m_nPfoHitsTotal > 0) ? static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMatchedPfo.m_nPfoHitsTotal) : 0.f);
850  const float completeness((simpleMCPrimary.m_nMCHitsTotal > 0) ? static_cast<float>(simpleMatchedPfo.m_nMatchedHitsTotal) / static_cast<float>(simpleMCPrimary.m_nMCHitsTotal) : 0.f);
851 
852  return ((simpleMatchedPfo.m_nMatchedHitsTotal >= m_matchingMinSharedHits) && (purity >= m_matchingMinPurity) && (completeness >= m_matchingMinCompleteness));
853 }
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 815 of file PFParticleValidation_module.cc.

816 {
817  if (simpleMCPrimary.m_nMCHitsTotal < m_matchingMinPrimaryHits)
818  return false;
819 
820  int nGoodViews(0);
821  if (simpleMCPrimary.m_nMCHitsU >= m_matchingMinHitsForGoodView) ++nGoodViews;
822  if (simpleMCPrimary.m_nMCHitsV >= m_matchingMinHitsForGoodView) ++nGoodViews;
823  if (simpleMCPrimary.m_nMCHitsW >= m_matchingMinHitsForGoodView) ++nGoodViews;
824 
825  if (nGoodViews < m_matchingMinPrimaryGoodViews)
826  return false;
827 
828  return true;
829 }
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 513 of file PFParticleValidation_module.cc.

514 {
515  MCParticlesToMCTruth::const_iterator iter = artMCParticlesToMCTruth.find(pMCParticle);
516 
517  if (artMCParticlesToMCTruth.end() == iter)
518  return false;
519 
520  const art::Ptr<simb::MCTruth> pMCTruth = iter->second;
521  return (simb::kBeamNeutrino == pMCTruth->Origin());
522 }
simb::Origin_t Origin() const
Definition: MCTruth.h:74
intermediate_table::const_iterator const_iterator
Beam neutrinos.
Definition: MCTruth.h:23
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 673 of file PFParticleValidation_module.cc.

674 {
675  // Get best matches, one-by-one, until no more strong matches possible
676  IntSet usedMCIds, usedPfoIds;
677  while (GetStrongestPfoMatch(mcPrimaryMatchingMap, usedMCIds, usedPfoIds, matchingDetailsMap)) {}
678 
679  // Assign any remaining pfos to primaries, based on number of matched hits
680  GetRemainingPfoMatches(mcPrimaryMatchingMap, usedPfoIds, matchingDetailsMap);
681 }
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 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 632 of file PFParticleValidation_module.cc.

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

762 {
763  std::cout << "---PROCESSED-MATCHING-OUTPUT--------------------------------------------------------------------" << std::endl;
764  std::cout << "MinPrimaryGoodHits " << m_matchingMinPrimaryHits << ", MinHitsForGoodView " << m_matchingMinHitsForGoodView << ", MinPrimaryGoodViews " << m_matchingMinPrimaryGoodViews << std::endl;
765  std::cout << "UseSmallPrimaries " << m_useSmallPrimaries << ", MinSharedHits " << m_matchingMinSharedHits << ", MinCompleteness " << m_matchingMinCompleteness << ", MinPurity " << m_matchingMinPurity << std::endl;
766 
767  bool isCorrect(true), isCalculable(false);
768 
769  for (const MCPrimaryMatchingMap::value_type &mapValue : mcPrimaryMatchingMap)
770  {
771  const SimpleMCPrimary &simpleMCPrimary(mapValue.first);
772  const bool hasMatch(this->HasMatch(simpleMCPrimary, mapValue.second, matchingDetailsMap));
773  const bool isTargetPrimary(this->IsGoodMCPrimary(simpleMCPrimary) && (2112 != simpleMCPrimary.m_pdgCode));
774 
775  if (!hasMatch && !isTargetPrimary)
776  continue;
777 
778  std::cout << std::endl << (!isTargetPrimary ? "(Non target) " : "")
779  << "Primary " << simpleMCPrimary.m_id << ", PDG " << simpleMCPrimary.m_pdgCode << ", nMCHits " << simpleMCPrimary.m_nMCHitsTotal
780  << " (" << simpleMCPrimary.m_nMCHitsU << ", " << simpleMCPrimary.m_nMCHitsV << ", " << simpleMCPrimary.m_nMCHitsW << ")" << std::endl;
781 
782  if (2112 != simpleMCPrimary.m_pdgCode)
783  isCalculable = true;
784 
785  unsigned int nMatches(0);
786 
787  for (const SimpleMatchedPfo &simpleMatchedPfo : mapValue.second)
788  {
789  if (matchingDetailsMap.count(simpleMatchedPfo.m_id) && (simpleMCPrimary.m_id == matchingDetailsMap.at(simpleMatchedPfo.m_id).m_matchedPrimaryId))
790  {
791  const bool isGoodMatch(this->IsGoodMatch(simpleMCPrimary, simpleMatchedPfo));
792 
793  if (isGoodMatch) ++nMatches;
794  std::cout << "-" << (!isGoodMatch ? "(Below threshold) " : "") << "MatchedPfo " << simpleMatchedPfo.m_id;
795 
796  if (simpleMatchedPfo.m_parentId >= 0) std::cout << ", ParentPfo " << simpleMatchedPfo.m_parentId;
797 
798  std::cout << ", PDG " << simpleMatchedPfo.m_pdgCode << ", nMatchedHits " << simpleMatchedPfo.m_nMatchedHitsTotal
799  << " (" << simpleMatchedPfo.m_nMatchedHitsU << ", " << simpleMatchedPfo.m_nMatchedHitsV << ", " << simpleMatchedPfo.m_nMatchedHitsW << ")"
800  << ", nPfoHits " << simpleMatchedPfo.m_nPfoHitsTotal
801  << " (" << simpleMatchedPfo.m_nPfoHitsU << ", " << simpleMatchedPfo.m_nPfoHitsV << ", " << simpleMatchedPfo.m_nPfoHitsW << ")" << std::endl;
802  }
803  }
804 
805  if (isTargetPrimary && (1 != nMatches))
806  isCorrect = false;
807  }
808 
809  std::cout << std::endl << "Is correct? " << (isCorrect && isCalculable) << std::endl;
810  std::cout << "------------------------------------------------------------------------------------------------" << std::endl;
811 }
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.
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.
if(!yymsg) yymsg
QTextStream & endl(QTextStream &s)
void lar_pandora::PFParticleValidation::reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 350 of file PFParticleValidation_module.cc.

351 {
352  m_particleLabel = pset.get<std::string>("PFParticleModule", "pandoraNu");
353  m_hitfinderLabel = pset.get<std::string>("HitFinderModule", "gaushit");
354  m_geantModuleLabel = pset.get<std::string>("GeantModule","largeant");
355  m_backtrackerLabel = pset.get<std::string>("BackTrackerModule","gaushitTruthMatch");
356  m_printAllToScreen = pset.get<bool>("PrintAllToScreen", true);
357  m_printMatchingToScreen = pset.get<bool>("PrintMatchingToScreen", true);
358  m_neutrinoInducedOnly = pset.get<bool>("NeutrinoInducedOnly", true);
359  m_matchingMinPrimaryHits = pset.get<int>("MatchingMinPrimaryHits", 15);
360  m_matchingMinHitsForGoodView = pset.get<int>("MatchingMinHitsForGoodView", 5);
361  m_matchingMinPrimaryGoodViews = pset.get<int>("MatchingMinPrimaryGoodViews", 2);
362  m_useSmallPrimaries = pset.get<bool>("UseSmallPrimaries", true);
363  m_matchingMinSharedHits = pset.get<int>("MatchingMinSharedHits", 5);
364  m_matchingMinCompleteness = pset.get<float>("MatchingMinCompleteness", 0.1f);
365  m_matchingMinPurity = pset.get<float>("MatchingMinPurity", 0.5f);
366 }
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
std::string string
Definition: nybbler.cc:12
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.
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 882 of file PFParticleValidation_module.cc.

883 {
884  if (lhs.m_nMatchedHitsTotal != rhs.m_nMatchedHitsTotal)
885  return (lhs.m_nMatchedHitsTotal > rhs.m_nMatchedHitsTotal);
886 
887  if (lhs.m_nPfoHitsTotal != rhs.m_nPfoHitsTotal)
888  return (lhs.m_nPfoHitsTotal > rhs.m_nPfoHitsTotal);
889 
890  return (lhs.m_id < rhs.m_id);
891 }
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 872 of file PFParticleValidation_module.cc.

873 {
874  if (lhs.m_nMCHitsTotal != rhs.m_nMCHitsTotal)
875  return (lhs.m_nMCHitsTotal > rhs.m_nMCHitsTotal);
876 
877  return (lhs.m_energy > rhs.m_energy);
878 }

Member Data Documentation

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

The name/label of the back-tracker module.

Definition at line 296 of file PFParticleValidation_module.cc.

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

The name/label of the geant module.

Definition at line 295 of file PFParticleValidation_module.cc.

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

The name/label of the hit producer module.

Definition at line 293 of file PFParticleValidation_module.cc.

float lar_pandora::PFParticleValidation::m_matchingMinCompleteness
private

The minimum particle completeness to declare a match.

Definition at line 309 of file PFParticleValidation_module.cc.

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 304 of file PFParticleValidation_module.cc.

int lar_pandora::PFParticleValidation::m_matchingMinPrimaryGoodViews
private

The minimum number of good views for a mc primary.

Definition at line 305 of file PFParticleValidation_module.cc.

int lar_pandora::PFParticleValidation::m_matchingMinPrimaryHits
private

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

Definition at line 303 of file PFParticleValidation_module.cc.

float lar_pandora::PFParticleValidation::m_matchingMinPurity
private

The minimum particle purity to declare a match.

Definition at line 310 of file PFParticleValidation_module.cc.

int lar_pandora::PFParticleValidation::m_matchingMinSharedHits
private

The minimum number of shared hits used in matching scheme.

Definition at line 308 of file PFParticleValidation_module.cc.

bool lar_pandora::PFParticleValidation::m_neutrinoInducedOnly
private

Whether to consider only mc particles that were neutrino induced.

Definition at line 301 of file PFParticleValidation_module.cc.

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

The name/label of the particle producer module.

Definition at line 294 of file PFParticleValidation_module.cc.

bool lar_pandora::PFParticleValidation::m_printAllToScreen
private

Whether to print all/raw matching details to screen.

Definition at line 298 of file PFParticleValidation_module.cc.

bool lar_pandora::PFParticleValidation::m_printMatchingToScreen
private

Whether to print matching output to screen.

Definition at line 299 of file PFParticleValidation_module.cc.

bool lar_pandora::PFParticleValidation::m_useSmallPrimaries
private

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

Definition at line 307 of file PFParticleValidation_module.cc.


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