Public Member Functions | Private Member Functions | Private Attributes | List of all members
lar_content::HierarchyMonitoringAlgorithm Class Reference

HierarchyMonitoringAlgorithm class. More...

#include <HierarchyMonitoringAlgorithm.h>

Inheritance diagram for lar_content::HierarchyMonitoringAlgorithm:

Public Member Functions

 HierarchyMonitoringAlgorithm ()
 Default constructor. More...
 
virtual ~HierarchyMonitoringAlgorithm ()
 

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 
void VisualizeMC (const LArHierarchyHelper::MCHierarchy &hierarchy) const
 Visualize MC nodes. More...
 
void VisualizeMCDistinct (const LArHierarchyHelper::MCHierarchy &hierarchy) const
 Visualize MC nodes without grouping by particle id. More...
 
void VisualizeMCProcess (const LArHierarchyHelper::MCHierarchy &hierarchy) const
 Visualize MC nodes based on the MC process that created them. More...
 
void VisualizeReco (const LArHierarchyHelper::RecoHierarchy &hierarchy) const
 Visualize the reco nodes. More...
 
void VisualizeMatches (const LArHierarchyHelper::MatchInfo &matchInfo) const
 Visualize reco to MC matches. More...
 
void VisualizeMatchedMC (const LArHierarchyHelper::MCMatches &matches, const int mcIdx) const
 Visualize the reco nodes matched to a single MC node. More...
 
void VisualizeUnmatchedReco (const LArHierarchyHelper::RecoHierarchy::Node *pNode) const
 Visualize the unmatched reco node. More...
 
void Visualize (const pandora::CaloHitList &hits, const std::string &label, const int color) const
 Visualize a calo hit list. More...
 
void FillHitLists (const pandora::CaloHitList &hits, pandora::CaloHitList &uHits, pandora::CaloHitList &vHits, pandora::CaloHitList &wHits) const
 Fill per view hit lists. More...
 

Private Attributes

std::string m_caloHitListName
 Name of input calo hit list. More...
 
std::string m_pfoListName
 Name of input PFO list. More...
 
bool m_visualizeMC
 Whether or not to visualize the MC nodes. More...
 
bool m_visualizeReco
 Whether or not to visualize the reco nodes. More...
 
bool m_visualizeDistinct
 If true, allocate colours without consideration of particle id. More...
 
bool m_visualizeProcess
 If true, allocate colours based on the MC process. More...
 
bool m_match
 Whether or not to visualize the reco to MC matches. More...
 
bool m_collectionOnly
 Limit display to the collection plane only. More...
 
bool m_foldToPrimaries
 Whether or not to fold everything back to primaries. More...
 
bool m_foldDynamic
 Whether or not to fold based on process information. More...
 
float m_transparencyThresholdE
 Cell energy for which transparency is saturated (0%, fully opaque) More...
 
float m_energyScaleThresholdE
 Cell energy for which color is at top end of continous color palette. More...
 
float m_scalingFactor
 TEve works with [cm], Pandora usually works with [mm] (but LArContent went with cm too) More...
 

Detailed Description

HierarchyMonitoringAlgorithm class.

Definition at line 22 of file HierarchyMonitoringAlgorithm.h.

Constructor & Destructor Documentation

lar_content::HierarchyMonitoringAlgorithm::HierarchyMonitoringAlgorithm ( )

Default constructor.

Definition at line 18 of file HierarchyMonitoringAlgorithm.cc.

18  :
19  m_visualizeMC(false),
20  m_visualizeReco(false),
21  m_visualizeDistinct(false),
22  m_visualizeProcess{false},
23  m_match(false),
24  m_collectionOnly{false},
25  m_foldToPrimaries{false},
26  m_foldDynamic{true},
29  m_scalingFactor{1.f}
30 {
31 }
bool m_visualizeMC
Whether or not to visualize the MC nodes.
bool m_visualizeProcess
If true, allocate colours based on the MC process.
float m_scalingFactor
TEve works with [cm], Pandora usually works with [mm] (but LArContent went with cm too) ...
bool m_visualizeReco
Whether or not to visualize the reco nodes.
bool m_foldToPrimaries
Whether or not to fold everything back to primaries.
bool m_match
Whether or not to visualize the reco to MC matches.
bool m_collectionOnly
Limit display to the collection plane only.
float m_transparencyThresholdE
Cell energy for which transparency is saturated (0%, fully opaque)
bool m_foldDynamic
Whether or not to fold based on process information.
float m_energyScaleThresholdE
Cell energy for which color is at top end of continous color palette.
bool m_visualizeDistinct
If true, allocate colours without consideration of particle id.
lar_content::HierarchyMonitoringAlgorithm::~HierarchyMonitoringAlgorithm ( )
virtual

