All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Static Public Member Functions | List of all members
lar_content::LArClusterHelper Class Reference

LArClusterHelper class. More...

#include <LArClusterHelper.h>

Public Types

typedef std::set< unsigned int > UIntSet
 

Static Public Member Functions

static pandora::HitType GetClusterHitType (const pandora::Cluster *const pCluster)
 Get the hit type associated with a two dimensional cluster. More...
 
static void GetClustersUVW (const pandora::ClusterList &inputClusters, pandora::ClusterList &clusterListU, pandora::ClusterList &clusterListV, pandora::ClusterList &clusterListW)
 Divide an input cluster list into separate u, v and w lists (exception raised if alternative hit type encountered) More...
 
static void GetClustersByHitType (const pandora::ClusterList &inputClusters, const pandora::HitType hitType, pandora::ClusterList &clusterList)
 Get the subset of clusters, from a provided list, that match the specified hit type. More...
 
static float GetLengthSquared (const pandora::Cluster *const pCluster)
 Get length squared of cluster. More...
 
static float GetLength (const pandora::Cluster *const pCluster)
 Get length of cluster. More...
 
static float GetEnergyFromLength (const pandora::Cluster *const pCluster)
 Get energy of cluster, based on length. More...
 
static unsigned int GetLayerSpan (const pandora::Cluster *const pCluster)
 Get number of layers spanned by cluster (1+Last-First) More...
 
static float GetLayerOccupancy (const pandora::Cluster *const pCluster)
 Fraction of occupied layers in cluster. More...
 
static float GetLayerOccupancy (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2)
 Fraction of occupied layers in a pair of clusters. More...
 
static float GetClosestDistance (const pandora::ClusterList &clusterList1, const pandora::ClusterList &clusterList2)
 Get closest distance between clusters in a pair of cluster lists. More...
 
static float GetClosestDistance (const pandora::Cluster *const pCluster, const pandora::ClusterList &clusterList)
 Get closest distance between a specified cluster and list of clusters. More...
 
static float GetClosestDistance (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2)
 Get closest distance between a pair of clusters. More...
 
static float GetClosestDistance (const pandora::CartesianVector &position, const pandora::ClusterList &clusterList)
 Get closest distance between a specified position and list of clusters. More...
 
static float GetClosestDistance (const pandora::CartesianVector &position, const pandora::Cluster *const pCluster)
 Get closest distance between a specified position vector and the hits in a specified cluster. More...
 
static float GetClosestDistance (const pandora::CartesianVector &position, const pandora::CaloHitList &caloHitList)
 Get closest distance between a specified position vector and the hits in a specified calo hit list. More...
 
static pandora::CartesianVector GetClosestPosition (const pandora::CartesianVector &position, const pandora::ClusterList &clusterList)
 Get closest position in a list of clusters to a specified input position vector. More...
 
static pandora::CartesianVector GetClosestPosition (const pandora::CartesianVector &position, const pandora::Cluster *const pCluster)
 Get closest position on a cluster to a specified input position vector. More...
 
static pandora::CartesianVector GetClosestPosition (const pandora::CartesianVector &position, const pandora::CaloHitList &caloHitList)
 Get closest position of hits in a given calo hit list to a specified input position vector. More...
 
static void GetClosestPositions (const pandora::Cluster *const pCluster1, const pandora::Cluster *const pCluster2, pandora::CartesianVector &position1, pandora::CartesianVector &position2)
 Get pair of closest positions for a pair of clusters. More...
 
