31 for (
const auto &mapEntry : pfoInfoMap)
32 sortedPfos.push_back(mapEntry.first);
35 for (
const Pfo *
const pPfo : sortedPfos)
37 const PfoInfo *
const pPfoInfo(pfoInfoMap.at(pPfo));
41 assignedPfos.push_back(pPfoInfo->
GetThisPfo());
45 unassignedPfos.push_back(pPfoInfo->
GetThisPfo());
55 PfoList candidateDaughterPfoList;
65 std::cout <<
"NeutrinoHierarchyAlgorithm: required input pfos unavailable." << std::endl;
67 if (STATUS_CODE_NOT_FOUND != statusCodeException.
GetStatusCode())
68 throw statusCodeException;
70 return STATUS_CODE_SUCCESS;
83 pPfoRelationTool->Run(
this, pNeutrinoVertex, pfoInfoMap);
90 std::cout <<
"NeutrinoHierarchyAlgorithm: unable to process input neutrino pfo, " << statusCodeException.
ToString() << std::endl;
96 for (
auto &mapIter : pfoInfoMap)
97 delete mapIter.second;
99 return STATUS_CODE_SUCCESS;
106 const PfoList *pPfoList =
nullptr;
110 if (!pPfoList || pPfoList->empty())
113 std::cout <<
"NeutrinoHierarchyAlgorithm: unable to find pfo list " <<
m_neutrinoPfoListName << std::endl;
119 pNeutrinoPfo = ((1 == pPfoList->size()) ? *(pPfoList->begin()) :
nullptr);
131 const PfoList *pCandidatePfoList(
nullptr);
135 candidateDaughterPfoList.insert(candidateDaughterPfoList.end(), pCandidatePfoList->begin(), pCandidatePfoList->end());
139 std::cout <<
"NeutrinoHierarchyAlgorithm: unable to find pfo list " << daughterPfoListName << std::endl;
143 if (candidateDaughterPfoList.empty())
160 (void)pfoInfoMap.insert(PfoInfoMap::value_type(pPfo, pPfoInfo));
165 std::cout <<
"NeutrinoHierarchyAlgorithm: Unable to calculate pfo information " << std::endl;
175 PfoInfoMap &pfoInfoMap,
const unsigned int callDepth)
const
177 PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
183 PfoInfoMap::const_iterator iter = pfoInfoMap.find(pDaughterPfo);
185 if ((pfoInfoMap.end() != iter) && (iter->second->IsNeutrinoVertexAssociated()))
193 return this->
ProcessPfoInfoMap(pNeutrinoPfo, candidateDaughterPfoList, pfoInfoMap, callDepth + 1);
198 for (
const auto &mapEntry : pfoInfoMap)
199 sortedPfos.push_back(mapEntry.first);
202 for (
const Pfo *
const pPfo : sortedPfos)
204 const PfoInfo *
const pPfoInfo(pfoInfoMap.at(pPfo));
217 if (!pRemainingPfo->GetParentPfoList().empty())
230 PfoVector candidateDaughterPfoVector(candidateDaughterPfoList.begin(), candidateDaughterPfoList.end());
234 if (candidateDaughterPfoVector.empty())
242 if (daughterClusterList3D.empty())
248 PandoraContentApi::Vertex::Parameters parameters;
249 parameters.m_position = newVertexPosition;
251 parameters.m_vertexType = pOldNeutrinoVertex->
GetVertexType();
252 parameters.m_x0 = pOldNeutrinoVertex->
GetX0();
255 if (neutrinoVertexListName.empty())
258 std::string temporaryVertexListName;
259 const VertexList *pTemporaryVertexList(
nullptr);
260 const Vertex *pNewNeutrinoVertex(
nullptr);
263 PANDORA_THROW_RESULT_IF(STATUS_CODE_SUCCESS, !=, PandoraContentApi::Vertex::Create(*
this, parameters, pNewNeutrinoVertex));
270 for (
auto &mapIter : pfoInfoMap)
271 delete mapIter.second;
276 pPfoRelationTool->Run(
this, pNewNeutrinoVertex, pfoInfoMap);
285 std::cout <<
"-Neutrino Pfo, nDaughters " << pNeutrinoPfo->
GetDaughterPfoList().size() <<
", nVertices "
289 for (
const auto &mapEntry : pfoInfoMap)
290 sortedPfos.push_back(mapEntry.first);
293 for (
const Pfo *
const pPfo : sortedPfos)
295 const PfoInfo *
const pPfoInfo(pfoInfoMap.at(pPfo));
301 std::cout << pDaughterPfo <<
" ";
302 std::cout <<
") " << std::endl;
319 for (
const Pfo *
const pPfo : sortedPfos)
321 const PfoInfo *
const pPfoInfo(pfoInfoMap.at(pPfo));
340 m_pCluster3D(nullptr),
341 m_pVertex3D(nullptr),
342 m_pSlidingFitResult3D(nullptr),
343 m_isNeutrinoVertexAssociated(false),
344 m_isInnerLayerAssociated(false),
345 m_pParentPfo(nullptr)
350 if (1 != clusterList3D.size())
363 m_pThisPfo(rhs.m_pThisPfo),
364 m_pCluster3D(rhs.m_pCluster3D),
365 m_pVertex3D(rhs.m_pVertex3D),
366 m_pSlidingFitResult3D(nullptr),
367 m_isNeutrinoVertexAssociated(rhs.m_isNeutrinoVertexAssociated),
368 m_isInnerLayerAssociated(rhs.m_isInnerLayerAssociated),
369 m_pParentPfo(rhs.m_pParentPfo),
370 m_daughterPfoList(rhs.m_daughterPfoList)
396 delete m_pSlidingFitResult3D;
408 delete m_pSlidingFitResult3D;
415 m_isNeutrinoVertexAssociated = isNeutrinoVertexAssociated;
422 m_isInnerLayerAssociated = isInnerLayerAssociated;
432 m_pParentPfo = pParentPfo;
439 m_pParentPfo =
nullptr;
446 if (m_daughterPfoList.end() != std::find(m_daughterPfoList.begin(), m_daughterPfoList.end(), pDaughterPfo))
449 m_daughterPfoList.push_back(pDaughterPfo);
456 PfoList::iterator eraseIter = std::find(m_daughterPfoList.begin(), m_daughterPfoList.end(), pDaughterPfo);
458 if (m_daughterPfoList.end() == eraseIter)
461 m_daughterPfoList.erase(eraseIter);
472 for (AlgorithmToolVector::const_iterator iter = algorithmToolVector.begin(), iterEnd = algorithmToolVector.end(); iter != iterEnd; ++iter)
476 if (!pPfoRelationTool)
477 return STATUS_CODE_INVALID_PARAMETER;
495 return STATUS_CODE_SUCCESS;
Header file for the cluster helper class.
Header file for the geometry helper class.
Header file for the pfo helper class.
Header file for the neutrino hierarchy algorithm class.
#define PANDORA_THROW_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_THROW_RESULT_IF(StatusCode1, Operator, Command)
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
#define PANDORA_RETURN_RESULT_IF(StatusCode1, Operator, Command)
static pandora::StatusCode ReplaceCurrentList(const pandora::Algorithm &algorithm, const std::string &newListName)
Replace the current list with a pre-saved list; use this new list as a permanent replacement for the ...
static pandora::StatusCode AddToPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Add a cluster to a particle flow object.
static pandora::StatusCode CreateTemporaryListAndSetCurrent(const pandora::Algorithm &algorithm, const T *&pT, std::string &temporaryListName)
Create a temporary list and set it to be the current list, enabling object creation.
static pandora::StatusCode SetPfoParentDaughterRelationship(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pParentPfo, const pandora::ParticleFlowObject *const pDaughterPfo)
Set parent-daughter particle flow object relationship.
static pandora::StatusCode RemoveFromPfo(const pandora::Algorithm &algorithm, const pandora::ParticleFlowObject *const pPfo, const T *const pT)
Remove a cluster from a particle flow object. Note this function will not remove the final object (tr...
static pandora::StatusCode GetList(const pandora::Algorithm &algorithm, const std::string &listName, const T *&pT)
Get a named list.
static const pandora::PandoraSettings * GetSettings(const pandora::Algorithm &algorithm)
Get the pandora settings instance.
static pandora::CartesianVector GetClosestPosition(const pandora::CartesianVector &position, const pandora::ClusterList &clusterList)
Get closest position in a list of clusters to a specified input position vector.
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position,...
static float GetWireZPitch(const pandora::Pandora &pandora, const float maxWirePitchDiscrepancy=0.01)
Return the wire pitch.
static void GetThreeDClusterList(const pandora::ParticleFlowObject *const pPfo, pandora::ClusterList &clusterList)
Get the list of 3D clusters from an input pfo.
static bool IsNeutrino(const pandora::ParticleFlowObject *const pPfo)
Whether a pfo is a neutrino or (antineutrino)
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static const pandora::Vertex * GetVertex(const pandora::ParticleFlowObject *const pPfo)
Get the pfo vertex.
bool IsNeutrinoVertexAssociated() const
Whether the pfo is associated with the neutrino vertex.
const pandora::ParticleFlowObject * m_pThisPfo
The address of the pfo.
const pandora::Vertex * m_pVertex3D
The address of the three dimensional vertex.
void SetNeutrinoVertexAssociation(const bool isNeutrinoVertexAssociated)
Set the neutrino vertex association flag.
pandora::PfoList m_daughterPfoList
The daughter pfo list.
ThreeDSlidingFitResult * m_pSlidingFitResult3D
The three dimensional sliding fit result.
const pandora::ParticleFlowObject * GetThisPfo() const
Get the address of the pfo.
void RemoveParentPfo()
Remove the parent pfo.
const pandora::PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
const pandora::ParticleFlowObject * m_pParentPfo
The address of the parent pfo.
const pandora::Cluster * m_pCluster3D
The address of the three dimensional cluster.
void RemoveDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo)
Remove a daughter pfo.
PfoInfo & operator=(const PfoInfo &rhs)
Assignment operator.
bool m_isNeutrinoVertexAssociated
Whether the pfo is associated with the neutrino vertex.
const pandora::ParticleFlowObject * GetParentPfo() const
Get the address of the parent pfo.
void AddDaughterPfo(const pandora::ParticleFlowObject *const pDaughterPfo)
Add a daughter pfo.
PfoInfo(const pandora::ParticleFlowObject *const pPfo, const unsigned int halfWindowLayers, const float layerPitch)
Constructor.
bool m_isInnerLayerAssociated
If associated, whether association to parent (vtx or pfo) is at sliding fit inner layer.
void SetParentPfo(const pandora::ParticleFlowObject *const pParentPfo)
Set the parent pfo.
void SetInnerLayerAssociation(const bool isInnerLayerAssociated)
Set the inner layer association flag.
void SeparatePfos(const NeutrinoHierarchyAlgorithm::PfoInfoMap &pfoInfoMap, pandora::PfoVector &assignedPfos, pandora::PfoVector &unassignedPfos) const
Query the pfo info map and separate/extract pfos currently either acting as parents or associated wit...
unsigned int m_halfWindowLayers
The number of layers to use for half-window of sliding fit.
void GetCandidateDaughterPfoList(pandora::PfoList &candidateDaughterPfoList) const
Get the list of candidate daughter pfos.
void GetInitialPfoInfoMap(const pandora::PfoList &pfoList, PfoInfoMap &pfoInfoMap) const
Process a provided pfo list and populate an initial pfo info map.
std::string m_neutrinoVertexListName
The neutrino vertex list name - if not specified will assume current list.
std::unordered_map< const pandora::ParticleFlowObject *, PfoInfo * > PfoInfoMap
void AdjustVertexAndPfoInfo(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap) const
Adjust neutrino vertex to ensure agreement with at least one pfo (first in sorted input list)
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
std::string m_neutrinoPfoListName
The neutrino pfo list name.
NeutrinoHierarchyAlgorithm()
Default constructor.
void ProcessPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const pandora::PfoList &candidateDaughterPfoList, PfoInfoMap &pfoInfoMap, const unsigned int callDepth=0) const
Process the information in a pfo info map, creating pfo parent/daughter links.
void GetNeutrinoPfo(const pandora::ParticleFlowObject *&pNeutrinoPfo) const
Get the address of the input neutrino pfo - enforces only one pfo present in input list; can return N...
pandora::StringVector m_daughterPfoListNames
The list of daughter pfo list names.
void DisplayPfoInfoMap(const pandora::ParticleFlowObject *const pNeutrinoPfo, const PfoInfoMap &pfoInfoMap) const
Display the information in a pfo info map, visualising pfo parent/daughter links.
pandora::StatusCode Run()
Run the algorithm.
bool m_displayPfoInfoMap
Whether to display the pfo info map (if monitoring is enabled)
PfoRelationToolVector m_algorithmToolVector
The algorithm tool vector.
ThreeDSlidingFitResult class.
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
const TwoDSlidingFitResult & GetFirstFitResult() const
Get the first sliding fit result for this cluster.
float GetLayerPitch() const
Get the layer pitch, units cm.
unsigned int GetLayerFitHalfWindow() const
Get the layer fit half window.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const PfoList & GetDaughterPfoList() const
Get the daughter pfo list.
const VertexList & GetVertexList() const
Get the vertex list.
unsigned int GetNDaughterPfos() const
Get the number of daughter pfos.
const Pandora & GetPandora() const
Get the associated pandora instance.
StatusCodeException class.
std::string ToString() const
Get status code as a string.
StatusCode GetStatusCode() const
Get status code.
VertexType GetVertexType() const
Get the vertex type.
const CartesianVector & GetPosition() const
Get the vertex position.
VertexLabel GetVertexLabel() const
Get the vertex label.
float GetX0() const
For LArTPC usage, the x-coordinate shift associated with a drift time t0 shift, units mm.
static StatusCode ReadVectorOfValues(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, std::vector< T > &vector)
Read a vector of values from a (space separated) list in an xml element.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
static StatusCode ProcessAlgorithmToolList(const Algorithm &algorithm, const TiXmlHandle &xmlHandle, const std::string &listName, AlgorithmToolVector &algorithmToolVector)
Process a list of algorithms tools in an xml file.
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< const ParticleFlowObject * > PfoVector
std::vector< AlgorithmTool * > AlgorithmToolVector
MANAGED_CONTAINER< const Vertex * > VertexList
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList