Find the best layer for splitting the cluster.
43 const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
46 return STATUS_CODE_NOT_FOUND;
48 bool foundSplit(
false);
50 float bestCosTheta(1.f);
51 CartesianVector bestPosition(0.f, 0.f, 0.f);
53 for (
unsigned int iLayer = pCluster->GetInnerPseudoLayer() + 4; iLayer + 4 <= pCluster->GetOuterPseudoLayer(); ++iLayer)
55 if (orderedCaloHitList.find(iLayer) == orderedCaloHitList.end())
58 unsigned int innerLayer((pCluster->GetInnerPseudoLayer() +
m_layerWindow > iLayer) ? pCluster->GetInnerPseudoLayer() : iLayer -
m_layerWindow);
59 unsigned int outerLayer((iLayer +
m_layerWindow > pCluster->GetOuterPseudoLayer()) ? pCluster->GetOuterPseudoLayer() : iLayer +
m_layerWindow);
61 for (; innerLayer >= pCluster->GetInnerPseudoLayer(); --innerLayer)
63 if (orderedCaloHitList.find(innerLayer) != orderedCaloHitList.end())
67 for (; outerLayer <= pCluster->GetOuterPseudoLayer(); ++outerLayer)
69 if (orderedCaloHitList.find(outerLayer) != orderedCaloHitList.end())
73 const CartesianVector splitPosition(pCluster->GetCentroid(iLayer));
74 const CartesianVector innerPosition(pCluster->GetCentroid(innerLayer));
75 const CartesianVector outerPosition(pCluster->GetCentroid(outerLayer));
77 const CartesianVector r1(innerPosition - splitPosition);
78 const CartesianVector r2(outerPosition - splitPosition);
79 const CartesianVector
p1(r1.GetUnitVector());
80 const CartesianVector p2(r2.GetUnitVector());
82 const float cosTheta(-
p1.GetDotProduct(p2));
83 const float rms1(this->
CalculateRms(pCluster, innerLayer, iLayer));
84 const float rms2(this->
CalculateRms(pCluster, outerLayer, iLayer));
85 const float rms(std::max(rms1, rms2));
87 float rmsCut(std::numeric_limits<float>::max());
99 if (rms < rmsCut && cosTheta < bestCosTheta)
101 bestCosTheta = cosTheta;
102 bestPosition = splitPosition;
110 return STATUS_CODE_NOT_FOUND;
112 return STATUS_CODE_SUCCESS;
unsigned int m_minClusterLayers
float m_maxScatterCosTheta
unsigned int m_layerWindow
float CalculateRms(const pandora::Cluster *const pCluster, const unsigned int &firstLayer, const unsigned int &secondLayer) const
Calculate rms deviation of cluster centroids between two extremal layers.
physics associatedGroupsWithLeft p1
float m_maxSlidingCosTheta