Definition at line 35 of file HierarchyMonitoringAlgorithm.cc.

36 {
37  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), "processes", "processes.root", "UPDATE"));
38 }

Member Function Documentation

void lar_content::HierarchyMonitoringAlgorithm::FillHitLists ( const pandora::CaloHitList &  hits,
pandora::CaloHitList &  uHits,
pandora::CaloHitList &  vHits,
pandora::CaloHitList &  wHits 
) const
private

Fill per view hit lists.

Parameters
hitsThe input list of hits
uHitsThe output list of hits in U
vHitsThe output list of hits in V
wHitsThe output list of hits in W

Definition at line 378 of file HierarchyMonitoringAlgorithm.cc.

379 {
380  for (const CaloHit *pCaloHit : hits)
381  {
382  const HitType view{pCaloHit->GetHitType()};
383  if (view == HitType::TPC_VIEW_U)
384  uHits.emplace_back(pCaloHit);
385  else if (view == HitType::TPC_VIEW_V)
386  vHits.emplace_back(pCaloHit);
387  else if (view == HitType::TPC_VIEW_W)
388  wHits.emplace_back(pCaloHit);
389  }
390 }
enum cvn::HType HitType
StatusCode lar_content::HierarchyMonitoringAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 394 of file HierarchyMonitoringAlgorithm.cc.

