Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-27 09:14:59

0001 /**
0002  *  @file   LCContent/include/LCHelpers/ClusterHelper.h
0003  *
0004  *  @brief  Header file for the cluster helper class.
0005  *
0006  *  $Log: $
0007  */
0008 #ifndef LC_CLUSTER_HELPER_H
0009 #define LC_CLUSTER_HELPER_H 1
0010 
0011 #include "Pandora/PandoraInputTypes.h"
0012 #include "Pandora/PandoraInternal.h"
0013 
0014 namespace pandora {
0015 class ClusterFitResult;
0016 class Pandora;
0017 } // namespace pandora
0018 
0019 //------------------------------------------------------------------------------------------------------------------------------------------
0020 
0021 namespace lc_content {
0022 
0023 /**
0024  *  @brief  ClusterHelper class
0025  */
0026 class ClusterHelper {
0027 public:
0028   /**
0029    *  @brief  Get the closest distance of approach between two cluster fit results
0030    *
0031    *  @param  lhs first cluster fit result
0032    *  @param  rhs second cluster fit result
0033    *  @param  closestApproach to receive the closest distance of approach
0034    */
0035   static pandora::StatusCode GetFitResultsClosestApproach(const pandora::ClusterFitResult& lhs,
0036                                                           const pandora::ClusterFitResult& rhs, float& closestApproach);
0037 
0038   /**
0039    *  @brief  Get closest distance of approach between projected cluster fit result and hits in a second cluster
0040    *
0041    *  @param  clusterFitResult the fit result to the first cluster
0042    *  @param  pCluster address of the second cluster
0043    *  @param  startLayer first layer to examine
0044    *  @param  endLayer last layer to examine
0045    *
0046    *  @return the closest distance of approach
0047    */
0048   static float GetDistanceToClosestHit(const pandora::ClusterFitResult& clusterFitResult,
0049                                        const pandora::Cluster* const pCluster, const unsigned int startLayer,
0050                                        const unsigned int endLayer);
0051 
0052   /**
0053    *  @brief  Get smallest distance between pairs of hits in two clusters
0054    *
0055    *  @param  pClusterI address of the first cluster
0056    *  @param  pClusterJ address of the second cluster
0057    *
0058    *  @return the smallest distance
0059    */
0060   static float GetDistanceToClosestHit(const pandora::Cluster* const pClusterI,
0061                                        const pandora::Cluster* const pClusterJ);
0062 
0063   /**
0064    *  @brief  Get closest distance of approach between projected cluster fit result and layer centroid position of a
0065    * second cluster
0066    *
0067    *  @param  clusterFitResult the fit result to the first cluster
0068    *  @param  pCluster address of the second cluster
0069    *  @param  startLayer first layer to examine
0070    *  @param  endLayer last layer to examine
0071    *
0072    *  @return the closest distance of approach
0073    */
0074   static float GetDistanceToClosestCentroid(const pandora::ClusterFitResult& clusterFitResult,
0075                                             const pandora::Cluster* const pCluster, const unsigned int startLayer,
0076                                             const unsigned int endLayer);
0077 
0078   /**
0079    *  @brief  Get the closest distance between layer centroid positions in two overlapping clusters
0080    *
0081    *  @param  pClusterI address of the first cluster
0082    *  @param  pClusterJ address of the second cluster
0083    *  @param  intraLayerDistance to receive the closest centroid distance
0084    */
0085   static pandora::StatusCode GetDistanceToClosestCentroid(const pandora::Cluster* const pClusterI,
0086                                                           const pandora::Cluster* const pClusterJ,
0087                                                           float& centroidDistance);
0088 
0089   /**
0090    *  @brief  Get the closest distance between same layer centroid positions in two overlapping clusters
0091    *
0092    *  @param  pClusterI address of the first cluster
0093    *  @param  pClusterJ address of the second cluster
0094    *  @param  intraLayerDistance to receive the closest intra layer distance
0095    */
0096   static pandora::StatusCode GetClosestIntraLayerDistance(const pandora::Cluster* const pClusterI,
0097                                                           const pandora::Cluster* const pClusterJ,
0098                                                           float& intraLayerDistance);
0099 
0100   /**
0101    *  @brief  Get the distance of closest approach between the projected track direction at calorimeter and the hits
0102    * within a cluster. Note that only a specified number of layers are examined.
0103    *
0104    *  @param  pT track, trackState or vector of trackStates, for a Track the TrackStateAtCalorimeter is used
0105    *  @param  pCluster address of the cluster
0106    *  @param  maxSearchLayer the maximum pseudolayer to examine
0107    *  @param  parallelDistanceCut maximum allowed projection of track-cluster separation along track direction
0108    *  @param  minTrackClusterCosAngle min cos(angle) between track and cluster initial direction
0109    *  @param  trackClusterDistance to receive the track cluster distance
0110    */
0111   template <typename T>
0112   static pandora::StatusCode GetTrackClusterDistance(const T* const pT, const pandora::Cluster* const pCluster,
0113                                                      const unsigned int maxSearchLayer, const float parallelDistanceCut,
0114                                                      const float minTrackClusterCosAngle, float& trackClusterDistance);
0115 
0116   /**
0117    *  @brief  Whether a cluster can be merged with another. Uses simple suggested criteria, including cluster photon id
0118    * flag and supplied cuts on cluster mip fraction and all hits fit rms.
0119    *
0120    *  @param  pandora the associated pandora instance
0121    *  @param  pCluster address of the cluster
0122    *  @param  minMipFraction the minimum mip fraction for clusters (flagged as photons) to be merged
0123    *  @param  maxAllHitsFitRms the maximum all hit fit rms for clusters (flagged as photons) to be merged
0124    *
0125    *  @return boolean
0126    */
0127   static bool CanMergeCluster(const pandora::Pandora& pandora, const pandora::Cluster* const pCluster,
0128                               const float minMipFraction, const float maxAllHitsFitRms);
0129 
0130   /**
0131    *  @brief  Get the energy-weighted mean time of the non-isolated hits in a specified cluster, units ns
0132    *
0133    *  @param  pCluster address of the cluster
0134    *
0135    *  @return The energy-weighted mean time, units ns
0136    */
0137   static float GetEnergyWeightedMeanTime(const pandora::Cluster* const pCluster);
0138 
0139   /**
0140    *  @brief  Whether a linear fit to a cluster crosses a registered gap region. Only the region between the startlayer
0141    * and endlayer is considered in the fit and in the comparison with registered gap regions.
0142    *
0143    *  @param  pandora the associated pandora instance
0144    *  @param  pCluster address of the cluster
0145    *  @param  startLayer the start layer (adjusted to maximum of specified layer and cluster inner layer)
0146    *  @param  endLayer the end layer (adjusted to minimum of specified layer and cluster outer layer)
0147    *  @param  nSamplingPoints number of points at which to sample the fit within the specified layer region
0148    *
0149    *  @return boolean
0150    */
0151   static bool DoesClusterCrossGapRegion(const pandora::Pandora& pandora, const pandora::Cluster* const pCluster,
0152                                         const unsigned int startLayer, const unsigned int endLayer,
0153                                         const unsigned int nSamplingPoints = 50);
0154 
0155   /**
0156    *  @brief  Whether a linear fit crosses a registered gap region. The fit will be propagated through the specified
0157    * distance from its closest approach to the startPosition. Within this propagation, the fit will be sampled a
0158    * specified number of times and the resulting position compared with registered gap regions.
0159    *
0160    *  @param  pandora the associated pandora instance
0161    *  @param  clusterFitResult the cluster fit result
0162    *  @param  startPosition the propagation start position (adjusted to closest point on fit trajectory)
0163    *  @param  propagationDistance the propagation distance, which can be negative for propagation towards the ip
0164    *  @param  nSamplingPoints number of points at which to sample the fit within its propagation
0165    *
0166    *  @return boolean
0167    */
0168   static bool DoesFitCrossGapRegion(const pandora::Pandora& pandora, const pandora::ClusterFitResult& clusterFitResult,
0169                                     const pandora::CartesianVector& startPosition, const float propagationDistance,
0170                                     const unsigned int nSamplingPoints = 50);
0171 
0172   /**
0173    *  @brief  Whether a cluster should be considered as leaving the calorimeters, leading to leakage of its energy
0174    *
0175    *  @param  pCluster address of the cluster
0176    *  @param  nOuterLayersToExamine number of outer layers to examine in order to identify a leaving cluster
0177    *  @param  nMipLikeNOccupiedLayers number of occupied outer layers for a mip-like leaving cluster
0178    *  @param  nShowerLikeNOccupiedLayers number of occupied outer layers for a shower-like leaving cluster
0179    *  @param  showerLikeEnergyInOuterLayers energy deposited in outer layers by a shower-like leaving cluster
0180    *
0181    *  @return boolean
0182    */
0183   static bool IsClusterLeavingDetector(const pandora::Cluster* const pCluster,
0184                                        const unsigned int nOuterLayersToExamine = 4,
0185                                        const unsigned int nMipLikeOccupiedLayers = 4,
0186                                        const unsigned int nShowerLikeOccupiedLayers = 3,
0187                                        const float showerLikeEnergyInOuterLayers = 1.f);
0188 
0189   /**
0190    *  @brief  Whether a cluster contains a calo hit of the specified hit type
0191    *
0192    *  @param  pCluster address of the cluster
0193    *  @param  hitType the hit type
0194    *
0195    *  @return boolean
0196    */
0197   static bool ContainsHitType(const pandora::Cluster* const pCluster, const pandora::HitType hitType);
0198 
0199   /**
0200    *  @brief  Whether a cluster contains a calo hit flagged as being in an outer sampling layer
0201    *
0202    *  @param  pCluster address of the cluster
0203    *
0204    *  @return boolean
0205    */
0206   static bool ContainsHitInOuterSamplingLayer(const pandora::Cluster* const pCluster);
0207 };
0208 
0209 } // namespace lc_content
0210 
0211 #endif // #ifndef LC_CLUSTER_HELPER_H