LArSoft  v10_06_00
Liquid Argon Software toolkit - https://larsoft.org/
lar_dl_content::DLNeutrinoHierarchyAlgorithm Class Reference

DLNeutrinoHierarchyAlgorithm class. More...

#include "DLNeutrinoHierarchyAlgorithm.h"

Inheritance diagram for lar_dl_content::DLNeutrinoHierarchyAlgorithm:

Public Member Functions

 DLNeutrinoHierarchyAlgorithm ()
 Default constructor. More...
 
 ~DLNeutrinoHierarchyAlgorithm ()
 Default destructor. More...
 

Private Types

typedef std::map< const pandora::ParticleFlowObject *, const pandora::MCParticle * > PfoToMCParticleMap
 
typedef std::map< const pandora::ParticleFlowObject *, std::pair< const pandora::ParticleFlowObject *, int > > ChildToParentPfoMap
 
typedef std::vector< pandora::PfoVector > Hierarchy
 

Private Member Functions

pandora::StatusCode Run ()
 
bool GetNeutrinoPfo (const pandora::ParticleFlowObject *&pNeutrinoPfo) const
 Return the neutrino pfo. More...
 
void FillTrackShowerVectors (const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const
 Fill the track and shower-like HierarchyPfoVector. More...
 
bool GetExtremalVerticesAndDirections (const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::ParticleFlowObject *const pPfo, const ThreeDSlidingFitResult &slidingFitResult, ExtremalPoint &upstreamPoint, ExtremalPoint &downstreamPoint) const
 Identify the upstream (closest to the nu vertex) and downstream (furthest from the nu vertex) endpoints and directions of an input pfo. More...
 
bool GetShowerDirection (const pandora::ParticleFlowObject *const pPfo, const pandora::CartesianVector &vertex, pandora::CartesianVector &direction) const
 Obtain the direction of a shower at a given endpoint from the angular decomposition of the shower's 'close' 3D hits. More...
 
void SetPrimaryScores (const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const
 Set the primary network scores of the HierarchyPfos. More...
 
float GetPrimaryScore (const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfo &hierarchyPfo) const
 Call the primary network tool to obtain the primary score of a HierarchyPfo. More...
 
void UpdateHierarchy (const pandora::ParticleFlowObject *const pNeutrinoPfo, const bool buildPrimaryTier, const bool usePrimaryScore, const float trackThreshold, const float showerThreshold, const bool isLowerThreshold, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos, Hierarchy &hierarchy) const
 Add particles to the hierarchy if they satisfy a criteria. More...
 
void SetLaterTierScores (const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const
 Set the predicted parent and later tier score of the HierarchyPfos to be considered for the later tiers. More...
 
float GetLaterTierScore (const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfo &parentPfo, const HierarchyPfo &childPfo) const
 Call the later tier network tool to obtain the later tier score of a parent-child link. More...
 
void BuildPandoraHierarchy (const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos) const
 Register the parent-child relationships in Pandora. More...
 
bool ShouldTrainOnEvent (const pandora::ParticleFlowObject *const pNeutrinoPfo) const
 Whether the event should be trained on. More...
 
void GetParticleIDMap (const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, std::map< const pandora::ParticleFlowObject *, int > &particleIDMap) const
 Obtain the [pfo -> unique ID] map. More...
 
std::pair< float, float > GetTrainingCuts (const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo, const bool trueParentOrientation, const bool trueChildOrientation) const
 Get the training cuts for the later tier parent-child link these describe how well the child points back to the parent. More...
 
void FillEventTree (const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, const int nPrimaryTrackLinks, const int nPrimaryShowerLinks, const int nLaterTierTrackTrackLinks, const int nLaterTierTrackShowerLinks) const
 Fill the output event tree (containing event-level info) More...
 
void FillPrimaryTrees (const PfoToMCParticleMap &matchingMap, const ChildToParentPfoMap &childToParentPfoMap, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, const std::map< const pandora::ParticleFlowObject *, int > &particleIDMap, int &nPrimaryTrackLinks, int &nPrimaryShowerLinks) const
 Fill the primary trees (containing primary link info) More...
 
void FillPrimaryTree (const std::string &treeName, const bool isTrainingLink, const bool isTrueLink, const bool isOrientationCorrect, const int trueVisibleGen, const int truePDG, const int trueParentID, const int particleID, const DLPrimaryHierarchyTool::DLPrimaryNetworkParams &primaryNetworkParams) const
 Enter an entry into the specified primary tree. More...
 
void FillLaterTierTrees (const PfoToMCParticleMap &matchingMap, const ChildToParentPfoMap &childToParentPfoMap, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, const std::map< const pandora::ParticleFlowObject *, int > &particleIDMap, int &nTrackLinks, int &nShowerLinks) const
 Fill the later tier trees (containing later tier link info) More...
 
void FillLaterTierTree (const std::string &treeName, const bool isTrainingLink, const bool isTrueLink, const bool isOrientationCorrect, const int childTrueGen, const std::pair< float, float > &trainingCuts, const int parentID, const int childID, const DLLaterTierHierarchyTool::DLLaterTierNetworkParams &networkParams) const
 Enter an entry into the specified later tier tree. More...
 
pandora::StatusCode ReadSettings (const pandora::TiXmlHandle xmlHandle)
 

Private Attributes

int m_eventID
 the event counter More...
 
bool m_trainingMode
 whether to run in training mode More...
 
std::string m_trainingFileName
 the name of the output training file More...
 
std::string m_eventTreeName
 the name of the output event tree More...
 
std::string m_primaryTrackTreeName
 the name of the output primary track link tree More...
 
std::string m_primaryShowerTreeName
 the name of the output primary shower link tree More...
 
std::string m_laterTierTrackTrackTreeName
 the name of the output track-track later tier link tree More...
 
std::string m_laterTierTrackShowerTreeName
 the name of the output track-shower later tier link tree More...
 
std::string m_mcParticleListName
 the name of the MCParticle list More...
 
float m_trainingVertexAccuracy
 the maximum true-reco nu vertex displacement allowed for training More...
 
std::string m_neutrinoPfoListName
 the name of the neutrino pfo list More...
 
pandora::StringVector m_pfoListNames
 the name of the pfo lists More...
 
unsigned int m_minClusterSize
 the minimum threshold of 3D hits of a considered pfo More...
 
int m_slidingFitWindow
 the sliding fit window to use in pfo sliding linear fits More...
 
float m_regionForDirFit
 the radius of the region used in shower direction fits More...
 
int m_nAngularBins
 the number of angle bins used by the shower direction fitter More...
 
float m_primaryRegion
 the radius of the nu vertex region where particles are assumed to be primaries More...
 
float m_primaryThresholdTrackPass1
 The threshold applied to tracks in pass 1 primary tier building. More...
 
float m_primaryThresholdShowerPass1
 The threshold applied to showers in pass 1 primary tier building. More...
 
float m_laterTierThresholdTrackPass1
 The threshold applied to track-track links in pass 1 later tier building. More...
 
float m_laterTierThresholdShowerPass1
 The threshold applied to track-shower links in pass 1 later tier building. More...
 
float m_primaryThresholdTrackPass2
 The threshold applied to tracks in pass 2 primary tier building. More...
 
float m_primaryThresholdShowerPass2
 The threshold applied to showers in pass 2 primary tier building. More...
 
float m_laterTierThresholdTrackPass2
 The threshold applied to track-track links in pass 2 later tier building. More...
 
float m_laterTierThresholdShowerPass2
 The threshold applied to track-shower links in pass 2 later tier building. More...
 
DLPrimaryHierarchyToolm_primaryHierarchyTool
 The tool used to build the primary tiers. More...
 
DLLaterTierHierarchyToolm_laterTierHierarchyTool
 The tool used to build the later tiers. More...
 
DLCheatHierarchyToolm_cheatHierarchyTool
 The tool used to obtain the true hierarchy. More...
 

Detailed Description

Member Typedef Documentation

typedef std::map<const pandora::ParticleFlowObject *, std::pair<const pandora::ParticleFlowObject *, int> > lar_dl_content::DLNeutrinoHierarchyAlgorithm::ChildToParentPfoMap
private

Definition at line 46 of file DLNeutrinoHierarchyAlgorithm.h.

typedef std::vector<pandora::PfoVector> lar_dl_content::DLNeutrinoHierarchyAlgorithm::Hierarchy
private

Definition at line 47 of file DLNeutrinoHierarchyAlgorithm.h.

typedef std::map<const pandora::ParticleFlowObject *, const pandora::MCParticle *> lar_dl_content::DLNeutrinoHierarchyAlgorithm::PfoToMCParticleMap
private

Definition at line 45 of file DLNeutrinoHierarchyAlgorithm.h.

Constructor & Destructor Documentation

lar_dl_content::DLNeutrinoHierarchyAlgorithm::DLNeutrinoHierarchyAlgorithm ( )

Default constructor.

Definition at line 31 of file DLNeutrinoHierarchyAlgorithm.cc.

References f, m_laterTierThresholdShowerPass1, m_laterTierThresholdShowerPass2, m_laterTierThresholdTrackPass1, m_laterTierThresholdTrackPass2, m_minClusterSize, m_nAngularBins, m_primaryRegion, m_primaryThresholdShowerPass1, m_primaryThresholdShowerPass2, m_primaryThresholdTrackPass1, m_primaryThresholdTrackPass2, m_regionForDirFit, and m_slidingFitWindow.

31  :
32  m_eventID(0),
33  m_trainingMode(false),
34  m_trainingFileName("DLHierarchyTrainingFile.root"),
35  m_eventTreeName("EventTree"),
36  m_primaryTrackTreeName("PrimaryTrackTree"),
37  m_primaryShowerTreeName("PrimaryShowerTree"),
38  m_laterTierTrackTrackTreeName("LaterTierTrackTrackTree"),
39  m_laterTierTrackShowerTreeName("LaterTierTrackShowerTree"),
40  m_mcParticleListName("Input"),
42  m_neutrinoPfoListName("NeutrinoParticles3D"),
43  m_pfoListNames({"TrackParticles3D", "ShowerParticles3D"}),
46  m_regionForDirFit(25.f),
47  m_nAngularBins(180),
48  m_primaryRegion(15.f),
57 {
58 }
float m_primaryThresholdTrackPass2
The threshold applied to tracks in pass 2 primary tier building.
float m_primaryThresholdShowerPass2
The threshold applied to showers in pass 2 primary tier building.
float m_laterTierThresholdTrackPass2
The threshold applied to track-track links in pass 2 later tier building.
std::string m_primaryTrackTreeName
the name of the output primary track link tree
pandora::StringVector m_pfoListNames
the name of the pfo lists
std::string m_primaryShowerTreeName
the name of the output primary shower link tree
float m_primaryThresholdTrackPass1
The threshold applied to tracks in pass 1 primary tier building.
std::string m_mcParticleListName
the name of the MCParticle list
std::string m_laterTierTrackTrackTreeName
the name of the output track-track later tier link tree
TFile f
Definition: plotHisto.C:6
std::string m_neutrinoPfoListName
the name of the neutrino pfo list
std::string m_laterTierTrackShowerTreeName
the name of the output track-shower later tier link tree
std::string m_trainingFileName
the name of the output training file
bool m_trainingMode
whether to run in training mode
float m_primaryRegion
the radius of the nu vertex region where particles are assumed to be primaries
float m_primaryThresholdShowerPass1
The threshold applied to showers in pass 1 primary tier building.
int m_slidingFitWindow
the sliding fit window to use in pfo sliding linear fits
float m_regionForDirFit
the radius of the region used in shower direction fits
float m_laterTierThresholdTrackPass1
The threshold applied to track-track links in pass 1 later tier building.
std::string m_eventTreeName
the name of the output event tree
unsigned int m_minClusterSize
the minimum threshold of 3D hits of a considered pfo
float m_laterTierThresholdShowerPass2
The threshold applied to track-shower links in pass 2 later tier building.
int m_nAngularBins
the number of angle bins used by the shower direction fitter
float m_trainingVertexAccuracy
the maximum true-reco nu vertex displacement allowed for training
float m_laterTierThresholdShowerPass1
The threshold applied to track-shower links in pass 1 later tier building.
lar_dl_content::DLNeutrinoHierarchyAlgorithm::~DLNeutrinoHierarchyAlgorithm ( )

Default destructor.

Definition at line 62 of file DLNeutrinoHierarchyAlgorithm.cc.

References m_eventTreeName, m_laterTierTrackShowerTreeName, m_laterTierTrackTrackTreeName, m_primaryShowerTreeName, m_primaryTrackTreeName, m_trainingFileName, and m_trainingMode.

63 {
64  if (m_trainingMode)
65  {
66  try
67  {
68  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_eventTreeName.c_str(), m_trainingFileName.c_str(), "UPDATE"));
69  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_primaryTrackTreeName.c_str(), m_trainingFileName.c_str(), "UPDATE"));
70  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_primaryShowerTreeName.c_str(), m_trainingFileName.c_str(), "UPDATE"));
71  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_laterTierTrackTrackTreeName.c_str(), m_trainingFileName.c_str(), "UPDATE"));
72  PANDORA_MONITORING_API(SaveTree(this->GetPandora(), m_laterTierTrackShowerTreeName.c_str(), m_trainingFileName.c_str(), "UPDATE"));
73  }
74  catch (...)
75  {
76  }
77  }
78 }
std::string m_primaryTrackTreeName
the name of the output primary track link tree
std::string m_primaryShowerTreeName
the name of the output primary shower link tree
std::string m_laterTierTrackTrackTreeName
the name of the output track-track later tier link tree
std::string m_laterTierTrackShowerTreeName
the name of the output track-shower later tier link tree
std::string m_trainingFileName
the name of the output training file
bool m_trainingMode
whether to run in training mode
std::string m_eventTreeName
the name of the output event tree

