LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::LArMonitoringHelper Class Reference

LArMonitoringHelper class. More...

#include "LArMonitoringHelper.h"

Static Public Member Functions

static unsigned int CountHitsByType (const pandora::HitType hitType, const pandora::CaloHitList &caloHitList)
 Count the number of calo hits, in a provided list, of a specified type. More...
 
static void GetOrderedMCParticleVector (const LArMCParticleHelper::MCContributionMapVector &selectedMCParticleToGoodHitsMaps, pandora::MCParticleVector &orderedMCParticleVector)
 Order input MCParticles by their number of hits. More...
 
static void GetOrderedPfoVector (const LArMCParticleHelper::PfoContributionMap &pfoToReconstructable2DHitsMap, pandora::PfoVector &orderedPfoVector)
 Order input Pfos by their number of hits. More...
 
static void PrintMCParticleTable (const LArMCParticleHelper::MCContributionMap &selectedMCParticleToGoodHitsMaps, const pandora::MCParticleVector &orderedMCParticleVector)
 Print details of selected MCParticles to the terminal in a table. More...
 
static void PrintPfoTable (const LArMCParticleHelper::PfoContributionMap &pfoToReconstructable2DHitsMap, const pandora::PfoVector &orderedPfoVector)
 Print details of input Pfos to the terminal in a table. More...
 
static void PrintMatchingTable (const pandora::PfoVector &orderedPfoVector, const pandora::MCParticleVector &orderedMCParticleVector, const LArMCParticleHelper::MCParticleToPfoHitSharingMap &mcParticleToPfoHitSharingMap, const unsigned int nMatches)
 Print the shared good hits between all Pfos and MCParticles. More...
 
template<typename Ti , typename Tj >
static float CalcRandIndex (const std::map< const Ti, std::map< const Tj, int >> &cTable)
 Calculate the adjusted Rand Index for a given contingency table that summarises two clusterings A and B. Adjusted Rand Index is a measure of the similarity of two clusterings that is bounded above by 1 (identical), is 0 when the two clusterings are as similar as two random clusterings with the same number of clusters, and has no lower bound. An index < 0 means very discordant clusterings and is rare in most cases. Reference - https://link.springer.com/article/10.1007/BF01908075. More...
 
static float CalcRandIndex (const pandora::CaloHitList &caloHits, const pandora::ClusterList &clusters)
 Calculate the adjusted Rand Index for the clustering defined by MCPartices and by CaloHits. Adjusted Rand Index is a measure of the similarity of two clusterings that is bounded above by 1 (identical), is 0 when the two clusterings are as similar as two random clusterings with the same number of clusters, and has no lower bound. An index < 0 means very discordant clusterings and is rare in most cases. Reference - https://link.springer.com/article/10.1007/BF01908075. More...
 
static void FillContingencyTable (const pandora::CaloHitList &caloHits, const pandora::ClusterList &clusters, std::map< const pandora::Cluster *const, std::map< const pandora::MCParticle *const, int >> &cTable)
 Fill the contingency table for a set of CaloHits partitioned by Cluster and parent MCParticle. More...
 

Detailed Description

LArMonitoringHelper class.

Definition at line 21 of file LArMonitoringHelper.h.

Member Function Documentation

template<typename Ti , typename Tj >
float lar_content::LArMonitoringHelper::CalcRandIndex ( const std::map< const Ti, std::map< const Tj, int >> &  cTable)
static

Calculate the adjusted Rand Index for a given contingency table that summarises two clusterings A and B. Adjusted Rand Index is a measure of the similarity of two clusterings that is bounded above by 1 (identical), is 0 when the two clusterings are as similar as two random clusterings with the same number of clusters, and has no lower bound. An index < 0 means very discordant clusterings and is rare in most cases. Reference - https://link.springer.com/article/10.1007/BF01908075.

Parameters
[in]cTableContingency table as a map of the object that defines the clustering A (e.g. pandora::Cluster) to a map of the object that defines the clustering B (e.g. pandora::MCParticle) to the value of the table at this entry (which is the intersection of the two clusters)