395 {
396  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "CaloHitListName", m_caloHitListName));
397  if (m_caloHitListName.empty())
398  m_caloHitListName = "CaloHitList2D";
399  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PfoListName", m_pfoListName));
400  if (m_pfoListName.empty())
401  m_pfoListName = "RecreatedPfos";
402  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VisualizeMC", m_visualizeMC));
403  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VisualizeReco", m_visualizeReco));
404  PANDORA_RETURN_RESULT_IF_AND_IF(
405  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VisualizeDistinct", m_visualizeDistinct));
406  PANDORA_RETURN_RESULT_IF_AND_IF(
407  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "VisualizeProcess", m_visualizeProcess));
408  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PerformMatching", m_match));
409  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "CollectionOnly", m_collectionOnly));
410  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldToPrimaries", m_foldToPrimaries));
411  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldDynamic", m_foldDynamic));
412  if (m_foldToPrimaries)
413  m_foldDynamic = false;
414  PANDORA_RETURN_RESULT_IF_AND_IF(
415  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TransparencyThresholdE", m_transparencyThresholdE));
416  PANDORA_RETURN_RESULT_IF_AND_IF(
417  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EnergyScaleThresholdE", m_energyScaleThresholdE));
418  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ScalingFactor", m_scalingFactor));
419 
420  return STATUS_CODE_SUCCESS;
421 }
std::string m_pfoListName
Name of input PFO list.
bool m_visualizeMC
Whether or not to visualize the MC nodes.
bool m_visualizeProcess
If true, allocate colours based on the MC process.
float m_scalingFactor
TEve works with [cm], Pandora usually works with [mm] (but LArContent went with cm too) ...
bool m_visualizeReco
Whether or not to visualize the reco nodes.
bool m_foldToPrimaries
Whether or not to fold everything back to primaries.
std::string m_caloHitListName
Name of input calo hit list.
bool m_match
Whether or not to visualize the reco to MC matches.
bool m_collectionOnly
Limit display to the collection plane only.
float m_transparencyThresholdE
Cell energy for which transparency is saturated (0%, fully opaque)
bool m_foldDynamic
Whether or not to fold based on process information.
float m_energyScaleThresholdE
Cell energy for which color is at top end of continous color palette.
bool m_visualizeDistinct
If true, allocate colours without consideration of particle id.
StatusCode lar_content::HierarchyMonitoringAlgorithm::Run ( )
private

Definition at line 42 of file HierarchyMonitoringAlgorithm.cc.

43 {
44  PANDORA_MONITORING_API(
45  SetEveDisplayParameters(this->GetPandora(), true, DETECTOR_VIEW_XZ, m_transparencyThresholdE, m_energyScaleThresholdE, m_scalingFactor));
46 
47  const CaloHitList *pCaloHitList(nullptr);
48  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_caloHitListName, pCaloHitList));
49  const MCParticleList *pMCParticleList(nullptr);
50  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pMCParticleList));
51  const PfoList *pPfoList(nullptr);
52  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_pfoListName, pPfoList));
53 
54  LArHierarchyHelper::MCHierarchy::ReconstructabilityCriteria criteria(15, 5, 2, false);
55  LArHierarchyHelper::MCHierarchy mcHierarchy(criteria);
56  LArHierarchyHelper::RecoHierarchy recoHierarchy;
57  LArHierarchyHelper::FoldingParameters foldParameters;
59  foldParameters.m_foldToTier = true;
60  else if (m_foldDynamic)
61  foldParameters.m_foldDynamic = true;
62 
63  if (m_visualizeMC || m_match)
64  LArHierarchyHelper::FillMCHierarchy(*pMCParticleList, *pCaloHitList, foldParameters, mcHierarchy);
65  if (m_visualizeReco || m_match)
66  LArHierarchyHelper::FillRecoHierarchy(*pPfoList, foldParameters, recoHierarchy);
67  if (m_match)
68  {
69  LArHierarchyHelper::MatchInfo matchInfo;
70  LArHierarchyHelper::MatchHierarchies(mcHierarchy, recoHierarchy, matchInfo);
71  matchInfo.Print(mcHierarchy);
72  this->VisualizeMatches(matchInfo);
73  }
74  else
75  {
76  if (m_visualizeMC)
77  {
79  this->VisualizeMCDistinct(mcHierarchy);
80  else if (m_visualizeProcess)
81  this->VisualizeMCProcess(mcHierarchy);
82  else
83  this->VisualizeMC(mcHierarchy);
84  }
85  if (m_visualizeReco)
86  this->VisualizeReco(recoHierarchy);
87  }
88 
89  return STATUS_CODE_SUCCESS;
90 }
std::string m_pfoListName
Name of input PFO list.
bool m_visualizeMC
Whether or not to visualize the MC nodes.
bool m_visualizeProcess
If true, allocate colours based on the MC process.
void VisualizeMCProcess(const LArHierarchyHelper::MCHierarchy &hierarchy) const
Visualize MC nodes based on the MC process that created them.
float m_scalingFactor
TEve works with [cm], Pandora usually works with [mm] (but LArContent went with cm too) ...
bool m_visualizeReco
Whether or not to visualize the reco nodes.
static void MatchHierarchies(const MCHierarchy &mcHierarchy, const RecoHierarchy &recoHierarchy, MatchInfo &matchInfo)
Finds the matches between reconstructed and MC hierarchies.
void VisualizeMatches(const LArHierarchyHelper::MatchInfo &matchInfo) const
Visualize reco to MC matches.
static void FillRecoHierarchy(const pandora::PfoList &pfoList, const FoldingParameters &foldParameters, RecoHierarchy &hierarchy)
Fill a reconstructed hierarchy based on the specified folding criteria (see RecoHierarchy::FillHierar...
bool m_foldToPrimaries
Whether or not to fold everything back to primaries.
void VisualizeReco(const LArHierarchyHelper::RecoHierarchy &hierarchy) const
Visualize the reco nodes.
void VisualizeMC(const LArHierarchyHelper::MCHierarchy &hierarchy) const
Visualize MC nodes.
std::string m_caloHitListName
Name of input calo hit list.
bool m_match
Whether or not to visualize the reco to MC matches.
static void FillMCHierarchy(const pandora::MCParticleList &mcParticleList, const pandora::CaloHitList &caloHitList, const FoldingParameters &foldParameters, MCHierarchy &hierarchy)
Fill an MC hierarchy based on the specified folding criteria (see MCHierarchy::FillHierarchy for deta...
void VisualizeMCDistinct(const LArHierarchyHelper::MCHierarchy &hierarchy) const
Visualize MC nodes without grouping by particle id.
float m_transparencyThresholdE
Cell energy for which transparency is saturated (0%, fully opaque)
bool m_foldDynamic
Whether or not to fold based on process information.
float m_energyScaleThresholdE
Cell energy for which color is at top end of continous color palette.
bool m_visualizeDistinct
If true, allocate colours without consideration of particle id.
void lar_content::HierarchyMonitoringAlgorithm::Visualize ( const pandora::CaloHitList &  hits,
const std::string label,
const int  color 
) const
private

Visualize a calo hit list.

Parameters
hitsThe hits to visualize
labelThe label to apply to the hits
colorThe color to apply to the hits

Definition at line 366 of file HierarchyMonitoringAlgorithm.cc.

367 {
368  if (!hits.empty() && hits.size() > 1)
369  {
370  if (m_collectionOnly && hits.front()->GetHitType() != TPC_VIEW_W)
371  return;
372  PANDORA_MONITORING_API(VisualizeCaloHits(this->GetPandora(), &hits, label, static_cast<Color>(color)));
373  }
374 }
std::size_t color(std::string const &procname)
bool m_collectionOnly
Limit display to the collection plane only.
void lar_content::HierarchyMonitoringAlgorithm::VisualizeMatchedMC ( const LArHierarchyHelper::MCMatches matches,
const int  mcIdx 
) const
private

Visualize the reco nodes matched to a single MC node.

Parameters
matchesThe MC to reco matches
mcIdxThe unique identifier for the MC particle

Definition at line 273 of file HierarchyMonitoringAlgorithm.cc.

274 {
275  const std::map<int, const std::string> keys = {{13, "mu"}, {11, "e"}, {22, "gamma"}, {321, "kaon"}, {211, "pi"}, {2212, "p"}};
276  const int green{3}, gray{14};
277  const std::map<int, int> colors = {{0, 5}, {1, 2}, {2, 9}, {3, 1}, {4, 4}};
278 
279  const LArHierarchyHelper::MCHierarchy::Node *pMCNode{matches.GetMC()};
280  const int pdg{pMCNode->GetParticleId()};
281 
282  std::string key("other");
283  if (keys.find(pdg) != keys.end())
284  key = keys.at(pdg);
285 
286  CaloHitList mcUHits, mcVHits, mcWHits;
287  this->FillHitLists(pMCNode->GetCaloHits(), mcUHits, mcVHits, mcWHits);
288  std::string leading{pMCNode->IsLeadingLepton() ? "_leading" : ""};
289  if (!matches.GetRecoMatches().empty())
290  {
291  std::string suffix{std::to_string(mcIdx) + "_" + key + leading};
292  this->Visualize(mcUHits, "u_" + suffix, green);
293  this->Visualize(mcVHits, "v_" + suffix, green);
294  this->Visualize(mcWHits, "w_" + suffix, green);
295  }
296  else
297  {
298  std::string suffix{std::to_string(mcIdx) + "_" + key + "_unmatched"};
299  this->Visualize(mcUHits, "u_" + suffix, gray);
300  this->Visualize(mcVHits, "v_" + suffix, gray);
301  this->Visualize(mcWHits, "w_" + suffix, gray);
302  }
303 
304  int recoIdx{0};
305  size_t colorIdx{0};
306  for (const LArHierarchyHelper::RecoHierarchy::Node *pRecoNode : matches.GetRecoMatches())
307  {
308  CaloHitList recoUHits, recoVHits, recoWHits;
309  this->FillHitLists(pRecoNode->GetCaloHits(), recoUHits, recoVHits, recoWHits);
310  const int characterisation{pRecoNode->GetParticleId()};
311  const std::string recoKey{characterisation == MU_MINUS ? "T" : characterisation == E_MINUS ? "S" : "?"};
312  const std::string recoSuffix{std::to_string(mcIdx) + "->" + std::to_string(recoIdx) + "_" + recoKey};
313  if (!recoUHits.empty())
314  {
315  const float purity{matches.GetPurity(pRecoNode, TPC_VIEW_U, true)};
316  const float completeness{matches.GetCompleteness(pRecoNode, TPC_VIEW_U, true)};
317  std::ostringstream metrics;
318  metrics.precision(2);
319  metrics << std::fixed << " p: " << purity << " c: " << completeness;
320  PANDORA_MONITORING_API(
321  VisualizeCaloHits(this->GetPandora(), &recoUHits, "u_" + recoSuffix + metrics.str(), static_cast<Color>(colors.at(colorIdx))));
322  }
323  if (!recoVHits.empty())
324  {
325  const float purity{matches.GetPurity(pRecoNode, TPC_VIEW_V, true)};
326  const float completeness{matches.GetCompleteness(pRecoNode, TPC_VIEW_V, true)};
327  std::ostringstream metrics;
328  metrics.precision(2);
329  metrics << std::fixed << " p: " << purity << " c: " << completeness;
330  PANDORA_MONITORING_API(
331  VisualizeCaloHits(this->GetPandora(), &recoVHits, "v_" + recoSuffix + metrics.str(), static_cast<Color>(colors.at(colorIdx))));
332  }
333  if (!recoWHits.empty())
334  {
335  const float purity{matches.GetPurity(pRecoNode, TPC_VIEW_W, true)};
336  const float completeness{matches.GetCompleteness(pRecoNode, TPC_VIEW_W, true)};
337  std::ostringstream metrics;
338  metrics.precision(2);
339  metrics << std::fixed << " p: " << purity << " c: " << completeness;
340  PANDORA_MONITORING_API(
341  VisualizeCaloHits(this->GetPandora(), &recoWHits, "w_" + recoSuffix + metrics.str(), static_cast<Color>(colors.at(colorIdx))));
342  }
343  colorIdx = (colorIdx + 1) >= colors.size() ? 0 : colorIdx + 1;
344  ++recoIdx;
345  }
346 }
void Visualize(const pandora::CaloHitList &hits, const std::string &label, const int color) const
Visualize a calo hit list.
QMapNodeBase Node
Definition: qmap.cpp:41
std::string string
Definition: nybbler.cc:12
Definition: image.cpp:28
def key(type, name=None)
Definition: graph.py:13
void FillHitLists(const pandora::CaloHitList &hits, pandora::CaloHitList &uHits, pandora::CaloHitList &vHits, pandora::CaloHitList &wHits) const
Fill per view hit lists.
metrics
Definition: train.py:350
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar_content::HierarchyMonitoringAlgorithm::VisualizeMatches ( const LArHierarchyHelper::MatchInfo matchInfo) const
private

Visualize reco to MC matches.

Parameters
matchInfoThe match information between reco and MC hierarchies

Definition at line 254 of file HierarchyMonitoringAlgorithm.cc.

255 {
256  std::map<const LArHierarchyHelper::MCHierarchy::Node *, int> mcIdxMap;
257  int mcIdx{0};
258  for (const LArHierarchyHelper::MCMatches &matches : matchInfo.GetMatches())
259  if (mcIdxMap.find(matches.GetMC()) == mcIdxMap.end())
260  mcIdxMap[matches.GetMC()] = mcIdx++;
261 
262  for (const LArHierarchyHelper::MCMatches &matches : matchInfo.GetMatches())
263  this->VisualizeMatchedMC(matches, mcIdxMap.at(matches.GetMC()));
264 
265  for (const LArHierarchyHelper::RecoHierarchy::Node *pNode : matchInfo.GetUnmatchedReco())
266  this->VisualizeUnmatchedReco(pNode);
267 
268  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
269 }
QMapNodeBase Node
Definition: qmap.cpp:41
void VisualizeMatchedMC(const LArHierarchyHelper::MCMatches &matches, const int mcIdx) const
Visualize the reco nodes matched to a single MC node.
void VisualizeUnmatchedReco(const LArHierarchyHelper::RecoHierarchy::Node *pNode) const
Visualize the unmatched reco node.
void lar_content::HierarchyMonitoringAlgorithm::VisualizeMC ( const LArHierarchyHelper::MCHierarchy hierarchy) const
private

Visualize MC nodes.

Parameters
hierarchyThe MC hierarchy to render

Definition at line 94 of file HierarchyMonitoringAlgorithm.cc.

95 {
96  const std::map<int, const std::string> keys = {{13, "mu"}, {11, "e"}, {22, "gamma"}, {321, "kaon"}, {211, "pi"}, {2212, "p"}};
97  const std::map<std::string, int> colors = {{"mu", 5}, {"e", 2}, {"gamma", 9}, {"kaon", 1}, {"pi", 3}, {"p", 4}, {"other", 14}};
98 
100  hierarchy.GetFlattenedNodes(nodes);
101 
102  int nodeIdx{0};
103  for (const LArHierarchyHelper::MCHierarchy::Node *pNode : nodes)
104  {
105  std::string key("other");
106  const int pdg{std::abs(pNode->GetParticleId())};
107  if (keys.find(pdg) != keys.end())
108  key = keys.at(pdg);
109 
110  CaloHitList uHits, vHits, wHits;
111  this->FillHitLists(pNode->GetCaloHits(), uHits, vHits, wHits);
112  std::string suffix{std::to_string(nodeIdx) + "_" + key};
113  this->Visualize(uHits, "u_" + suffix, colors.at(key));
114  this->Visualize(vHits, "v_" + suffix, colors.at(key));
115  this->Visualize(wHits, "w_" + suffix, colors.at(key));
116  ++nodeIdx;
117  }
118 
119  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
120 }
void Visualize(const pandora::CaloHitList &hits, const std::string &label, const int color) const
Visualize a calo hit list.
QMapNodeBase Node
Definition: qmap.cpp:41
std::string string
Definition: nybbler.cc:12
T abs(T value)
#define nodes
def key(type, name=None)
Definition: graph.py:13
void FillHitLists(const pandora::CaloHitList &hits, pandora::CaloHitList &uHits, pandora::CaloHitList &vHits, pandora::CaloHitList &wHits) const
Fill per view hit lists.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar_content::HierarchyMonitoringAlgorithm::VisualizeMCDistinct ( const LArHierarchyHelper::MCHierarchy hierarchy) const
private

Visualize MC nodes without grouping by particle id.

Parameters
hierarchyThe MC hierarchy to render

Definition at line 124 of file HierarchyMonitoringAlgorithm.cc.

125 {
126  const std::map<int, const std::string> keys = {{13, "mu"}, {11, "e"}, {22, "gamma"}, {321, "kaon"}, {211, "pi"}, {2212, "p"}};
127  const int nColours{9};
128  const int colors[nColours] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
129 
131  hierarchy.GetFlattenedNodes(nodes);
132 
133  int nodeIdx{0}, colorIdx{0};
134  for (const LArHierarchyHelper::MCHierarchy::Node *pNode : nodes)
135  {
136  std::string key("other");
137  const int pdg{std::abs(pNode->GetParticleId())};
138  if (keys.find(pdg) != keys.end())
139  key = keys.at(pdg);
140 
141  CaloHitList uHits, vHits, wHits;
142  this->FillHitLists(pNode->GetCaloHits(), uHits, vHits, wHits);
143  std::string suffix{std::to_string(nodeIdx) + "_" + key};
144  this->Visualize(uHits, "u_" + suffix, colors[colorIdx]);
145  this->Visualize(vHits, "v_" + suffix, colors[colorIdx]);
146  this->Visualize(wHits, "w_" + suffix, colors[colorIdx]);
147  colorIdx = (colorIdx + 1) >= nColours ? 0 : colorIdx + 1;
148  ++nodeIdx;
149  }
150 
151  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
152 }
void Visualize(const pandora::CaloHitList &hits, const std::string &label, const int color) const
Visualize a calo hit list.
QMapNodeBase Node
Definition: qmap.cpp:41
std::string string
Definition: nybbler.cc:12
T abs(T value)
#define nodes
def key(type, name=None)
Definition: graph.py:13
void FillHitLists(const pandora::CaloHitList &hits, pandora::CaloHitList &uHits, pandora::CaloHitList &vHits, pandora::CaloHitList &wHits) const
Fill per view hit lists.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar_content::HierarchyMonitoringAlgorithm::VisualizeMCProcess ( const LArHierarchyHelper::MCHierarchy hierarchy) const
private

Visualize MC nodes based on the MC process that created them.

Parameters
hierarchyThe MC hierarchy to render

Definition at line 156 of file HierarchyMonitoringAlgorithm.cc.

157 {
158  const std::map<MCProcess, std::string> procToCategoryMap = {{MC_PROC_INCIDENT_NU, "invisible"}, {MC_PROC_UNKNOWN, "invisible"},
159  {MC_PROC_PRIMARY, "primary"}, {MC_PROC_COMPT, "compt"}, {MC_PROC_PHOT, "phot"}, {MC_PROC_ANNIHIL, "annihil"}, {MC_PROC_E_IONI, "ioni"},
160  {MC_PROC_E_BREM, "brem"}, {MC_PROC_CONV, "conv"}, {MC_PROC_MU_IONI, "ioni"}, {MC_PROC_MU_MINUS_CAPTURE_AT_REST, "capture"},
161  {MC_PROC_NEUTRON_INELASTIC, "inelastic"}, {MC_PROC_N_CAPTURE, "capture"}, {MC_PROC_HAD_ELASTIC, "elastic"}, {MC_PROC_DECAY, "decay"},
162  {MC_PROC_COULOMB_SCAT, "coulomb"}, {MC_PROC_MU_BREM, "brem"}, {MC_PROC_MU_PAIR_PROD, "pair_prod"}, {MC_PROC_PHOTON_INELASTIC, "inelastic"},
163  {MC_PROC_HAD_IONI, "ioni"}, {MC_PROC_PROTON_INELASTIC, "inelastic"}, {MC_PROC_PI_PLUS_INELASTIC, "inelastic"},
165  {MC_PROC_RAYLEIGH, "rayleigh"}, {MC_PROC_HAD_BREM, "brem"}, {MC_PROC_HAD_PAIR_PROD, "pair_prod"}, {MC_PROC_ION_IONI, "ioni"},
166  {MC_PROC_NEUTRON_KILLER, "kill"}, {MC_PROC_ION_INELASTIC, "inelastic"}, {MC_PROC_HE3_INELASTIC, "inelastic"},
167  {MC_PROC_ALPHA_INELASTIC, "inelastic"}, {MC_PROC_ANTI_HE3_INELASTIC, "inelastic"}, {MC_PROC_ANTI_ALPHA_INELASTIC, "inelastic"},
169  {MC_PROC_ANTI_NEUTRON_INELASTIC, "inelastic"}, {MC_PROC_ANTI_PROTON_INELASTIC, "inelastic"},
170  {MC_PROC_ANTI_TRITON_INELASTIC, "inelastic"}, {MC_PROC_DEUTERON_INELASTIC, "inelastic"}, {MC_PROC_ELECTRON_NUCLEAR, "nuclear"},
171  {MC_PROC_PHOTON_NUCLEAR, "nuclear"}, {MC_PROC_KAON_PLUS_INELASTIC, "inelastic"}, {MC_PROC_KAON_MINUS_INELASTIC, "inelastic"},
172  {MC_PROC_HAD_BERTINI_CAPTURE_AT_REST, "capture"}, {MC_PROC_LAMBDA_INELASTIC, "inelastic"}, {MC_PROC_MU_NUCLEAR, "nuclear"},
173  {MC_PROC_TRITON_INELASTIC, "inelastic"}, {MC_PROC_PRIMARY_BACKGROUND, "background"}};
174 
175  const std::map<std::string, int> categoryToColorMap = {{"invisible", 0}, {"primary", 1}, {"compt", 2}, {"phot", 3}, {"annihil", 4},
176  {"ioni", 5}, {"brem", 6}, {"conv", 3}, {"capture", 6}, {"inelastic", 9}, {"elastic", 8}, {"decay", 7}, {"coulomb", 9},
177  {"pair_prod", 4}, {"transport", 1}, {"rayleigh", 9}, {"kill", 2}, {"nuclear", 5}, {"background", 7}};
178 
180  hierarchy.GetFlattenedNodes(nodes);
181 
182  int nodeIdx{0};
183  for (const LArHierarchyHelper::MCHierarchy::Node *pNode : nodes)
184  {
185  const LArMCParticle *pMC{dynamic_cast<const LArMCParticle *>(pNode->GetLeadingMCParticle())};
186  if (!pMC)
187  continue;
188  const MCProcess process{pMC->GetProcess()};
189  const std::string category{procToCategoryMap.at(process)};
190  const int pdg{std::abs(pNode->GetParticleId())};
191  const int tier{LArMCParticleHelper::GetHierarchyTier(pMC)};
192 
193  CaloHitList uHits, vHits, wHits;
194  this->FillHitLists(pNode->GetCaloHits(), uHits, vHits, wHits);
195  std::string suffix{std::to_string(nodeIdx) + " (" + std::to_string(tier) + ") " + std::to_string(pdg) + " " + category + " " +
197  if (process == MC_PROC_DECAY)
198  {
199  const MCParticleList &parentList{pMC->GetParentList()};
200  if (!parentList.empty())
201  {
202  const MCParticle *pParent{parentList.front()};
203  const int parentPdg{std::abs(pParent->GetParticleId())};
204  suffix += " from " + std::to_string(parentPdg);
205  }
206  }
207 
208  this->Visualize(uHits, "U " + suffix, categoryToColorMap.at(category));
209  this->Visualize(vHits, "V " + suffix, categoryToColorMap.at(category));
210  this->Visualize(wHits, "W " + suffix, categoryToColorMap.at(category));
211  ++nodeIdx;
212 
213  const int proc{static_cast<int>(process)};
214  const float mom{pMC->GetMomentum().GetMagnitude()};
215  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), "processes", "process", proc));
216  PANDORA_MONITORING_API(SetTreeVariable(this->GetPandora(), "processes", "momentum", mom));
217  PANDORA_MONITORING_API(FillTree(this->GetPandora(), "processes"));
218  }
219 
220  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
221 }
void Visualize(const pandora::CaloHitList &hits, const std::string &label, const int color) const
Visualize a calo hit list.
QMapNodeBase Node
Definition: qmap.cpp:41
std::string string
Definition: nybbler.cc:12
static int GetHierarchyTier(const pandora::MCParticle *const pMCParticle)
Determine the position in the hierarchy for the MCParticle.
def process(f, kind)
Definition: search.py:254
T abs(T value)
#define nodes
void FillHitLists(const pandora::CaloHitList &hits, pandora::CaloHitList &uHits, pandora::CaloHitList &vHits, pandora::CaloHitList &wHits) const
Fill per view hit lists.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar_content::HierarchyMonitoringAlgorithm::VisualizeReco ( const LArHierarchyHelper::RecoHierarchy hierarchy) const
private