Member Function Documentation

void lar_dl_content::DLNeutrinoHierarchyAlgorithm::BuildPandoraHierarchy ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const HierarchyPfoVector trackPfos,
const HierarchyPfoVector showerPfos 
) const
private

Register the parent-child relationships in Pandora.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector

Definition at line 576 of file DLNeutrinoHierarchyAlgorithm.cc.

References lar_dl_content::DLPrimaryHierarchyTool::CalculateConnectionDistances(), FillEventTree(), FillLaterTierTree(), FillLaterTierTrees(), FillPrimaryTree(), FillPrimaryTrees(), lar_dl_content::HierarchyPfo::GetChildPfoVector(), lar_dl_content::HierarchyPfo::GetDownstreamPoint(), lar_dl_content::HierarchyPfo::GetIsInHierarchy(), lar_dl_content::HierarchyPfo::GetParentPfo(), GetParticleIDMap(), GetTrainingCuts(), lar_dl_content::HierarchyPfo::GetUpstreamPoint(), lar_dl_content::DLCheatHierarchyTool::IsNeutronChild(), m_cheatHierarchyTool, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_childConnectionDistance, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_childCPDCA, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_childCPExtrapDistance, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_childCPLRatio, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_childIsPOIClosestToNu, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_childNSpacepoints, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_childNuVertexSep, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_childTrackScore, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_connectionExtrapDistance, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_dca, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_doesChildConnect, m_eventID, m_eventTreeName, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_isPOIClosestToNu, m_laterTierHierarchyTool, m_laterTierTrackShowerTreeName, m_laterTierTrackTrackTreeName, m_mcParticleListName, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_nSpacepoints, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_nuSeparation, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_overshootEndDCA, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_overshootEndL, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_overshootStartDCA, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_overshootStartL, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_parentConnectionDistance, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentCPEigenvalueRatio, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentCPNDownstreamHits, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentCPNHitRatio, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentCPNUpstreamHits, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentCPOpeningAngle, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentEndRegionNHits, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentEndRegionNParticles, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentEndRegionRToWall, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentIsPOIClosestToNu, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentNSpacepoints, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentNuVertexSep, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_parentTrackScore, m_pfoListNames, m_primaryHierarchyTool, m_primaryShowerTreeName, m_primaryTrackTreeName, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_separation3D, m_trainingVertexAccuracy, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_vertexRegionNHits, lar_dl_content::DLPrimaryHierarchyTool::DLPrimaryNetworkParams::m_vertexRegionNParticles, lar_dl_content::DLLaterTierHierarchyTool::DLLaterTierNetworkParams::m_vertexSeparation, lar_dl_content::DLCheatHierarchyTool::Run(), lar_dl_content::DLPrimaryHierarchyTool::Run(), lar_dl_content::DLLaterTierHierarchyTool::Run(), and ShouldTrainOnEvent().

Referenced by Run().

