Skip to content

Commit

Permalink
ClusterHelper::GetTrackClusterDistance: template the function to acce…
Browse files Browse the repository at this point in the history
…pt Track, TrackState of vector<TrackState>
  • Loading branch information
andresailer committed Sep 21, 2017
1 parent 70785a5 commit 596f0b2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
5 changes: 3 additions & 2 deletions include/LCHelpers/ClusterHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,15 @@ class ClusterHelper
* @brief Get the distance of closest approach between the projected track direction at calorimeter and the hits within a cluster.
* Note that only a specified number of layers are examined.
*
* @param pTrack address of the track
* @param pT track, trackState or vector of trackStates, for a Track the TrackStateAtCalorimeter is used
* @param pCluster address of the cluster
* @param maxSearchLayer the maximum pseudolayer to examine
* @param parallelDistanceCut maximum allowed projection of track-cluster separation along track direction
* @param minTrackClusterCosAngle min cos(angle) between track and cluster initial direction
* @param trackClusterDistance to receive the track cluster distance
*/
static pandora::StatusCode GetTrackClusterDistance(const pandora::Track *const pTrack, const pandora::Cluster *const pCluster,
template<typename T>
static pandora::StatusCode GetTrackClusterDistance(const T *const pT, const pandora::Cluster *const pCluster,
const unsigned int maxSearchLayer, const float parallelDistanceCut, const float minTrackClusterCosAngle, float &trackClusterDistance);

/**
Expand Down
40 changes: 36 additions & 4 deletions src/LCHelpers/ClusterHelper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ StatusCode ClusterHelper::GetClosestIntraLayerDistance(const Cluster *const pClu

//------------------------------------------------------------------------------------------------------------------------------------------

StatusCode ClusterHelper::GetTrackClusterDistance(const Track *const pTrack, const Cluster *const pCluster, const unsigned int maxSearchLayer,
template <>
StatusCode ClusterHelper::GetTrackClusterDistance(const TrackState *const trackState, const Cluster *const pCluster, const unsigned int maxSearchLayer,
const float parallelDistanceCut, const float minTrackClusterCosAngle, float &trackClusterDistance)
{
if ((0 == pCluster->GetNCaloHits()) || (pCluster->GetInnerPseudoLayer() > maxSearchLayer))
return STATUS_CODE_NOT_FOUND;

const TrackState &trackState(pTrack->GetTrackStateAtCalorimeter());
const CartesianVector &trackPosition(trackState.GetPosition());
const CartesianVector trackDirection(trackState.GetMomentum().GetUnitVector());
const CartesianVector &trackPosition(trackState->GetPosition());
const CartesianVector trackDirection(trackState->GetMomentum().GetUnitVector());

if (trackDirection.GetCosOpeningAngle(pCluster->GetInitialDirection()) < minTrackClusterCosAngle)
return STATUS_CODE_NOT_FOUND;
Expand Down Expand Up @@ -276,6 +276,38 @@ StatusCode ClusterHelper::GetTrackClusterDistance(const Track *const pTrack, con
return STATUS_CODE_SUCCESS;
}


//------------------------------------------------------------------------------------------------------------------------------------------

template <>
StatusCode ClusterHelper::GetTrackClusterDistance(const Track *const pTrack, const Cluster *const pCluster, const unsigned int maxSearchLayer,
const float parallelDistanceCut, const float minTrackClusterCosAngle, float &trackClusterDistance)
{
return GetTrackClusterDistance( &pTrack->GetTrackStateAtCalorimeter(), pCluster, maxSearchLayer, parallelDistanceCut, minTrackClusterCosAngle, trackClusterDistance);
}

//------------------------------------------------------------------------------------------------------------------------------------------

template <>
StatusCode ClusterHelper::GetTrackClusterDistance(const std::vector<TrackState> *const pTrackStates, const Cluster *const pCluster, const unsigned int maxSearchLayer,
const float parallelDistanceCut, const float minTrackClusterCosAngle, float &trackClusterDistance)
{
bool successful=false;
for (auto const& trackState: *pTrackStates)
{
float trackClusterDistanceTemp(std::numeric_limits<float>::max());
StatusCode statusCode = GetTrackClusterDistance(&trackState, pCluster, maxSearchLayer, parallelDistanceCut, minTrackClusterCosAngle, trackClusterDistanceTemp);
if(STATUS_CODE_SUCCESS == statusCode)
{
successful = true;
if(trackClusterDistanceTemp < trackClusterDistance)
trackClusterDistance = trackClusterDistanceTemp;
}
}
return successful ? STATUS_CODE_SUCCESS : STATUS_CODE_NOT_FOUND;
}


//------------------------------------------------------------------------------------------------------------------------------------------

bool ClusterHelper::CanMergeCluster(const Pandora &pandora, const Cluster *const pCluster, const float minMipFraction, const float maxAllHitsFitRms)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ StatusCode TrackClusterAssociationAlgorithm::Run()
continue;

float trackClusterDistance(std::numeric_limits<float>::max());
if (STATUS_CODE_SUCCESS != lc_content::ClusterHelper::GetTrackClusterDistance(pTrack, pCluster, m_maxSearchLayer, m_parallelDistanceCut,
if (STATUS_CODE_SUCCESS != lc_content::ClusterHelper::GetTrackClusterDistance(&trackState, pCluster, m_maxSearchLayer, m_parallelDistanceCut,
m_minTrackClusterCosAngle, trackClusterDistance))
{
continue;
Expand Down

0 comments on commit 596f0b2

Please sign in to comment.