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

LArHitWidthHelper class. More...

#include <LArHitWidthHelper.h>

Classes

class  ClusterParameters
 ClusterParameters class. More...
 
class  ConstituentHit
 ConstituentHit class. More...
 
class  SortByHigherXExtrema
 SortByHigherExtrema class. More...
 

Public Types

typedef std::vector
< ConstituentHit
ConstituentHitVector
 
typedef std::unordered_map
< const pandora::Cluster
*, const ClusterParameters
ClusterToParametersMap
 

Static Public Member Functions

static const ClusterParametersGetClusterParameters (const pandora::Cluster *const pCluster, const ClusterToParametersMap &clusterToParametersMap)
 Return the cluster parameters of a given cluster, exception thrown if not found in map [cluster -> cluster parameter] or if map is empty. More...
 
static unsigned int GetNProposedConstituentHits (const pandora::Cluster *const pCluster, const float maxConstituentHitWidth, const float hitWidthScalingFactor)
 Return the number of constituent hits that a given cluster would be broken into. More...
 
static ConstituentHitVector GetConstituentHits (const pandora::Cluster *const pCluster, const float maxConstituentHitWidth, const float hitWidthScalingFactor, const bool isUniform)
 Break up the cluster hits into constituent hits. More...
 
static void SplitHitIntoConstituents (const pandora::CaloHit *const pCaloHit, const pandora::Cluster *const pCluster, const unsigned int numberOfConstituentHits, const float constituentHitWidth, ConstituentHitVector &constituentHitVector)
 Break up the calo hit into constituent hits. More...
 
static
pandora::CartesianPointVector 
GetConstituentHitPositionVector (const ConstituentHitVector &constituentHitVector)
 Obtain a vector of the contituent hit central positions. More...
 
static float GetTotalClusterWeight (const ConstituentHitVector &constituentHitVector)
 Sum the widths of constituent hits. More...
 
static float GetOriginalTotalClusterWeight (const pandora::Cluster *const pCluster)
 Sum the widths of the original, unscaled hits contained within a cluster. More...
 
static pandora::CartesianVector GetExtremalCoordinatesLowerX (const ConstituentHitVector &constituentHitVector)
 Return the lower x extremal point of the constituent hits. More...
 
static pandora::CartesianVector GetExtremalCoordinatesHigherX (const ConstituentHitVector &constituentHitVector)
 Return the higher x extremal point of the constituent hits. More...
 
static void GetExtremalCoordinatesX (const ConstituentHitVector &constituentHitVector, pandora::CartesianVector &lowerXCoordinate, pandora::CartesianVector &higherXCoordinate)
 Calculate the higher and lower x extremal points of the constituent hits. More...
 
static pandora::CartesianVector GetClosestPointToLine2D (const pandora::CartesianVector &lineStart, const pandora::CartesianVector &lineDirection, const pandora::CaloHit *const pCaloHit)
 Consider the hit width to find the closest position of a calo hit to a specified line. More...
 
static float GetClosestDistanceToPoint2D (const pandora::CaloHit *const pCaloHit, const pandora::CartesianVector &point2D)
 Consider the hit width to find the smallest distance between a calo hit and a given point. More...
 

Detailed Description

LArHitWidthHelper class.

Definition at line 19 of file LArHitWidthHelper.h.

Member Typedef Documentation

typedef std::unordered_map<const pandora::Cluster *, const ClusterParameters> lar_content::LArHitWidthHelper::ClusterToParametersMap

Definition at line 160 of file LArHitWidthHelper.h.

Definition at line 87 of file LArHitWidthHelper.h.

Member Function Documentation

float lar_content::LArHitWidthHelper::GetClosestDistanceToPoint2D ( const pandora::CaloHit *const  pCaloHit,
const pandora::CartesianVector &  point2D 
)
static

Consider the hit width to find the smallest distance between a calo hit and a given point.

Parameters
pCaloHitthe input calo hit
point2Dthe position
Returns
the smallest distance

Definition at line 306 of file LArHitWidthHelper.cc.

307 {
308  const CartesianVector &hitPosition(pCaloHit->GetPositionVector());
309  const float hitWidth(pCaloHit->GetCellSize1());
310  const float hitLowXEdge(hitPosition.GetX() - (hitWidth * 0.5f));
311  const float hitHighXEdge(hitPosition.GetX() + (hitWidth * 0.5f));
312  const float modDeltaZ(std::fabs(hitPosition.GetZ() - point2D.GetZ()));
313 
314  if ((hitLowXEdge < point2D.GetX()) && (hitHighXEdge > point2D.GetX()))
315  return modDeltaZ;
316 
317  const float deltaX = hitLowXEdge > point2D.GetX() ? (point2D.GetX() - hitLowXEdge) : (point2D.GetX() - hitHighXEdge);
318 
319  return std::sqrt((deltaX * deltaX) + (modDeltaZ * modDeltaZ));
320 }
CartesianVector lar_content::LArHitWidthHelper::GetClosestPointToLine2D ( const pandora::CartesianVector &  lineStart,
const pandora::CartesianVector &  lineDirection,
const pandora::CaloHit *const  pCaloHit 
)
static