578 {
579  PfoVector pfoVector;
580 
581  // Get All pfos
582  for (const std::string &pfoListName : m_pfoListNames)
583  {
584  const PfoList *pPfoList(nullptr);
585 
586  if (PandoraContentApi::GetList(*this, pfoListName, pPfoList) != STATUS_CODE_SUCCESS)
587  continue;
588 
589  for (const ParticleFlowObject *const pPfo : *pPfoList)
590  pfoVector.emplace_back(pPfo);
591  }
592 
593  // Sort to maintain reproducibility
594  std::sort(pfoVector.begin(), pfoVector.end(), LArPfoHelper::SortByNHits);
595 
596  // Build known hierarchy
597  for (const ParticleFlowObject *const pPfo : pfoVector)
598  {
599  const HierarchyPfo *hierarchyPfo(nullptr);
600 
601  const auto trackIter(std::find(trackPfos.begin(), trackPfos.end(), pPfo));
602  const auto showerIter(std::find(showerPfos.begin(), showerPfos.end(), pPfo));
603 
604  if (trackIter != trackPfos.end())
605  {
606  hierarchyPfo = &(*trackIter);
607  }
608  else if (showerIter != showerPfos.end())
609  {
610  hierarchyPfo = &(*showerIter);
611  }
612  else
613  {
614  // If alg never handled the pfo, assign as primary
615  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pPfo));
616  continue;
617  }
618 
619  // If pfo was never assigned to hierarchy, add as primary
620  if (!hierarchyPfo->GetIsInHierarchy())
621  {
622  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pPfo));
623  continue;
624  }
625 
626  // If parent is a neutrino we have to assign its parent
627  if (hierarchyPfo->GetParentPfo() == pNeutrinoPfo)
628  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pNeutrinoPfo, pPfo));
629 
630  // Assign parent-child links of its children
631  PfoVector childPfos(hierarchyPfo->GetChildPfoVector());
632  std::sort(childPfos.begin(), childPfos.end(), LArPfoHelper::SortByNHits);
633 
634  // Demand that showers do not have children
635  if ((!childPfos.empty()) && (showerIter != showerPfos.end()))
636  throw StatusCodeException(STATUS_CODE_FAILURE);
637 
638  for (const ParticleFlowObject *const pChildPfo : childPfos)
639  PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::SetPfoParentDaughterRelationship(*this, pPfo, pChildPfo));
640  }
641 }
pandora::StringVector m_pfoListNames
the name of the pfo lists
void lar_dl_content::DLNeutrinoHierarchyAlgorithm::FillEventTree ( const HierarchyPfoVector trackPfos,
const HierarchyPfoVector showerPfos,
const int  nPrimaryTrackLinks,
const int  nPrimaryShowerLinks,
const int  nLaterTierTrackTrackLinks,
const int  nLaterTierTrackShowerLinks 
) const
private

Fill the output event tree (containing event-level info)

Parameters
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector
nPrimaryTrackLinksthe number of recorded primary track links
nPrimaryShowerLinksthe number of recorded primary shower links
nLaterTierTrackTrackLinksthe number of recorded track-track later tier links
nLaterTierTrackShowerLinksthe number of recorded track-shower later tier links

Referenced by BuildPandoraHierarchy(), and Run().

void lar_dl_content::DLNeutrinoHierarchyAlgorithm::FillLaterTierTree ( const std::string &  treeName,
const bool  isTrainingLink,
const bool  isTrueLink,
const bool  isOrientationCorrect,
const int  childTrueGen,
const std::pair< float, float > &  trainingCuts,
const int  parentID,
const int  childID,
const DLLaterTierHierarchyTool::DLLaterTierNetworkParams networkParams 
) const
private

Enter an entry into the specified later tier tree.

Parameters
treeNamethe name of the tree to fill
isTrainingLinkwhether the input link is one to train on
isTrueLinkwhether the input link is a true parent-child link
isOrientationCorrectwhether the assumed orientation of the particles is correct
trueChildGenthe true visible generation of the child particle
thetraining cut pair of the parent-child link
parentIDthe unique ID of the parent particle
childIDthe unique ID of the child particle
networkParamsthe network parameter variable values of the input link

Referenced by BuildPandoraHierarchy().

void lar_dl_content::DLNeutrinoHierarchyAlgorithm::FillLaterTierTrees ( const PfoToMCParticleMap matchingMap,
const ChildToParentPfoMap childToParentPfoMap,
const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const HierarchyPfoVector trackPfos,
const HierarchyPfoVector showerPfos,
const std::map< const pandora::ParticleFlowObject *, int > &  particleIDMap,
int &  nTrackLinks,
int &  nShowerLinks 
) const
private

Fill the later tier trees (containing later tier link info)

Parameters
matchingMapthe [pfo -> mcparticle] matching map
childToParentPfoMapthe [child pfo -> true parent pfo] map
pNeutrinoPfoa pointer to the neutrino pfo
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector
particleIDMapthe [pfo -> unique ID] map
nTrackLinksthe number of recorded track-track later tier links
nShowerLinksthe number of recorded track-shower later tier links

Referenced by BuildPandoraHierarchy(), and Run().

void lar_dl_content::DLNeutrinoHierarchyAlgorithm::FillPrimaryTree ( const std::string &  treeName,
const bool  isTrainingLink,
const bool  isTrueLink,
const bool  isOrientationCorrect,
const int  trueVisibleGen,
const int  truePDG,
const int  trueParentID,
const int  particleID,
const DLPrimaryHierarchyTool::DLPrimaryNetworkParams primaryNetworkParams 
) const
private

Enter an entry into the specified primary tree.

Parameters
treeNamethe name of the tree to fill
isTrainingLinkwhether the input link is one to train on
isTrueLinkwhether the input link is a true parent-child link
isOrientationCorrectwhether the assumed orientation of the particle is correct
trueVisibleGenthe true visible generation of the particle
truePDGthe PDG of the matched MCParticle
trueParentIDthe unique ID of the true parent
particleIDthe unique ID of the particle
primaryNetworkParamsthe network parameter variable values of the input link

Referenced by BuildPandoraHierarchy().

void lar_dl_content::DLNeutrinoHierarchyAlgorithm::FillPrimaryTrees ( const PfoToMCParticleMap matchingMap,
const ChildToParentPfoMap childToParentPfoMap,
const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const HierarchyPfoVector trackPfos,
const HierarchyPfoVector showerPfos,
const std::map< const pandora::ParticleFlowObject *, int > &  particleIDMap,
int &  nPrimaryTrackLinks,
int &  nPrimaryShowerLinks 
) const
private

Fill the primary trees (containing primary link info)

Parameters
matchingMapthe [pfo -> mcparticle] matching map
childToParentPfoMapthe [child pfo -> true parent pfo] map
pNeutrinoPfoa pointer to the neutrino pfo
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector
particleIDMapthe [pfo -> unique ID] map
nPrimaryTrackLinksthe number of recorded primary track links
nPrimaryShowerLinksthe number of recorded primary shower links

Referenced by BuildPandoraHierarchy(), and Run().

void lar_dl_content::DLNeutrinoHierarchyAlgorithm::FillTrackShowerVectors ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
HierarchyPfoVector trackPfos,
HierarchyPfoVector showerPfos 
) const
private

Fill the track and shower-like HierarchyPfoVector.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector

Definition at line 178 of file DLNeutrinoHierarchyAlgorithm.cc.

References GetExtremalVerticesAndDirections(), m_minClusterSize, m_pfoListNames, and m_slidingFitWindow.

Referenced by Run().

180 {
181  // Sliding fit shenanigans
182  const float pitchU{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_U)};
183  const float pitchV{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_V)};
184  const float pitchW{LArGeometryHelper::GetWirePitch(this->GetPandora(), TPC_VIEW_W)};
185  const float slidingFitPitch(std::max({pitchU, pitchV, pitchW}));
186 
187  // Get All pfos
188  PfoVector pfoVector;
189  for (const std::string &pfoListName : m_pfoListNames)
190  {
191  const PfoList *pPfoList(nullptr);
192 
193  if (PandoraContentApi::GetList(*this, pfoListName, pPfoList) != STATUS_CODE_SUCCESS)
194  continue;
195 
196  for (const ParticleFlowObject *const pPfo : *pPfoList)
197  {
198  // Apply hit cut
199  if (LArPfoHelper::GetNumberOfThreeDHits(pPfo) >= m_minClusterSize)
200  pfoVector.emplace_back(pPfo);
201  }
202  }
203 
204  // Sort to maintain reproducibility
205  std::sort(pfoVector.begin(), pfoVector.end(), LArPfoHelper::SortByNHits);
206 
207  for (const ParticleFlowObject *const pPfo : pfoVector)
208  {
209  // Attempt sliding linear fit
210  try
211  {
212  ClusterList clusters3D;
213  LArPfoHelper::GetThreeDClusterList(pPfo, clusters3D);
214 
215  if (clusters3D.size() != 1)
216  continue;
217 
218  const ThreeDSlidingFitResult slidingFitResult(*clusters3D.begin(), m_slidingFitWindow, slidingFitPitch);
219 
220  // We need directions...
221  ExtremalPoint upstreamPoint, downstreamPoint;
222 
223  if (!this->GetExtremalVerticesAndDirections(pNeutrinoPfo, pPfo, slidingFitResult, upstreamPoint, downstreamPoint))
224  continue;
225 
226  // Create track/shower objects
227  if (pPfo->GetParticleId() == 13)
228  {
229  trackPfos.push_back(HierarchyPfo(pPfo, slidingFitResult, upstreamPoint, downstreamPoint));
230  }
231  else if (pPfo->GetParticleId() == 11)
232  {
233  showerPfos.push_back(HierarchyPfo(pPfo, slidingFitResult, upstreamPoint, downstreamPoint));
234  }
235  }
236  catch (...)
237  {
238  continue;
239  }
240  }
241 }
pandora::StringVector m_pfoListNames
the name of the pfo lists
bool GetExtremalVerticesAndDirections(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::ParticleFlowObject *const pPfo, const ThreeDSlidingFitResult &slidingFitResult, ExtremalPoint &upstreamPoint, ExtremalPoint &downstreamPoint) const
Identify the upstream (closest to the nu vertex) and downstream (furthest from the nu vertex) endpoin...
int m_slidingFitWindow
the sliding fit window to use in pfo sliding linear fits
unsigned int m_minClusterSize
the minimum threshold of 3D hits of a considered pfo
bool lar_dl_content::DLNeutrinoHierarchyAlgorithm::GetExtremalVerticesAndDirections ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const pandora::ParticleFlowObject *const  pPfo,
const ThreeDSlidingFitResult slidingFitResult,
ExtremalPoint upstreamPoint,
ExtremalPoint downstreamPoint 
) const
private

