9 #include "Pandora/AlgorithmHeaders.h" 21 CosmicRayTrackMatchingAlgorithm::CosmicRayTrackMatchingAlgorithm() :
22 m_clusterMinLength(10.
f),
25 m_minXOverlapFraction(0.8
f),
26 m_maxDisplacement(10.
f)
37 for (
const Cluster *
const pCluster : inputVector)
42 clusterVector.push_back(pCluster);
46 for (
const Cluster *
const pCluster : clusterVector)
49 CartesianVector innerVertex(0.
f,0.
f,0.
f), outerVertex(0.
f,0.
f,0.
f);
52 bool isDeltaRay(
false);
54 for (
const Cluster *
const pClusterCheck : clusterVector)
56 if (pCluster == pClusterCheck)
69 outputVector.push_back(pCluster);
78 CartesianVector innerVertex1(0.
f,0.
f,0.
f), outerVertex1(0.
f,0.
f,0.
f);
79 CartesianVector innerVertex2(0.
f,0.
f,0.
f), outerVertex2(0.
f,0.
f,0.
f);
84 const float dxA(std::fabs(innerVertex2.GetX() - innerVertex1.GetX()));
85 const float dxB(std::fabs(outerVertex2.GetX() - outerVertex1.GetX()));
87 const float dxC(std::fabs(outerVertex2.GetX() - innerVertex1.GetX()));
88 const float dxD(std::fabs(innerVertex2.GetX() - outerVertex1.GetX()));
96 float xMin1(0.
f), xMax1(0.
f), xMin2(0.
f), xMax2(0.
f);
103 if (xSpan < std::numeric_limits<float>::epsilon())
115 const Cluster *
const pCluster3)
const 122 if (hitType1 == hitType2 || hitType2 == hitType3 || hitType3 == hitType1)
123 throw StatusCodeException(STATUS_CODE_FAILURE);
125 CartesianVector innerVertex1(0.
f,0.
f,0.
f), outerVertex1(0.
f,0.
f,0.
f);
126 CartesianVector innerVertex2(0.
f,0.
f,0.
f), outerVertex2(0.
f,0.
f,0.
f);
127 CartesianVector innerVertex3(0.
f,0.
f,0.
f), outerVertex3(0.
f,0.
f,0.
f);
133 for (
unsigned int n = 0;
n < 4; ++
n)
135 CartesianVector vtx1(1 ==
n ? outerVertex1 : innerVertex1);
136 CartesianVector end1(1 ==
n ? innerVertex1 : outerVertex1);
138 CartesianVector vtx2(2 ==
n ? outerVertex2 : innerVertex2);
139 CartesianVector end2(2 ==
n ? innerVertex2 : outerVertex2);
141 CartesianVector vtx3(3 ==
n ? outerVertex3 : innerVertex3);
142 CartesianVector end3(3 ==
n ? innerVertex3 : outerVertex3);
144 if (std::fabs(vtx1.GetX() - vtx2.GetX()) <
std::max(
m_vtxXOverlap, std::fabs(vtx1.GetX() - end2.GetX())) &&
145 std::fabs(end1.GetX() - end2.GetX()) <
std::max(
m_vtxXOverlap, std::fabs(end1.GetX() - vtx2.GetX())) &&
146 std::fabs(vtx2.GetX() - vtx3.GetX()) <
std::max(
m_vtxXOverlap, std::fabs(vtx2.GetX() - end3.GetX())) &&
147 std::fabs(end2.GetX() - end3.GetX()) <
std::max(
m_vtxXOverlap, std::fabs(end2.GetX() - vtx3.GetX())) &&
148 std::fabs(vtx3.GetX() - vtx1.GetX()) <
std::max(
m_vtxXOverlap, std::fabs(vtx3.GetX() - end1.GetX())) &&
149 std::fabs(end3.GetX() - end1.GetX()) <
std::max(
m_vtxXOverlap, std::fabs(end3.GetX() - vtx1.GetX())))
152 CartesianVector projVtx1(0.
f,0.
f,0.
f), projEnd1(0.
f,0.
f,0.
f);
153 CartesianVector projVtx2(0.
f,0.
f,0.
f), projEnd2(0.
f,0.
f,0.
f);
154 CartesianVector projVtx3(0.
f,0.
f,0.
f), projEnd3(0.
f,0.
f,0.
f);
171 const bool matchedCluster1(matchedVtx1 || matchedEnd1);
172 const bool matchedCluster2(matchedVtx2 || matchedEnd2);
173 const bool matchedCluster3(matchedVtx3 || matchedEnd3);
174 const bool matchedVtx(matchedVtx1 || matchedVtx2 || matchedVtx3);
175 const bool matchedEnd(matchedEnd1 || matchedEnd2 || matchedEnd3);
177 if (matchedCluster1 && matchedCluster2 && matchedCluster3 && matchedVtx && matchedEnd)
189 ClusterList clusterList;
195 pfoParameters.m_particleId = MU_MINUS;
196 pfoParameters.m_charge = PdgTable::GetParticleCharge(pfoParameters.m_particleId.Get());
197 pfoParameters.m_mass = PdgTable::GetParticleMass(pfoParameters.m_particleId.Get());
198 pfoParameters.m_energy = 0.f;
199 pfoParameters.m_momentum = CartesianVector(0.
f, 0.
f, 0.
f);
200 pfoParameters.m_clusterList = clusterList;
207 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
210 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
213 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
216 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
219 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
void SetPfoParameters(const Particle &protoParticle, PandoraContentApi::ParticleFlowObject::Parameters &pfoParameters) const
Calculate Pfo properties from proto particle.
void SelectCleanClusters(const pandora::ClusterVector &inputVector, pandora::ClusterVector &outputVector) const
Select a set of clusters judged to be clean.
float m_vtxXOverlap
requirement on X overlap of start/end positions
float m_clusterMinLength
minimum length of clusters for this algorithm
const pandora::Cluster * m_pClusterV
Address of cluster in V view.
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
Header file for the geometry helper class.
float m_maxDisplacement
requirement on 3D consistency checks
Header file for the cluster helper class.
const pandora::Cluster * m_pClusterW
Address of cluster in W view.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const pandora::Cluster * m_pClusterU
Address of cluster in U view.
static float MergeTwoPositions(const pandora::Pandora &pandora, const pandora::HitType view1, const pandora::HitType view2, const float position1, const float position2)
Merge two views (U,V) to give a third view (Z).
float m_minXOverlap
requirement on minimum X overlap for associated clusters
bool MatchClusters(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2) const
Match a pair of clusters from two views.
std::vector< art::Ptr< recob::Cluster > > ClusterVector
bool CheckMatchedClusters3D(const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, const pandora::Cluster *const pCluster3) const
Check that three clusters have a consistent 3D position.
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) ...
float m_minXOverlapFraction
requirement on minimum X overlap fraction for associated clusters
static void GetClusterSpanX(const pandora::Cluster *const pCluster, float &xmin, float &xmax)
Get minimum and maximum X positions of the calo hits in a cluster.
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
Header file for the cosmic ray track matching algorithm class.
static float GetClosestDistance(const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
Get closest distance between clusters in a pair of cluster lists.