LArSoft  v09_93_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_writeEventTree
 Whether or not to output event validation information to a ROOT file. More...
 
bool m_writeMCTree
 Whether or not to output MC validation information to a ROOT file. More...
 
std::string m_eventFileName
 The name of the event ROOT file to write. More...
 
std::string m_eventTreeName
 The name of the event ROOT tree to write. More...
 
std::string m_MCFileName
 The name of the MC ROOT file to write. More...
 
std::string m_MCTreeName
 The name of the MC 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...
 
unsigned int m_minRecoHits
 Minimum number of reconstructed primary good hits. More...
 
unsigned int m_minRecoHitsPerView
 Minimum number of reconstructed hits for a good view. More...
 
unsigned int m_minRecoGoodViews
 Minimum number of reconstructed primary good views. More...
 
bool m_removeRecoNeutrons
 Whether to remove reconstructed neutrons and their downstream particles. 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_minRecoGoodViews, m_minRecoHits, m_minRecoHitsPerView, m_removeRecoNeutrons, m_validateEvent, m_validateMC, m_writeEventTree, and m_writeMCTree.

21  :
22  m_event{-1},
23  m_detector{"dune_fd_hd"},
24  m_writeEventTree{false},
25  m_writeMCTree{false},
26  m_foldToPrimaries{false},
27  m_foldDynamic{false},
29  m_validateEvent{false},
30  m_validateMC{false},
31  m_minPurity{0.8f},
32  m_minCompleteness{0.65f},
33  m_minRecoHits{30},
37 {
38 }
unsigned int m_minRecoGoodViews
Minimum number of reconstructed primary good views.
bool m_foldToPrimaries
Whether or not to fold the hierarchy back to primary particles.
unsigned int m_minRecoHits
Minimum number of reconstructed primary good hits.
bool m_foldToLeadingShowers
Whether or not to fold the hierarchy back to leading shower particles.
bool m_writeEventTree
Whether or not to output event validation information to a ROOT file.
bool m_writeMCTree
Whether or not to output MC validation information to a ROOT file.
float m_minPurity
Minimum purity to tag a node as being of good quality.
bool m_removeRecoNeutrons
Whether to remove reconstructed neutrons and their downstream particles.
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.
unsigned int m_minRecoHitsPerView
Minimum number of reconstructed hits for a good view.
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 42 of file HierarchyValidationAlgorithm.cc.

References m_eventFileName, m_eventTreeName, m_MCFileName, m_MCTreeName, m_writeEventTree, and m_writeMCTree.

43 {
44  if (m_writeEventTree)
45  {
46  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_eventTreeName.c_str(), m_eventFileName.c_str(), "UPDATE"));
47  }
48  if (m_writeMCTree)
49  {
50  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_MCTreeName.c_str(), m_MCFileName.c_str(), "UPDATE"));
51  }
52 }
bool m_writeEventTree
Whether or not to output event validation information to a ROOT file.
bool m_writeMCTree
Whether or not to output MC validation information to a ROOT file.
std::string m_MCFileName
The name of the MC ROOT file to write.
std::string m_eventTreeName
The name of the event ROOT tree to write.
std::string m_MCTreeName
The name of the MC ROOT tree to write.
std::string m_eventFileName
The name of the event ROOT file to write.

Member Function Documentation

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

Definition at line 520 of file HierarchyValidationAlgorithm.cc.

References m_caloHitListName, m_detector, m_eventFileName, m_eventTreeName, m_foldDynamic, m_foldToLeadingShowers, m_foldToPrimaries, m_MCFileName, m_MCTreeName, m_minCompleteness, m_minPurity, m_minRecoGoodViews, m_minRecoHits, m_minRecoHitsPerView, m_pfoListName, m_removeRecoNeutrons, m_validateEvent, m_validateMC, m_writeEventTree, and m_writeMCTree.