Definition at line 319 of file LArMonitoringHelper.cc.

References util::abs(), f, and n.

Referenced by lar_content::EventClusterValidationAlgorithm::CalcRandIndex().

320 {
321  double aTerm{0.}; // Term made from summing over columns
322  int n{0}; // Total entries in table
323  for (const auto &[i, jToVal] : cTable)
324  {
325  int a{0};
326  for (const auto &[j, val] : jToVal)
327  {
328  a += val;
329  n += val;
330  }
331  aTerm += static_cast<double>(a * (a - 1)) / 2.;
332  }
333  if (n == 0 || n == 1) // Clustering of a set with cardinality 0 or 1 can only be perfect
334  return 1.f;
335 
336  double bTerm{0.}; // Term made from summing over rows
337  std::set<Tj> js;
338  for (const auto &[i, jToVal] : cTable)
339  {
340  for (const auto &[j, val] : jToVal)
341  {
342  js.insert(j);
343  }
344  }
345  for (const auto j : js)
346  {
347  int b{0};
348  for (const auto &[i, jToVal] : cTable)
349  {
350  if (jToVal.find(j) != jToVal.end())
351  b += cTable.at(i).at(j);
352  }
353  bTerm += static_cast<double>(b * (b - 1)) / 2.;
354  }
355 
356  double indexTerm{0.};
357  for (const auto &[i, jToVal] : cTable)
358  {
359  for (const auto &[j, val] : jToVal)
360  {
361  indexTerm += static_cast<double>(val * (val - 1)) / 2.;
362  }
363  }
364 
365  double expIndexTerm{(aTerm * bTerm) / static_cast<double>(n * (n - 1)) / 2.};
366  double maxIndexTerm{0.5 * (aTerm + bTerm)};
367  if (std::abs(maxIndexTerm - expIndexTerm) < std::numeric_limits<double>::epsilon())
368  return indexTerm >= expIndexTerm ? 1.f : -1.f;
369  double adjustedRandIndex{(indexTerm - expIndexTerm) / (maxIndexTerm - expIndexTerm)};
370 
371  return adjustedRandIndex;
372 }
constexpr auto abs(T v)
Returns the absolute value of the argument.
TFile f
Definition: plotHisto.C:6
Char_t n[5]
static float lar_content::LArMonitoringHelper::CalcRandIndex ( const pandora::CaloHitList &  caloHits,
const pandora::ClusterList &  clusters 
)
static

Calculate the adjusted Rand Index for the clustering defined by MCPartices and by CaloHits. Adjusted Rand Index is a measure of the similarity of two clusterings that is bounded above by 1 (identical), is 0 when the two clusterings are as similar as two random clusterings with the same number of clusters, and has no lower bound. An index < 0 means very discordant clusterings and is rare in most cases. Reference - https://link.springer.com/article/10.1007/BF01908075.

Parameters
[in]caloHitsList of hits
[in]clustersList of clusters
unsigned int lar_content::LArMonitoringHelper::CountHitsByType ( const pandora::HitType  hitType,
const pandora::CaloHitList &  caloHitList 
)
static

Count the number of calo hits, in a provided list, of a specified type.

Parameters
hitTypethe hit type
caloHitListthe calo hit list
Returns
the number of calo hits of the specified type

Definition at line 28 of file LArMonitoringHelper.cc.

Referenced by lar_content::MCParticleMonitoringAlgorithm::PrintMCParticle(), lar_content::CosmicRayTaggingMonitoringTool::PrintPfoTable(), lar_content::MCParticleMonitoringAlgorithm::PrintPrimaryMCParticles(), lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput(), lar_content::MuonLeadingEventValidationAlgorithm::ProcessOutput(), and lar_content::LArMCParticleHelper::SelectParticlesByHitCount().