Identify the upstream (closest to the nu vertex) and downstream (furthest from the nu vertex) endpoints and directions of an input pfo.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
pPfoa pointer to the pfo
slidingFitResultthe sliding fit result of the input pfo
upstreamPointthe upstream endpoint
downstreamPointthe downstream endpoint
Returns
whether this was successful

Definition at line 245 of file DLNeutrinoHierarchyAlgorithm.cc.

References f, lar_content::LArPointingCluster::Vertex::GetDirection(), lar_content::ThreeDSlidingFitResult::GetGlobalMaxLayerPosition(), lar_content::ThreeDSlidingFitResult::GetGlobalMinLayerPosition(), lar_content::LArPointingCluster::GetInnerVertex(), lar_content::LArPointingCluster::GetOuterVertex(), lar_content::LArPointingCluster::Vertex::GetPosition(), GetShowerDirection(), and lar_dl_content::ExtremalPoint::Set().

Referenced by FillTrackShowerVectors().

247 {
248  // First, get the neutrino vertex
249  const Vertex *const pNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
250  const CartesianVector nuVertex(
251  pNeutrinoVertex->GetPosition().GetX(), pNeutrinoVertex->GetPosition().GetY(), pNeutrinoVertex->GetPosition().GetZ());
252 
253  if (pPfo->GetParticleId() == 13)
254  {
255  try
256  {
257  const LArPointingCluster pointingCluster(slidingFitResult); // this could throw an exception
258  const CartesianVector innerVertex(pointingCluster.GetInnerVertex().GetPosition().GetX(),
259  pointingCluster.GetInnerVertex().GetPosition().GetY(), pointingCluster.GetInnerVertex().GetPosition().GetZ());
260  CartesianVector innerDirection(pointingCluster.GetInnerVertex().GetDirection().GetX(),
261  pointingCluster.GetInnerVertex().GetDirection().GetY(), pointingCluster.GetInnerVertex().GetDirection().GetZ());
262  const CartesianVector outerVertex(pointingCluster.GetOuterVertex().GetPosition().GetX(),
263  pointingCluster.GetOuterVertex().GetPosition().GetY(), pointingCluster.GetOuterVertex().GetPosition().GetZ());
264  CartesianVector outerDirection(pointingCluster.GetOuterVertex().GetDirection().GetX(),
265  pointingCluster.GetOuterVertex().GetDirection().GetY(), pointingCluster.GetOuterVertex().GetDirection().GetZ());
266 
267  // want them to both point into the particle
268  if (innerDirection.GetDotProduct(outerVertex - innerVertex) < 0.f)
269  innerDirection *= (-1.f);
270 
271  if (outerDirection.GetDotProduct(innerVertex - outerVertex) < 0.f)
272  outerDirection *= (-1.f);
273 
274  // determine upstream/downstream
275  if ((innerVertex - nuVertex).GetMagnitudeSquared() < (outerVertex - nuVertex).GetMagnitudeSquared())
276  {
277  upstreamPoint.Set(innerVertex, innerDirection);
278  downstreamPoint.Set(outerVertex, outerDirection);
279  }
280  else
281  {
282  upstreamPoint.Set(outerVertex, outerDirection);
283  downstreamPoint.Set(innerVertex, innerDirection);
284  }
285  }
286  catch (...)
287  {
288  return false;
289  }
290  }
291  else
292  {
293  // find directions, demand that we have at least one
294  CartesianVector minLayerDir(0.f, 0.f, 0.f), maxLayerDir(0.f, 0.f, 0.f);
295  const bool minLayerDirSet(this->GetShowerDirection(pPfo, slidingFitResult.GetGlobalMinLayerPosition(), minLayerDir));
296  const bool maxLayerDirSet(this->GetShowerDirection(pPfo, slidingFitResult.GetGlobalMaxLayerPosition(), maxLayerDir));
297 
298  if (!minLayerDirSet && !maxLayerDirSet)
299  return false;
300 
301  const float minSepSq((slidingFitResult.GetGlobalMinLayerPosition() - nuVertex).GetMagnitudeSquared());
302  const float maxSepSq((slidingFitResult.GetGlobalMaxLayerPosition() - nuVertex).GetMagnitudeSquared());
303 
304  if (minLayerDirSet)
305  {
306  ExtremalPoint &toChange = (minSepSq < maxSepSq) ? upstreamPoint : downstreamPoint;
307  toChange.Set(slidingFitResult.GetGlobalMinLayerPosition(), minLayerDir);
308  }
309 
310  if (maxLayerDirSet)
311  {
312  ExtremalPoint &toChange = (minSepSq < maxSepSq) ? downstreamPoint : upstreamPoint;
313  toChange.Set(slidingFitResult.GetGlobalMaxLayerPosition(), maxLayerDir);
314  }
315  }
316 
317  return true;
318 }
LArPointingCluster class.
TFile f
Definition: plotHisto.C:6
const pandora::CartesianVector & GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
bool GetShowerDirection(const pandora::ParticleFlowObject *const pPfo, const pandora::CartesianVector &vertex, pandora::CartesianVector &direction) const
Obtain the direction of a shower at a given endpoint from the angular decomposition of the shower&#39;s &#39;...
const pandora::CartesianVector & GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.
float lar_dl_content::DLNeutrinoHierarchyAlgorithm::GetLaterTierScore ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const HierarchyPfo parentPfo,
const HierarchyPfo childPfo 
) const
private

Call the later tier network tool to obtain the later tier score of a parent-child link.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
parentPfothe HierarchyPfo object of the parent pfo
childPfothe HierarchyPfo object of the child pfo
Returns
the parent-child network score

Definition at line 562 of file DLNeutrinoHierarchyAlgorithm.cc.

References m_laterTierHierarchyTool, and lar_dl_content::DLLaterTierHierarchyTool::Run().

Referenced by SetLaterTierScores().

564 {
565  std::vector<DLLaterTierHierarchyTool::DLLaterTierNetworkParams> networkParamVector;
566  float laterTierScore(std::numeric_limits<float>::lowest());
567 
568  if (m_laterTierHierarchyTool->Run(this, pNeutrinoPfo, parentPfo, childPfo, networkParamVector, laterTierScore) != STATUS_CODE_SUCCESS)
569  return std::numeric_limits<float>::lowest();
570 
571  return laterTierScore;
572 }
pandora::StatusCode Run(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfo &parentHierarchyPfo, const HierarchyPfo &childHierarchyPfo, std::vector< DLLaterTierNetworkParams > &networkParamVector, float &laterTierScore)
DLLaterTierHierarchyTool * m_laterTierHierarchyTool
The tool used to build the later tiers.
bool lar_dl_content::DLNeutrinoHierarchyAlgorithm::GetNeutrinoPfo ( const pandora::ParticleFlowObject *&  pNeutrinoPfo) const
private

Return the neutrino pfo.

Parameters
thepointer to the neutrino pfo to fill
Returns
whether the neutrino pfo can be found

Definition at line 157 of file DLNeutrinoHierarchyAlgorithm.cc.

References m_neutrinoPfoListName.

Referenced by Run().

158 {
159  const PfoList *pPfoList(nullptr);
160 
161  PANDORA_THROW_RESULT_IF_AND_IF(
162  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_INITIALIZED, !=, PandoraContentApi::GetList(*this, m_neutrinoPfoListName, pPfoList));
163 
164  if (!pPfoList || pPfoList->empty())
165  return false;
166 
167  // ATTN Enforces that only one pfo, of neutrino-type, be in the specified input list
168  pNeutrinoPfo = (1 == pPfoList->size()) ? *(pPfoList->begin()) : nullptr;
169 
170  if (!pNeutrinoPfo || !LArPfoHelper::IsNeutrino(pNeutrinoPfo))
171  throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
172 
173  return true;
174 }
std::string m_neutrinoPfoListName
the name of the neutrino pfo list
void lar_dl_content::DLNeutrinoHierarchyAlgorithm::GetParticleIDMap ( const HierarchyPfoVector trackPfos,
const HierarchyPfoVector showerPfos,
std::map< const pandora::ParticleFlowObject *, int > &  particleIDMap 
) const
private

Obtain the [pfo -> unique ID] map.

Parameters
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector
particleIDMapthe [pfo -> unique ID] map to populate

Referenced by BuildPandoraHierarchy(), and Run().

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::GetPrimaryScore ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const HierarchyPfoVector trackPfos,
const HierarchyPfo hierarchyPfo 
) const
private

Call the primary network tool to obtain the primary score of a HierarchyPfo.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
trackPfosthe track-like HierarchyPfoVector
hierarchyPfothe HierarchyPfo object of the input pfo
Returns
the primary network score

Definition at line 404 of file DLNeutrinoHierarchyAlgorithm.cc.

