LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_content::HierarchyValidationAlgorithm Class Reference

HierarchyValidationAlgorithm class. More...

#include "HierarchyValidationAlgorithm.h"

Inheritance diagram for lar_content::HierarchyValidationAlgorithm:

Public Member Functions

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

Private Member Functions

pandora::StatusCode Run ()
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

int m_event
 The current event. More...
 
std::string m_caloHitListName
 Name of input calo hit list. More...
 
std::string m_pfoListName
 Name of input PFO list. More...
 
std::string m_detector
 Name of the detector. More...
 
bool m_writeTree
 Whether or not to output validation information to a ROOT file. More...
 
std::string m_filename
 The name of the ROOT file to write. More...
 
std::string m_treename
 The name of the ROOT tree to write. More...
 
bool m_foldToPrimaries
 Whether or not to fold the hierarchy back to primary particles. More...
 
bool m_foldDynamic
 Whether or not to fold the hierarchy dynamically. More...
 
bool m_foldToLeadingShowers
 Whether or not to fold the hierarchy back to leading shower particles. More...
 
bool m_validateEvent
 Whether to validate at the level of an event. More...
 
bool m_validateMC
 Whether to validate at the level of MC nodes. More...
 
float m_minPurity
 Minimum purity to tag a node as being of good quality. More...
 
float m_minCompleteness
 Minimum completeness to tag a node as being of good quality. More...
 

Detailed Description

Constructor & Destructor Documentation

lar_content::HierarchyValidationAlgorithm::HierarchyValidationAlgorithm ( )

Default constructor.

Definition at line 21 of file HierarchyValidationAlgorithm.cc.

References m_detector, m_foldDynamic, m_foldToLeadingShowers, m_foldToPrimaries, m_minCompleteness, m_minPurity, m_validateEvent, m_validateMC, and m_writeTree.

21  :
22  m_event{-1},
23  m_detector{"dune_fd_hd"},
24  m_writeTree{false},
25  m_foldToPrimaries{false},
26  m_foldDynamic{false},
28  m_validateEvent{false},
29  m_validateMC{false},
30  m_minPurity{0.8f},
31  m_minCompleteness{0.65f}
32 {
33 }
bool m_foldToPrimaries
Whether or not to fold the hierarchy back to primary particles.
bool m_foldToLeadingShowers
Whether or not to fold the hierarchy back to leading shower particles.
float m_minPurity
Minimum purity to tag a node as being of good quality.
float m_minCompleteness
Minimum completeness to tag a node as being of good quality.
bool m_foldDynamic
Whether or not to fold the hierarchy dynamically.
bool m_writeTree
Whether or not to output validation information to a ROOT file.
bool m_validateMC
Whether to validate at the level of MC nodes.
bool m_validateEvent
Whether to validate at the level of an event.
lar_content::HierarchyValidationAlgorithm::~HierarchyValidationAlgorithm ( )
virtual

Definition at line 37 of file HierarchyValidationAlgorithm.cc.

References m_filename, m_treename, and m_writeTree.

38 {
39  if (m_writeTree)
40  {
41  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_treename.c_str(), m_filename.c_str(), "UPDATE"));
42  }
43 }
bool m_writeTree
Whether or not to output validation information to a ROOT file.
std::string m_filename
The name of the ROOT file to write.
std::string m_treename
The name of the ROOT tree to write.

Member Function Documentation

StatusCode lar_content::HierarchyValidationAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 442 of file HierarchyValidationAlgorithm.cc.

References m_caloHitListName, m_detector, m_filename, m_foldDynamic, m_foldToLeadingShowers, m_foldToPrimaries, m_minCompleteness, m_minPurity, m_pfoListName, m_treename, m_validateEvent, m_validateMC, and m_writeTree.