521 {
522  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "CaloHitListName", m_caloHitListName));
523  if (m_caloHitListName.empty())
524  m_caloHitListName = "CaloHitList2D";
525  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PfoListName", m_pfoListName));
526  if (m_pfoListName.empty())
527  m_pfoListName = "RecreatedPfos";
528 
529  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "Detector", m_detector));
530 
531  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ValidateEvent", m_validateEvent));
532  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "ValidateMC", m_validateMC));
533 
534  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "WriteEventTree", m_writeEventTree));
535  if (m_writeEventTree)
536  {
537  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "EventFileName", m_eventFileName));
538  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "EventTreeName", m_eventTreeName));
539  }
540 
541  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "WriteMCTree", m_writeMCTree));
542  if (m_writeMCTree)
543  {
544  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCFileName", m_MCFileName));
545  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ReadValue(xmlHandle, "MCTreeName", m_MCTreeName));
546  }
547 
548  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldToPrimaries", m_foldToPrimaries));
549  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldDynamic", m_foldDynamic));
550  PANDORA_RETURN_RESULT_IF_AND_IF(
551  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "FoldToLeadingShowers", m_foldToLeadingShowers));
552 
553  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinPurity", m_minPurity));
554  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinCompleteness", m_minCompleteness));
555  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinRecoHits", m_minRecoHits));
556  PANDORA_RETURN_RESULT_IF_AND_IF(
557  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinRecoHitsPerView", m_minRecoHitsPerView));
558  PANDORA_RETURN_RESULT_IF_AND_IF(
559  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinRecoGoodViews", m_minRecoGoodViews));
560  PANDORA_RETURN_RESULT_IF_AND_IF(
561  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "RemoveRecoNeutrons", m_removeRecoNeutrons));
562 
563  return STATUS_CODE_SUCCESS;
564 }
unsigned int m_minRecoGoodViews
Minimum number of reconstructed primary good views.
bool m_foldToPrimaries
Whether or not to fold the hierarchy back to primary particles.
unsigned int m_minRecoHits
Minimum number of reconstructed primary good hits.
bool m_foldToLeadingShowers
Whether or not to fold the hierarchy back to leading shower particles.
bool m_writeEventTree
Whether or not to output event validation information to a ROOT file.
bool m_writeMCTree
Whether or not to output MC validation information to a ROOT file.
float m_minPurity
Minimum purity to tag a node as being of good quality.
std::string m_MCFileName
The name of the MC ROOT file to write.
bool m_removeRecoNeutrons
Whether to remove reconstructed neutrons and their downstream particles.
std::string m_eventTreeName
The name of the event ROOT tree to write.
float m_minCompleteness
Minimum completeness to tag a node as being of good quality.
std::string m_MCTreeName
The name of the MC ROOT tree to write.
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.
std::string m_eventFileName
The name of the event ROOT file to write.
unsigned int m_minRecoHitsPerView
Minimum number of reconstructed hits for a good view.
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 56 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, m_eventTreeName, 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_MCTreeName, m_minCompleteness, m_minPurity, m_minRecoGoodViews, m_minRecoHits, m_minRecoHitsPerView, m_pfoListName, m_removeRecoNeutrons, m_validateEvent, m_validateMC, m_writeEventTree, m_writeMCTree, lar_content::LArHierarchyHelper::MatchHierarchies(), lar_content::LArHierarchyHelper::MatchInfo::Print(), and lar_content::LArMCParticleHelper::SortByMomentum().

