All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PFParticleValidation_module.cc
Go to the documentation of this file.
1 /**
2  * @file larpandora/LArPandoraAnalysis/PFParticleValidation_module.cc
3  *
4  * @brief Analysis module for created particles
5  *
6  */
7 
8 #include "art/Framework/Core/ModuleMacros.h"
9 #include "art/Framework/Core/EDAnalyzer.h"
10 
13 
14 #include <string>
15 
16 //------------------------------------------------------------------------------------------------------------------------------------------
17 
18 namespace lar_pandora
19 {
20 
21 /**
22  * @brief PFParticleValidation class
23  */
24 class PFParticleValidation : public art::EDAnalyzer
25 {
26 public:
27  /**
28  * @brief Constructor
29  *
30  * @param pset
31  */
32  PFParticleValidation(fhicl::ParameterSet const &pset);
33 
34  /**
35  * @brief Destructor
36  */
37  virtual ~PFParticleValidation();
38 
39  void beginJob();
40  void endJob();
41  void analyze(const art::Event &evt);
42  void reconfigure(fhicl::ParameterSet const &pset);
43 
44 private:
45  /**
46  * @brief SimpleMCPrimary class
47  */
49  {
50  public:
51  /**
52  * @brief Constructor
53  */
55 
56  /**
57  * @brief operator <
58  *
59  * @param rhs object for comparison
60  *
61  * @return boolean
62  */
63  bool operator<(const SimpleMCPrimary &rhs) const;
64 
65  int m_id; ///< The unique identifier
66  int m_pdgCode; ///< The pdg code
67  int m_nMCHitsTotal; ///< The total number of mc hits
68  int m_nMCHitsU; ///< The number of u mc hits
69  int m_nMCHitsV; ///< The number of v mc hits
70  int m_nMCHitsW; ///< The number of w mc hits
71  float m_energy; ///< The energy
72  int m_nMatchedPfos; ///< The number of matched pfos
73  const simb::MCParticle *m_pAddress; ///< The address of the mc primary
74  };
75 
76  typedef std::vector<SimpleMCPrimary> SimpleMCPrimaryList;
77 
78  /**
79  * @brief SimpleMatchedPfo class
80  */
82  {
83  public:
84  /**
85  * @brief Constructor
86  */
88 
89  int m_id; ///< The unique identifier
90  int m_parentId; ///< The unique identifier of the parent pfo (-1 if no parent set)
91  int m_pdgCode; ///< The pdg code
92  int m_nPfoHitsTotal; ///< The total number of pfo hits
93  int m_nPfoHitsU; ///< The number of u pfo hits
94  int m_nPfoHitsV; ///< The number of v pfo hits
95  int m_nPfoHitsW; ///< The number of w pfo hits
96  int m_nMatchedHitsTotal; ///< The total number of matched hits
97  int m_nMatchedHitsU; ///< The number of u matched hits
98  int m_nMatchedHitsV; ///< The number of v matched hits
99  int m_nMatchedHitsW; ///< The number of w matched hits
100  const recob::PFParticle *m_pAddress; ///< The address of the pf primary
101  };
102 
103  typedef std::vector<SimpleMatchedPfo> SimpleMatchedPfoList;
104 
105  /**
106  * @brief MatchingDetails class
107  */
109  {
110  public:
111  /**
112  * @brief Default constructor
113  */
114  MatchingDetails();
115 
116  int m_matchedPrimaryId; ///< The total number of occurences
117  int m_nMatchedHits; ///< The number of times the primary has 0 pfo matches
118  float m_completeness; ///< The completeness of the match
119  };
120 
121  typedef std::map<int, MatchingDetails> MatchingDetailsMap;
122  typedef std::map<SimpleMCPrimary, SimpleMatchedPfoList> MCPrimaryMatchingMap; // SimpleMCPrimary has a defined operator<
123 
124  typedef std::map< art::Ptr<recob::PFParticle>, HitVector > PFParticleToMatchedHits;
125  typedef std::map< art::Ptr<simb::MCParticle>, PFParticleToMatchedHits > MCParticleMatchingMap;
126 
127  /**
128  * @brief Performing matching between true and reconstructed particles
129  *
130  * @param recoParticlesToHits the mapping from reconstructed particles to hits
131  * @param trueParticlesToHits the mapping from true particles to hits
132  * @param hitsToTrueParticles the mapping from hits to true particles
133  * @param mcParticleMatchingMap the output matches between all reconstructed and true particles
134  */
135  void GetMCParticleMatchingMap(const PFParticlesToHits &recoParticlesToHits, const MCParticlesToHits &trueParticlesToHits,
136  const HitsToMCParticles &hitsToTrueParticles, MCParticleMatchingMap &mcParticleMatchingMap) const;
137 
138  /**
139  * @brief Extract details of each mc primary (ordered by number of true hits)
140  *
141  * @param evt the event
142  * @param mcParticlesToHits the mc primary to hits map
143  * @param hitsToMCParticles the hits to mc particles map
144  * @param mcParticleMatchingMap the mc to particle to pf particle matching map (to record number of matched pf particles)
145  * @param simpleMCPrimaryList to receive the populated simple mc primary list
146  */
147  void GetSimpleMCPrimaryList(const art::Event &evt, const MCParticlesToHits &mcParticlesToHits, const HitsToMCParticles &hitsToMCParticles,
148  const MCParticleMatchingMap &mcParticleMatchingMap, SimpleMCPrimaryList &simpleMCPrimaryList) const;
149 
150  /**
151  * @brief Obtain a sorted list of matched pfos for each mc primary
152  *
153  * @param simpleMCPrimaryList the simple mc primary list
154  * @param mcToFullPfoMatchingMap the mc to full pfo matching map
155  * @param pfoToHitListMap the pfo to hit list map
156  * @param mcPrimaryMatchingMap to receive the populated mc primary matching map
157  */
158  void GetMCPrimaryMatchingMap(const SimpleMCPrimaryList &simpleMCPrimaryList, const MCParticleMatchingMap &mcParticleMatchingMap,
159  const PFParticlesToHits &pfParticlesToHits, MCPrimaryMatchingMap &mcPrimaryMatchingMap) const;
160 
161  /**
162  * @brief Whether a mc particle is neutrino induced
163  *
164  * @param pMCParticle address of the mc particle
165  * @param artMCParticlesToMCTruth the mapping from mc particles to mc truth
166  *
167  * @return boolean
168  */
169  bool IsNeutrinoInduced(const art::Ptr<simb::MCParticle> pMCParticle, const MCParticlesToMCTruth &artMCParticlesToMCTruth) const;
170 
171  /**
172  * @brief Obtain a vector of mc truth
173  *
174  * @param evt the event
175  * @param mcNeutrinoVector to receive the populated vector of mc truth
176  */
177  void GetMCTruth(const art::Event &evt, MCTruthVector &mcTruthVector) const;
178 
179  /**
180  * @brief Obtain a vector of reco neutrinos
181  *
182  * @param evt the event
183  * @param recoNeutrinoVector to receive the populated vector of reco neutrinos
184  */
185  void GetRecoNeutrinos(const art::Event &evt, PFParticleVector &recoNeutrinoVector) const;
186 
187  /**
188  * @brief Print all the raw matching output to screen
189  *
190  * @param mcTruthVector the mc truth vector
191  * @param recoNeutrinoVector the reco neutrino vector
192  * @param mcPrimaryMatchingMap the input/raw mc primary matching map
193  */
194  void PrintAllOutput(const MCTruthVector &mcTruthVector, const PFParticleVector &recoNeutrinoVector, const MCPrimaryMatchingMap &mcPrimaryMatchingMap) const;
195 
196  /**
197  * @brief Apply a well-defined matching procedure to the comprehensive matches in the provided mc primary matching map
198  *
199  * @param mcPrimaryMatchingMap the input/raw mc primary matching map
200  * @param matchingDetailsMap the matching details map, to be populated
201  */
202  void PerformMatching(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, MatchingDetailsMap &matchingDetailsMap) const;
203 
204  typedef std::set<int> IntSet;
205 
206  /**
207  * @brief Get the strongest pfo match (most matched hits) between an available mc primary and an available pfo
208  *
209  * @param mcPrimaryMatchingMap the input/raw mc primary matching map
210  * @param usedMCIds the list of mc primary ids with an existing match
211  * @param usedPfoIds the list of pfo ids with an existing match
212  * @param matchingDetailsMap the matching details map, to be populated
213  */
214  bool GetStrongestPfoMatch(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, IntSet &usedMCIds, IntSet &usedPfoIds, MatchingDetailsMap &matchingDetailsMap) const;
215 
216  /**
217  * @brief Get the best matches for any pfos left-over after the strong matching procedure
218  *
219  * @param mcPrimaryMatchingMap the input/raw mc primary matching map
220  * @param usedPfoIds the list of pfo ids with an existing match
221  * @param matchingDetailsMap the matching details map, to be populated
222  */
223  void GetRemainingPfoMatches(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const IntSet &usedPfoIds, MatchingDetailsMap &matchingDetailsMap) const;
224 
225  /**
226  * @brief Print the results of the matching procedure
227  *
228  * @param mcPrimaryMatchingMap the input/raw mc primary matching map
229  * @param matchingDetailsMap the matching details map
230  */
231  void PrintMatchingOutput(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const MatchingDetailsMap &matchingDetailsMap) const;
232 
233  /**
234  * @brief Whether a provided mc primary passes selection, based on number of "good" hits
235  *
236  * @param simpleMCPrimary the simple mc primary
237  *
238  * @return boolean
239  */
240  bool IsGoodMCPrimary(const SimpleMCPrimary &simpleMCPrimary) const;
241 
242  /**
243  * @brief Whether a provided mc primary has a match, of any quality (use simple matched pfo list and information in matching details map)
244  *
245  * @param simpleMCPrimary the simple mc primary
246  * @param simpleMatchedPfoList the list of simple matched pfos
247  * @param matchingDetailsMap the matching details map
248  *
249  * @return boolean
250  */
251  bool HasMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfoList &simpleMatchedPfoList, const MatchingDetailsMap &matchingDetailsMap) const;
252 
253  /**
254  * @brief Whether a provided mc primary and pfo are deemed to be a good match
255  *
256  * @param simpleMCPrimary the simple mc primary
257  * @param simpleMatchedPfo the simple matched pfo
258  *
259  * @return boolean
260  */
261  bool IsGoodMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfo &simpleMatchedPfo) const;
262 
263  /**
264  * @brief Count the number of hits, in a provided vector, of a specified view
265  *
266  * @param view the view
267  * @param hitVector the hit vector
268  *
269  * @return the number of hits of the specified view
270  */
271  unsigned int CountHitsByType(const geo::View_t view, const HitVector &hitVector) const;
272 
273  /**
274  * @brief Sort simple mc primaries by number of mc hits
275  *
276  * @param lhs the left-hand side
277  * @param rhs the right-hand side
278  *
279  * @return boolean
280  */
281  static bool SortSimpleMCPrimaries(const SimpleMCPrimary &lhs, const SimpleMCPrimary &rhs);
282 
283  /**
284  * @brief Sort simple matched pfos by number of matched hits
285  *
286  * @param lhs the left-hand side
287  * @param rhs the right-hand side
288  *
289  * @return boolean
290  */
291  static bool SortSimpleMatchedPfos(const SimpleMatchedPfo &lhs, const SimpleMatchedPfo &rhs);
292 
293  std::string m_hitfinderLabel; ///< The name/label of the hit producer module
294  std::string m_particleLabel; ///< The name/label of the particle producer module
295  std::string m_geantModuleLabel; ///< The name/label of the geant module
296  std::string m_backtrackerLabel; ///< The name/label of the back-tracker module
297 
298  bool m_printAllToScreen; ///< Whether to print all/raw matching details to screen
299  bool m_printMatchingToScreen; ///< Whether to print matching output to screen
300 
301  bool m_neutrinoInducedOnly; ///< Whether to consider only mc particles that were neutrino induced
302 
303  int m_matchingMinPrimaryHits; ///< The minimum number of good mc primary hits used in matching scheme
304  int m_matchingMinHitsForGoodView; ///< The minimum number of good mc primary hits in given view to declare view to be good
305  int m_matchingMinPrimaryGoodViews; ///< The minimum number of good views for a mc primary
306 
307  bool m_useSmallPrimaries; ///< Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits
308  int m_matchingMinSharedHits; ///< The minimum number of shared hits used in matching scheme
309  float m_matchingMinCompleteness; ///< The minimum particle completeness to declare a match
310  float m_matchingMinPurity; ///< The minimum particle purity to declare a match
311 };
312 
313 DEFINE_ART_MODULE(PFParticleValidation)
314 
315 } // namespace lar_pandora
316 
317 //------------------------------------------------------------------------------------------------------------------------------------------
318 
319 
320 #include "art/Framework/Principal/Event.h"
321 
322 #include "fhiclcpp/ParameterSet.h"
323 
324 #include "nusimdata/SimulationBase/MCParticle.h"
325 #include "nusimdata/SimulationBase/MCTruth.h"
326 
327 #include "lardataobj/RecoBase/Hit.h"
329 
330 #include <algorithm>
331 #include <iostream>
332 
333 namespace lar_pandora
334 {
335 
336 PFParticleValidation::PFParticleValidation(fhicl::ParameterSet const &pset) :
337  art::EDAnalyzer(pset)
338 {
339  this->reconfigure(pset);
340 }
341 
342 //------------------------------------------------------------------------------------------------------------------------------------------
343 
345 {
346 }
347 
348 //------------------------------------------------------------------------------------------------------------------------------------------
349 
350 void PFParticleValidation::reconfigure(fhicl::ParameterSet const &pset)
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 }
367 
368 //------------------------------------------------------------------------------------------------------------------------------------------
369 
371 {
372 }
373 
374 //------------------------------------------------------------------------------------------------------------------------------------------
375 
377 {
378 }
379 
380 //------------------------------------------------------------------------------------------------------------------------------------------
381 
382 void PFParticleValidation::analyze(const art::Event &evt)
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 }
431 
432 //------------------------------------------------------------------------------------------------------------------------------------------
433 
434 void PFParticleValidation::GetMCParticleMatchingMap(const PFParticlesToHits &pfParticlesToHits, const MCParticlesToHits &mcParticlesToHits,
435  const HitsToMCParticles &hitsToMCParticles, MCParticleMatchingMap &mcParticleMatchingMap) const
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 }
462 
463 //------------------------------------------------------------------------------------------------------------------------------------------
464 
465 void PFParticleValidation::GetSimpleMCPrimaryList(const art::Event &evt, const MCParticlesToHits &mcParticlesToHits,
466  const HitsToMCParticles &hitsToMCParticles, const MCParticleMatchingMap &mcParticleMatchingMap, SimpleMCPrimaryList &simpleMCPrimaryList) const
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 }
510 
511 //------------------------------------------------------------------------------------------------------------------------------------------
512 
513 bool PFParticleValidation::IsNeutrinoInduced(const art::Ptr<simb::MCParticle> pMCParticle, const MCParticlesToMCTruth &artMCParticlesToMCTruth) const
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 }
523 
524 //------------------------------------------------------------------------------------------------------------------------------------------
525 
526 void PFParticleValidation::GetMCPrimaryMatchingMap(const SimpleMCPrimaryList &simpleMCPrimaryList, const MCParticleMatchingMap &mcParticleMatchingMap,
527  const PFParticlesToHits &pfParticlesToHits, MCPrimaryMatchingMap &mcPrimaryMatchingMap) const
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 }
600 
601 //------------------------------------------------------------------------------------------------------------------------------------------
602 
603 void PFParticleValidation::GetMCTruth(const art::Event &evt, MCTruthVector &mcTruthVector) const
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 }
620 
621 //------------------------------------------------------------------------------------------------------------------------------------------
622 
623 void PFParticleValidation::GetRecoNeutrinos(const art::Event &evt, PFParticleVector &recoNeutrinoVector) const
624 {
625  PFParticleVector allPFParticles;
627  LArPandoraHelper::SelectNeutrinoPFParticles(allPFParticles, recoNeutrinoVector);
628 }
629 
630 //------------------------------------------------------------------------------------------------------------------------------------------
631 
632 void PFParticleValidation::PrintAllOutput(const MCTruthVector &mcTruthVector, const PFParticleVector &recoNeutrinoVector,
633  const MCPrimaryMatchingMap &mcPrimaryMatchingMap) const
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 }
670 
671 //------------------------------------------------------------------------------------------------------------------------------------------
672 
673 void PFParticleValidation::PerformMatching(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, MatchingDetailsMap &matchingDetailsMap) const
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 }
682 
683 //------------------------------------------------------------------------------------------------------------------------------------------
684 
685 bool PFParticleValidation::GetStrongestPfoMatch(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, IntSet &usedMCIds, IntSet &usedPfoIds,
686  MatchingDetailsMap &matchingDetailsMap) const
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 }
729 
730 //------------------------------------------------------------------------------------------------------------------------------------------
731 
732 void PFParticleValidation::GetRemainingPfoMatches(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const IntSet &usedPfoIds,
733  MatchingDetailsMap &matchingDetailsMap) const
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 }
758 
759 //------------------------------------------------------------------------------------------------------------------------------------------
760 
761 void PFParticleValidation::PrintMatchingOutput(const MCPrimaryMatchingMap &mcPrimaryMatchingMap, const MatchingDetailsMap &matchingDetailsMap) const
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 }
812 
813 //------------------------------------------------------------------------------------------------------------------------------------------
814 
815 bool PFParticleValidation::IsGoodMCPrimary(const SimpleMCPrimary &simpleMCPrimary) const
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 }
830 
831 //------------------------------------------------------------------------------------------------------------------------------------------
832 
833 bool PFParticleValidation::HasMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfoList &simpleMatchedPfoList,
834  const MatchingDetailsMap &matchingDetailsMap) const
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 }
844 
845 //------------------------------------------------------------------------------------------------------------------------------------------
846 
847 bool PFParticleValidation::IsGoodMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfo &simpleMatchedPfo) const
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 }
854 
855 //------------------------------------------------------------------------------------------------------------------------------------------
856 
857 unsigned int PFParticleValidation::CountHitsByType(const geo::View_t view, const HitVector &hitVector) const
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 }
869 
870 //------------------------------------------------------------------------------------------------------------------------------------------
871 
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 }
879 
880 //------------------------------------------------------------------------------------------------------------------------------------------
881 
883 {
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 }
892 
893 //------------------------------------------------------------------------------------------------------------------------------------------
894 //------------------------------------------------------------------------------------------------------------------------------------------
895 
897  m_id(-1),
898  m_pdgCode(0),
899  m_nMCHitsTotal(0),
900  m_nMCHitsU(0),
901  m_nMCHitsV(0),
902  m_nMCHitsW(0),
903  m_energy(0.f),
904  m_nMatchedPfos(0),
905  m_pAddress(nullptr)
906 {
907 }
908 
909 //------------------------------------------------------------------------------------------------------------------------------------------
910 
912 {
913  if (this == &rhs)
914  return false;
915 
916  return (m_id < rhs.m_id);
917 }
918 
919 //------------------------------------------------------------------------------------------------------------------------------------------
920 //------------------------------------------------------------------------------------------------------------------------------------------
921 
923  m_id(-1),
924  m_parentId(-1),
925  m_pdgCode(0),
926  m_nPfoHitsTotal(0),
927  m_nPfoHitsU(0),
928  m_nPfoHitsV(0),
929  m_nPfoHitsW(0),
930  m_nMatchedHitsTotal(0),
931  m_nMatchedHitsU(0),
932  m_nMatchedHitsV(0),
933  m_nMatchedHitsW(0),
934  m_pAddress(nullptr)
935 {
936 }
937 
938 //------------------------------------------------------------------------------------------------------------------------------------------
939 //------------------------------------------------------------------------------------------------------------------------------------------
940 
942  m_matchedPrimaryId(-1),
943  m_nMatchedHits(0),
944  m_completeness(0.f)
945 {
946 }
947 
948 } //namespace lar_pandora
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.
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...
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
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...
bool IsNeutrinoInduced(const art::Ptr< simb::MCParticle > pMCParticle, const MCParticlesToMCTruth &artMCParticlesToMCTruth) const
Whether a mc particle is neutrino induced.
then if[["$THISISATEST"==1]]
Definition: neoSmazza.sh:95
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
PFParticleValidation(fhicl::ParameterSet const &pset)
Constructor.
float m_matchingMinCompleteness
The minimum particle completeness to declare a match.
const simb::MCParticle * m_pAddress
The address of the mc primary.
static bool IsNeutrino(const art::Ptr< recob::PFParticle > particle)
Determine whether a particle has been reconstructed as a neutrino.
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Planes which measure V.
Definition: geo_types.h:130
void GetRecoNeutrinos(const art::Event &evt, PFParticleVector &recoNeutrinoVector) const
Obtain a vector of reco neutrinos.
Declaration of signal hit object.
bool m_neutrinoInducedOnly
Whether to consider only mc particles that were neutrino induced.
std::map< art::Ptr< simb::MCParticle >, art::Ptr< simb::MCTruth > > MCParticlesToMCTruth
int m_matchingMinPrimaryHits
The minimum number of good mc primary hits used in matching scheme.
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
const recob::PFParticle * m_pAddress
The address of the pf primary.
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.
bool m_useSmallPrimaries
Whether to consider matches to mc primaries with fewer than m_matchingMinPrimaryHits.
Planes which measure U.
Definition: geo_types.h:129
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 IsGoodMatch(const SimpleMCPrimary &simpleMCPrimary, const SimpleMatchedPfo &simpleMatchedPfo) const
Whether a provided mc primary and pfo are deemed to be a good match.
std::map< art::Ptr< simb::MCParticle >, HitVector > MCParticlesToHits
bool m_printAllToScreen
Whether to print all/raw matching details to screen.
int m_nMatchedHits
The number of times the primary has 0 pfo matches.
std::vector< art::Ptr< recob::PFParticle > > PFParticleVector
std::map< art::Ptr< simb::MCTruth >, MCParticleVector > MCTruthToMCParticles
float m_matchingMinPurity
The minimum particle purity to declare a match.
std::string m_backtrackerLabel
The name/label of the back-tracker module.
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticlesToHits
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.
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.
std::vector< SimpleMatchedPfo > SimpleMatchedPfoList
static bool SortSimpleMatchedPfos(const SimpleMatchedPfo &lhs, const SimpleMatchedPfo &rhs)
Sort simple matched pfos by number of matched hits.
Definition of data types for geometry description.
std::map< art::Ptr< recob::PFParticle >, HitVector > PFParticleToMatchedHits
static void CollectPFParticles(const art::Event &evt, const std::string &label, PFParticleVector &particleVector)
Collect the reconstructed PFParticles from the ART event record.
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
static void SelectNeutrinoPFParticles(const PFParticleVector &inputParticles, PFParticleVector &outputParticles)
Select reconstructed neutrino particles from a list of all reconstructed particles.
std::vector< art::Ptr< recob::Hit > > HitVector
bool IsGoodMCPrimary(const SimpleMCPrimary &simpleMCPrimary) const
Whether a provided mc primary passes selection, based on number of &quot;good&quot; hits.
Hierarchical representation of particle flow.
Definition: PFParticle.h:44
int m_matchingMinHitsForGoodView
The minimum number of good mc primary hits in given view to declare view to be good.
std::map< art::Ptr< recob::Hit >, art::Ptr< recob::PFParticle > > HitsToPFParticles
static bool SortSimpleMCPrimaries(const SimpleMCPrimary &lhs, const SimpleMCPrimary &rhs)
Sort simple mc primaries by number of mc hits.
void reconfigure(fhicl::ParameterSet const &pset)
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.
Planes which measure W (third view for Bo, MicroBooNE, etc).
Definition: geo_types.h:131
bool operator<(const SimpleMCPrimary &rhs) const
operator &lt;
TCEvent evt
Definition: DataStructs.cxx:8
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.
static void CollectMCParticles(const art::Event &evt, const std::string &label, MCParticleVector &particleVector)
Collect a vector of MCParticle objects from the ART event record.
helper function for LArPandoraInterface producer module
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.
std::string m_hitfinderLabel
The name/label of the hit producer module.
BEGIN_PROLOG could also be cout
int m_parentId
The unique identifier of the parent pfo (-1 if no parent set)