11#ifndef DETECTORS_EMCAL_BASE_INCLUDE_EMCALBASE_CLUSTERFACTORY_H_
12#define DETECTORS_EMCAL_BASE_INCLUDE_EMCALBASE_CLUSTERFACTORY_H_
25#include <fmt/format.h>
43template <
class InputType>
55 mClusterID(clusterIndex),
56 mMaxClusters(maxClusters),
57 mErrorMessage(
fmt::
format(
"Cluster out of range: %d, max %d", mClusterID, mMaxClusters))
66 [[nodiscard]] const
char*
what() const noexcept final {
return mErrorMessage.data(); }
79 std::string mErrorMessage;
89 mCellIndex(cellIndex),
90 mMaxCellIndex(maxCellIndex),
91 mErrorMessage(
fmt::
format(
"Cell Index out of range: %d, max %d", mCellIndex, mMaxCellIndex))
100 [[nodiscard]] const
char*
what() const noexcept final {
return mErrorMessage.data(); }
112 int mMaxCellIndex = 0;
113 std::string mErrorMessage;
128 [[nodiscard]] const
char*
what() const noexcept final {
return "Geometry not set"; }
185 bool mForward =
true;
197 ClusterFactory(std::span<const o2::emcal::Cluster> clustersContainer, std::span<const InputType> inputsContainer, std::span<const int> cellsIndices);
239 mJustCluster = justCluster;
261 static void getDeffW0(
const Double_t esum, Double_t& deff, Double_t& w0);
278 bool isExoticCell(int16_t towerId,
float ecell,
float const exoticTime,
float& fCross)
const;
285 float getECross(int16_t absID,
float energy,
float const exoticTime)
const;
312 Double_t
tMaxInCm(
const Double_t e = 0.0,
const int key = 0)
const;
334 void setContainer(std::span<const o2::emcal::Cluster> clusterContainer, std::span<const InputType> cellContainer, std::span<const int> indicesContainer, std::span<const o2::emcal::CellLabel> cellLabelContainer = {})
336 mClustersContainer = clusterContainer;
337 mInputsContainer = cellContainer;
338 mCellsIndices = indicesContainer;
342 if (!cellLabelContainer.empty()) {
343 mCellLabelContainer = cellLabelContainer;
349 mLoolUpTowerToIndex.fill(-1);
350 for (
auto iCellIndex : mCellsIndices) {
351 mLoolUpTowerToIndex[mInputsContainer[iCellIndex].getTower()] = iCellIndex;
358 return mClustersContainer.size();
377 [[nodiscard]] const
char*
what() const noexcept final {
return "Lookup table not initialized, exotics evaluation not possible!"; }
419 struct CellGeomInfo {
430 float mCoreRadius = 10;
432 float mLogWeight = 4.5;
434 bool mJustCluster = kFALSE;
435 bool mLookUpInit =
false;
437 mutable int mSuperModuleNumber = 0;
438 float mDistToBadTower = -1;
439 mutable bool mSharedCluster =
false;
440 float mExoticCellFraction = 0.97;
441 float mExoticCellDiffTime = 1e6;
442 float mExoticCellMinAmplitude = 4.;
443 float mExoticCellInCrossMinAmplitude = 0.1;
444 bool mUseWeightExotic =
false;
446 mutable std::vector<CellGeomInfo> mCellGeomBuffer;
447 std::span<const o2::emcal::Cluster> mClustersContainer;
448 std::span<const InputType> mInputsContainer;
449 std::span<const int> mCellsIndices;
450 std::array<int16_t, 17664> mLoolUpTowerToIndex{};
451 std::span<const o2::emcal::CellLabel> mCellLabelContainer;
Cluster class for kinematic cluster parametersported from AliVCluster in AliRoot.
int getMaxNumberOfCellIndexs() const
Get the maximum number of cell indices handled by the cluster factory.
CellIndexRangeException(int cellIndex, int maxCellIndex)
Constructor defining the error.
~CellIndexRangeException() noexcept final=default
Destructor.
const char * what() const noexcept final
Provide error message.
int getCellIndex() const
Get the index of the cell raising the exception.
ClusterIterator & operator--()
Prefix decrementation operator.
AnalysisCluster * operator*()
Get pointer to the current cluster.
bool operator!=(const ClusterIterator &rhs) const
Check for not equalness.
int current_index() const
Get the index of the current event.
~ClusterIterator()=default
Destructor.
bool operator==(const ClusterIterator &rhs) const
Check for equalness.
ClusterIterator & operator++()
Prefix incrementation operator.
const char * what() const noexcept final
Provide error message.
int getMaxNumberOfClusters() const
Get the maximum number of events handled by the event handler.
~ClusterRangeException() noexcept final=default
Destructor.
int getClusterID() const
Get the ID of the event raising the exception.
ClusterRangeException(int clusterIndex, int maxClusters)
Constructor defining the error.
const char * what() const noexcept final
Provide error message.
GeometryNotSetException()=default
Constructor.
~GeometryNotSetException() noexcept final=default
Destructor.
Exception handling uninitialized look up table.
UninitLookUpTableException()=default
constructor
const char * what() const noexcept final
Access to error message of the exception.
~UninitLookUpTableException() noexcept final=default
Destructor.
EMCal clusters factory Ported from class AliEMCALcluster.
ClusterIterator rend() const
Get backward end iteration marker.
ClusterIterator rbegin() const
Get backward start iterator.
void reset()
Reset containers.
float GetCellWeight(float eCell, float eCluster) const
return weight of cell for shower shape calculation
int getSuperModuleNumber() const
~ClusterFactory()=default
Destructor.
ClusterFactory(const ClusterFactory &rp)=default
Copy constructor.
float etaToTheta(float eta) const
Converts Eta (Radians) to Theta (Radians)
void doEvalLocal2tracking(bool justCluster)
void evalGlobalPosition(std::span< const int > inputsIndices, AnalysisCluster &cluster) const
Calculates the center of gravity in the global ALICE coordinates.
bool isExoticCell(int16_t towerId, float ecell, float const exoticTime, float &fCross) const
Look to cell neighbourhood and reject if it seems exotic.
std::tuple< int, float, float, bool > getMaximalEnergyIndex(std::span< const int > inputsIndices) const
Finds the maximum energy in the cluster and computes the Summed amplitude of digits/cells.
float getExoticCellDiffTime() const
void setGeometry(o2::emcal::Geometry *geometry)
Initialize Cluster Factory with geometry.
bool getLookUpInit() const
float getECross(int16_t absID, float energy, float const exoticTime) const
Calculate the energy in the cross around the energy of a given cell.
int getMultiplicityAtLevel(float level, std::span< const int > inputsIndices, AnalysisCluster &clusterAnalysis) const
Calculates the multiplicity of digits/cells with energy larger than level*energy.
Double_t tMaxInCm(const Double_t e=0.0, const int key=0) const
void evalTime(std::span< const int > inputsIndices, AnalysisCluster &clusterAnalysis) const
Time is set to the time of the digit with the maximum energy.
void setExoticCellFraction(float exoticCellFraction)
void evalLocalPosition(std::span< const int > inputsIndices, AnalysisCluster &cluster) const
Calculates the center of gravity in the local EMCAL-module coordinates.
static void getDeffW0(const Double_t esum, Double_t &deff, Double_t &w0)
float getCoreRadius() const
ClusterFactory()=default
Dummy constructor.
void setContainer(std::span< const o2::emcal::Cluster > clusterContainer, std::span< const InputType > cellContainer, std::span< const int > indicesContainer, std::span< const o2::emcal::CellLabel > cellLabelContainer={})
bool getUseWeightExotic() const
ClusterIterator end() const
Get forward end iteration marker.
void setExoticCellInCrossMinAmplitude(float exoticCellInCrossMinAmplitude)
float GetECALogWeight() const
void evalLocalPositionFit(double deff, double mLogWeight, double phiSlope, std::span< const int > inputsIndices, AnalysisCluster &clusterAnalysis) const
evaluates local position of clusters in SM
void setExoticCellMinAmplitude(float exoticCellMinAmplitude)
bool sharedCluster() const
void evalCoreEnergy(std::span< const int > inputsIndices, AnalysisCluster &clusterAnalysis) const
ClusterFactory & operator=(const ClusterFactory &cf)=default
Assignment operator.
void evalDispersion(std::span< const int > inputsIndices, AnalysisCluster &clusterAnalysis) const
Calculates the dispersion of the shower at the origin of the cluster in cell units.
void setUseWeightExotic(bool useWeightExotic)
ClusterIterator begin() const
Get forward start iterator.
void evalElipsAxis(std::span< const int > inputsIndices, AnalysisCluster &clusterAnalysis) const
Calculates the axis of the shower ellipsoid in eta and phi in cell units.
void setCoreRadius(float radius)
float getExoticCellInCrossMinAmplitude() const
float getExoticCellMinAmplitude() const
int getNumberOfClusters() const
void evalLocal2TrackingCSTransform() const
void setSharedCluster(bool s)
float thetaToEta(float theta) const
Converts Theta (Radians) to Eta (Radians)
float getExoticCellFraction() const
void SetECALogWeight(Float_t w)
AnalysisCluster buildCluster(int index, o2::emcal::ClusterLabel *clusterLabel=nullptr) const
evaluates cluster parameters: position, shower shape, primaries ...
void evalNExMax(std::span< const int > inputsIndices, AnalysisCluster &clusterAnalysis) const
Calculate the number of local maxima in the cluster.
void setExoticCellDiffTime(float exoticCellDiffTime)
cluster class for MC particle IDs and their respective energy fraction
EMCAL geometry definition.
GLubyte GLubyte GLubyte GLubyte w
GLint GLint GLsizei GLint GLenum format