443 {
444  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "CaloHitListName", m_caloHitListName));
445  if (m_caloHitListName.empty())
446  m_caloHitListName = "CaloHitList2D";
447  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PfoListName", m_pfoListName));
448  if (m_pfoListName.empty())
449  m_pfoListName = "RecreatedPfos";
450 
451  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Detector", m_detector));
452 
453  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ValidateEvent", m_validateEvent));
454  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ValidateMC", m_validateMC));
455 
456  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "WriteTree", m_writeTree));
457  if (m_writeTree)
458  {
459  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "FileName", m_filename));
460  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "TreeName", m_treename));
461  if (!(m_validateEvent || m_validateMC))
462  {
463  std::cout << "Error: WriteTree requested but no tree names found" << std::endl;
464  return STATUS_CODE_NOT_FOUND;
465  }
466  else if (m_validateEvent && m_validateMC)
467  {
468  std::cout << "Error: Both event-level and MC-level validation requested simulataneously" << std::endl;
469  return STATUS_CODE_INVALID_PARAMETER;
470  }
471  }
472 
473  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldToPrimaries", m_foldToPrimaries));
474  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldDynamic", m_foldDynamic));
475  PANDORA_RETURN_RESULT_IF_AND_IF(
476  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldToLeadingShowers", m_foldToLeadingShowers));
477 
478  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinPurity", m_minPurity));
479  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCompleteness", m_minCompleteness));
480 
481  return STATUS_CODE_SUCCESS;
482 }
bool m_foldToPrimaries
Whether or not to fold the hierarchy back to primary particles.
bool m_foldToLeadingShowers
Whether or not to fold the hierarchy back to leading shower particles.
float m_minPurity
Minimum purity to tag a node as being of good quality.
float m_minCompleteness
Minimum completeness to tag a node as being of good quality.
std::string m_pfoListName
Name of input PFO list.
bool m_foldDynamic
Whether or not to fold the hierarchy dynamically.
std::string m_caloHitListName
Name of input calo hit list.
bool m_writeTree
Whether or not to output validation information to a ROOT file.
std::string m_filename
The name of the ROOT file to write.
std::string m_treename
The name of the ROOT tree to write.
bool m_validateMC
Whether to validate at the level of MC nodes.
bool m_validateEvent
Whether to validate at the level of an event.
StatusCode lar_content::HierarchyValidationAlgorithm::Run ( )
private

Definition at line 47 of file HierarchyValidationAlgorithm.cc.

References util::abs(), lar_content::LArHierarchyHelper::FillMCHierarchy(), lar_content::LArHierarchyHelper::FillRecoHierarchy(), lar_content::LArInteractionTypeHelper::GetInteractionDescriptor(), lar_content::LArHierarchyHelper::MCHierarchy::Node::GetLeadingMCParticle(), lar_content::LArHierarchyHelper::MatchInfo::GetMatches(), lar_content::LArHierarchyHelper::MatchInfo::GetNMCNodes(), lar_content::LArHierarchyHelper::MatchInfo::GetQualityCuts(), lar_content::LArHierarchyHelper::MatchInfo::GetRecoHierarchy(), lar_content::LArHierarchyHelper::MatchInfo::GetRootMCParticles(), lar_content::LArHierarchyHelper::RecoHierarchy::GetRootPfos(), lar_content::LArPfoHelper::GetVertex(), lcvn::interaction, lar_content::InteractionDescriptor::IsCC(), lar_content::LArMCParticleHelper::IsDecay(), lar_content::LArVertexHelper::IsInFiducialVolume(), lar_content::LArHierarchyHelper::MCHierarchy::Node::IsTestBeamParticle(), m_caloHitListName, m_detector, m_event, lar_content::LArHierarchyHelper::FoldingParameters::m_foldDynamic, m_foldDynamic, lar_content::LArHierarchyHelper::FoldingParameters::m_foldToLeadingShowers, m_foldToLeadingShowers, m_foldToPrimaries, lar_content::LArHierarchyHelper::FoldingParameters::m_foldToTier, m_minCompleteness, m_minPurity, m_pfoListName, m_treename, m_validateEvent, m_validateMC, m_writeTree, lar_content::LArHierarchyHelper::MatchHierarchies(), lar_content::LArHierarchyHelper::MatchInfo::Print(), and lar_content::LArMCParticleHelper::SortByMomentum().

