22 m_distanceForMatching(3.f),
23 m_minParentLengthSquared(10.f * 10.f),
24 m_maxDaughterLengthSquared(175.f * 175.f)
36 if (parentPfos.empty())
39 std::cout <<
"DeltaRayIdentificationAlgorithm: pfo list " <<
m_parentPfoListName <<
" unavailable." << std::endl;
40 return STATUS_CODE_SUCCESS;
51 if (!newDaughterPfoList.empty())
57 return STATUS_CODE_SUCCESS;
70 outputPfoVector.insert(outputPfoVector.end(), pPfoList->begin(), pPfoList->end());
78 PfoSet parentPfoList, daughterPfoList;
79 parentPfoList.insert(parentPfos.begin(), parentPfos.end());
80 daughterPfoList.insert(daughterPfos.begin(), daughterPfos.end());
82 PfoVector allPfos(parentPfos.begin(), parentPfos.end());
83 allPfos.insert(allPfos.end(), daughterPfos.begin(), daughterPfos.end());
86 for (PfoVector::const_iterator iter1 = parentPfos.begin(), iterEnd1 = parentPfos.end(); iter1 != iterEnd1; ++iter1)
92 float bestDisplacement(std::numeric_limits<float>::max());
94 for (PfoVector::const_iterator iter2 = allPfos.begin(), iterEnd2 = allPfos.end(); iter2 != iterEnd2; ++iter2)
97 float thisDisplacement(std::numeric_limits<float>::max());
99 if (pDaughterPfo == pThisParentPfo)
102 if (!this->
IsAssociated(pDaughterPfo, pThisParentPfo, thisDisplacement))
105 if (thisDisplacement < bestDisplacement)
107 bestDisplacement = thisDisplacement;
108 pBestParentPfo = pThisParentPfo;
119 if (daughterPfoList.count(pBestParentPfo))
122 pfoAssociationMap.insert(PfoAssociationMap::value_type(pDaughterPfo, pBestParentPfo));
129 if (parentPfoList.count(pBestParentPfo))
142 pfoAssociationMap.insert(PfoAssociationMap::value_type(pDaughterPfo, pReplacementParentPfo));
152 displacement = std::numeric_limits<float>::max();
154 if (pDaughterPfo == pParentPfo)
160 if (daughterLengthSquared >
m_maxDaughterLengthSquared || parentLengthSquared < m_minParentLengthSquared || daughterLengthSquared > 0.5 * parentLengthSquared)
163 const float transitionLengthSquared(125.f);
164 const float displacementCut((daughterLengthSquared > transitionLengthSquared)
174 if (STATUS_CODE_FAILURE == statusCodeException.
GetStatusCode())
175 throw statusCodeException;
178 if (displacement > displacementCut)
193 ClusterList clusterListU, clusterListV, clusterListW;
199 float sumDisplacementSquared(0.f);
201 if (!vertexVectorU.empty())
204 sumDisplacementSquared += thisDisplacement * thisDisplacement;
208 if (!vertexVectorV.empty())
211 sumDisplacementSquared += thisDisplacement * thisDisplacement;
215 if (!vertexVectorW.empty())
218 sumDisplacementSquared += thisDisplacement * thisDisplacement;
222 if (sumViews < std::numeric_limits<float>::epsilon())
225 return std::sqrt(sumDisplacementSquared / sumViews);
235 for (ClusterList::const_iterator iter = clusterList.begin(), iterEnd = clusterList.end(); iter != iterEnd; ++iter)
237 const Cluster *
const pCluster = *iter;
239 CartesianVector firstCoordinate(0.f, 0.f, 0.f), secondCoordinate(0.f, 0.f, 0.f);
242 vertexVector.push_back(firstCoordinate);
243 vertexVector.push_back(secondCoordinate);
251 if (vertexVector.empty() || clusterList.empty())
254 float bestDisplacement(std::numeric_limits<float>::max());
256 for (CartesianPointVector::const_iterator iter1 = vertexVector.begin(), iterEnd1 = vertexVector.end(); iter1 != iterEnd1; ++iter1)
260 for (ClusterList::const_iterator iter2 = clusterList.begin(), iterEnd2 = clusterList.end(); iter2 != iterEnd2; ++iter2)
262 const Cluster *
const pCluster = *iter2;
265 if (thisDisplacement < bestDisplacement)
266 bestDisplacement = thisDisplacement;
270 return bestDisplacement;
278 for (
const auto &mapEntry : pfoAssociationMap)
279 pfoList.push_back(mapEntry.first);
294 PandoraContentApi::ParticleFlowObject::Metadata metadata;
295 metadata.m_particleId = E_MINUS;
298 daughterPfoList.push_back(pDaughterPfo);
311 PfoAssociationMap::const_iterator iter = pfoAssociationMap.find(pDaughterPfo);
312 if (pfoAssociationMap.end() == iter)
315 pParentPfo = iter->second;
316 pDaughterPfo = pParentPfo;
338 STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=,
XmlHelper::ReadValue(xmlHandle,
"MaxDaughterLength", maxDaughterLength));
341 return STATUS_CODE_SUCCESS;
Header file for the delta ray identification algorithm class.
Header file for the cluster helper class.
Header file for the pfo helper 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 SaveList(const pandora::Algorithm &algorithm, const T &t, const std::string &newListName)
Save a provided input object list under a new name.
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 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.
void GetTwoDVertices(const pandora::ParticleFlowObject *const pPfo, const pandora::HitType &hitType, pandora::CartesianPointVector &vertexVector) const
Calculate 2D separation between two Pfos.
std::unordered_map< const pandora::ParticleFlowObject *, const pandora::ParticleFlowObject * > PfoAssociationMap
void BuildParentDaughterLinks(const PfoAssociationMap &pfoAssociationMap, pandora::PfoList &outputPfoList) const
Build the parent/daughter links from the map of parent/daughter associations.
bool IsAssociated(const pandora::ParticleFlowObject *const pDaughterPfo, const pandora::ParticleFlowObject *const pParentPfo, float &displacement) const
Determine if a given pair of Pfos have a parent/daughter association.
void GetPfos(const std::string &inputPfoListName, pandora::PfoVector &outputPfoVector) const
Get the vector of Pfos, given the input list name.
DeltaRayIdentificationAlgorithm()
Default constructor.
const pandora::ParticleFlowObject * GetParent(const PfoAssociationMap &pfoAssociationMap, const pandora::ParticleFlowObject *const pPfo) const
For a given daughter, follow the parent/daughter links to find the overall parent.
pandora::StatusCode Run()
Run the algorithm.
float m_minParentLengthSquared
Minimum allowed length of parent cosmic ray.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
float GetTwoDSeparation(const pandora::ParticleFlowObject *const pDaughterPfo, const pandora::ParticleFlowObject *const pParentPfo) const
Calculate 2D separation between two Pfos.
float GetClosestDistance(const pandora::CartesianPointVector &vertexVector, const pandora::ClusterList &clusterList) const
Calculate closest 2D separation between a set of vertices and a set of clusters.
void BuildAssociationMap(const pandora::PfoVector &inputPfos, const pandora::PfoVector &outputPfos, PfoAssociationMap &pfoAssociationMap) const
Build parent/daughter associations between PFOs.
float m_maxDaughterLengthSquared
Maximum allowed length of daughter delta ray.
float m_distanceForMatching
Maximum allowed distance of delta ray from parent cosmic ray.
std::string m_parentPfoListName
The parent pfo list name.
std::string m_daughterPfoListName
The daughter pfo list name.
static void GetExtremalCoordinates(const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
Get positions of the two most distant calo hits in a list of cluster (ordered by Z)
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.
static bool IsTrack(const pandora::ParticleFlowObject *const pPfo)
Return track flag based on Pfo Particle ID.
static bool SortByNHits(const pandora::ParticleFlowObject *const pLhs, const pandora::ParticleFlowObject *const pRhs)
Sort pfos by number of constituent hits.
static void GetClusters(const pandora::PfoList &pfoList, const pandora::HitType &hitType, pandora::ClusterList &clusterList)
Get a list of clusters of a particular hit type from a list of pfos.
static float GetTwoDLengthSquared(const pandora::ParticleFlowObject *const pPfo)
Calculate length of Pfo using 2D clusters.
bool ShouldDisplayAlgorithmInfo() const
Whether to display algorithm information during processing.
ParticleFlowObject class.
const PfoList & GetParentPfoList() const
Get the parent pfo list.
StatusCode AlterMetadata(const object_creation::ParticleFlowObject::Metadata &metadata)
Alter particle flow object metadata parameters.
StatusCodeException class.
StatusCode GetStatusCode() const
Get status code.
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
HitType
Calorimeter hit type enum.
std::unordered_set< const ParticleFlowObject * > PfoSet
MANAGED_CONTAINER< const Cluster * > ClusterList
std::vector< const ParticleFlowObject * > PfoVector
std::vector< CartesianVector > CartesianPointVector
StatusCode
The StatusCode enum.
MANAGED_CONTAINER< const ParticleFlowObject * > PfoList