References m_primaryHierarchyTool, and lar_dl_content::DLPrimaryHierarchyTool::Run().

Referenced by SetPrimaryScores().

406 {
407  std::vector<DLPrimaryHierarchyTool::DLPrimaryNetworkParams> networkParamVector;
408  float primaryScore(std::numeric_limits<float>::lowest());
409 
410  if (m_primaryHierarchyTool->Run(this, pNeutrinoPfo, trackPfos, hierarchyPfo, networkParamVector, primaryScore) != STATUS_CODE_SUCCESS)
411  return std::numeric_limits<float>::lowest();
412 
413  return primaryScore;
414 }
pandora::StatusCode Run(const pandora::Algorithm *const pAlgorithm, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfo &hierarchyPfo, std::vector< DLPrimaryNetworkParams > &networkParamVector, float &primaryScore)
DLPrimaryHierarchyTool * m_primaryHierarchyTool
The tool used to build the primary tiers.
bool lar_dl_content::DLNeutrinoHierarchyAlgorithm::GetShowerDirection ( const pandora::ParticleFlowObject *const  pPfo,
const pandora::CartesianVector &  vertex,
pandora::CartesianVector &  direction 
) const
private

Obtain the direction of a shower at a given endpoint from the angular decomposition of the shower's 'close' 3D hits.

Parameters
pPfoa pointer to the pfo
vertexthe position at which to find the direction
directionthe found direction
Returns
whether a shower direction could be found

Definition at line 322 of file DLNeutrinoHierarchyAlgorithm.cc.

References f, m_nAngularBins, and m_regionForDirFit.

Referenced by GetExtremalVerticesAndDirections().

323 {
324  CartesianPointVector pointVector;
325  LArPfoHelper::GetCoordinateVector(pPfo, TPC_3D, pointVector);
326 
327  if (pointVector.empty())
328  return false;
329 
330  // set direction by angular distribution
331  const float angleMin(0.f), angleMax(2.f * M_PI);
332  const float binWidth((angleMax - angleMin) / static_cast<float>(m_nAngularBins));
333 
334  std::vector<std::vector<int>> spatialDist(m_nAngularBins, std::vector<int>(m_nAngularBins, 0));
335  std::vector<std::vector<float>> tieBreakerDist(m_nAngularBins, std::vector<float>(m_nAngularBins, 0.f));
336 
337  int highestSP(0), bestTheta0YZBin(-1), bestTheta0XZBin(-1);
338  float tieBreaker(std::numeric_limits<float>::max());
339 
340  for (const CartesianVector &position3D : pointVector)
341  {
342  const CartesianVector displacement(position3D - vertex);
343  const float mag(displacement.GetMagnitude());
344 
345  if (mag > m_regionForDirFit)
346  continue;
347 
348  const float magXZ(sqrt((displacement.GetX() * displacement.GetX()) + (displacement.GetZ() * displacement.GetZ())));
349 
350  float theta0YZ((mag < std::numeric_limits<float>::epsilon()) ? 0.f
351  : (std::fabs(std::fabs(displacement.GetY() / mag) - 1.f) < std::numeric_limits<float>::epsilon())
352  ? 0.f
353  : std::acos(displacement.GetY() / mag));
354 
355  float theta0XZ((magXZ < std::numeric_limits<float>::epsilon()) ? 0.f
356  : (std::fabs(std::fabs(displacement.GetX() / magXZ) - 1.f) < std::numeric_limits<float>::epsilon())
357  ? 0.f
358  : std::acos(displacement.GetX() / magXZ));
359 
360  // try do signed-ness
361  if (displacement.GetZ() < 0.f)
362  theta0XZ = (2.0 * M_PI) - theta0XZ;
363 
364  const int bin0YZ(std::floor(theta0YZ / binWidth));
365  const int bin0XZ(std::floor(theta0XZ / binWidth));
366 
367  spatialDist[bin0YZ][bin0XZ] += 1;
368  tieBreakerDist[bin0YZ][bin0XZ] += (1.f / mag); // tie-breaker
369 
370  if (((spatialDist[bin0YZ][bin0XZ] == highestSP) && (tieBreakerDist[bin0YZ][bin0XZ] < tieBreaker)) || (spatialDist[bin0YZ][bin0XZ] > highestSP))
371  {
372  highestSP = spatialDist[bin0YZ][bin0XZ];
373  tieBreaker = tieBreakerDist[bin0YZ][bin0XZ];
374  bestTheta0YZBin = bin0YZ;
375  bestTheta0XZBin = bin0XZ;
376  }
377  }
378 
379  if ((bestTheta0YZBin < 0) || (bestTheta0XZBin < 0))
380  return false;
381 
382  const float bestTheta0YZ(angleMin + ((static_cast<float>(bestTheta0YZBin) + 0.5f) * binWidth));
383  const float bestTheta0XZ(angleMin + ((static_cast<float>(bestTheta0XZBin) + 0.5f) * binWidth));
384 
385  direction = CartesianVector(std::sin(bestTheta0YZ) * std::cos(bestTheta0XZ), std::cos(bestTheta0YZ), std::sin(bestTheta0YZ) * std::sin(bestTheta0XZ));
386 
387  return true;
388 }
TFile f
Definition: plotHisto.C:6
float m_regionForDirFit
the radius of the region used in shower direction fits
int m_nAngularBins
the number of angle bins used by the shower direction fitter
vertex reconstruction
std::pair<float, float> lar_dl_content::DLNeutrinoHierarchyAlgorithm::GetTrainingCuts ( const HierarchyPfo parentHierarchyPfo,
const HierarchyPfo childHierarchyPfo,
const bool  trueParentOrientation,
const bool  trueChildOrientation 
) const
private

Get the training cuts for the later tier parent-child link these describe how well the child points back to the parent.

Parameters
parentHierarchyPfothe HierarchyPfo object of the parent
childHierarchyPfothe HierarchyPfo object of the child
trueParentOrientationwhether the parent POI is in the upstream position
trueChildOrientationwhether the child POI is in the upstream position
Returns
the training cut pair

Referenced by BuildPandoraHierarchy().

StatusCode lar_dl_content::DLNeutrinoHierarchyAlgorithm::ReadSettings ( const pandora::TiXmlHandle  xmlHandle)
private

Definition at line 975 of file DLNeutrinoHierarchyAlgorithm.cc.

References m_cheatHierarchyTool, m_eventID, m_eventTreeName, m_laterTierHierarchyTool, m_laterTierThresholdShowerPass1, m_laterTierThresholdShowerPass2, m_laterTierThresholdTrackPass1, m_laterTierThresholdTrackPass2, m_laterTierTrackShowerTreeName, m_laterTierTrackTrackTreeName, m_mcParticleListName, m_minClusterSize, m_nAngularBins, m_neutrinoPfoListName, m_pfoListNames, m_primaryHierarchyTool, m_primaryRegion, m_primaryShowerTreeName, m_primaryThresholdShowerPass1, m_primaryThresholdShowerPass2, m_primaryThresholdTrackPass1, m_primaryThresholdTrackPass2, m_primaryTrackTreeName, m_regionForDirFit, m_slidingFitWindow, m_trainingFileName, m_trainingMode, and m_trainingVertexAccuracy.