Visualize the reco nodes.

Parameters
hierarchyThe reco hierarchy to render

Definition at line 225 of file HierarchyMonitoringAlgorithm.cc.

226 {
227  const int nColors{7};
228  const int colors[nColors] = {5, 2, 9, 1, 3, 4, 14};
229 
231  hierarchy.GetFlattenedNodes(nodes);
232 
233  int colorIdx{0};
234  int pfoIdx{0};
235  for (const LArHierarchyHelper::RecoHierarchy::Node *pNode : nodes)
236  {
237  CaloHitList uHits, vHits, wHits;
238  this->FillHitLists(pNode->GetCaloHits(), uHits, vHits, wHits);
239  const int pdg{pNode->GetParticleId()};
240  const std::string key{pdg == MU_MINUS ? "T" : pdg == E_MINUS ? "S" : "?"};
241  const std::string suffix{std::to_string(pfoIdx) + "_" + key};
242  this->Visualize(uHits, "u_" + suffix, colors[colorIdx]);
243  this->Visualize(vHits, "v_" + suffix, colors[colorIdx]);
244  this->Visualize(wHits, "w_" + suffix, colors[colorIdx]);
245  colorIdx = (colorIdx + 1) >= nColors ? 0 : colorIdx + 1;
246  ++pfoIdx;
247  }
248 
249  PANDORA_MONITORING_API(ViewEvent(this->GetPandora()));
250 }
void Visualize(const pandora::CaloHitList &hits, const std::string &label, const int color) const
Visualize a calo hit list.
QMapNodeBase Node
Definition: qmap.cpp:41
std::string string
Definition: nybbler.cc:12
#define nodes
def key(type, name=None)
Definition: graph.py:13
void FillHitLists(const pandora::CaloHitList &hits, pandora::CaloHitList &uHits, pandora::CaloHitList &vHits, pandora::CaloHitList &wHits) const
Fill per view hit lists.
std::string to_string(ModuleType const mt)
Definition: ModuleType.h:34
void lar_content::HierarchyMonitoringAlgorithm::VisualizeUnmatchedReco ( const LArHierarchyHelper::RecoHierarchy::Node pNode) const
private

Visualize the unmatched reco node.

Parameters
pNodeThe unmatched reco node

Definition at line 350 of file HierarchyMonitoringAlgorithm.cc.

351 {
352  const int gray{14};
353 
354  CaloHitList uHits, vHits, wHits;
355  this->FillHitLists(pNode->GetCaloHits(), uHits, vHits, wHits);
356  const int pdg{pNode->GetParticleId()};
357  const std::string key{pdg == MU_MINUS ? "T" : pdg == E_MINUS ? "S" : "?"};
358  const std::string suffix{"unmatched_reco"};
359  this->Visualize(uHits, "u_" + suffix, gray);
360  this->Visualize(vHits, "v_" + suffix, gray);
361  this->Visualize(wHits, "w_" + suffix, gray);
362 }
void Visualize(const pandora::CaloHitList &hits, const std::string &label, const int color) const
Visualize a calo hit list.
std::string string
Definition: nybbler.cc:12
def key(type, name=None)
Definition: graph.py:13
void FillHitLists(const pandora::CaloHitList &hits, pandora::CaloHitList &uHits, pandora::CaloHitList &vHits, pandora::CaloHitList &wHits) const
Fill per view hit lists.

Member Data Documentation

std::string lar_content::HierarchyMonitoringAlgorithm::m_caloHitListName
private

