Skip to content

Commit 85923f0

Browse files
committed
[EMCAL-688] Update ClusterFactory and fix bug in buildCluster
- Remove TMath calls with std function calls - Fix wrong comments for `thetaToEta` and `etaToTheta` in the .cxx - `buildCluster` uses the local index of cells in eta and phi for calcualting M02, M20 and dispersion. The member `mSharedCluster` would need to be set to true, to apply a correction for the local index when switching from one SM to antoher for cluster spanning two SM. This commit fixes this issue by setting `mSharedCluster` in `buildCluster`. - Add `mCellGeomBuffer` as new member which stores the geometry information of all cells of the current cluster. This way this information is only obtained ONCE instead of THREE times. - Removed unused unary operator& which can be dangerous.
1 parent b122c5f commit 85923f0

2 files changed

Lines changed: 143 additions & 151 deletions

File tree

Detectors/EMCAL/base/include/EMCALBase/ClusterFactory.h

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
// In applying this license CERN does not waive the privileges and immunities
99
// granted to it by virtue of its status as an Intergovernmental Organization
1010
// or submit itself to any jurisdiction.
11-
#ifndef ALICEO2_EMCAL_CLUSTERFACTORY_H_
12-
#define ALICEO2_EMCAL_CLUSTERFACTORY_H_
11+
#ifndef DETECTORS_EMCAL_BASE_INCLUDE_EMCALBASE_CLUSTERFACTORY_H_
12+
#define DETECTORS_EMCAL_BASE_INCLUDE_EMCALBASE_CLUSTERFACTORY_H_
1313

1414
#include "EMCALBase/Geometry.h"
1515
#include "DataFormatsEMCAL/AnalysisCluster.h"
@@ -26,8 +26,9 @@
2626

2727
#include <array>
2828
#include <span>
29-
// #include <vector>
30-
// #include <utility>
29+
#include <string>
30+
#include <tuple>
31+
#include <vector>
3132