976 {
977  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EventID", m_eventID));
978  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrainingMode", m_trainingMode));
979  PANDORA_RETURN_RESULT_IF_AND_IF(
980  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MCParticleListName", m_mcParticleListName));
981  PANDORA_RETURN_RESULT_IF_AND_IF(
982  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrainingVertexAccuracy", m_trainingVertexAccuracy));
983  PANDORA_RETURN_RESULT_IF_AND_IF(
984  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "TrainingFileName", m_trainingFileName));
985  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "EventTreeName", m_eventTreeName));
986  PANDORA_RETURN_RESULT_IF_AND_IF(
987  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PrimaryTrackTreeName", m_primaryTrackTreeName));
988  PANDORA_RETURN_RESULT_IF_AND_IF(
989  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PrimaryShowerTreeName", m_primaryShowerTreeName));
990  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
991  XmlHelper::ReadValue(xmlHandle, "LaterTierTrackTrackTreeName", m_laterTierTrackTrackTreeName));
992  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
993  XmlHelper::ReadValue(xmlHandle, "LaterTierTrackShowerTreeName", m_laterTierTrackShowerTreeName));
994  PANDORA_RETURN_RESULT_IF_AND_IF(
995  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NeutrinoPfoListName", m_neutrinoPfoListName));
996  PANDORA_RETURN_RESULT_IF_AND_IF(
997  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadVectorOfValues(xmlHandle, "PfoListNames", m_pfoListNames));
998  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "MinClusterSize", m_minClusterSize));
999  PANDORA_RETURN_RESULT_IF_AND_IF(
1000  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "SlidingFitWindow", m_slidingFitWindow));
1001  PANDORA_RETURN_RESULT_IF_AND_IF(
1002  STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "RegionForDirectionFit", m_regionForDirFit));
1003  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "NAngularBins", m_nAngularBins));
1004  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle, "PrimaryRegion", m_primaryRegion));
1005  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1006  XmlHelper::ReadValue(xmlHandle, "PrimaryThresholdTrackPass1", m_primaryThresholdTrackPass1));
1007  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1008  XmlHelper::ReadValue(xmlHandle, "PrimaryThresholdShowerPass1", m_primaryThresholdShowerPass1));
1009  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1010  XmlHelper::ReadValue(xmlHandle, "LaterTierThresholdTrackPass1", m_laterTierThresholdTrackPass1));
1011  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1012  XmlHelper::ReadValue(xmlHandle, "LaterTierThresholdShowerPass1", m_laterTierThresholdShowerPass1));
1013  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1014  XmlHelper::ReadValue(xmlHandle, "PrimaryThresholdTrackPass2", m_primaryThresholdTrackPass2));
1015  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1016  XmlHelper::ReadValue(xmlHandle, "PrimaryThresholdShowerPass2", m_primaryThresholdShowerPass2));
1017  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1018  XmlHelper::ReadValue(xmlHandle, "LaterTierThresholdTrackPass2", m_laterTierThresholdTrackPass2));
1019  PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
1020  XmlHelper::ReadValue(xmlHandle, "LaterTierThresholdShowerPass2", m_laterTierThresholdShowerPass2));
1021 
1022  AlgorithmTool *pAlgorithmTool(nullptr);
1023  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmTool(*this, xmlHandle, "DLPrimaryHierarchyTool", pAlgorithmTool));
1024  m_primaryHierarchyTool = dynamic_cast<DLPrimaryHierarchyTool *>(pAlgorithmTool);
1025 
1027  return STATUS_CODE_INVALID_PARAMETER;
1028 
1029  pAlgorithmTool = nullptr;
1030  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmTool(*this, xmlHandle, "DLLaterTierHierarchyTool", pAlgorithmTool));
1031  m_laterTierHierarchyTool = dynamic_cast<DLLaterTierHierarchyTool *>(pAlgorithmTool);
1032 
1034  return STATUS_CODE_INVALID_PARAMETER;
1035 
1036  if (m_trainingMode)
1037  {
1038  pAlgorithmTool = nullptr;
1039  PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmTool(*this, xmlHandle, "DLCheatHierarchyTool", pAlgorithmTool));
1040  m_cheatHierarchyTool = dynamic_cast<DLCheatHierarchyTool *>(pAlgorithmTool);
1041 
1042  if (!m_cheatHierarchyTool)
1043  return STATUS_CODE_INVALID_PARAMETER;
1044  }
1045 
1046  return STATUS_CODE_SUCCESS;
1047 }
float m_primaryThresholdTrackPass2
The threshold applied to tracks in pass 2 primary tier building.
float m_primaryThresholdShowerPass2
The threshold applied to showers in pass 2 primary tier building.
float m_laterTierThresholdTrackPass2
The threshold applied to track-track links in pass 2 later tier building.
std::string m_primaryTrackTreeName
the name of the output primary track link tree
pandora::StringVector m_pfoListNames
the name of the pfo lists
std::string m_primaryShowerTreeName
the name of the output primary shower link tree
float m_primaryThresholdTrackPass1
The threshold applied to tracks in pass 1 primary tier building.
std::string m_mcParticleListName
the name of the MCParticle list
std::string m_laterTierTrackTrackTreeName
the name of the output track-track later tier link tree
std::string m_neutrinoPfoListName
the name of the neutrino pfo list
std::string m_laterTierTrackShowerTreeName
the name of the output track-shower later tier link tree
std::string m_trainingFileName
the name of the output training file
bool m_trainingMode
whether to run in training mode
float m_primaryRegion
the radius of the nu vertex region where particles are assumed to be primaries
float m_primaryThresholdShowerPass1
The threshold applied to showers in pass 1 primary tier building.
int m_slidingFitWindow
the sliding fit window to use in pfo sliding linear fits
DLLaterTierHierarchyTool * m_laterTierHierarchyTool
The tool used to build the later tiers.
float m_regionForDirFit
the radius of the region used in shower direction fits
float m_laterTierThresholdTrackPass1
The threshold applied to track-track links in pass 1 later tier building.
DLPrimaryHierarchyTool * m_primaryHierarchyTool
The tool used to build the primary tiers.
std::string m_eventTreeName
the name of the output event tree
unsigned int m_minClusterSize
the minimum threshold of 3D hits of a considered pfo
float m_laterTierThresholdShowerPass2
The threshold applied to track-shower links in pass 2 later tier building.
DLCheatHierarchyTool * m_cheatHierarchyTool
The tool used to obtain the true hierarchy.
int m_nAngularBins
the number of angle bins used by the shower direction fitter
float m_trainingVertexAccuracy
the maximum true-reco nu vertex displacement allowed for training
float m_laterTierThresholdShowerPass1
The threshold applied to track-shower links in pass 1 later tier building.
StatusCode lar_dl_content::DLNeutrinoHierarchyAlgorithm::Run ( )
private

Definition at line 82 of file DLNeutrinoHierarchyAlgorithm.cc.

References BuildPandoraHierarchy(), FillEventTree(), lar_dl_content::DLCheatHierarchyTool::FillHierarchyMap(), FillLaterTierTrees(), FillPrimaryTrees(), FillTrackShowerVectors(), GetNeutrinoPfo(), GetParticleIDMap(), m_cheatHierarchyTool, m_eventID, m_laterTierThresholdShowerPass1, m_laterTierThresholdShowerPass2, m_laterTierThresholdTrackPass1, m_laterTierThresholdTrackPass2, m_primaryThresholdShowerPass1, m_primaryThresholdShowerPass2, m_primaryThresholdTrackPass1, m_primaryThresholdTrackPass2, m_trainingMode, SetLaterTierScores(), SetPrimaryScores(), and UpdateHierarchy().

83 {
84  ++m_eventID;
85 
86  // Get neutrino pfo
87  const ParticleFlowObject *pNeutrinoPfo(nullptr);
88  if (!this->GetNeutrinoPfo(pNeutrinoPfo))
89  return STATUS_CODE_SUCCESS;
90 
91  // Ensure neutrino has a vertex
92  if (pNeutrinoPfo->GetVertexList().empty())
93  return STATUS_CODE_NOT_INITIALIZED;
94 
95  // Fill the track/shower vectors
96  HierarchyPfoVector trackPfos, showerPfos;
97  this->FillTrackShowerVectors(pNeutrinoPfo, trackPfos, showerPfos);
98 
99 #ifdef MONITORING
100 
101  if (m_trainingMode)
102  {
103  if ((trackPfos.empty()) && (showerPfos.empty()))
104  return STATUS_CODE_SUCCESS;
105 
106  // Do ID
107  std::map<const pandora::ParticleFlowObject *, int> particleIDMap;
108  this->GetParticleIDMap(trackPfos, showerPfos, particleIDMap);
109 
110  // Get truth
111  PfoToMCParticleMap matchingMap;
112  ChildToParentPfoMap childToParentPfoMap;
113  m_cheatHierarchyTool->FillHierarchyMap(this, matchingMap, childToParentPfoMap);
114 
115  // Fill trees
116  int nPrimaryTrackLinks(0), nPrimaryShowerLinks(0);
117  int nLaterTierTrackTrackLinks(0), nLaterTierTrackShowerLinks(0);
118 
119  this->FillPrimaryTrees(matchingMap, childToParentPfoMap, pNeutrinoPfo, trackPfos, showerPfos, particleIDMap, nPrimaryTrackLinks, nPrimaryShowerLinks);
120  this->FillLaterTierTrees(matchingMap, childToParentPfoMap, pNeutrinoPfo, trackPfos, showerPfos, particleIDMap,
121  nLaterTierTrackTrackLinks, nLaterTierTrackShowerLinks);
122  this->FillEventTree(trackPfos, showerPfos, nPrimaryTrackLinks, nPrimaryShowerLinks, nLaterTierTrackTrackLinks, nLaterTierTrackShowerLinks);
123 
124  return STATUS_CODE_SUCCESS;
125  }
126 
127 #endif
128 
129  // Calculate primary scores
130  this->SetPrimaryScores(pNeutrinoPfo, trackPfos, showerPfos);
131 
132  // Build initial primary tier
133  Hierarchy hierarchy({PfoVector()});
134  this->UpdateHierarchy(pNeutrinoPfo, true, true, m_primaryThresholdTrackPass1, m_primaryThresholdShowerPass1, true, trackPfos, showerPfos, hierarchy);
135 
136  // Set later tier scores
137  this->SetLaterTierScores(pNeutrinoPfo, trackPfos, showerPfos);
138 
139  // Build the later tier
140  this->UpdateHierarchy(
141  pNeutrinoPfo, false, false, m_laterTierThresholdTrackPass1, m_laterTierThresholdShowerPass1, true, trackPfos, showerPfos, hierarchy);
142 
143  // Try to recover primaries using laterTierScore
144  this->UpdateHierarchy(pNeutrinoPfo, true, false, m_primaryThresholdTrackPass2, m_primaryThresholdShowerPass2, false, trackPfos, showerPfos, hierarchy);
145 
146  // Try to recover any children using laterTierScore
147  this->UpdateHierarchy(
148  pNeutrinoPfo, false, false, m_laterTierThresholdTrackPass2, m_laterTierThresholdShowerPass2, true, trackPfos, showerPfos, hierarchy);
149 
150  this->BuildPandoraHierarchy(pNeutrinoPfo, trackPfos, showerPfos);
151 
152  return STATUS_CODE_SUCCESS;
153 }
float m_primaryThresholdTrackPass2
The threshold applied to tracks in pass 2 primary tier building.
float m_primaryThresholdShowerPass2
The threshold applied to showers in pass 2 primary tier building.
void FillEventTree(const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, const int nPrimaryTrackLinks, const int nPrimaryShowerLinks, const int nLaterTierTrackTrackLinks, const int nLaterTierTrackShowerLinks) const
Fill the output event tree (containing event-level info)
float m_laterTierThresholdTrackPass2
The threshold applied to track-track links in pass 2 later tier building.
void FillHierarchyMap(const pandora::Algorithm *const pAlgorithm, PfoToMCParticleMap &pfoToMCParticleMap, ChildToParentPfoMap &childToParentPfoMap) const
Determine the true child -> parent pfo visible matches, filling the pfo->MCParticle matching map in t...
void FillPrimaryTrees(const PfoToMCParticleMap &matchingMap, const ChildToParentPfoMap &childToParentPfoMap, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, const std::map< const pandora::ParticleFlowObject *, int > &particleIDMap, int &nPrimaryTrackLinks, int &nPrimaryShowerLinks) const
Fill the primary trees (containing primary link info)
void FillLaterTierTrees(const PfoToMCParticleMap &matchingMap, const ChildToParentPfoMap &childToParentPfoMap, const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, const std::map< const pandora::ParticleFlowObject *, int > &particleIDMap, int &nTrackLinks, int &nShowerLinks) const
Fill the later tier trees (containing later tier link info)
void FillTrackShowerVectors(const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const
Fill the track and shower-like HierarchyPfoVector.
float m_primaryThresholdTrackPass1
The threshold applied to tracks in pass 1 primary tier building.
void BuildPandoraHierarchy(const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos) const
Register the parent-child relationships in Pandora.
std::map< const pandora::ParticleFlowObject *, std::pair< const pandora::ParticleFlowObject *, int > > ChildToParentPfoMap
std::vector< HierarchyPfo > HierarchyPfoVector
void GetParticleIDMap(const HierarchyPfoVector &trackPfos, const HierarchyPfoVector &showerPfos, std::map< const pandora::ParticleFlowObject *, int > &particleIDMap) const
Obtain the [pfo -> unique ID] map.
bool GetNeutrinoPfo(const pandora::ParticleFlowObject *&pNeutrinoPfo) const
Return the neutrino pfo.
bool m_trainingMode
whether to run in training mode
float m_primaryThresholdShowerPass1
The threshold applied to showers in pass 1 primary tier building.
float m_laterTierThresholdTrackPass1
The threshold applied to track-track links in pass 1 later tier building.
void SetLaterTierScores(const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const
Set the predicted parent and later tier score of the HierarchyPfos to be considered for the later tie...
float m_laterTierThresholdShowerPass2
The threshold applied to track-shower links in pass 2 later tier building.
DLCheatHierarchyTool * m_cheatHierarchyTool
The tool used to obtain the true hierarchy.
std::map< const pandora::ParticleFlowObject *, const pandora::MCParticle * > PfoToMCParticleMap
void SetPrimaryScores(const pandora::ParticleFlowObject *const pNeutrinoPfo, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos) const
Set the primary network scores of the HierarchyPfos.
void UpdateHierarchy(const pandora::ParticleFlowObject *const pNeutrinoPfo, const bool buildPrimaryTier, const bool usePrimaryScore, const float trackThreshold, const float showerThreshold, const bool isLowerThreshold, HierarchyPfoVector &trackPfos, HierarchyPfoVector &showerPfos, Hierarchy &hierarchy) const
Add particles to the hierarchy if they satisfy a criteria.
float m_laterTierThresholdShowerPass1
The threshold applied to track-shower links in pass 1 later tier building.
void lar_dl_content::DLNeutrinoHierarchyAlgorithm::SetLaterTierScores ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
HierarchyPfoVector trackPfos,
HierarchyPfoVector showerPfos 
) const
private

Set the predicted parent and later tier score of the HierarchyPfos to be considered for the later tiers.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector

Definition at line 508 of file DLNeutrinoHierarchyAlgorithm.cc.

References GetLaterTierScore(), and m_primaryRegion.

Referenced by Run().

510 {
511  for (bool isTrack : {true, false})
512  {
513  HierarchyPfoVector &hierarchyPfoVector(isTrack ? trackPfos : showerPfos);
514 
515  for (HierarchyPfo &childHierarchyPfo : hierarchyPfoVector)
516  {
517  // Continue if parent already found
518  if (childHierarchyPfo.GetIsInHierarchy())
519  continue;
520 
521  // Only consider for later tier if far away from nu vertex
522  const Vertex *const pNeutrinoVertex(LArPfoHelper::GetVertex(pNeutrinoPfo));
523  const CartesianVector nuVertex(
524  pNeutrinoVertex->GetPosition().GetX(), pNeutrinoVertex->GetPosition().GetY(), pNeutrinoVertex->GetPosition().GetZ());
525 
526  if ((childHierarchyPfo.GetUpstreamPoint().GetPosition() - nuVertex).GetMagnitudeSquared() < (m_primaryRegion * m_primaryRegion))
527  continue;
528 
529  float highestScore(std::numeric_limits<float>::lowest());
530 
531  for (const HierarchyPfo &parentHierarchyPfo : trackPfos)
532  {
533  if (childHierarchyPfo == parentHierarchyPfo)
534  continue;
535 
536  const float thisScore(this->GetLaterTierScore(pNeutrinoPfo, parentHierarchyPfo, childHierarchyPfo));
537 
538  if ((childHierarchyPfo.GetPredictedParentPfo()) && (std::fabs(thisScore - highestScore) < std::numeric_limits<float>::epsilon()))
539  {
540  // If tie, pick closest
541  const float currentSep(LArPfoHelper::GetThreeDSeparation(childHierarchyPfo.GetPredictedParentPfo(), childHierarchyPfo.GetPfo()));
542  const float thisSep(LArPfoHelper::GetThreeDSeparation(parentHierarchyPfo.GetPfo(), childHierarchyPfo.GetPfo()));
543 
544  if (thisSep > currentSep)
545  continue;
546  }
547  else if (thisScore < highestScore)
548  {
549  continue;
550  }
551 
552  highestScore = thisScore;
553  childHierarchyPfo.SetLaterTierScore(thisScore);
554  childHierarchyPfo.SetPredictedParentPfo(parentHierarchyPfo.GetPfo());
555  }
556  }
557  }
558 }
std::vector< HierarchyPfo > HierarchyPfoVector
float GetLaterTierScore(const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfo &parentPfo, const HierarchyPfo &childPfo) const
Call the later tier network tool to obtain the later tier score of a parent-child link...
float m_primaryRegion
the radius of the nu vertex region where particles are assumed to be primaries
boost::graph_traits< ModuleGraph >::vertex_descriptor Vertex
Definition: ModuleGraph.h:25
void lar_dl_content::DLNeutrinoHierarchyAlgorithm::SetPrimaryScores ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
HierarchyPfoVector trackPfos,
HierarchyPfoVector showerPfos 
) const
private

Set the primary network scores of the HierarchyPfos.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector

Definition at line 392 of file DLNeutrinoHierarchyAlgorithm.cc.

References GetPrimaryScore().

Referenced by Run().

394 {
395  for (HierarchyPfo &hierarchyPfo : trackPfos)
396  hierarchyPfo.SetPrimaryScore(this->GetPrimaryScore(pNeutrinoPfo, trackPfos, hierarchyPfo));
397 
398  for (HierarchyPfo &hierarchyPfo : showerPfos)
399  hierarchyPfo.SetPrimaryScore(this->GetPrimaryScore(pNeutrinoPfo, trackPfos, hierarchyPfo));
400 }
float GetPrimaryScore(const pandora::ParticleFlowObject *const pNeutrinoPfo, const HierarchyPfoVector &trackPfos, const HierarchyPfo &hierarchyPfo) const
Call the primary network tool to obtain the primary score of a HierarchyPfo.
bool lar_dl_content::DLNeutrinoHierarchyAlgorithm::ShouldTrainOnEvent ( const pandora::ParticleFlowObject *const  pNeutrinoPfo) const
private

Whether the event should be trained on.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
Returns
whether to train on the links in the event

Referenced by BuildPandoraHierarchy().

void lar_dl_content::DLNeutrinoHierarchyAlgorithm::UpdateHierarchy ( const pandora::ParticleFlowObject *const  pNeutrinoPfo,
const bool  buildPrimaryTier,
const bool  usePrimaryScore,
const float  trackThreshold,
const float  showerThreshold,
const bool  isLowerThreshold,
HierarchyPfoVector trackPfos,
HierarchyPfoVector showerPfos,
Hierarchy hierarchy 
) const
private