Consider the hit width to find the closest position of a calo hit to a specified line.

Parameters
lineStartthe start position of the line
lineDirectionthe direction of the line
pCaloHitthe input calo hit
Returns
the closest position

Definition at line 281 of file LArHitWidthHelper.cc.

283 {
284  const CartesianVector &hitPosition(pCaloHit->GetPositionVector());
285 
286  if (std::fabs(lineDirection.GetZ()) < std::numeric_limits<float>::epsilon())
287  return hitPosition;
288 
289  float xOnLine(lineStart.GetX());
290  if (std::fabs(lineDirection.GetX()) > std::numeric_limits<float>::epsilon())
291  {
292  const float gradient(lineDirection.GetZ() / lineDirection.GetX());
293  xOnLine += ((hitPosition.GetZ() - lineStart.GetZ()) / gradient);
294  }
295 
296  const float &hitWidth(pCaloHit->GetCellSize1());
297  const float hitLowXEdge(hitPosition.GetX() - (hitWidth * 0.5f));
298  const float hitHighXEdge(hitPosition.GetX() + (hitWidth * 0.5f));
299  const float closestPointX(xOnLine < hitLowXEdge ? hitLowXEdge : xOnLine > hitHighXEdge ? hitHighXEdge : xOnLine);
300 
301  return CartesianVector(closestPointX, 0.f, hitPosition.GetZ());
302 }
const LArHitWidthHelper::ClusterParameters & lar_content::LArHitWidthHelper::GetClusterParameters ( const pandora::Cluster *const  pCluster,
const ClusterToParametersMap clusterToParametersMap 
)
static

Return the cluster parameters of a given cluster, exception thrown if not found in map [cluster -> cluster parameter] or if map is empty.

Parameters
pClusterthe input cluster
clusterToParametersMapthe map [cluster -> cluster parameter]
Returns
the cluster parameters of the input cluster

Definition at line 74 of file LArHitWidthHelper.cc.

76 {
77  if (clusterToParametersMap.empty())
78  throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
79 
80  const auto clusterParametersIter(clusterToParametersMap.find(pCluster));
81 
82  if (clusterParametersIter == clusterToParametersMap.end())
83  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
84 
85  return clusterParametersIter->second;
86 }
CartesianPointVector lar_content::LArHitWidthHelper::GetConstituentHitPositionVector ( const ConstituentHitVector constituentHitVector)
static

Obtain a vector of the contituent hit central positions.

Parameters
constituentHitVectorthe input vector of contituent hits
Returns
a vector of constituent hit central positions

Definition at line 223 of file LArHitWidthHelper.cc.

224 {
225  CartesianPointVector constituentHitPositionVector;
226 
227  for (const ConstituentHit &constituentHit : constituentHitVector)
228  constituentHitPositionVector.push_back(constituentHit.GetPositionVector());
229 
230  return constituentHitPositionVector;
231 }
LArHitWidthHelper::ConstituentHitVector lar_content::LArHitWidthHelper::GetConstituentHits ( const pandora::Cluster *const  pCluster,
const float  maxConstituentHitWidth,
const float  hitWidthScalingFactor,
const bool  isUniform 
)
static

Break up the cluster hits into constituent hits.

Parameters
pClusterthe input cluster
maxConstituentHitWidththe maximum width of a constituent hit
hitWidthScalingFactorthe constituent hit width scaling factor
isUniformwhether to break up the hit into uniform constituent hits (and pad the hit) or not in the non-uniform case constituent hits from different hits may have different weights
Returns
the vector of constituent hits

Definition at line 120 of file LArHitWidthHelper.cc.