3233
namespace o2::emcal
3334
{
@@ -173,10 +174,6 @@ class ClusterFactory
173174
/// \return Pointer to the current event
174175
AnalysisCluster* operator*() { return &mCurrentCluster; }
175176

176-
/// \brief Get reference to the current cluster
177-
/// \return Reference to the current event of the iterator
178-
AnalysisCluster& operator&() { return mCurrentCluster; }
179-
180177
/// \brief Get the index of the current event
181178
/// \return Index of the current event
182179
[[nodiscard]] int current_index() const { return mClusterID; }
@@ -221,11 +218,11 @@ class ClusterFactory
221218

222219
/// \brief Get backward start iterator
223220
/// \return Start iterator
224-
ClusterIterator rbegin() const { return ClusterIterator(*this, getNumberOfClusters() - 1, false); };
221+
ClusterIterator rbegin() const { return ClusterIterator(*this, getNumberOfClusters() - 1, false); }
225222

226223
/// \brief Get backward end iteration marker
227224
/// \return Iteration end marker
228-
ClusterIterator rend() const { return ClusterIterator(*this, -1, false); };
225+
ClusterIterator rend() const { return ClusterIterator(*this, -1, false); }
229226

230227
/// \brief Reset containers
231228
void reset();
@@ -278,14 +275,14 @@ class ClusterFactory
278275
/// \param exoticTime: time of the cell with largest energy fraction in cluster
279276
/// \param fCross: exoticity parameter (1-E_cross/E_cell^max) will be caluclated for this check
280277
/// \return bool true if cell is found exotic
281-
bool isExoticCell(short towerId, float ecell, float const exoticTime, float& fCross) const;
278+
bool isExoticCell(int16_t towerId, float ecell, float const exoticTime, float& fCross) const;
282279

283280
/// \brief Calculate the energy in the cross around the energy of a given cell.
284281
/// \param absID: controlled cell absolute ID number
285282
/// \param energy: cluster or cell max energy, used for weight calculation
286283
/// \param exoticTime time of the cell with largest energy fraction in cluster
287284
/// \return the energy in the cross around the energy of a given cell
288-
float getECross(short absID, float energy, float const exoticTime) const;
285+
float getECross(int16_t absID, float energy, float const exoticTime) const;
289286

290287
/// \param eCell: cluster cell energy
291288
/// \param eCluster: cluster or cell max energy
@@ -409,14 +406,25 @@ class ClusterFactory
409406
void evalTime(std::span<const int> inputsIndices, AnalysisCluster& clusterAnalysis) const;
410407

411408
///
412-
/// Converts Theta (Radians) to Eta (Radians)
413-
float thetaToEta(float arg) const;
409+
/// \brief Converts Theta (Radians) to Eta (Radians)
410+
/// \param theta theta
411+
float thetaToEta(float theta) const;
414412

415413
///
416-
/// Converts Eta (Radians) to Theta (Radians)
417-
float etaToTheta(float arg) const;
414+
/// \brief Converts Eta (Radians) to Theta (Radians)
415+
/// \param eta eta
416+
float etaToTheta(float eta) const;
418417

419418
private:
419+
struct CellGeomInfo {
420+
int8_t nSupMod;
421+
int8_t iphi;
422+
int8_t ieta;
423+
int8_t ietaShared;
424+
int16_t row;
425+
int16_t col;
426+
};
427+
420428
o2::emcal::Geometry* mGeomPtr = nullptr;
421429

422430
float mCoreRadius = 10; ///< The radius in which the core energy is evaluated
@@ -426,23 +434,24 @@ class ClusterFactory
426434
bool mJustCluster = kFALSE; ///< Flag to evaluates local to "tracking" c.s. transformation (B.P.).
427435
bool mLookUpInit = false; ///< Flag to check if the mLoolUpTowerToIndex is currently set. Will be checked when needed and created if not set!
428436

429-
mutable int mSuperModuleNumber = 0; ///< number identifying supermodule containing cluster, reference is cell with maximum energy.
437+
mutable int mSuperModuleNumber = 0; ///<! Number identifying supermodule containing cluster, reference is cell with maximum energy.
430438
float mDistToBadTower = -1; ///< Distance to nearest bad tower
431-
bool mSharedCluster = false; ///< States if cluster is shared by 2 SuperModules in same phi rack (0,1), (2,3) ... (10,11).
439+
mutable bool mSharedCluster = false; ///<! States if cluster is shared by 2 SuperModules in same phi rack (0,1), (2,3) ... (10,11).
432440
float mExoticCellFraction = 0.97; ///< Good cell if fraction < 1-ecross/ecell
433441
float mExoticCellDiffTime = 1e6; ///< If time of candidate to exotic and close cell is too different (in ns), it must be noisy, set amp to 0
434442
float mExoticCellMinAmplitude = 4.; ///< Check for exotic only if amplitud is larger than this value
435443
float mExoticCellInCrossMinAmplitude = 0.1; ///< Minimum energy of cells in cross, if lower not considered in cross
436444
bool mUseWeightExotic = false; ///< States if weights should be used for exotic cell cut
437445

446+
mutable std::vector<CellGeomInfo> mCellGeomBuffer; ///<! Per-cluster cell geometry cache, reused across buildCluster() calls
438447
std::span<const o2::emcal::Cluster> mClustersContainer; ///<! Container for all the clusters in the event
439448
std::span<const InputType> mInputsContainer; ///<! Container for all the cells/digits in the event
440449
std::span<const int> mCellsIndices; ///<! Container for cells indices in the event
441-
std::array<short, 17664> mLoolUpTowerToIndex{}; ///< Lookup table to match tower id with cell index, needed for exotic check
450+
std::array<int16_t, 17664> mLoolUpTowerToIndex{}; ///< Lookup table to match tower id with cell index, needed for exotic check
442451
std::span<const o2::emcal::CellLabel> mCellLabelContainer; ///<! Container for all the cell labels in the event
443452

444-
ClassDefNV(ClusterFactory, 2);
453+
ClassDefNV(ClusterFactory, 3);
445454
};
446455

447456
} // namespace o2::emcal
448-
#endif // ALICEO2_EMCAL_CLUSTERFACTORY_H_
457+
#endif // DETECTORS_EMCAL_BASE_INCLUDE_EMCALBASE_CLUSTERFACTORY_H_

0 commit comments

Comments
 (0)