9 #include "Objects/Cluster.h" 22 float SimpleCone::GetMeanRT(
const Cluster *
const pCluster)
const 24 CartesianPointVector hitPositionVector;
25 LArClusterHelper::GetCoordinateVector(pCluster, hitPositionVector);
28 const unsigned int nClusterHits(pCluster->GetNCaloHits());
30 for (
const CartesianVector &hitPosition : hitPositionVector)
32 const CartesianVector displacement(hitPosition - this->GetConeApex());
33 const float rT(displacement.GetCrossProduct(this->GetConeDirection()).GetMagnitude());
37 return ((nClusterHits > 0) ? rTSum /
static_cast<float>(nClusterHits) : 0.
f);
42 float SimpleCone::GetBoundedHitFraction(
const Cluster *
const pCluster,
const float coneLength,
const float coneTanHalfAngle)
const 44 CartesianPointVector hitPositionVector;
45 LArClusterHelper::GetCoordinateVector(pCluster, hitPositionVector);
47 unsigned int nMatchedHits(0);
48 const unsigned int nClusterHits(pCluster->GetNCaloHits());
50 for (
const CartesianVector &hitPosition : hitPositionVector)
52 const CartesianVector displacement(hitPosition - this->GetConeApex());
53 const float rL(displacement.GetDotProduct(this->GetConeDirection()));
55 if ((rL < 0.
f) || (rL > coneLength))
58 const float rT(displacement.GetCrossProduct(this->GetConeDirection()).GetMagnitude());
60 if (rL * coneTanHalfAngle > rT)
64 return ((nClusterHits > 0) ?
static_cast<float>(nMatchedHits) / static_cast<float>(nClusterHits) : 0.f);
71 ThreeDSlidingConeFitResult::ThreeDSlidingConeFitResult(
const T *
const pT,
const unsigned int slidingFitWindow,
const float slidingFitLayerPitch) :
83 const int nSteps(static_cast<int>((maxLayerPosition3D - minLayerPosition3D).GetMagnitude() / slidingFitLayerPitch));
85 for (
int iStep = 0; iStep <= nSteps; ++iStep)
89 const float rL((static_cast<float>(iStep) + 0.5
f) * slidingFitLayerPitch);
90 CartesianVector fitPosition3D(0.
f, 0.
f, 0.
f), fitDirection3D(0.
f, 0.
f, 0.
f);
99 if (!contributionMap1.count(fitResult1.GetLayer(rL)) && !contributionMap2.count(fitResult2.GetLayer(rL)))
102 (void)
m_trackStateMap.insert(TrackStateMap::value_type(iStep, TrackState(fitPosition3D, fitDirection3D)));
104 catch (
const StatusCodeException &)
114 const unsigned int nLayersForConeFit,
const unsigned int nCones,
const ConeSelection coneSelection,
SimpleConeList &simpleConeList)
const 117 const unsigned int nLayers(trackStateMap.size());
119 if (nLayers + 1 < nLayersForConeFit + nCones)
120 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
123 const unsigned int coneInterval((nCones > 1) ? (nLayers - nLayersForConeFit) / (nCones - 1) : 1);
126 const bool isForward(coneDisplacement.GetZ() > std::numeric_limits<float>::epsilon());
127 const unsigned int coneOffset1((nLayers - nLayersForConeFit - (nCones - 1) * coneInterval) / 2);
128 const unsigned int coneOffset2((1 == nLayers % 2) && isForward ? 1 : 0);
129 const unsigned int coneOffset(coneOffset1 + coneOffset2);
132 CartesianVector directionSum(0.
f, 0.
f, 0.
f);
133 const float clusterLength((trackStateMap.begin()->second.GetPosition() - trackStateMap.rbegin()->second.GetPosition()).GetMagnitude());
135 unsigned int nConeSamplingSteps(0);
139 if (nConeSamplingSteps >= nCones)
142 trackStateList.push_back(iter->second);
143 directionSum += iter->second.GetMomentum();
145 const unsigned int beginDistance(static_cast<unsigned int>(
std::distance(trackStateMap.begin(), iter)));
147 if (beginDistance + 1 < nLayersForConeFit)
150 const TrackState &maxLayerTrackState(trackStateList.back());
151 const TrackState &minLayerTrackState(trackStateList.front());
153 if ((beginDistance + 1 >= nLayersForConeFit + coneOffset) && (beginDistance + 1 - nLayersForConeFit - coneOffset) % coneInterval == 0)
155 const CartesianVector &minLayerApex(minLayerTrackState.GetPosition());
156 const CartesianVector &maxLayerApex(maxLayerTrackState.GetPosition());
158 const CartesianVector minLayerDirection(directionSum.GetUnitVector());
159 const CartesianVector maxLayerDirection(directionSum.GetUnitVector() * -1.f);
162 ++nConeSamplingSteps;
163 const float placeHolderTanHalfAngle(0.5
f);
166 simpleConeList.push_back(
SimpleCone(minLayerApex, minLayerDirection, clusterLength, placeHolderTanHalfAngle));
169 simpleConeList.push_back(
SimpleCone(maxLayerApex, maxLayerDirection, clusterLength, placeHolderTanHalfAngle));
172 directionSum -= minLayerTrackState.GetMomentum();
173 trackStateList.pop_front();
const ThreeDSlidingFitResult m_slidingFitResult
The sliding fit result for the full cluster.
ThreeDSlidingConeFitResult(const T *const pT, const unsigned int slidingFitWindow, const float slidingFitLayerPitch)
Constructor.
const TwoDSlidingFitResult & GetSecondFitResult() const
Get the second sliding fit result for this cluster.
std::vector< SimpleCone > SimpleConeList
const ThreeDSlidingFitResult & GetSlidingFitResult() const
Get the sliding fit result for the full cluster.
std::list< pandora::TrackState > TrackStateLinkedList
The track state linked list typedef.
Header file for the lar three dimensional sliding cone fit result class.
void GetSimpleConeList(const unsigned int nLayersForConeFit, const unsigned int nCones, const ConeSelection coneSelection, SimpleConeList &simpleConeList) const
Get the list of simple cones fitted to the three dimensional cluster.
std::map< int, LayerFitContribution > LayerFitContributionMap
std::map< int, pandora::TrackState > TrackStateMap
Header file for the cluster helper class.
pandora::StatusCode GetGlobalFitDirection(const float rL, pandora::CartesianVector &direction) const
Get global fit direction for a given longitudinal coordinate.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
const pandora::CartesianVector & GetGlobalMaxLayerPosition() const
Get global position corresponding to the fit result in maximum fit layer.
const TrackStateMap & GetTrackStateMap() const
Get the track state map, which caches results from the sliding fit result.
ThreeDSlidingFitResult class.
const TwoDSlidingFitResult & GetFirstFitResult() const
Get the first sliding fit result for this cluster.
ConeSelection
ConeSelection enum.
pandora::StatusCode GetGlobalFitPosition(const float rL, pandora::CartesianVector &position) const
Get global fit position for a given longitudinal coordinate.
TwoDSlidingFitResult class.
TrackStateMap m_trackStateMap
The track state map.
const pandora::CartesianVector & GetGlobalMinLayerPosition() const
Get global position corresponding to the fit result in minimum fit layer.