48 {
49  ++m_event;
50  const CaloHitList *pCaloHitList(nullptr);
51  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_caloHitListName, pCaloHitList));
52  const MCParticleList *pMCParticleList(nullptr);
53  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pMCParticleList));
54  const PfoList *pPfoList(nullptr);
55  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_pfoListName, pPfoList));
56 
57  LArHierarchyHelper::FoldingParameters foldParameters;
59  foldParameters.m_foldToTier = true;
60  else if (m_foldDynamic)
61  foldParameters.m_foldDynamic = true;
62  else if (m_foldToLeadingShowers)
63  foldParameters.m_foldToLeadingShowers = true;
64  LArHierarchyHelper::MCHierarchy mcHierarchy;
65  LArHierarchyHelper::FillMCHierarchy(*pMCParticleList, *pCaloHitList, foldParameters, mcHierarchy);
66  LArHierarchyHelper::RecoHierarchy recoHierarchy;
67  LArHierarchyHelper::FillRecoHierarchy(*pPfoList, foldParameters, recoHierarchy);
68  LArHierarchyHelper::QualityCuts quality(m_minPurity, m_minCompleteness);
69  LArHierarchyHelper::MatchInfo matchInfo(mcHierarchy, recoHierarchy, quality);
71  matchInfo.Print(mcHierarchy);
72 
73 #ifdef MONITORING
74  if (m_validateEvent)
75  this->EventValidation(matchInfo);
76  else if (m_validateMC)
77  this->MCValidation(matchInfo);
78 #endif
79 
80  return STATUS_CODE_SUCCESS;
81 }
bool m_foldToPrimaries
Whether or not to fold the hierarchy back to primary particles.
bool m_foldToLeadingShowers
Whether or not to fold the hierarchy back to leading shower particles.
static void MatchHierarchies(MatchInfo &matchInfo)
Finds the matches between reconstructed and MC hierarchies.
float m_minPurity
Minimum purity to tag a node as being of good quality.
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...
float m_minCompleteness
Minimum completeness to tag a node as being of good quality.
std::string m_pfoListName
Name of input PFO list.
bool m_foldDynamic
Whether or not to fold the hierarchy dynamically.
std::string m_caloHitListName
Name of input calo hit list.
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...
bool m_validateMC
Whether to validate at the level of MC nodes.
bool m_validateEvent
Whether to validate at the level of an event.

Member Data Documentation

std::string lar_content::HierarchyValidationAlgorithm::m_caloHitListName
private

Name of input calo hit list.

Definition at line 54 of file HierarchyValidationAlgorithm.h.

Referenced by ReadSettings(), and Run().

std::string lar_content::HierarchyValidationAlgorithm::m_detector
private

Name of the detector.

Definition at line 56 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

int lar_content::HierarchyValidationAlgorithm::m_event
private

The current event.

Definition at line 53 of file HierarchyValidationAlgorithm.h.

Referenced by Run().

std::string lar_content::HierarchyValidationAlgorithm::m_filename
private

The name of the ROOT file to write.

Definition at line 58 of file HierarchyValidationAlgorithm.h.

Referenced by ReadSettings(), and ~HierarchyValidationAlgorithm().

bool lar_content::HierarchyValidationAlgorithm::m_foldDynamic
private

Whether or not to fold the hierarchy dynamically.

Definition at line 61 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

bool lar_content::HierarchyValidationAlgorithm::m_foldToLeadingShowers
private

Whether or not to fold the hierarchy back to leading shower particles.

Definition at line 62 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

bool lar_content::HierarchyValidationAlgorithm::m_foldToPrimaries
private

Whether or not to fold the hierarchy back to primary particles.

Definition at line 60 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

float lar_content::HierarchyValidationAlgorithm::m_minCompleteness
private

Minimum completeness to tag a node as being of good quality.

Definition at line 66 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

float lar_content::HierarchyValidationAlgorithm::m_minPurity
private

Minimum purity to tag a node as being of good quality.

Definition at line 65 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

std::string lar_content::HierarchyValidationAlgorithm::m_pfoListName
private

Name of input PFO list.

Definition at line 55 of file HierarchyValidationAlgorithm.h.

Referenced by ReadSettings(), and Run().

std::string lar_content::HierarchyValidationAlgorithm::m_treename
private

The name of the ROOT tree to write.

Definition at line 59 of file HierarchyValidationAlgorithm.h.

Referenced by ReadSettings(), Run(), and ~HierarchyValidationAlgorithm().

bool lar_content::HierarchyValidationAlgorithm::m_validateEvent
private

Whether to validate at the level of an event.

Definition at line 63 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

bool lar_content::HierarchyValidationAlgorithm::m_validateMC
private

Whether to validate at the level of MC nodes.

Definition at line 64 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), and Run().

bool lar_content::HierarchyValidationAlgorithm::m_writeTree
private

Whether or not to output validation information to a ROOT file.

Definition at line 57 of file HierarchyValidationAlgorithm.h.

Referenced by HierarchyValidationAlgorithm(), ReadSettings(), Run(), and ~HierarchyValidationAlgorithm().


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