Add particles to the hierarchy if they satisfy a criteria.

Parameters
pNeutrinoPfoa pointer to the neutrino pfo
buildPrimaryTierwhether to build the primary tier (or the later tier)
usePrimaryScorewhether to assess the primary score (or the later tier score)
trackThresholdthe threshold network score for tracks
showerThresholdthe threshold network score for showers
isLowerThresholdwhether the threshold is a minimum or maximum requirement
trackPfosthe track-like HierarchyPfoVector
showerPfosthe shower-like HierarchyPfoVector
hierarchythe hierarchy object to modify

Definition at line 418 of file DLNeutrinoHierarchyAlgorithm.cc.

Referenced by Run().

421 {
422  bool found(true);
423  unsigned int tierIndex(buildPrimaryTier ? 0 : 1);
424 
425  while (found)
426  {
427  found = false;
428 
429  // If building later tiers, check that we do have primaries
430  if (!buildPrimaryTier && hierarchy.at(0).empty())
431  return;
432 
433  PfoVector &thisTier(hierarchy.at(tierIndex));
434 
435  for (bool isTrack : {true, false})
436  {
437  HierarchyPfoVector &hierarchyPfoVector(isTrack ? trackPfos : showerPfos);
438 
439  for (HierarchyPfo &childHierarchyPfo : hierarchyPfoVector)
440  {
441  const ParticleFlowObject *const pChildPfo(childHierarchyPfo.GetPfo());
442 
443  // Continue if parent already found
444  if (childHierarchyPfo.GetIsInHierarchy())
445  continue;
446 
447  const ParticleFlowObject *pPredictedParent(pNeutrinoPfo);
448 
449  // If not buildPrimaryTier correct pPredictedParent
450  if (!buildPrimaryTier)
451  {
452  // Do we have a predicted parent
453  if (!childHierarchyPfo.GetPredictedParentPfo())
454  continue;
455 
456  // Is predicted parent in preceeding tier?
457  const PfoVector &preceedingTier(hierarchy.at(tierIndex - 1));
458 
459  pPredictedParent = childHierarchyPfo.GetPredictedParentPfo();
460 
461  if (std::find(preceedingTier.begin(), preceedingTier.end(), pPredictedParent) == preceedingTier.end())
462  continue;
463  }
464 
465  // Does it pass tier cut?
466  const float networkScore(usePrimaryScore ? childHierarchyPfo.GetPrimaryScore() : childHierarchyPfo.GetLaterTierScore());
467  const float thresholdScore(isTrack ? trackThreshold : showerThreshold);
468 
469  if ((isLowerThreshold && (networkScore > thresholdScore)) || (!isLowerThreshold && (networkScore < thresholdScore)))
470  {
471  found = true;
472 
473  // Add child to hierarchy tier
474  thisTier.emplace_back(pChildPfo);
475 
476  // Add info to childHierarchyPfo
477  childHierarchyPfo.SetIsInHierarchy(true);
478  childHierarchyPfo.SetParentPfo(pPredictedParent);
479 
480  // Add info to parentPfo
481  if (!buildPrimaryTier)
482  {
483  const auto iter(std::find(trackPfos.begin(), trackPfos.end(), pPredictedParent));
484 
485  if (iter == trackPfos.end())
486  throw StatusCodeException(STATUS_CODE_FAILURE);
487 
488  iter->AddChildPfo(pChildPfo);
489  }
490  }
491  }
492  }
493 
494  // Make sure to add the next tier
495  if (hierarchy.size() == (tierIndex + 1))
496  hierarchy.push_back(PfoVector());
497 
498  // If buildPrimaryTier, our work is done!
499  if (buildPrimaryTier)
500  break;
501 
502  ++tierIndex;
503  }
504 }
std::vector< HierarchyPfo > HierarchyPfoVector

Member Data Documentation

DLCheatHierarchyTool* lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_cheatHierarchyTool
private

The tool used to obtain the true hierarchy.

Definition at line 312 of file DLNeutrinoHierarchyAlgorithm.h.

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

int lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_eventID
private

the event counter

Definition at line 285 of file DLNeutrinoHierarchyAlgorithm.h.

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

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_eventTreeName
private

the name of the output event tree

Definition at line 288 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), ReadSettings(), and ~DLNeutrinoHierarchyAlgorithm().

DLLaterTierHierarchyTool* lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_laterTierHierarchyTool
private

The tool used to build the later tiers.

Definition at line 311 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), GetLaterTierScore(), and ReadSettings().

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_laterTierThresholdShowerPass1
private

The threshold applied to track-shower links in pass 1 later tier building.

Definition at line 305 of file DLNeutrinoHierarchyAlgorithm.h.

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

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_laterTierThresholdShowerPass2
private

The threshold applied to track-shower links in pass 2 later tier building.

Definition at line 309 of file DLNeutrinoHierarchyAlgorithm.h.

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

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_laterTierThresholdTrackPass1
private

The threshold applied to track-track links in pass 1 later tier building.

Definition at line 304 of file DLNeutrinoHierarchyAlgorithm.h.

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

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_laterTierThresholdTrackPass2
private

The threshold applied to track-track links in pass 2 later tier building.

Definition at line 308 of file DLNeutrinoHierarchyAlgorithm.h.

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

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_laterTierTrackShowerTreeName
private

the name of the output track-shower later tier link tree

Definition at line 292 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), ReadSettings(), and ~DLNeutrinoHierarchyAlgorithm().

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_laterTierTrackTrackTreeName
private

the name of the output track-track later tier link tree

Definition at line 291 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), ReadSettings(), and ~DLNeutrinoHierarchyAlgorithm().

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_mcParticleListName
private

the name of the MCParticle list

Definition at line 293 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), and ReadSettings().

unsigned int lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_minClusterSize
private

the minimum threshold of 3D hits of a considered pfo

Definition at line 297 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by DLNeutrinoHierarchyAlgorithm(), FillTrackShowerVectors(), and ReadSettings().

int lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_nAngularBins
private

the number of angle bins used by the shower direction fitter

Definition at line 300 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by DLNeutrinoHierarchyAlgorithm(), GetShowerDirection(), and ReadSettings().

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_neutrinoPfoListName
private

the name of the neutrino pfo list

Definition at line 295 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by GetNeutrinoPfo(), and ReadSettings().

pandora::StringVector lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_pfoListNames
private

the name of the pfo lists

Definition at line 296 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), FillTrackShowerVectors(), and ReadSettings().

DLPrimaryHierarchyTool* lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryHierarchyTool
private

The tool used to build the primary tiers.

Definition at line 310 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), GetPrimaryScore(), and ReadSettings().

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryRegion
private

the radius of the nu vertex region where particles are assumed to be primaries

Definition at line 301 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by DLNeutrinoHierarchyAlgorithm(), ReadSettings(), and SetLaterTierScores().

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryShowerTreeName
private

the name of the output primary shower link tree

Definition at line 290 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), ReadSettings(), and ~DLNeutrinoHierarchyAlgorithm().

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryThresholdShowerPass1
private

The threshold applied to showers in pass 1 primary tier building.

Definition at line 303 of file DLNeutrinoHierarchyAlgorithm.h.

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

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryThresholdShowerPass2
private

The threshold applied to showers in pass 2 primary tier building.

Definition at line 307 of file DLNeutrinoHierarchyAlgorithm.h.

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

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryThresholdTrackPass1
private

The threshold applied to tracks in pass 1 primary tier building.

Definition at line 302 of file DLNeutrinoHierarchyAlgorithm.h.

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

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryThresholdTrackPass2
private

The threshold applied to tracks in pass 2 primary tier building.

Definition at line 306 of file DLNeutrinoHierarchyAlgorithm.h.

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

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_primaryTrackTreeName
private

the name of the output primary track link tree

Definition at line 289 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), ReadSettings(), and ~DLNeutrinoHierarchyAlgorithm().

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_regionForDirFit
private

the radius of the region used in shower direction fits

Definition at line 299 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by DLNeutrinoHierarchyAlgorithm(), GetShowerDirection(), and ReadSettings().

int lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_slidingFitWindow
private

the sliding fit window to use in pfo sliding linear fits

Definition at line 298 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by DLNeutrinoHierarchyAlgorithm(), FillTrackShowerVectors(), and ReadSettings().

std::string lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_trainingFileName
private

the name of the output training file

Definition at line 287 of file DLNeutrinoHierarchyAlgorithm.h.

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

bool lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_trainingMode
private

whether to run in training mode

Definition at line 286 of file DLNeutrinoHierarchyAlgorithm.h.

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

float lar_dl_content::DLNeutrinoHierarchyAlgorithm::m_trainingVertexAccuracy
private

the maximum true-reco nu vertex displacement allowed for training

Definition at line 294 of file DLNeutrinoHierarchyAlgorithm.h.

Referenced by BuildPandoraHierarchy(), and ReadSettings().


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