29 {
30  unsigned int nHitsOfSpecifiedType(0);
31 
32  for (const CaloHit *const pCaloHit : caloHitList)
33  {
34  if (hitType == pCaloHit->GetHitType())
35  ++nHitsOfSpecifiedType;
36  }
37 
38  return nHitsOfSpecifiedType;
39 }
void lar_content::LArMonitoringHelper::FillContingencyTable ( const pandora::CaloHitList &  caloHits,
const pandora::ClusterList &  clusters,
std::map< const pandora::Cluster *const, std::map< const pandora::MCParticle *const, int >> &  cTable 
)
static

Fill the contingency table for a set of CaloHits partitioned by Cluster and parent MCParticle.

Parameters
[in]caloHitsList of hits to be considered
[in]clustersList of clusters that contain the hits
[out]cTableContingency table as a map of Cluster to a map of MCParticle to the value of the table at this entry which is the intersection of clusterings defined by each object

Definition at line 385 of file LArMonitoringHelper.cc.

References weight.

387 {
388  struct CaloHitParents
389  {
390  const pandora::MCParticle *m_pMainMC;
391  const pandora::Cluster *m_pCluster;
392 
393  CaloHitParents() :
394  m_pMainMC{nullptr},
395  m_pCluster{nullptr} {};
396  };
397  std::map<const CaloHit *const, CaloHitParents> hitParents;
398 
399  // Track the parent MC particle of each hit
400  for (const CaloHit *const pCaloHit : caloHits)
401  {
402  const MCParticle *pMainMC{nullptr};
403  const MCParticleWeightMap &weightMap{pCaloHit->GetMCParticleWeightMap()};
404  float maxWeight{std::numeric_limits<float>::lowest()};
405  for (const auto &[pMC, weight] : weightMap)
406  {
407  if (weight > maxWeight)
408  {
409  pMainMC = pMC;
410  maxWeight = weight;
411  }
412  }
413  if (pMainMC)
414  {
415  hitParents[pCaloHit] = CaloHitParents();
416  hitParents[pCaloHit].m_pMainMC = pMainMC;
417  }
418  }
419 
420  // Also track the reco cluster the hits are in
421  for (const Cluster *const pCluster : clusters)
422  {
423  const CaloHitList &isolatedHits{pCluster->GetIsolatedCaloHitList()};
424  CaloHitList clusterCaloHits;
425  pCluster->GetOrderedCaloHitList().FillCaloHitList(clusterCaloHits);
426  clusterCaloHits.insert(clusterCaloHits.end(), isolatedHits.begin(), isolatedHits.end());
427  for (const CaloHit *const pCaloHit : clusterCaloHits)
428  {
429  if (hitParents.find(pCaloHit) == hitParents.end()) // Hit not being considered or truth mathching was missing
430  continue;
431  hitParents[pCaloHit].m_pCluster = pCluster;
432  }
433  }
434 
435  // The reco clusters and parent MC particle are the two partitions of the set of hits, fill the contingency table
436  for (const auto &[pCaloHit, parents] : hitParents)
437  {
438  const MCParticle *const pMC = parents.m_pMainMC;
439  const Cluster *const pCluster = parents.m_pCluster;
440 
441  if (cTable.find(pCluster) == cTable.end() || cTable.at(pCluster).find(pMC) == cTable.at(pCluster).end())
442  cTable[pCluster][pMC] = 0;
443  cTable.at(pCluster).at(pMC)++;
444  }
445 }
double weight
Definition: plottest35.C:25
void lar_content::LArMonitoringHelper::GetOrderedMCParticleVector ( const LArMCParticleHelper::MCContributionMapVector selectedMCParticleToGoodHitsMaps,
pandora::MCParticleVector &  orderedMCParticleVector 
)
static

Order input MCParticles by their number of hits.

Parameters
selectedMCParticleToGoodHitsMapsthe input vector of mappings from selected reconstructable MCParticles to their good hits
orderedMCParticleVectorthe output vector of ordered MCParticles

Definition at line 43 of file LArMonitoringHelper.cc.

Referenced by lar_content::MuonLeadingEventValidationAlgorithm::DetermineIncorrectlyReconstructedCosmicRays(), lar_content::NeutrinoEventValidationAlgorithm::FillValidationInfo(), lar_content::CosmicRayTaggingMonitoringTool::FindAmbiguousPfos(), lar_content::EventValidationBaseAlgorithm::InterpretMatching(), lar_content::MCParticleMonitoringAlgorithm::PrintPrimaryMCParticles(), lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput(), and lar_content::PfoValidationAlgorithm::Run().

45 {
46  for (const LArMCParticleHelper::MCContributionMap &mcParticleToGoodHitsMap : selectedMCParticleToGoodHitsMaps)
47  {
48  if (mcParticleToGoodHitsMap.empty())
49  continue;
50 
51  // Copy map contents to vector it can be sorted
52  std::vector<LArMCParticleHelper::MCParticleCaloHitListPair> mcParticleToGoodHitsVect;
53  std::copy(mcParticleToGoodHitsMap.begin(), mcParticleToGoodHitsMap.end(), std::back_inserter(mcParticleToGoodHitsVect));
54 
55  // Sort by number of hits descending
56  std::sort(mcParticleToGoodHitsVect.begin(), mcParticleToGoodHitsVect.end(),
58  {
59  // Neutrinos, then beam particles, then cosmic rays
60  const bool isANuFinalState(LArMCParticleHelper::IsBeamNeutrinoFinalState(a.first)),
61  isBNuFinalState(LArMCParticleHelper::IsBeamNeutrinoFinalState(b.first));
62 
63  if (isANuFinalState != isBNuFinalState)
64  return isANuFinalState;
65 
66  const bool isABeamParticle(LArMCParticleHelper::IsBeamParticle(a.first)),
67  isBBeamParticle(LArMCParticleHelper::IsBeamParticle(b.first));
68 
69  if (isABeamParticle != isBBeamParticle)
70  return isABeamParticle;
71 
72  // Then sort by numbers of true hits
73  if (a.second.size() != b.second.size())
74  return (a.second.size() > b.second.size());
75 
76  // Default to normal MCParticle sorting
77  return LArMCParticleHelper::SortByMomentum(a.first, b.first);
78  });
79 
80  for (const LArMCParticleHelper::MCParticleCaloHitListPair &mcParticleCaloHitPair : mcParticleToGoodHitsVect)
81  orderedMCParticleVector.push_back(mcParticleCaloHitPair.first);
82  }
83 
84  // Check that all elements of the vector are unique
85  const unsigned int nMCParticles(orderedMCParticleVector.size());
86  if (std::distance(orderedMCParticleVector.begin(), std::unique(orderedMCParticleVector.begin(), orderedMCParticleVector.end())) != nMCParticles)
87  throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
88 }
std::unordered_map< const pandora::MCParticle *, pandora::CaloHitList > MCContributionMap
std::pair< const pandora::MCParticle *, pandora::CaloHitList > MCParticleCaloHitListPair
static bool SortByMomentum(const pandora::MCParticle *const pLhs, const pandora::MCParticle *const pRhs)
Sort mc particles by their momentum.
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
static bool IsBeamNeutrinoFinalState(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary neutrino final state MCParticle.
void lar_content::LArMonitoringHelper::GetOrderedPfoVector ( const LArMCParticleHelper::PfoContributionMap pfoToReconstructable2DHitsMap,
pandora::PfoVector &  orderedPfoVector 
)
static

Order input Pfos by their number of hits.

Parameters
pfoToReconstructable2DHitsMapthe input vector of mappings from Pfos to their reconstructable hits
orderedPfoVectorthe output vector of ordered Pfos

Definition at line 92 of file LArMonitoringHelper.cc.

Referenced by lar_content::CosmicRayTaggingMonitoringTool::FindAmbiguousPfos(), lar_content::NeutrinoEventValidationAlgorithm::ProcessOutput(), and lar_content::PfoValidationAlgorithm::Run().

93 {
94  // Copy map contents to vector it can be sorted
95  std::vector<LArMCParticleHelper::PfoCaloHitListPair> pfoToReconstructable2DHitsVect;
96  std::copy(pfoToReconstructable2DHitsMap.begin(), pfoToReconstructable2DHitsMap.end(), std::back_inserter(pfoToReconstructable2DHitsVect));
97 
98  // Sort by number of hits descending putting neutrino final states first
99  std::sort(pfoToReconstructable2DHitsVect.begin(), pfoToReconstructable2DHitsVect.end(),
101  {
102  // Neutrinos before cosmic rays
103  const bool isANuFinalState(LArPfoHelper::IsNeutrinoFinalState(a.first)), isBNuFinalState(LArPfoHelper::IsNeutrinoFinalState(b.first));
104 
105  if (isANuFinalState != isBNuFinalState)
106  return isANuFinalState;
107 
108  if (a.second.size() != b.second.size())
109  return (a.second.size() > b.second.size());
110 
111  // Default to normal pfo sorting
112  return LArPfoHelper::SortByNHits(a.first, b.first);
113  });
114 
115  for (const LArMCParticleHelper::PfoCaloHitListPair &pfoCaloHitPair : pfoToReconstructable2DHitsVect)
116  orderedPfoVector.push_back(pfoCaloHitPair.first);
117 
118  // Check that all elements of the vector are unique
119  const unsigned int nPfos(orderedPfoVector.size());
120  if (std::distance(orderedPfoVector.begin(), std::unique(orderedPfoVector.begin(), orderedPfoVector.end())) != nPfos)
121  throw StatusCodeException(STATUS_CODE_ALREADY_PRESENT);
122 }
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
std::pair< const pandora::ParticleFlowObject *, pandora::CaloHitList > PfoCaloHitListPair
static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
void lar_content::LArMonitoringHelper::PrintMatchingTable ( const pandora::PfoVector &  orderedPfoVector,
const pandora::MCParticleVector &  orderedMCParticleVector,
const LArMCParticleHelper::MCParticleToPfoHitSharingMap mcParticleToPfoHitSharingMap,
const unsigned int  nMatches 
)
static

Print the shared good hits between all Pfos and MCParticles.

Parameters
orderedPfoVectorthe input vector of ordered Pfos
orderedMCParticleVectorthe input vector of ordered MCParticles
mcParticleToPfoHitSharingMapthe output mapping from selected reconstructable MCParticles to Pfos and the number hits shared
nMatchesthe maximum number of Pfo matches to show

Definition at line 205 of file LArMonitoringHelper.cc.

References lar_content::LArFormattingHelper::Table::AddElement(), and lar_content::LArFormattingHelper::Table::Print().

Referenced by lar_content::PfoValidationAlgorithm::Run().

207 {
208  if (orderedPfoVector.empty())
209  {
210  std::cout << "No Pfos supplied." << std::endl;
211  return;
212  }
213 
214  if (orderedMCParticleVector.empty())
215  {
216  std::cout << "No MCParticles supplied." << std::endl;
217  return;
218  }
219 
220  // Get the maximum number of MCParticle to Pfos matches that need to be shown
221  unsigned int maxMatches(0);
222  for (const auto &entry : mcParticleToPfoHitSharingMap)
223  maxMatches = std::max(static_cast<unsigned int>(entry.second.size()), maxMatches);
224 
225  const bool showOthersColumn(maxMatches > nMatches);
226  const unsigned int nMatchesToShow(std::min(maxMatches, nMatches));
227 
228  // Set up the table headers
229  std::vector<std::string> tableHeaders({"MCParticle", ""});
230  for (unsigned int i = 0; i < nMatchesToShow; ++i)
231  {
232  tableHeaders.push_back("");
233  tableHeaders.push_back("Pfo");
234  tableHeaders.push_back("nSharedHits");
235  }
236 
237  if (showOthersColumn)
238  {
239  tableHeaders.push_back("");
240  tableHeaders.push_back("");
241  tableHeaders.push_back("nOtherPfos");
242  tableHeaders.push_back("nSharedHits");
243  }
244 
245  LArFormattingHelper::Table table(tableHeaders);
246 
247  // Make a new row for each MCParticle
248  for (unsigned int mcParticleId = 0; mcParticleId < orderedMCParticleVector.size(); ++mcParticleId)
249  {
250  const MCParticle *const pMCParticle(orderedMCParticleVector.at(mcParticleId));
251  LArMCParticleHelper::MCParticleToPfoHitSharingMap::const_iterator it = mcParticleToPfoHitSharingMap.find(pMCParticle);
252  LArMCParticleHelper::PfoToSharedHitsVector pfoToSharedHitsVector;
253 
254  if (it != mcParticleToPfoHitSharingMap.end())
255  pfoToSharedHitsVector = it->second;
256 
260 
261  // ATTN enumerate from 1 to match event validation algorithm
262  table.AddElement(mcParticleId + 1, LArFormattingHelper::REGULAR, mcCol);
263 
264  // Get the matched Pfos
265  unsigned int nPfosShown(0);
266  unsigned int nOtherHits(0);
267  for (const auto &pfoNSharedHitsPair : pfoToSharedHitsVector)
268  {
269  for (unsigned int pfoId = 0; pfoId < orderedPfoVector.size(); ++pfoId)
270  {
271  if (pfoNSharedHitsPair.first != orderedPfoVector.at(pfoId))
272  continue;
273 
274  if (nPfosShown < nMatchesToShow)
275  {
276  // ATTN enumerate from 1 to match event validation algorithm
277  const LArFormattingHelper::Color pfoCol(
279  table.AddElement(pfoId + 1, LArFormattingHelper::REGULAR, pfoCol);
280  table.AddElement(pfoNSharedHitsPair.second.size(), LArFormattingHelper::REGULAR, pfoCol);
281  nPfosShown++;
282  }
283  else
284  {
285  nOtherHits += pfoNSharedHitsPair.second.size();
286  }
287  break;
288  }
289  }
290 
291  // Pad the rest of the row with empty entries
292  for (unsigned int i = 0; i < nMatchesToShow - nPfosShown; ++i)
293  {
294  table.AddElement("");
295  table.AddElement("");
296  }
297 
298  // Print any remaining matches
299  if (!showOthersColumn)
300  continue;
301 
302  if (nOtherHits != 0)
303  {
304  table.AddElement(pfoToSharedHitsVector.size() - nPfosShown);
305  table.AddElement(nOtherHits);
306  }
307  else
308  {
309  table.AddElement("");
310  table.AddElement("");
311  }
312  }
313  table.Print();
314 }
std::vector< PfoCaloHitListPair > PfoToSharedHitsVector
intermediate_table::const_iterator const_iterator
static bool IsBeamParticle(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary beam MCParticle.
static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
static bool IsBeamNeutrinoFinalState(const pandora::MCParticle *const pMCParticle)
Returns true if passed a primary neutrino final state MCParticle.
map< int, array< map< int, double >, 2 >> Table
Definition: plot.C:18
void lar_content::LArMonitoringHelper::PrintMCParticleTable ( const LArMCParticleHelper::MCContributionMap selectedMCParticleToGoodHitsMaps,
const pandora::MCParticleVector &  orderedMCParticleVector 
)
static

Print details of selected MCParticles to the terminal in a table.

Parameters
selectedMCParticleToGoodHitsMapthe input mapping from selected reconstructable MCParticles to their good hits
orderedMCParticleVectorthe input vector of ordered MCParticles

Definition at line 126 of file LArMonitoringHelper.cc.

Referenced by lar_content::CosmicRayTaggingMonitoringTool::FindAmbiguousPfos(), and lar_content::PfoValidationAlgorithm::Run().

128 {
129  if (selectedMCParticleToGoodHitsMap.empty())
130  {
131  std::cout << "No MCParticles supplied." << std::endl;
132  return;
133  }
134 
135  LArFormattingHelper::Table table({"ID", "NUANCE", "TYPE", "", "E", "dist", "", "nGoodHits", "U", "V", "W"});
136 
137  unsigned int usedParticleCount(0);
138  for (unsigned int id = 0; id < orderedMCParticleVector.size(); ++id)
139  {
140  const MCParticle *const pMCParticle(orderedMCParticleVector.at(id));
141 
142  LArMCParticleHelper::MCContributionMap::const_iterator it = selectedMCParticleToGoodHitsMap.find(pMCParticle);
143  if (selectedMCParticleToGoodHitsMap.end() == it)
144  continue; // ATTN MCParticles in selectedMCParticleToGoodHitsMap may be a subset of orderedMCParticleVector
145 
146  // ATTN enumerate from 1 to match event validation algorithm
147  table.AddElement(id + 1);
148  table.AddElement(LArMCParticleHelper::GetNuanceCode(pMCParticle));
149  table.AddElement(PdgTable::GetParticleName(pMCParticle->GetParticleId()));
150 
151  table.AddElement(pMCParticle->GetEnergy());
152  table.AddElement((pMCParticle->GetEndpoint() - pMCParticle->GetVertex()).GetMagnitude());
153 
154  table.AddElement(it->second.size());
155  table.AddElement(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, it->second));
156  table.AddElement(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, it->second));
157  table.AddElement(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, it->second));
158 
159  usedParticleCount++;
160  }
161 
162  // Check every MCParticle in selectedMCParticleToGoodHitsMap has been printed
163  if (usedParticleCount != selectedMCParticleToGoodHitsMap.size())
164  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
165 
166  table.Print();
167 }
intermediate_table::const_iterator const_iterator
static unsigned int GetNuanceCode(const pandora::MCParticle *const pMCParticle)
Get the nuance code of an MCParticle.
static unsigned int CountHitsByType(const pandora::HitType hitType, const pandora::CaloHitList &caloHitList)
Count the number of calo hits, in a provided list, of a specified type.
map< int, array< map< int, double >, 2 >> Table
Definition: plot.C:18
void lar_content::LArMonitoringHelper::PrintPfoTable ( const LArMCParticleHelper::PfoContributionMap pfoToReconstructable2DHitsMap,
const pandora::PfoVector &  orderedPfoVector 
)
static