Name of input calo hit list.

Definition at line 105 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_collectionOnly
private

Limit display to the collection plane only.

Definition at line 112 of file HierarchyMonitoringAlgorithm.h.

float lar_content::HierarchyMonitoringAlgorithm::m_energyScaleThresholdE
private

Cell energy for which color is at top end of continous color palette.

Definition at line 116 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_foldDynamic
private

Whether or not to fold based on process information.

Definition at line 114 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_foldToPrimaries
private

Whether or not to fold everything back to primaries.

Definition at line 113 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_match
private

Whether or not to visualize the reco to MC matches.

Definition at line 111 of file HierarchyMonitoringAlgorithm.h.

std::string lar_content::HierarchyMonitoringAlgorithm::m_pfoListName
private

Name of input PFO list.

Definition at line 106 of file HierarchyMonitoringAlgorithm.h.

float lar_content::HierarchyMonitoringAlgorithm::m_scalingFactor
private

TEve works with [cm], Pandora usually works with [mm] (but LArContent went with cm too)

Definition at line 117 of file HierarchyMonitoringAlgorithm.h.

float lar_content::HierarchyMonitoringAlgorithm::m_transparencyThresholdE
private

Cell energy for which transparency is saturated (0%, fully opaque)

Definition at line 115 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_visualizeDistinct
private

If true, allocate colours without consideration of particle id.

Definition at line 109 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_visualizeMC
private

Whether or not to visualize the MC nodes.

Definition at line 107 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_visualizeProcess
private

If true, allocate colours based on the MC process.

Definition at line 110 of file HierarchyMonitoringAlgorithm.h.

bool lar_content::HierarchyMonitoringAlgorithm::m_visualizeReco
private

Whether or not to visualize the reco nodes.

Definition at line 108 of file HierarchyMonitoringAlgorithm.h.


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