122 {
123  if (maxConstituentHitWidth < std::numeric_limits<float>::epsilon())
124  {
125  std::cout << "LArHitWidthHelper::GetConstituentHits - Negative or equivalent to zero constitent hit width not allowed" << std::endl;
126  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
127  }
128 
129  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
130 
131  if (orderedCaloHitList.empty())
132  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
133 
134  ConstituentHitVector constituentHitVector;
135  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
136  {
137  for (const CaloHit *const pCaloHit : *mapEntry.second)
138  {
139  const float hitWidth = pCaloHit->GetCellSize1() * hitWidthScalingFactor;
140  const unsigned int numberOfConstituentHits = std::ceil(hitWidth / maxConstituentHitWidth);
141  if (isUniform)
142  {
143  LArHitWidthHelper::SplitHitIntoConstituents(pCaloHit, pCluster, numberOfConstituentHits, maxConstituentHitWidth, constituentHitVector);
144  }
145  else
146  {
147  const float constituentHitWidth = hitWidth / numberOfConstituentHits;
148  LArHitWidthHelper::SplitHitIntoConstituents(pCaloHit, pCluster, numberOfConstituentHits, constituentHitWidth, constituentHitVector);
149  }
150  }
151  }
152 
153  return constituentHitVector;
154 }
static void SplitHitIntoConstituents(const pandora::CaloHit *const pCaloHit, const pandora::Cluster *const pCluster, const unsigned int numberOfConstituentHits, const float constituentHitWidth, ConstituentHitVector &constituentHitVector)
Break up the calo hit into constituent hits.
std::vector< ConstituentHit > ConstituentHitVector
BEGIN_PROLOG could also be cout
CartesianVector lar_content::LArHitWidthHelper::GetExtremalCoordinatesHigherX ( const ConstituentHitVector constituentHitVector)
static

Return the higher x extremal point of the constituent hits.

Parameters
constituentHitVectorthe input vector of contituent hits
Returns
the higher x extremal point of the constituent hits

Definition at line 245 of file LArHitWidthHelper.cc.

246 {
247  CartesianVector lowerXCoordinate(0.f, 0.f, 0.f), higherXCoordinate(0.f, 0.f, 0.f);
248  LArHitWidthHelper::GetExtremalCoordinatesX(constituentHitVector, lowerXCoordinate, higherXCoordinate);
249 
250  return higherXCoordinate;
251 }
static void GetExtremalCoordinatesX(const ConstituentHitVector &constituentHitVector, pandora::CartesianVector &lowerXCoordinate, pandora::CartesianVector &higherXCoordinate)
Calculate the higher and lower x extremal points of the constituent hits.
CartesianVector lar_content::LArHitWidthHelper::GetExtremalCoordinatesLowerX ( const ConstituentHitVector constituentHitVector)
static

Return the lower x extremal point of the constituent hits.

Parameters
constituentHitVectorthe input vector of contituent hits
Returns
the lower x extremal point of the constituent hits

Definition at line 235 of file LArHitWidthHelper.cc.

236 {
237  CartesianVector lowerXCoordinate(0.f, 0.f, 0.f), higherXCoordinate(0.f, 0.f, 0.f);
238  LArHitWidthHelper::GetExtremalCoordinatesX(constituentHitVector, lowerXCoordinate, higherXCoordinate);
239 
240  return lowerXCoordinate;
241 }
static void GetExtremalCoordinatesX(const ConstituentHitVector &constituentHitVector, pandora::CartesianVector &lowerXCoordinate, pandora::CartesianVector &higherXCoordinate)
Calculate the higher and lower x extremal points of the constituent hits.
void lar_content::LArHitWidthHelper::GetExtremalCoordinatesX ( const ConstituentHitVector constituentHitVector,
pandora::CartesianVector &  lowerXCoordinate,
pandora::CartesianVector &  higherXCoordinate 
)
static

Calculate the higher and lower x extremal points of the constituent hits.

Parameters
constituentHitVectorthe input vector of contituent hits
lowerXCoordinatethe lower x extremal point
higherXCoordinatethe higher x extremal point

Definition at line 255 of file LArHitWidthHelper.cc.

257 {
258  const CartesianPointVector &constituentHitPositionVector(GetConstituentHitPositionVector(constituentHitVector));
259 
260  CartesianVector innerCoordinate(0.f, 0.f, 0.f), outerCoordinate(0.f, 0.f, 0.f);
261  LArClusterHelper::GetExtremalCoordinates(constituentHitPositionVector, innerCoordinate, outerCoordinate);
262 
263  // set the lower/higher XCoordinate (in the event of a tie, use z)
264  const float deltaX(outerCoordinate.GetX() - innerCoordinate.GetX());
265  const float deltaZ(outerCoordinate.GetZ() - innerCoordinate.GetZ());
266 
267  if ((deltaX > 0.f) || ((std::fabs(deltaX) < std::numeric_limits<float>::epsilon()) && (deltaZ > 0.f)))
268  {
269  lowerXCoordinate = innerCoordinate;
270  higherXCoordinate = outerCoordinate;
271  }
272  else
273  {
274  lowerXCoordinate = outerCoordinate;
275  higherXCoordinate = innerCoordinate;
276  }
277 }
static pandora::CartesianPointVector GetConstituentHitPositionVector(const ConstituentHitVector &constituentHitVector)
Obtain a vector of the contituent hit central positions.
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) ...
unsigned int lar_content::LArHitWidthHelper::GetNProposedConstituentHits ( const pandora::Cluster *const  pCluster,
const float  maxConstituentHitWidth,
const float  hitWidthScalingFactor 
)
static

Return the number of constituent hits that a given cluster would be broken into.

Parameters
pClusterthe input cluster
maxConstituentHitWidththe maximum width of a constituent hit
hitWidthScalingFactorthe constituent hit width scaling factor
Returns
the number of constituent hits the cluster would be broken into

Definition at line 90 of file LArHitWidthHelper.cc.

91 {
92  if (maxConstituentHitWidth < std::numeric_limits<float>::epsilon())
93  {
94  std::cout << "LArHitWidthHelper::GetConstituentHits - Negative or equivalent to zero constitent hit width not allowed" << std::endl;
95  throw StatusCodeException(STATUS_CODE_NOT_ALLOWED);
96  }
97 
98  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
99 
100  if (orderedCaloHitList.empty())
101  throw StatusCodeException(STATUS_CODE_NOT_FOUND);
102 
103  unsigned int totalConstituentHits(0);
104  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
105  {
106  for (const CaloHit *const pCaloHit : *mapEntry.second)
107  {
108  const float hitWidth = pCaloHit->GetCellSize1() * hitWidthScalingFactor;
109  const unsigned int numberOfConstituentHits = std::ceil(hitWidth / maxConstituentHitWidth);
110 
111  totalConstituentHits += numberOfConstituentHits;
112  }
113  }
114 
115  return totalConstituentHits;
116 }
BEGIN_PROLOG could also be cout
float lar_content::LArHitWidthHelper::GetOriginalTotalClusterWeight ( const pandora::Cluster *const  pCluster)
static

Sum the widths of the original, unscaled hits contained within a cluster.

Parameters
pClusterthe input cluster
Returns
the total weight sum

Definition at line 207 of file LArHitWidthHelper.cc.

208 {
209  float clusterWeight(0.f);
210  const OrderedCaloHitList &orderedCaloHitList(pCluster->GetOrderedCaloHitList());
211 
212  for (const OrderedCaloHitList::value_type &mapEntry : orderedCaloHitList)
213  {
214  for (const CaloHit *const pCaloHit : *mapEntry.second)
215  clusterWeight += pCaloHit->GetCellSize1();
216  }
217 
218  return clusterWeight;
219 }
float lar_content::LArHitWidthHelper::GetTotalClusterWeight ( const ConstituentHitVector constituentHitVector)
static

Sum the widths of constituent hits.

Parameters
constituentHitVectorthe input vector of contituent hits
Returns
the total weight sum

Definition at line 196 of file LArHitWidthHelper.cc.

197 {
198  float clusterWeight(0.f);
199  for (const ConstituentHit &constituentHit : constituentHitVector)
200  clusterWeight += constituentHit.GetHitWidth();
201 
202  return clusterWeight;
203 }
void lar_content::LArHitWidthHelper::SplitHitIntoConstituents ( const pandora::CaloHit *const  pCaloHit,
const pandora::Cluster *const  pCluster,
const unsigned int  numberOfConstituentHits,
const float  constituentHitWidth,
ConstituentHitVector constituentHitVector 
)
static

Break up the calo hit into constituent hits.

Parameters
pCaloHitthe input calo hit
pClusterthe parent cluster
numberOfConstituentHitsthe number of constituent hits the hit will be broken into
constituentHitWidththe hit width of the constituent hits
constituentHitVectorthe input vector to which to add the contituent hits

Definition at line 158 of file LArHitWidthHelper.cc.

160 {
161  const CartesianVector &hitCenter(pCaloHit->GetPositionVector());
162  const bool isOdd(numberOfConstituentHits % 2 == 1);
163  float xDistanceFromCenter(0.f);
164 
165  // find constituent hit centers by moving out from the original hit center position
166  unsigned int loopIterations(std::ceil(numberOfConstituentHits / 2.0));
167  for (unsigned int i = 0; i < loopIterations; ++i)
168  {
169  if (i == 0)
170  {
171  if (isOdd)
172  {
173  constituentHitVector.push_back(ConstituentHit(hitCenter, constituentHitWidth, pCluster));
174  continue;
175  }
176  else
177  {
178  xDistanceFromCenter += constituentHitWidth / 2;
179  }
180  }
181  else
182  {
183  xDistanceFromCenter += constituentHitWidth;
184  }
185 
186  CartesianVector positivePosition(hitCenter + CartesianVector(xDistanceFromCenter, 0.f, 0.f)),
187  negativePosition(hitCenter - CartesianVector(xDistanceFromCenter, 0.f, 0.f));
188 
189  constituentHitVector.push_back(ConstituentHit(positivePosition, constituentHitWidth, pCluster));
190  constituentHitVector.push_back(ConstituentHit(negativePosition, constituentHitWidth, pCluster));
191  }
192 }

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