Print details of input Pfos to the terminal in a table.

Parameters
pfoToReconstructable2DHitsMapthe input vector of mappings from Pfos to their reconstructable hits
orderedPfoVectorthe input vector of ordered Pfos

Definition at line 171 of file LArMonitoringHelper.cc.

Referenced by lar_content::PfoValidationAlgorithm::Run().

172 {
173  if (pfoToReconstructable2DHitsMap.empty())
174  {
175  std::cout << "No Pfos supplied." << std::endl;
176  return;
177  }
178 
179  LArFormattingHelper::Table table({"ID", "PID", "Is Nu FS", "", "nGoodHits", "U", "V", "W"});
180 
181  for (unsigned int id = 0; id < orderedPfoVector.size(); ++id)
182  {
183  const ParticleFlowObject *const pPfo(orderedPfoVector.at(id));
184 
185  LArMCParticleHelper::PfoContributionMap::const_iterator it = pfoToReconstructable2DHitsMap.find(pPfo);
186  if (pfoToReconstructable2DHitsMap.end() == it)
187  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
188 
189  // ATTN enumerate from 1 to match event validation algorithm
190  table.AddElement(id + 1);
191  table.AddElement(pPfo->GetParticleId());
192  table.AddElement(LArPfoHelper::IsNeutrinoFinalState(pPfo));
193 
194  table.AddElement(it->second.size());
195  table.AddElement(LArMonitoringHelper::CountHitsByType(TPC_VIEW_U, it->second));
196  table.AddElement(LArMonitoringHelper::CountHitsByType(TPC_VIEW_V, it->second));
197  table.AddElement(LArMonitoringHelper::CountHitsByType(TPC_VIEW_W, it->second));
198  }
199 
200  table.Print();
201 }
intermediate_table::const_iterator const_iterator
static bool IsNeutrinoFinalState(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a final-state particle from a neutrino (or antineutrino) interaction.
static unsigned int CountHitsByType(const pandora::HitType hitType, const pandora::CaloHitList &caloHitList)
Count the number of calo hits, in a provided list, of a specified type.
map< int, array< map< int, double >, 2 >> Table
Definition: plot.C:18

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