19 m_minClusterLayers(20),
21 m_maxScatterRms(0.35f),
22 m_maxScatterCosTheta(0.5f),
23 m_maxSlidingCosTheta(0.866f)
31 unsigned int splitLayer(0);
34 return this->
DivideCaloHits(pCluster, splitLayer, firstHitList, secondHitList);
36 return STATUS_CODE_NOT_FOUND;
46 return STATUS_CODE_NOT_FOUND;
48 bool foundSplit(
false);
50 float bestCosTheta(1.f);
55 if (orderedCaloHitList.
find(iLayer) == orderedCaloHitList.
end())
63 if (orderedCaloHitList.
find(innerLayer) != orderedCaloHitList.
end())
69 if (orderedCaloHitList.
find(outerLayer) != orderedCaloHitList.
end())
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;
121 const unsigned int innerLayer(std::min(firstLayer, secondLayer));
122 const unsigned int outerLayer(std::max(firstLayer, secondLayer));
126 const CartesianVector predictedDirection((outerPosition - innerPosition).GetUnitVector());
128 float totalChi2(0.f);
129 float totalLayers(0.f);
131 for (
unsigned int iLayer = innerLayer + 1; iLayer + 1 < outerLayer; ++iLayer)
133 if (orderedCaloHitList.
find(iLayer) == orderedCaloHitList.
end())
137 const CartesianVector predictedPosition(innerPosition + predictedDirection * predictedDirection.
GetDotProduct(hitPosition - innerPosition));
139 totalChi2 += (predictedPosition - hitPosition).GetMagnitudeSquared();
143 if (totalLayers > 0.f)
144 return std::sqrt(totalChi2 / totalLayers);
158 const unsigned int thisLayer(iter->first);
160 for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
162 const CaloHit *
const pCaloHit = *hitIter;
164 if (thisLayer < splitLayer)
166 firstHitList.push_back(pCaloHit);
170 secondHitList.push_back(pCaloHit);
175 if (firstHitList.empty() || secondHitList.empty())
176 return STATUS_CODE_NOT_FOUND;
178 return STATUS_CODE_SUCCESS;
#define PANDORA_RETURN_RESULT_IF_AND_IF(StatusCode1, StatusCode2, Operator, Command)
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
pandora::StatusCode DivideCaloHits(const pandora::Cluster *const pCluster, pandora::CaloHitList &firstCaloHitList, pandora::CaloHitList &secondCaloHitList) const
Divide calo hits in a cluster into two lists, each associated with a separate fragment cluster.
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.
unsigned int m_layerWindow
float m_maxSlidingCosTheta
unsigned int m_minClusterLayers
LayerSplittingAlgorithm()
Default constructor.
pandora::StatusCode FindBestSplitLayer(const pandora::Cluster *const pCluster, unsigned int &splitLayer) const
Find the best layer for splitting the cluster.
float m_maxScatterCosTheta
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
Read the algorithm settings.
CartesianVector GetUnitVector() const
Get a unit vector in the direction of the cartesian vector.
float GetDotProduct(const CartesianVector &rhs) const
Get the dot product of the cartesian vector with a second cartesian vector.
unsigned int GetOuterPseudoLayer() const
Get the outermost pseudo layer in the cluster.
unsigned int GetInnerPseudoLayer() const
Get the innermost pseudo layer in the cluster.
const CartesianVector GetCentroid(const unsigned int pseudoLayer) const
Get unweighted centroid for cluster at a particular pseudo layer, calculated using cached values of h...
const OrderedCaloHitList & GetOrderedCaloHitList() const
Get the ordered calo hit list.
Calo hit lists arranged by pseudo layer.
const_iterator end() const
Returns a const iterator referring to the past-the-end element in the ordered calo hit list.
const_iterator begin() const
Returns a const iterator referring to the first element in the ordered calo hit list.
TheList::const_iterator const_iterator
unsigned int size() const
Returns the number of elements in the container.
const_iterator find(const unsigned int index) const
Searches the container for an element with specified layer and returns an iterator to it if found,...
static StatusCode ReadValue(const TiXmlHandle &xmlHandle, const std::string &xmlElementName, T &t)
Read a value from an xml element.
MANAGED_CONTAINER< const CaloHit * > CaloHitList
StatusCode
The StatusCode enum.