static void GetExtremalCoordinates (const pandora::ClusterList &clusterList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
 Get positions of the two most distant calo hits in a list of cluster (ordered by Z) More...
 
static void GetExtremalCoordinates (const pandora::Cluster *const pCluster, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
 Get positions of the two most distant calo hits in a cluster (ordered by Z) More...
 
static void GetExtremalCoordinates (const pandora::OrderedCaloHitList &orderedCaloHitList, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
 Get positions of the two most distant calo hits in an ordered calo hit list (ordered by Z) More...
 
static void GetExtremalCoordinates (const pandora::CartesianPointVector &coordinateVector, pandora::CartesianVector &innerCoordinate, pandora::CartesianVector &outerCoordinate)
 Get positions of the two most distant points in a provided list (ordered by Z) More...
 
static void GetClusterBoundingBox (const pandora::Cluster *const pCluster, pandora::CartesianVector &minimumCoordinate, pandora::CartesianVector &maximumCoordinate)
 Get minimum and maximum X, Y and Z positions of the calo hits in a cluster. More...
 
static void GetCoordinateVector (const pandora::Cluster *const pCluster, pandora::CartesianPointVector &coordinateVector)
 Get vector of hit coordinates from an input cluster. More...
 
static void GetCaloHitListInBoundingBox (const pandora::Cluster *const pCluster, const pandora::CartesianVector &lowerBound, const pandora::CartesianVector &upperBound, pandora::CaloHitList &caloHitList)
 Get list of Calo hits from an input cluster that are contained in a bounding box. The hits are sorted by position. More...
 
static void GetDaughterVolumeIDs (const pandora::Cluster *const pCluster, UIntSet &daughterVolumeIds)
 Get the set of the daughter volumes that contains the cluster. More...
 
static pandora::StatusCode GetAverageZ (const pandora::Cluster *const pCluster, const float xmin, const float xmax, float &averageZ)
 Get average Z positions of the calo hits in a cluster in range xmin to xmax. More...
 
static bool SortByNOccupiedLayers (const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
 Sort clusters by number of occupied layers, and by inner layer, then energy in event of a tie. More...
 
static bool SortByNHits (const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
 Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height. More...
 
static bool SortByLayerSpan (const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
 Sort clusters by layer span, then inner layer, then position, then pulse-height. More...
 
static bool SortByInnerLayer (const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
 Sort clusters by inner layer, then position, then pulse-height. More...
 
static bool SortByPosition (const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
 Sort clusters by position, then pulse-height. More...
 
static bool SortByPulseHeight (const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
 Sort clusters by pulse-height. More...
 
static bool SortHitsByPosition (const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
 Sort calo hits by their position (use Z, followed by X, followed by Y) More...
 
static bool SortHitsByPositionInX (const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
 Sort calo hits by their position (use X, followed by Z, followed by Y) More...
 
static bool SortHitsByPulseHeight (const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
 Sort calo hits by their pulse height. More...
 
static bool SortCoordinatesByPosition (const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
 Sort cartesian vectors by their position (use Z, followed by X, followed by Y) More...
 

Detailed Description

LArClusterHelper class.

Definition at line 19 of file LArClusterHelper.h.

Member Typedef Documentation

typedef std::set<unsigned int> lar_content::LArClusterHelper::UIntSet

Definition at line 22 of file LArClusterHelper.h.

Member Function Documentation

StatusCode lar_content::LArClusterHelper::GetAverageZ ( const pandora::Cluster *const  pCluster,
const float  xmin,
const float  xmax,
float &  averageZ 
)
static

Get average Z positions of the calo hits in a cluster in range xmin to xmax.

Parameters
pClusteraddress of the cluster
xminfor range in x
xmaxfor range in x
averageZto receive the average Z position
Returns
status code, faster than throwing in regular use-cases

Definition at line 364 of file LArClusterHelper.cc.

365 {
366  averageZ = std::numeric_limits<float>::max();
367 
368  if (xmin > xmax)
369  return STATUS_CODE_INVALID_PARAMETER;
370 
371  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
372 
373  float zsum(0.f);
374  int count(0);
375 
376  for (OrderedCaloHitList::const_iterator ochIter = orderedCaloHitList.begin(), ochIterEnd = orderedCaloHitList.end(); ochIter != ochIterEnd; ++ochIter)
377  {
378  for (CaloHitList::const_iterator hIter = ochIter->second->begin(), hIterEnd = ochIter->second->end(); hIter != hIterEnd; ++hIter)
379  {
380  const CaloHit *const pCaloHit = *hIter;
381  const CartesianVector &hit(pCaloHit->GetPositionVector());
382 
383  if (hit.GetX() < xmin || hit.GetX() > xmax)
384  continue;
385 
386  zsum += hit.GetZ();
387  ++count;
388  }
389  }
390 
391  if (count == 0)
392  return STATUS_CODE_NOT_FOUND;
393 
394  averageZ = zsum / static_cast<float>(count);
395  return STATUS_CODE_SUCCESS;
396 }
process_name hit
Definition: cheaterreco.fcl:51
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
std::size_t count(Cont const &cont)
void lar_content::LArClusterHelper::GetCaloHitListInBoundingBox ( const pandora::Cluster *const  pCluster,
const pandora::CartesianVector &  lowerBound,
const pandora::CartesianVector &  upperBound,
pandora::CaloHitList &  caloHitList 
)
static

Get list of Calo hits from an input cluster that are contained in a bounding box. The hits are sorted by position.

Parameters
pClusteraddress of the cluster
lowerBoundone opposing corner of the bounding box
upperBoundthe other opposing corner of the bounding box
caloHitListthe CaloHitList to be filled

Definition at line 562 of file LArClusterHelper.cc.

564 {
565  const bool useX(std::fabs(upperBound.GetX() - lowerBound.GetX()) > std::numeric_limits<float>::epsilon());
566  const bool useY(std::fabs(upperBound.GetY() - lowerBound.GetY()) > std::numeric_limits<float>::epsilon());
567  const bool useZ(std::fabs(upperBound.GetZ() - lowerBound.GetZ()) > std::numeric_limits<float>::epsilon());
568  if (!useX && !useY && !useZ)
569  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
570 
571  const float minX(std::min(lowerBound.GetX(), upperBound.GetX()));
572  const float maxX(std::max(lowerBound.GetX(), upperBound.GetX()));
573  const float minY(std::min(lowerBound.GetY(), upperBound.GetY()));
574  const float maxY(std::max(lowerBound.GetY(), upperBound.GetY()));
575  const float minZ(std::min(lowerBound.GetZ(), upperBound.GetZ()));
576  const float maxZ(std::max(lowerBound.GetZ(), upperBound.GetZ()));
577 
578  for (const OrderedCaloHitList::value_type &layerEntry : pCluster->GetOrderedCaloHitList())
579  {
580  for (const CaloHit *const pCaloHit : *layerEntry.second)
581  {
582  const CartesianVector &hitPosition = pCaloHit->GetPositionVector();
583  if (useX && (hitPosition.GetX() < minX - std::numeric_limits<float>::epsilon() ||
584  hitPosition.GetX() > maxX + std::numeric_limits<float>::epsilon()))
585  continue;
586  else if (useY && (hitPosition.GetY() < minY - std::numeric_limits<float>::epsilon() ||
587  hitPosition.GetY() > maxY + std::numeric_limits<float>::epsilon()))
588  continue;
589  else if (useZ && (hitPosition.GetZ() < minZ - std::numeric_limits<float>::epsilon() ||
590  hitPosition.GetZ() > maxZ + std::numeric_limits<float>::epsilon()))
591  continue;
592 
593  caloHitList.push_back(pCaloHit);
594  }
595  }
596  caloHitList.sort(LArClusterHelper::SortHitsByPosition);
597 }
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
static float lar_content::LArClusterHelper::GetClosestDistance ( const pandora::ClusterList &  clusterList1,
const pandora::ClusterList &  clusterList2 
)
static

Get closest distance between clusters in a pair of cluster lists.

Parameters
clusterList1the first cluster list
clusterList2the second cluster list
Returns
the closest distance
static float lar_content::LArClusterHelper::GetClosestDistance ( const pandora::Cluster *const  pCluster,
const pandora::ClusterList &  clusterList 
)
static

Get closest distance between a specified cluster and list of clusters.

Parameters
pClusteraddress of the input cluster
clusterListlist of input clusters
Returns
the closest distance
static float lar_content::LArClusterHelper::GetClosestDistance ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2 
)
static

Get closest distance between a pair of clusters.

Parameters
pCluster1address of the first cluster
pCluster2address of the second cluster
Returns
the closest distance
static float lar_content::LArClusterHelper::GetClosestDistance ( const pandora::CartesianVector &  position,
const pandora::ClusterList &  clusterList 
)
static

Get closest distance between a specified position and list of clusters.

Parameters
positionthe position vector
clusterListlist of input clusters
Returns
the closest distance
static float lar_content::LArClusterHelper::GetClosestDistance ( const pandora::CartesianVector &  position,
const pandora::Cluster *const  pCluster 
)
static

Get closest distance between a specified position vector and the hits in a specified cluster.

Parameters
positionthe position vector
pClusteraddress of the cluster
Returns
the closest distance
static float lar_content::LArClusterHelper::GetClosestDistance ( const pandora::CartesianVector &  position,
const pandora::CaloHitList &  caloHitList 
)
static

Get closest distance between a specified position vector and the hits in a specified calo hit list.

Parameters
positionthe position vector
caloHitListthe list of calo hits
Returns
the closest distance
static pandora::CartesianVector lar_content::LArClusterHelper::GetClosestPosition ( const pandora::CartesianVector &  position,
const pandora::ClusterList &  clusterList 
)
static

Get closest position in a list of clusters to a specified input position vector.

Parameters
positionthe position vector
clusterListlist of input clusters
Returns
the closest position
static pandora::CartesianVector lar_content::LArClusterHelper::GetClosestPosition ( const pandora::CartesianVector &  position,
const pandora::Cluster *const  pCluster 
)
static

Get closest position on a cluster to a specified input position vector.

Parameters
positionthe position vector
pClusteraddress of the cluster
Returns
the closest position
static pandora::CartesianVector lar_content::LArClusterHelper::GetClosestPosition ( const pandora::CartesianVector &  position,
const pandora::CaloHitList &  caloHitList 
)
static

Get closest position of hits in a given calo hit list to a specified input position vector.

Parameters
positionthe position vector
caloHitListthe list of calo hits
Returns
the closest position
void lar_content::LArClusterHelper::GetClosestPositions ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2,
pandora::CartesianVector &  position1,
pandora::CartesianVector &  position2 
)
static

Get pair of closest positions for a pair of clusters.

Parameters
pCluster1the address of the first cluster
pCluster2the address of the second cluster
theclosest position in the first cluster
theclosest position in the second cluster

Definition at line 283 of file LArClusterHelper.cc.

285 {
286  bool distanceFound(false);
287  float minDistanceSquared(std::numeric_limits<float>::max());
288 
289  CartesianVector closestPosition1(0.f, 0.f, 0.f);
290  CartesianVector closestPosition2(0.f, 0.f, 0.f);
291 
292  const OrderedCaloHitList &orderedCaloHitList1(pCluster1->GetOrderedCaloHitList());
293  const OrderedCaloHitList &orderedCaloHitList2(pCluster2->GetOrderedCaloHitList());
294 
295  // Loop over hits in cluster 1
296  for (OrderedCaloHitList::const_iterator iter1 = orderedCaloHitList1.begin(), iter1End = orderedCaloHitList1.end(); iter1 != iter1End; ++iter1)
297  {
298  for (CaloHitList::const_iterator hitIter1 = iter1->second->begin(), hitIter1End = iter1->second->end(); hitIter1 != hitIter1End; ++hitIter1)
299  {
300  const CartesianVector &positionVector1((*hitIter1)->GetPositionVector());
301 
302  // Loop over hits in cluster 2
303  for (OrderedCaloHitList::const_iterator iter2 = orderedCaloHitList2.begin(), iter2End = orderedCaloHitList2.end(); iter2 != iter2End; ++iter2)
304  {
305  for (CaloHitList::const_iterator hitIter2 = iter2->second->begin(), hitIter2End = iter2->second->end(); hitIter2 != hitIter2End; ++hitIter2)
306  {
307  const CartesianVector &positionVector2((*hitIter2)->GetPositionVector());
308 
309  const float distanceSquared((positionVector1 - positionVector2).GetMagnitudeSquared());
310 
311  if (distanceSquared < minDistanceSquared)
312  {
313  minDistanceSquared = distanceSquared;
314  closestPosition1 = positionVector1;
315  closestPosition2 = positionVector2;
316  distanceFound = true;
317  }
318  }
319  }
320  }
321  }
322 
323  if (!distanceFound)
324  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
325 
326  outputPosition1 = closestPosition1;
327  outputPosition2 = closestPosition2;
328 }
void lar_content::LArClusterHelper::GetClusterBoundingBox ( const pandora::Cluster *const  pCluster,
pandora::CartesianVector &  minimumCoordinate,
pandora::CartesianVector &  maximumCoordinate 
)
static

Get minimum and maximum X, Y and Z positions of the calo hits in a cluster.

Parameters
pClusteraddress of the cluster
theminimum positions (x,y,z)
themaximum positions (x,y,z)

Definition at line 332 of file LArClusterHelper.cc.

333 {
334  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
335 
336  float xmin(std::numeric_limits<float>::max());
337  float ymin(std::numeric_limits<float>::max());
338  float zmin(std::numeric_limits<float>::max());
339  float xmax(-std::numeric_limits<float>::max());
340  float ymax(-std::numeric_limits<float>::max());
341  float zmax(-std::numeric_limits<float>::max());
342 
343  for (OrderedCaloHitList::const_iterator ochIter = orderedCaloHitList.begin(), ochIterEnd = orderedCaloHitList.end(); ochIter != ochIterEnd; ++ochIter)
344  {
345  for (CaloHitList::const_iterator hIter = ochIter->second->begin(), hIterEnd = ochIter->second->end(); hIter != hIterEnd; ++hIter)
346  {
347  const CaloHit *const pCaloHit = *hIter;
348  const CartesianVector &hit(pCaloHit->GetPositionVector());
349  xmin = std::min(hit.GetX(), xmin);
350  xmax = std::max(hit.GetX(), xmax);
351  ymin = std::min(hit.GetY(), ymin);
352  ymax = std::max(hit.GetY(), ymax);
353  zmin = std::min(hit.GetZ(), zmin);
354  zmax = std::max(hit.GetZ(), zmax);
355  }
356  }
357 
358  minimumCoordinate.SetValues(xmin, ymin, zmin);
359  maximumCoordinate.SetValues(xmax, ymax, zmax);
360 }
process_name hit
Definition: cheaterreco.fcl:51
process_name pandoraGausCryo1 vertexChargeCryo1 vertexStubCryo1 xmin
HitType lar_content::LArClusterHelper::GetClusterHitType ( const pandora::Cluster *const  pCluster)
static

Get the hit type associated with a two dimensional cluster.

Parameters
pClusterthe address of the cluster
Returns
the cluster hit type

Definition at line 21 of file LArClusterHelper.cc.

22 {
23  if (0 == pCluster->GetNCaloHits())
24  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
25 
26  // TODO Find a way of confirming single hit-type clustering mode; currently only checked in ListPreparation algorithm
27  // if (!pandora->GetSettings()->SingleHitTypeClusteringMode())
28  // throw StatusCodeException(STATUS_CODE_FAILURE);
29 
30  return (*(pCluster->GetOrderedCaloHitList().begin()->second->begin()))->GetHitType();
31 }
void lar_content::LArClusterHelper::GetClustersByHitType ( const pandora::ClusterList &  inputClusters,
const pandora::HitType  hitType,
pandora::ClusterList &  clusterList 
)
static

Get the subset of clusters, from a provided list, that match the specified hit type.

Parameters
inputClustersthe input cluster list
hitTypethe specified hit type
clusterListto receive the clusters

Definition at line 54 of file LArClusterHelper.cc.

55 {
56  for (ClusterList::const_iterator iter = inputClusters.begin(), iterEnd = inputClusters.end(); iter != iterEnd; ++iter)
57  {
58  if (hitType == LArClusterHelper::GetClusterHitType(*iter))
59  clusterList.push_back(*iter);
60  }
61 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void lar_content::LArClusterHelper::GetClustersUVW ( const pandora::ClusterList &  inputClusters,
pandora::ClusterList &  clusterListU,
pandora::ClusterList &  clusterListV,
pandora::ClusterList &  clusterListW 
)
static

Divide an input cluster list into separate u, v and w lists (exception raised if alternative hit type encountered)

Parameters
inputClustersthe input cluster list
clusterListUto receive the u clusters
clusterListVto receive the v clusters
clusterListWto receive the w clusters

Definition at line 35 of file LArClusterHelper.cc.

36 {
37  for (ClusterList::const_iterator iter = inputClusters.begin(), iterEnd = inputClusters.end(); iter != iterEnd; ++iter)
38  {
39  const HitType hitType(LArClusterHelper::GetClusterHitType(*iter));
40 
41  if (TPC_VIEW_U == hitType)
42  clusterListU.push_back(*iter);
43  else if (TPC_VIEW_V == hitType)
44  clusterListV.push_back(*iter);
45  else if (TPC_VIEW_W == hitType)
46  clusterListW.push_back(*iter);
47  else
48  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
49  }
50 }
static pandora::HitType GetClusterHitType(const pandora::Cluster *const pCluster)
Get the hit type associated with a two dimensional cluster.
void lar_content::LArClusterHelper::GetCoordinateVector ( const pandora::Cluster *const  pCluster,
pandora::CartesianPointVector &  coordinateVector 
)
static

Get vector of hit coordinates from an input cluster.

Parameters
pClusteraddress of the cluster
coordinateVector

Definition at line 549 of file LArClusterHelper.cc.

550 {
551  for (const OrderedCaloHitList::value_type &layerEntry : pCluster->GetOrderedCaloHitList())
552  {
553  for (const CaloHit *const pCaloHit : *layerEntry.second)
554  coordinateVector.push_back(pCaloHit->GetPositionVector());
555  }
556 
557  std::sort(coordinateVector.begin(), coordinateVector.end(), LArClusterHelper::SortCoordinatesByPosition);
558 }
static bool SortCoordinatesByPosition(const pandora::CartesianVector &lhs, const pandora::CartesianVector &rhs)
Sort cartesian vectors by their position (use Z, followed by X, followed by Y)
void lar_content::LArClusterHelper::GetDaughterVolumeIDs ( const pandora::Cluster *const  pCluster,
UIntSet daughterVolumeIds 
)
static

Get the set of the daughter volumes that contains the cluster.

Parameters
pClusteraddress of the cluster
daughterVolumeIdsoutput variable

Definition at line 601 of file LArClusterHelper.cc.

602 {
603  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
604 
605  for (OrderedCaloHitList::const_iterator ochIter = orderedCaloHitList.begin(), ochIterEnd = orderedCaloHitList.end(); ochIter != ochIterEnd; ++ochIter)
606  {
607  for (CaloHitList::const_iterator hIter = ochIter->second->begin(), hIterEnd = ochIter->second->end(); hIter != hIterEnd; ++hIter)
608  {
609  const CaloHit *const pCaloHit(*hIter);
610  const LArCaloHit *const pLArCaloHit(dynamic_cast<const LArCaloHit *>(pCaloHit));
611 
612  if (pLArCaloHit)
613  daughterVolumeIds.insert(pLArCaloHit->GetDaughterVolumeId());
614  }
615  }
616 }
float lar_content::LArClusterHelper::GetEnergyFromLength ( const pandora::Cluster *const  pCluster)
static

Get energy of cluster, based on length.

Parameters
pClusteraddress of the cluster
Returns
the energy

Definition at line 104 of file LArClusterHelper.cc.

105 {
106  const float dEdX(0.002f); // approximately 2 MeV/cm
107  return (dEdX * LArClusterHelper::GetLength(pCluster));
108 }
static float GetLength(const pandora::Cluster *const pCluster)
Get length of cluster.
static void lar_content::LArClusterHelper::GetExtremalCoordinates ( const pandora::ClusterList &  clusterList,
pandora::CartesianVector &  innerCoordinate,
pandora::CartesianVector &  outerCoordinate 
)
static

Get positions of the two most distant calo hits in a list of cluster (ordered by Z)

Parameters
clusterListthe input cluster list
theinner extremal position
theouter extremal position
static void lar_content::LArClusterHelper::GetExtremalCoordinates ( const pandora::Cluster *const  pCluster,
pandora::CartesianVector &  innerCoordinate,
pandora::CartesianVector &  outerCoordinate 
)
static

Get positions of the two most distant calo hits in a cluster (ordered by Z)

Parameters
pClusterthe input cluster
theinner extremal position
theouter extremal position
static void lar_content::LArClusterHelper::GetExtremalCoordinates ( const pandora::OrderedCaloHitList &  orderedCaloHitList,
pandora::CartesianVector &  innerCoordinate,
pandora::CartesianVector &  outerCoordinate 
)
static

Get positions of the two most distant calo hits in an ordered calo hit list (ordered by Z)

Parameters
orderedCaloHitListthe ordered calo hit list
theinner extremal position
theouter extremal position
static void lar_content::LArClusterHelper::GetExtremalCoordinates ( const pandora::CartesianPointVector &  coordinateVector,
pandora::CartesianVector &  innerCoordinate,
pandora::CartesianVector &  outerCoordinate 
)
static

Get positions of the two most distant points in a provided list (ordered by Z)

Parameters
coordinateVectorthe hit list
theinner extremal position
theouter extremal position
static float lar_content::LArClusterHelper::GetLayerOccupancy ( const pandora::Cluster *const  pCluster)
static

Fraction of occupied layers in cluster.

Parameters
pClusteraddress of the cluster
Returns
float
static float lar_content::LArClusterHelper::GetLayerOccupancy ( const pandora::Cluster *const  pCluster1,
const pandora::Cluster *const  pCluster2 
)
static

Fraction of occupied layers in a pair of clusters.

Parameters
pCluster1address of the first cluster
pCluster2address of the second cluster
Returns
float
unsigned int lar_content::LArClusterHelper::GetLayerSpan ( const pandora::Cluster *const  pCluster)
static

Get number of layers spanned by cluster (1+Last-First)

Parameters
pClusteraddress of the cluster
Returns
the layer span

Definition at line 112 of file LArClusterHelper.cc.

113 {
114  return (1 + pCluster->GetOuterPseudoLayer() - pCluster->GetInnerPseudoLayer());
115 }
float lar_content::LArClusterHelper::GetLength ( const pandora::Cluster *const  pCluster)
static

Get length of cluster.

Parameters
pClusteraddress of the cluster
Returns
the length

Definition at line 97 of file LArClusterHelper.cc.

98 {
99  return std::sqrt(LArClusterHelper::GetLengthSquared(pCluster));
100 }
static float GetLengthSquared(const pandora::Cluster *const pCluster)
Get length squared of cluster.
float lar_content::LArClusterHelper::GetLengthSquared ( const pandora::Cluster *const  pCluster)
static

Get length squared of cluster.

Parameters
pClusteraddress of the cluster
Returns
the length squared

Definition at line 65 of file LArClusterHelper.cc.

66 {
67  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
68 
69  if (orderedCaloHitList.empty())
70  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
71 
72  // ATTN In 2D case, we will actually calculate the quadrature sum of deltaX and deltaU/V/W
73  float minX(std::numeric_limits<float>::max()), maxX(-std::numeric_limits<float>::max());
74  float minY(std::numeric_limits<float>::max()), maxY(-std::numeric_limits<float>::max());
75  float minZ(std::numeric_limits<float>::max()), maxZ(-std::numeric_limits<float>::max());
76 
77  for (OrderedCaloHitList::const_iterator iter = orderedCaloHitList.begin(), iterEnd = orderedCaloHitList.end(); iter != iterEnd; ++iter)
78  {
79  for (CaloHitList::const_iterator hitIter = iter->second->begin(), hitIterEnd = iter->second->end(); hitIter != hitIterEnd; ++hitIter)
80  {
81  const CartesianVector &hitPosition((*hitIter)->GetPositionVector());
82  minX = std::min(hitPosition.GetX(), minX);
83  maxX = std::max(hitPosition.GetX(), maxX);
84  minY = std::min(hitPosition.GetY(), minY);
85  maxY = std::max(hitPosition.GetY(), maxY);
86  minZ = std::min(hitPosition.GetZ(), minZ);
87  maxZ = std::max(hitPosition.GetZ(), maxZ);
88  }
89  }
90 
91  const float deltaX(maxX - minX), deltaY(maxY - minY), deltaZ(maxZ - minZ);
92  return (deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ);
93 }
bool lar_content::LArClusterHelper::SortByInnerLayer ( const pandora::Cluster *const  pLhs,
const pandora::Cluster *const  pRhs 
)
static

Sort clusters by inner layer, then position, then pulse-height.

Parameters
pLhsaddress of first cluster
pRhsaddress of second cluster

Definition at line 658 of file LArClusterHelper.cc.

659 {
660  const unsigned int innerLayerLhs(pLhs->GetInnerPseudoLayer());
661  const unsigned int innerLayerRhs(pRhs->GetInnerPseudoLayer());
662 
663  if (innerLayerLhs != innerLayerRhs)
664  return (innerLayerLhs < innerLayerRhs);
665 
666  return SortByPosition(pLhs, pRhs);
667 }
static bool SortByPosition(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by position, then pulse-height.
bool lar_content::LArClusterHelper::SortByLayerSpan ( const pandora::Cluster *const  pLhs,
const pandora::Cluster *const  pRhs 
)
static

Sort clusters by layer span, then inner layer, then position, then pulse-height.

Parameters
pLhsaddress of first cluster
pRhsaddress of second cluster

Definition at line 645 of file LArClusterHelper.cc.

646 {
647  const unsigned int layerSpanLhs(pLhs->GetOuterPseudoLayer() - pLhs->GetInnerPseudoLayer());
648  const unsigned int layerSpanRhs(pRhs->GetOuterPseudoLayer() - pRhs->GetInnerPseudoLayer());
649 
650  if (layerSpanLhs != layerSpanRhs)
651  return (layerSpanLhs > layerSpanRhs);
652 
653  return SortByInnerLayer(pLhs, pRhs);
654 }
static bool SortByInnerLayer(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by inner layer, then position, then pulse-height.
bool lar_content::LArClusterHelper::SortByNHits ( const pandora::Cluster *const  pLhs,
const pandora::Cluster *const  pRhs 
)
static

Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.

Parameters
pLhsaddress of first cluster
pRhsaddress of second cluster

Definition at line 632 of file LArClusterHelper.cc.

633 {
634  const unsigned int nHitsLhs(pLhs->GetNCaloHits());
635  const unsigned int nHitsRhs(pRhs->GetNCaloHits());
636 
637  if (nHitsLhs != nHitsRhs)
638  return (nHitsLhs > nHitsRhs);
639 
640  return SortByLayerSpan(pLhs, pRhs);
641 }
static bool SortByLayerSpan(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by layer span, then inner layer, then position, then pulse-height.
bool lar_content::LArClusterHelper::SortByNOccupiedLayers ( const pandora::Cluster *const  pLhs,
const pandora::Cluster *const  pRhs 
)
static

Sort clusters by number of occupied layers, and by inner layer, then energy in event of a tie.

Parameters
pLhsaddress of first cluster
pRhsaddress of second cluster

Definition at line 619 of file LArClusterHelper.cc.

620 {
621  const unsigned int nOccupiedLayersLhs(pLhs->GetOrderedCaloHitList().size());
622  const unsigned int nOccupiedLayersRhs(pRhs->GetOrderedCaloHitList().size());
623 
624  if (nOccupiedLayersLhs != nOccupiedLayersRhs)
625  return (nOccupiedLayersLhs > nOccupiedLayersRhs);
626 
627  return SortByNHits(pLhs, pRhs);
628 }
static bool SortByNHits(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by number of hits, then layer span, then inner layer, then position, then pulse-height.
bool lar_content::LArClusterHelper::SortByPosition ( const pandora::Cluster *const  pLhs,
const pandora::Cluster *const  pRhs 
)
static

Sort clusters by position, then pulse-height.

Parameters
pLhsaddress of first cluster
pRhsaddress of second cluster

Definition at line 671 of file LArClusterHelper.cc.

672 {
673  const CartesianVector deltaPositionIL(pRhs->GetCentroid(pRhs->GetInnerPseudoLayer()) - pLhs->GetCentroid(pLhs->GetInnerPseudoLayer()));
674 
675  if (std::fabs(deltaPositionIL.GetZ()) > std::numeric_limits<float>::epsilon())
676  return (deltaPositionIL.GetZ() > std::numeric_limits<float>::epsilon());
677 
678  if (std::fabs(deltaPositionIL.GetX()) > std::numeric_limits<float>::epsilon())
679  return (deltaPositionIL.GetX() > std::numeric_limits<float>::epsilon());
680 
681  if (std::fabs(deltaPositionIL.GetY()) > std::numeric_limits<float>::epsilon())
682  return (deltaPositionIL.GetY() > std::numeric_limits<float>::epsilon());
683 
684  const CartesianVector deltaPositionOL(pRhs->GetCentroid(pRhs->GetOuterPseudoLayer()) - pLhs->GetCentroid(pLhs->GetOuterPseudoLayer()));
685 
686  if (std::fabs(deltaPositionOL.GetZ()) > std::numeric_limits<float>::epsilon())
687  return (deltaPositionOL.GetZ() > std::numeric_limits<float>::epsilon());
688 
689  if (std::fabs(deltaPositionOL.GetX()) > std::numeric_limits<float>::epsilon())
690  return (deltaPositionOL.GetX() > std::numeric_limits<float>::epsilon());
691 
692  if (std::fabs(deltaPositionOL.GetY()) > std::numeric_limits<float>::epsilon())
693  return (deltaPositionOL.GetY() > std::numeric_limits<float>::epsilon());
694 
695  // Use pulse height to resolve ties
696  return SortByPulseHeight(pLhs, pRhs);
697 }
static bool SortByPulseHeight(const pandora::Cluster *const pLhs, const pandora::Cluster *const pRhs)
Sort clusters by pulse-height.
bool lar_content::LArClusterHelper::SortByPulseHeight ( const pandora::Cluster *const  pLhs,
const pandora::Cluster *const  pRhs 
)
static

Sort clusters by pulse-height.

Parameters
pLhsaddress of first cluster
pRhsaddress of second cluster

Definition at line 701 of file LArClusterHelper.cc.

702 {
703  return (pLhs->GetHadronicEnergy() > pRhs->GetHadronicEnergy());
704 }
bool lar_content::LArClusterHelper::SortCoordinatesByPosition ( const pandora::CartesianVector &  lhs,
const pandora::CartesianVector &  rhs 
)
static

Sort cartesian vectors by their position (use Z, followed by X, followed by Y)

Parameters
lhsfirst point
rhssecond point

Definition at line 747 of file LArClusterHelper.cc.

748 {
749  const CartesianVector deltaPosition(rhs - lhs);
750 
751  if (std::fabs(deltaPosition.GetZ()) > std::numeric_limits<float>::epsilon())
752  return (deltaPosition.GetZ() > std::numeric_limits<float>::epsilon());
753 
754  if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
755  return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
756 
757  return (deltaPosition.GetY() > std::numeric_limits<float>::epsilon());
758 }
bool lar_content::LArClusterHelper::SortHitsByPosition ( const pandora::CaloHit *const  pLhs,
const pandora::CaloHit *const  pRhs 
)
static

Sort calo hits by their position (use Z, followed by X, followed by Y)

Parameters
pLhsaddress of first calo hit
pRhsaddress of second calo hit

Definition at line 708 of file LArClusterHelper.cc.

709 {
710  const CartesianVector deltaPosition(pRhs->GetPositionVector() - pLhs->GetPositionVector());
711 
712  if (std::fabs(deltaPosition.GetZ()) > std::numeric_limits<float>::epsilon())
713  return (deltaPosition.GetZ() > std::numeric_limits<float>::epsilon());
714 
715  if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
716  return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
717 
718  if (std::fabs(deltaPosition.GetY()) > std::numeric_limits<float>::epsilon())
719  return (deltaPosition.GetY() > std::numeric_limits<float>::epsilon());
720 
721  // Use pulse height to resolve ties
722  return SortHitsByPulseHeight(pLhs, pRhs);
723 }
static bool SortHitsByPulseHeight(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their pulse height.
bool lar_content::LArClusterHelper::SortHitsByPositionInX ( const pandora::CaloHit *const  pLhs,
const pandora::CaloHit *const  pRhs 
)
static

Sort calo hits by their position (use X, followed by Z, followed by Y)

Parameters
pLhsaddress of first calo hit
pRhsaddress of second calo hit

Definition at line 727 of file LArClusterHelper.cc.

728 {
729  const CartesianVector deltaPosition(pRhs->GetPositionVector() - pLhs->GetPositionVector());
730 
731  if (std::fabs(deltaPosition.GetX()) > std::numeric_limits<float>::epsilon())
732  return (deltaPosition.GetX() > std::numeric_limits<float>::epsilon());
733 
734  return SortHitsByPosition(pLhs, pRhs);
735 }
static bool SortHitsByPosition(const pandora::CaloHit *const pLhs, const pandora::CaloHit *const pRhs)
Sort calo hits by their position (use Z, followed by X, followed by Y)
bool lar_content::LArClusterHelper::SortHitsByPulseHeight ( const pandora::CaloHit *const  pLhs,
const pandora::CaloHit *const  pRhs 
)
static

Sort calo hits by their pulse height.

Parameters
pLhsaddress of first calo hit
pRhsaddress of second calo hit

Definition at line 739 of file LArClusterHelper.cc.

740 {
741  // TODO: Think about the correct energy to use here (should they ever be different)
742  return (pLhs->GetHadronicEnergy() > pRhs->GetHadronicEnergy());
743 }

The documentation for this class was generated from the following files: