Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
ClusterFitHelper.h
Go to the documentation of this file.
1
8#ifndef PANDORA_CLUSTER_FIT_HELPER_H
9#define PANDORA_CLUSTER_FIT_HELPER_H 1
10
13
14namespace pandora
15{
16
21{
22public:
28 ClusterFitPoint(const CaloHit *const pCaloHit);
29
39 ClusterFitPoint(const CartesianVector &position, const CartesianVector &cellNormalVector, const float cellSize,
40 const float energy, const unsigned int pseudoLayer);
41
47 const CartesianVector &GetPosition() const;
48
55
61 float GetCellSize() const;
62
68 float GetEnergy() const;
69
75 unsigned int GetPseudoLayer() const;
76
84 bool operator<(const ClusterFitPoint &rhs) const;
85
86private:
89 float m_cellSize;
90 float m_energy;
91 unsigned int m_pseudoLayer;
92};
93
94typedef std::vector<ClusterFitPoint> ClusterFitPointList;
95
96//------------------------------------------------------------------------------------------------------------------------------------------
97
102{
103public:
108
114 bool IsFitSuccessful() const;
115
121 const CartesianVector &GetDirection() const;
122
128 const CartesianVector &GetIntercept() const;
129
135 float GetChi2() const;
136
142 float GetRms() const;
143
149 float GetRadialDirectionCosine() const;
150
156 void SetSuccessFlag(const bool successFlag);
157
163 void SetDirection(const CartesianVector &direction);
164
170 void SetIntercept(const CartesianVector &intercept);
171
177 void SetChi2(const float chi2);
178
184 void SetRms(const float rms);
185
191 void SetRadialDirectionCosine(const float radialDirectionCosine);
192
196 void Reset();
197
198private:
205};
206
207typedef std::vector<ClusterFitResult> ClusterFitResultList;
208
209//------------------------------------------------------------------------------------------------------------------------------------------
210
215{
216public:
224 static StatusCode FitStart(const Cluster *const pCluster, const unsigned int maxOccupiedLayers, ClusterFitResult &clusterFitResult);
225
233 static StatusCode FitEnd(const Cluster *const pCluster, const unsigned int maxOccupiedLayers, ClusterFitResult &clusterFitResult);
234
241 static StatusCode FitFullCluster(const Cluster *const pCluster, ClusterFitResult &clusterFitResult);
242
251 static StatusCode FitLayers(const Cluster *const pCluster, const unsigned int startLayer, const unsigned int endLayer,
252 ClusterFitResult &clusterFitResult);
253
262 static StatusCode FitLayerCentroids(const Cluster *const pCluster, const unsigned int startLayer, const unsigned int endLayer,
263 ClusterFitResult &clusterFitResult);
264
271 static StatusCode FitPoints(ClusterFitPointList &clusterFitPointList, ClusterFitResult &clusterFitResult);
272
273private:
282 static StatusCode PerformLinearFit(const CartesianVector &centralPosition, const CartesianVector &centralDirection,
283 ClusterFitPointList &clusterFitPointList, ClusterFitResult &clusterFitResult);
284};
285
286//------------------------------------------------------------------------------------------------------------------------------------------
287//------------------------------------------------------------------------------------------------------------------------------------------
288
290{
291 return m_position;
292}
293
294//------------------------------------------------------------------------------------------------------------------------------------------
295
300
301//------------------------------------------------------------------------------------------------------------------------------------------
302
304{
305 return m_cellSize;
306}
307
308//------------------------------------------------------------------------------------------------------------------------------------------
309
310inline float ClusterFitPoint::GetEnergy() const
311{
312 return m_energy;
313}
314
315//------------------------------------------------------------------------------------------------------------------------------------------
316
317inline unsigned int ClusterFitPoint::GetPseudoLayer() const
318{
319 return m_pseudoLayer;
320}
321
322//------------------------------------------------------------------------------------------------------------------------------------------
323//------------------------------------------------------------------------------------------------------------------------------------------
324
326 m_isFitSuccessful(false),
327 m_direction(0.f, 0.f, 0.f),
328 m_intercept(0.f, 0.f, 0.f)
329{
330}
331
332//------------------------------------------------------------------------------------------------------------------------------------------
333
335{
336 return m_isFitSuccessful;
337}
338
339//------------------------------------------------------------------------------------------------------------------------------------------
340
342{
344 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
345
346 return m_direction;
347}
348
349//------------------------------------------------------------------------------------------------------------------------------------------
350
352{
354 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
355
356 return m_intercept;
357}
358
359//------------------------------------------------------------------------------------------------------------------------------------------
360
361inline float ClusterFitResult::GetChi2() const
362{
364 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
365
366 return m_chi2.Get();
367}
368
369//------------------------------------------------------------------------------------------------------------------------------------------
370
371inline float ClusterFitResult::GetRms() const
372{
374 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
375
376 return m_rms.Get();
377}
378
379//------------------------------------------------------------------------------------------------------------------------------------------
380
382{
384 throw StatusCodeException(STATUS_CODE_NOT_INITIALIZED);
385
386 return m_dirCosR.Get();
387}
388
389//------------------------------------------------------------------------------------------------------------------------------------------
390
391inline void ClusterFitResult::SetSuccessFlag(bool successFlag)
392{
393 m_isFitSuccessful = successFlag;
394}
395
396//------------------------------------------------------------------------------------------------------------------------------------------
397
399{
400 m_direction = direction;
401}
402
403//------------------------------------------------------------------------------------------------------------------------------------------
404
406{
407 m_intercept = intercept;
408}
409
410//------------------------------------------------------------------------------------------------------------------------------------------
411
412inline void ClusterFitResult::SetChi2(const float chi2)
413{
414 if (!(m_chi2 = chi2))
415 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
416}
417
418//------------------------------------------------------------------------------------------------------------------------------------------
419
420inline void ClusterFitResult::SetRms(const float rms)
421{
422 if (!(m_rms = rms))
423 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
424}
425
426//------------------------------------------------------------------------------------------------------------------------------------------
427
428inline void ClusterFitResult::SetRadialDirectionCosine(const float radialDirectionCosine)
429{
430 if (!(m_dirCosR = radialDirectionCosine))
431 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
432}
433
434//------------------------------------------------------------------------------------------------------------------------------------------
435
437{
438 m_isFitSuccessful = false;
439 m_direction.SetValues(0.f, 0.f, 0.f);
440 m_intercept.SetValues(0.f, 0.f, 0.f);
441 m_chi2.Reset();
442 m_rms.Reset();
444}
445
446} // namespace pandora
447
448#endif // #ifndef PANDORA_CLUSTER_FIT_HELPER_H
Header file for pandora input types and associated external typedefs exposed via the PandoraApi.
Header file defining relevant internal typedefs, sort and string conversion functions.
CaloHit class.
Definition CaloHit.h:26
CartesianVector class.
void SetValues(float x, float y, float z)
Set the values of cartesian vector components.
ClusterFitHelper class.
static StatusCode FitStart(const Cluster *const pCluster, const unsigned int maxOccupiedLayers, ClusterFitResult &clusterFitResult)
Fit points in first n occupied pseudolayers of a cluster.
static StatusCode FitLayers(const Cluster *const pCluster, const unsigned int startLayer, const unsigned int endLayer, ClusterFitResult &clusterFitResult)
Fit all cluster points within the specified (inclusive) pseudolayer range.
static StatusCode PerformLinearFit(const CartesianVector &centralPosition, const CartesianVector &centralDirection, ClusterFitPointList &clusterFitPointList, ClusterFitResult &clusterFitResult)
Perform linear fit to cluster fit points.
static StatusCode FitEnd(const Cluster *const pCluster, const unsigned int maxOccupiedLayers, ClusterFitResult &clusterFitResult)
Fit points in last n occupied pseudolayers of a cluster.
static StatusCode FitFullCluster(const Cluster *const pCluster, ClusterFitResult &clusterFitResult)
Fit all points in a cluster.
static StatusCode FitLayerCentroids(const Cluster *const pCluster, const unsigned int startLayer, const unsigned int endLayer, ClusterFitResult &clusterFitResult)
Fit all cluster centroids within the specified (inclusive) pseudolayer range.
static StatusCode FitPoints(ClusterFitPointList &clusterFitPointList, ClusterFitResult &clusterFitResult)
Perform linear regression of x vs d and y vs d and z vs d (assuming same error on all hits)
ClusterFitPoint class.
unsigned int m_pseudoLayer
The pseudolayer in which the point was recorded.
float m_cellSize
The size of the cell in which the point was recorded.
float m_energy
The energy deposited in the cell in which the point was recorded.
const CartesianVector & GetCellNormalVector() const
Get the unit normal vector to the cell in which the point was recorded.
CartesianVector m_position
The position vector of the fit point.
bool operator<(const ClusterFitPoint &rhs) const
operator< to define an ordering for cluster fit points
float GetCellSize() const
Get the size of the cell in which the point was recorded.
float GetEnergy() const
Get the energy deposited in the cell in which the point was recorded.
const CartesianVector & GetPosition() const
Get the position vector of the fit point.
CartesianVector m_cellNormalVector
The unit normal vector to the cell in which the point was recorded.
unsigned int GetPseudoLayer() const
Get the pseudolayer in which the point was recorded.
ClusterFitResult class.
const CartesianVector & GetDirection() const
Get the fit direction.
InputFloat m_chi2
The chi2 value for the fit.
float GetRms() const
Get the fit rms.
void SetSuccessFlag(const bool successFlag)
Set the fit success flag.
CartesianVector m_direction
The best fit direction.
CartesianVector m_intercept
The best fit intercept.
bool IsFitSuccessful() const
Query whether fit was successful.
float GetChi2() const
Get the fit ch2.
ClusterFitResult()
Default constructor.
float GetRadialDirectionCosine() const
Get the fit direction cosine w.r.t. the radial direction.
InputFloat m_dirCosR
The direction cosine wrt to the radial direction.
const CartesianVector & GetIntercept() const
Get the fit intercept.
void SetRms(const float rms)
Set the fit rms.
void SetRadialDirectionCosine(const float radialDirectionCosine)
Set the fit direction cosine w.r.t. the radial direction.
void SetDirection(const CartesianVector &direction)
Set the fit direction.
void Reset()
Reset the cluster fit result.
bool m_isFitSuccessful
Whether the fit was successful.
InputFloat m_rms
The rms of the fit.
void SetIntercept(const CartesianVector &intercept)
Set the fit intercept.
void SetChi2(const float chi2)
Set the fit chi2.
Cluster class.
Definition Cluster.h:31
void Reset()
Reset the pandora type.
const T & Get() const
Get the value held by the pandora type.
StatusCodeException class.
std::vector< ClusterFitResult > ClusterFitResultList
std::vector< ClusterFitPoint > ClusterFitPointList
StatusCode
The StatusCode enum.