9 #include "Pandora/AlgorithmHeaders.h" 21 ThreeDTransverseTracksAlgorithm::ThreeDTransverseTracksAlgorithm() :
22 m_nMaxTensorToolRepeats(1000),
23 m_maxFitSegmentIndex(50),
25 m_minSegmentMatchedFraction(0.1
f),
26 m_minSegmentMatchedPoints(3),
27 m_minOverallMatchedFraction(0.5
f),
28 m_minOverallMatchedPoints(10),
29 m_minSamplingPointsPerLayer(0.1
f)
38 PANDORA_THROW_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, this->
CalculateOverlapResult(pClusterU, pClusterV, pClusterW, overlapResult));
54 this->
GetFitSegmentTensor(slidingFitResultU, slidingFitResultV, slidingFitResultW, fitSegmentTensor);
60 return STATUS_CODE_NOT_FOUND;
63 return STATUS_CODE_NOT_FOUND;
68 const unsigned int meanLayersSpanned(static_cast<unsigned int>((1.
f / 3.
f) * static_cast<float>(nLayersSpannedU + nLayersSpannedV + nLayersSpannedW)));
70 if (0 == meanLayersSpanned)
71 return STATUS_CODE_FAILURE;
73 const float nSamplingPointsPerLayer(static_cast<float>(transverseOverlapResult.
GetNSamplingPoints()) / static_cast<float>(meanLayersSpanned));
76 return STATUS_CODE_NOT_FOUND;
78 overlapResult = transverseOverlapResult;
79 return STATUS_CODE_SUCCESS;
91 for (
unsigned int indexU = 0, indexUEnd = fitSegmentListU.size(); indexU < indexUEnd; ++indexU)
93 const FitSegment &fitSegmentU(fitSegmentListU.at(indexU));
95 for (
unsigned int indexV = 0, indexVEnd = fitSegmentListV.size(); indexV < indexVEnd; ++indexV)
97 const FitSegment &fitSegmentV(fitSegmentListV.at(indexV));
99 for (
unsigned int indexW = 0, indexWEnd = fitSegmentListW.size(); indexW < indexWEnd; ++indexW)
101 const FitSegment &fitSegmentW(fitSegmentListW.at(indexW));
104 if (STATUS_CODE_SUCCESS != this->
GetSegmentOverlap(fitSegmentU, fitSegmentV, fitSegmentW, slidingFitResultU, slidingFitResultV, slidingFitResultW, segmentOverlap))
110 fitSegmentTensor[indexU][indexV][indexW] = segmentOverlap;
123 const float xSpanU(fitSegmentU.
GetMaxX() - fitSegmentU.
GetMinX());
124 const float xSpanV(fitSegmentV.
GetMaxX() - fitSegmentV.
GetMinX());
125 const float xSpanW(fitSegmentW.
GetMaxX() - fitSegmentW.
GetMinX());
129 const float xOverlap(maxX - minX);
131 if (xOverlap < std::numeric_limits<float>::epsilon())
132 return STATUS_CODE_NOT_FOUND;
135 const float nPointsU(std::fabs((xOverlap / xSpanU) * static_cast<float>(fitSegmentU.
GetEndLayer() - fitSegmentU.
GetStartLayer())));
136 const float nPointsV(std::fabs((xOverlap / xSpanV) * static_cast<float>(fitSegmentV.
GetEndLayer() - fitSegmentV.
GetStartLayer())));
137 const float nPointsW(std::fabs((xOverlap / xSpanW) * static_cast<float>(fitSegmentW.
GetEndLayer() - fitSegmentW.
GetStartLayer())));
139 const unsigned int nPoints(1 + static_cast<unsigned int>((nPointsU + nPointsV + nPointsW) / 3.
f));
142 float pseudoChi2Sum(0.
f);
143 unsigned int nSamplingPoints(0), nMatchedSamplingPoints(0);
145 for (
unsigned int n = 0;
n <= nPoints; ++
n)
147 const float x(minX + (maxX - minX) * static_cast<float>(
n) / static_cast<float>(nPoints));
149 CartesianVector fitUVector(0.
f, 0.
f, 0.
f), fitVVector(0.
f, 0.
f, 0.
f), fitWVector(0.
f, 0.
f, 0.
f);
150 CartesianVector fitUDirection(0.
f, 0.
f, 0.
f), fitVDirection(0.
f, 0.
f, 0.
f), fitWDirection(0.
f, 0.
f, 0.
f);
152 if ((STATUS_CODE_SUCCESS != slidingFitResultU.
GetTransverseProjection(x, fitSegmentU, fitUVector, fitUDirection)) ||
153 (STATUS_CODE_SUCCESS != slidingFitResultV.
GetTransverseProjection(x, fitSegmentV, fitVVector, fitVDirection)) ||
159 const float u(fitUVector.GetZ()), v(fitVVector.GetZ()),
w(fitWVector.GetZ());
165 const float deltaU((vw2u - u) * fitUDirection.GetX());
166 const float deltaV((uw2v - v) * fitVDirection.GetX());
167 const float deltaW((uv2w -
w) * fitWDirection.GetX());
169 const float pseudoChi2(deltaW * deltaW + deltaV * deltaV + deltaU * deltaU);
170 pseudoChi2Sum += pseudoChi2;
173 ++nMatchedSamplingPoints;
176 if (0 == nSamplingPoints)
177 return STATUS_CODE_NOT_FOUND;
182 transverseOverlapResult =
TransverseOverlapResult(nMatchedSamplingPoints, nSamplingPoints, pseudoChi2Sum, xOverlapObject);
183 return STATUS_CODE_SUCCESS;
190 if (fitSegmentTensor.empty())
196 unsigned int maxIndexU(0), maxIndexV(0), maxIndexW(0);
199 maxIndexU =
std::max(tIter->first, maxIndexU);
203 maxIndexV =
std::max(mIter->first, maxIndexV);
206 maxIndexW =
std::max(rIter->first, maxIndexW);
216 for (
unsigned int indexU = 0; indexU <= maxIndexU; ++indexU)
218 for (
unsigned int indexV = 0; indexV <= maxIndexV; ++indexV)
220 for (
unsigned int indexW = 0; indexW <= maxIndexW; ++indexW)
229 if (fitSegmentTensor.count(indexU) && (fitSegmentTensor.find(indexU))->second.count(indexV) && ((fitSegmentTensor.find(indexU))->second.find(indexV))->second.count(indexW))
230 thisOverlapResult = (((fitSegmentTensor.find(indexU))->second.find(indexV))->second.find(indexW))->second;
232 if (!thisOverlapResult.IsInitialized() && !maxTransverseOverlapResult.IsInitialized())
235 fitSegmentSumTensor[indexU][indexV][indexW] = thisOverlapResult + maxTransverseOverlapResult;
240 for (
unsigned int indexU = 0; indexU <= maxIndexU; ++indexU)
242 for (
unsigned int indexV = 0; indexV <= maxIndexV; ++indexV)
244 for (
unsigned int indexW = 0; indexW <= maxIndexW; ++indexW)
251 if (transverseOverlapResult > bestTransverseOverlapResult)
252 bestTransverseOverlapResult = transverseOverlapResult;
263 for (
unsigned int iPermutation = 1; iPermutation < 8; ++iPermutation)
265 const bool decrementU((iPermutation >> 0) & 0
x1);
266 const bool decrementV((iPermutation >> 1) & 0
x1);
267 const bool decrementW((iPermutation >> 2) & 0
x1);
269 if ((decrementU && (0 == indexU)) || (decrementV && (0 == indexV)) || (decrementW && (0 == indexW)))
272 const unsigned int newIndexU(decrementU ? indexU - 1 : indexU);
273 const unsigned int newIndexV(decrementV ? indexV - 1 : indexV);
274 const unsigned int newIndexW(decrementW ? indexW - 1 : indexW);
279 transverseOverlapResultVector.push_back(transverseOverlapResult);
282 if (transverseOverlapResultVector.empty())
290 unsigned int repeatCounter(0);
313 AlgorithmToolVector algorithmToolVector;
314 PANDORA_RETURN_RESULT_IF(STATUS_CODE_SUCCESS, !=, XmlHelper::ProcessAlgorithmToolList(*
this, xmlHandle,
315 "TrackTools", algorithmToolVector));
321 if (NULL == pTransverseTensorTool)
322 return STATUS_CODE_INVALID_PARAMETER;
327 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
330 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
333 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
336 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
339 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
342 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
345 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
348 PANDORA_RETURN_RESULT_IF_AND_IF(STATUS_CODE_SUCCESS, STATUS_CODE_NOT_FOUND, !=, XmlHelper::ReadValue(xmlHandle,
float m_minSegmentMatchedFraction
The minimum segment matched sampling fraction to allow segment grouping.
float m_pseudoChi2Cut
The pseudo chi2 cut to identify matched sampling points.
int GetStartLayer() const
Get start layer.
void GetBestOverlapResult(const FitSegmentTensor &fitSegmentTensor, TransverseOverlapResult &bestTransverseOverlapResult) const
Get the best overlap result, by examining the fit segment tensor.
unsigned int m_maxFitSegmentIndex
The maximum number of fit segments used when identifying best overlap result.
unsigned int GetNMatchedSamplingPoints() const
Get the number of matched sampling points.
bool IsInitialized() const
Whether the track overlap result has been initialized.
unsigned int m_minOverallMatchedPoints
The minimum number of matched segment sampling points to allow particle creation. ...
Float_t x1[n_points_granero]
std::vector< FitSegment > FitSegmentList
TensorToolVector m_algorithmToolVector
The algorithm tool vector.
std::vector< TransverseOverlapResult > TransverseOverlapResultVector
pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
const TwoDSlidingFitResult & GetCachedSlidingFitResult(const pandora::Cluster *const pCluster) const
Get a sliding fit result from the algorithm cache.
Header file for the geometry helper class.
void SetOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW, const OverlapResult &overlapResult)
Set overlap result.
unsigned int GetNSamplingPoints() const
Get the number of sampling points.
int GetMaxLayer() const
Get the maximum occupied layer in the sliding fit.
int GetMinLayer() const
Get the minimum occupied layer in the sliding fit.
Header file for the cluster helper class.
TensorType m_overlapTensor
The overlap tensor.
float GetMatchedFraction() const
Get the fraction of sampling points resulting in a match.
void GetFitSegmentTensor(const TwoDSlidingFitResult &slidingFitResultU, const TwoDSlidingFitResult &slidingFitResultV, const TwoDSlidingFitResult &slidingFitResultW, FitSegmentTensor &fitSegmentTensor) const
Get the number of matched points for three fit segments and accompanying sliding fit results...
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).
const FitSegmentList & GetFitSegmentList() const
Get the fit segment list.
TransverseOverlapResult class.
void CalculateOverlapResult(const pandora::Cluster *const pClusterU, const pandora::Cluster *const pClusterV, const pandora::Cluster *const pClusterW)
Calculate cluster overlap result and store in tensor.
unsigned int m_nMaxTensorToolRepeats
The maximum number of repeat loops over tensor tools.
TransverseTensorTool class.
Header file for the three dimensional transverse tracks algorithm class.
virtual pandora::StatusCode ReadSettings(const pandora::TiXmlHandle xmlHandle)
double GetMinX() const
Get the minimum x value.
pandora::StatusCode GetTransverseProjection(const float x, const FitSegment &fitSegment, pandora::CartesianVector &position) const
Get projected position for a given input x coordinate and fit segment.
void GetPreviousOverlapResults(const unsigned int indexU, const unsigned int indexV, const unsigned int indexW, FitSegmentTensor &fitSegmentSumTensor, TransverseOverlapResultVector &transverseOverlapResultVector) const
Get track overlap results for possible connected segments.
float m_minOverallMatchedFraction
The minimum matched sampling fraction to allow particle creation.
void ExamineTensor()
Examine contents of tensor, collect together best-matching 2D particles and modify clusters as requir...
float m_minSamplingPointsPerLayer
The minimum number of sampling points per layer to allow particle creation.
std::map< unsigned int, FitSegmentMatrix > FitSegmentTensor
int GetEndLayer() const
Get end layer.
pandora::StatusCode GetSegmentOverlap(const FitSegment &fitSegmentU, const FitSegment &fitSegmentV, const FitSegment &fitSegmentW, const TwoDSlidingFitResult &slidingFitResultU, const TwoDSlidingFitResult &slidingFitResultV, const TwoDSlidingFitResult &slidingFitResultW, TransverseOverlapResult &transverseOverlapResult) const
Get the overlap result for three fit segments and the accompanying sliding fit results.
unsigned int m_minSegmentMatchedPoints
The minimum number of matched segment sampling points to allow segment grouping.
TwoDSlidingFitResult class.
double GetMaxX() const
Get the maximum x value.