57 {
58  ++m_event;
59  const CaloHitList *pCaloHitList(nullptr);
60  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_caloHitListName, pCaloHitList));
61  const MCParticleList *pMCParticleList(nullptr);
62  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetCurrentList(*this, pMCParticleList));
63  const PfoList *pPfoList(nullptr);
64  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::GetList(*this, m_pfoListName, pPfoList));
65 
66  LArHierarchyHelper::FoldingParameters foldParameters;
68  foldParameters.m_foldToTier = true;
69  else if (m_foldDynamic)
70  foldParameters.m_foldDynamic = true;
71  else if (m_foldToLeadingShowers)
72  foldParameters.m_foldToLeadingShowers = true;
73  const LArHierarchyHelper::MCHierarchy::ReconstructabilityCriteria recoCriteria(
75  LArHierarchyHelper::MCHierarchy mcHierarchy(recoCriteria);
76  LArHierarchyHelper::FillMCHierarchy(*pMCParticleList, *pCaloHitList, foldParameters, mcHierarchy);
77  LArHierarchyHelper::RecoHierarchy recoHierarchy;
78  LArHierarchyHelper::FillRecoHierarchy(*pPfoList, foldParameters, recoHierarchy);
79  const LArHierarchyHelper::QualityCuts quality(m_minPurity, m_minCompleteness);
80  LArHierarchyHelper::MatchInfo matchInfo(mcHierarchy, recoHierarchy, quality);
82  matchInfo.Print(mcHierarchy);
83 
84 #ifdef MONITORING
85  if (m_validateEvent)
86  this->EventValidation(matchInfo);
87  if (m_validateMC)
88  this->MCValidation(matchInfo);
89 #endif
90 
91  return STATUS_CODE_SUCCESS;
92 }
unsigned int m_minRecoGoodViews
Minimum number of reconstructed primary good views.
bool m_foldToPrimaries
Whether or not to fold the hierarchy back to primary particles.
unsigned int m_minRecoHits
Minimum number of reconstructed primary good hits.
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.
bool m_removeRecoNeutrons
Whether to remove reconstructed neutrons and their downstream particles.
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...
unsigned int m_minRecoHitsPerView
Minimum number of reconstructed hits for a good view.
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_eventFileName
private

The name of the event ROOT file to write.

Definition at line 59 of file HierarchyValidationAlgorithm.h.

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

std::string lar_content::HierarchyValidationAlgorithm::m_eventTreeName
private

The name of the event ROOT tree to write.

Definition at line 60 of file HierarchyValidationAlgorithm.h.

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

bool lar_content::HierarchyValidationAlgorithm::m_foldDynamic
private

Whether or not to fold the hierarchy dynamically.

Definition at line 64 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 65 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 63 of file HierarchyValidationAlgorithm.h.

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

std::string lar_content::HierarchyValidationAlgorithm::m_MCFileName
private

The name of the MC ROOT file to write.

Definition at line 61 of file HierarchyValidationAlgorithm.h.

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

std::string lar_content::HierarchyValidationAlgorithm::m_MCTreeName
private

The name of the MC ROOT tree to write.

Definition at line 62 of file HierarchyValidationAlgorithm.h.

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

float lar_content::HierarchyValidationAlgorithm::m_minCompleteness
private

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

Definition at line 69 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 68 of file HierarchyValidationAlgorithm.h.

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

unsigned int lar_content::HierarchyValidationAlgorithm::m_minRecoGoodViews
private

Minimum number of reconstructed primary good views.

Definition at line 72 of file HierarchyValidationAlgorithm.h.

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

unsigned int lar_content::HierarchyValidationAlgorithm::m_minRecoHits
private

Minimum number of reconstructed primary good hits.

Definition at line 70 of file HierarchyValidationAlgorithm.h.

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

unsigned int lar_content::HierarchyValidationAlgorithm::m_minRecoHitsPerView
private

Minimum number of reconstructed hits for a good view.

Definition at line 71 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().

bool lar_content::HierarchyValidationAlgorithm::m_removeRecoNeutrons
private

Whether to remove reconstructed neutrons and their downstream particles.

Definition at line 73 of file HierarchyValidationAlgorithm.h.

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

bool lar_content::HierarchyValidationAlgorithm::m_validateEvent
private

Whether to validate at the level of an event.

Definition at line 66 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 67 of file HierarchyValidationAlgorithm.h.

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

bool lar_content::HierarchyValidationAlgorithm::m_writeEventTree
private

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

Definition at line 57 of file HierarchyValidationAlgorithm.h.

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

bool lar_content::HierarchyValidationAlgorithm::m_writeMCTree
private

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

Definition at line 58 of file HierarchyValidationAlgorithm.h.

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


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