From 85923f02ff9d278971cb1bb6a5d659b28012eedc Mon Sep 17 00:00:00 2001 From: Marvin Hemmer Date: Fri, 11 Sep 2026 17:23:50 +0200 Subject: [PATCH] [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. --- .../base/include/EMCALBase/ClusterFactory.h | 51 ++-- Detectors/EMCAL/base/src/ClusterFactory.cxx | 243 ++++++++---------- 2 files changed, 143 insertions(+), 151 deletions(-) diff --git a/Detectors/EMCAL/base/include/EMCALBase/ClusterFactory.h b/Detectors/EMCAL/base/include/EMCALBase/ClusterFactory.h index 289fe7bf853f9..6b9e51bee842f 100644 --- a/Detectors/EMCAL/base/include/EMCALBase/ClusterFactory.h +++ b/Detectors/EMCAL/base/include/EMCALBase/ClusterFactory.h @@ -8,8 +8,8 @@ // In applying this license CERN does not waive the privileges and immunities // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. -#ifndef ALICEO2_EMCAL_CLUSTERFACTORY_H_ -#define ALICEO2_EMCAL_CLUSTERFACTORY_H_ +#ifndef DETECTORS_EMCAL_BASE_INCLUDE_EMCALBASE_CLUSTERFACTORY_H_ +#define DETECTORS_EMCAL_BASE_INCLUDE_EMCALBASE_CLUSTERFACTORY_H_ #include "EMCALBase/Geometry.h" #include "DataFormatsEMCAL/AnalysisCluster.h" @@ -26,8 +26,9 @@ #include #include -// #include -// #include +#include +#include +#include namespace o2::emcal { @@ -173,10 +174,6 @@ class ClusterFactory /// \return Pointer to the current event AnalysisCluster* operator*() { return &mCurrentCluster; } - /// \brief Get reference to the current cluster - /// \return Reference to the current event of the iterator - AnalysisCluster& operator&() { return mCurrentCluster; } - /// \brief Get the index of the current event /// \return Index of the current event [[nodiscard]] int current_index() const { return mClusterID; } @@ -221,11 +218,11 @@ class ClusterFactory /// \brief Get backward start iterator /// \return Start iterator - ClusterIterator rbegin() const { return ClusterIterator(*this, getNumberOfClusters() - 1, false); }; + ClusterIterator rbegin() const { return ClusterIterator(*this, getNumberOfClusters() - 1, false); } /// \brief Get backward end iteration marker /// \return Iteration end marker - ClusterIterator rend() const { return ClusterIterator(*this, -1, false); }; + ClusterIterator rend() const { return ClusterIterator(*this, -1, false); } /// \brief Reset containers void reset(); @@ -278,14 +275,14 @@ class ClusterFactory /// \param exoticTime: time of the cell with largest energy fraction in cluster /// \param fCross: exoticity parameter (1-E_cross/E_cell^max) will be caluclated for this check /// \return bool true if cell is found exotic - bool isExoticCell(short towerId, float ecell, float const exoticTime, float& fCross) const; + bool isExoticCell(int16_t towerId, float ecell, float const exoticTime, float& fCross) const; /// \brief Calculate the energy in the cross around the energy of a given cell. /// \param absID: controlled cell absolute ID number /// \param energy: cluster or cell max energy, used for weight calculation /// \param exoticTime time of the cell with largest energy fraction in cluster /// \return the energy in the cross around the energy of a given cell - float getECross(short absID, float energy, float const exoticTime) const; + float getECross(int16_t absID, float energy, float const exoticTime) const; /// \param eCell: cluster cell energy /// \param eCluster: cluster or cell max energy @@ -409,14 +406,25 @@ class ClusterFactory void evalTime(std::span inputsIndices, AnalysisCluster& clusterAnalysis) const; /// - /// Converts Theta (Radians) to Eta (Radians) - float thetaToEta(float arg) const; + /// \brief Converts Theta (Radians) to Eta (Radians) + /// \param theta theta + float thetaToEta(float theta) const; /// - /// Converts Eta (Radians) to Theta (Radians) - float etaToTheta(float arg) const; + /// \brief Converts Eta (Radians) to Theta (Radians) + /// \param eta eta + float etaToTheta(float eta) const; private: + struct CellGeomInfo { + int8_t nSupMod; + int8_t iphi; + int8_t ieta; + int8_t ietaShared; + int16_t row; + int16_t col; + }; + o2::emcal::Geometry* mGeomPtr = nullptr; float mCoreRadius = 10; ///< The radius in which the core energy is evaluated @@ -426,23 +434,24 @@ class ClusterFactory bool mJustCluster = kFALSE; ///< Flag to evaluates local to "tracking" c.s. transformation (B.P.). bool mLookUpInit = false; ///< Flag to check if the mLoolUpTowerToIndex is currently set. Will be checked when needed and created if not set! - mutable int mSuperModuleNumber = 0; ///< number identifying supermodule containing cluster, reference is cell with maximum energy. + mutable int mSuperModuleNumber = 0; /// mCellGeomBuffer; /// mClustersContainer; /// mInputsContainer; /// mCellsIndices; /// mLoolUpTowerToIndex{}; ///< Lookup table to match tower id with cell index, needed for exotic check + std::array mLoolUpTowerToIndex{}; ///< Lookup table to match tower id with cell index, needed for exotic check std::span mCellLabelContainer; /// +#include #include +#include #include +#include +#include using namespace o2::emcal; @@ -70,7 +76,28 @@ o2::emcal::AnalysisCluster ClusterFactory::buildCluster(int clusterIn auto [inputIndMax, inputEnergyMax, cellAmp, shared] = getMaximalEnergyIndex(inputsIndices); - short towerId = mInputsContainer[inputIndMax].getTower(); + // set if the cluster has cells shared across two SM (only allowed for SM touching each other in eta!) + // important for evalLocalPosition, evalDispersion and evalElipsAxis + mSharedCluster = shared; + + // Pre-compute per-cell geometry indices once; evalDispersion, evalElipsAxis and evalNExMax + // read this instead of each re-deriving the same values from mGeomPtr. + mCellGeomBuffer.clear(); + mCellGeomBuffer.reserve(inputsIndices.size()); + for (auto iInput : inputsIndices) { + auto [nSupMod, nModule, nIphi, nIeta] = mGeomPtr->GetCellIndex(mInputsContainer[iInput].getTower()); + auto [iphi, ieta] = mGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta); + auto [row, col] = mGeomPtr->GetTopologicalRowColumn(nSupMod, nModule, nIphi, nIeta); + + // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 + // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0 + int ietaShared = ieta + ((mSharedCluster && nSupMod % 2) ? EMCAL_COLS : 0); + + mCellGeomBuffer.push_back({static_cast(nSupMod), static_cast(iphi), static_cast(ieta), + static_cast(ietaShared), static_cast(row), static_cast(col)}); + } + + int16_t towerId = mInputsContainer[inputIndMax].getTower(); float exoticTime = mInputsContainer[inputIndMax].getTimeStamp(); @@ -91,7 +118,7 @@ o2::emcal::AnalysisCluster ClusterFactory::buildCluster(int clusterIn clusterAnalysis.setNCells(inputsIndices.size()); - std::vector cellsIdices; + std::vector cellsIdices; bool addClusterLabels = ((clusterLabel != nullptr) && (mCellLabelContainer.size() > 0)); for (auto cellIndex : inputsIndices) { @@ -141,40 +168,44 @@ o2::emcal::AnalysisCluster ClusterFactory::buildCluster(int clusterIn } /// -/// Calculates the dispersion of the shower at the origin of the cluster -/// in cell units +/// \brief Calculates the dispersion of the shower at the origin of the cluster in cell units +/// \param inputsIndices span of the input cell Indices +/// \param clusterAnalysis AnalysisCluster for which the elips axis is calculated //____________________________________________________________________________ template void ClusterFactory::evalDispersion(std::span inputsIndices, AnalysisCluster& clusterAnalysis) const { double d = 0., wtot = 0.; - int nstat = 0; - // Calculates the dispersion in cell units - double etaMean = 0.0, phiMean = 0.0; + if (clusterAnalysis.E() <= 0) { + clusterAnalysis.setDispersion(0.); + return; + } - // Calculate mean values - for (auto iInput : inputsIndices) { + struct CellWeight { + double eta, phi, w; + }; + std::vector cellData; + cellData.reserve(inputsIndices.size()); - if (clusterAnalysis.E() > 0 && mInputsContainer[iInput].getEnergy() > 0) { - auto [nSupMod, nModule, nIphi, nIeta] = mGeomPtr->GetCellIndex(mInputsContainer[iInput].getTower()); - auto [iphi, ieta] = mGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta); + double etaMean = 0.0, phiMean = 0.0; - // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 - // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0 - if (mSharedCluster && nSupMod % 2) { - ieta += EMCAL_COLS; - } + for (size_t i = 0; i < inputsIndices.size(); ++i) { + auto iInput = inputsIndices[i]; + if (mInputsContainer[iInput].getEnergy() <= 0) { + continue; + } - auto etai = static_cast(ieta); - auto phii = static_cast(iphi); - double w = TMath::Max(0., mLogWeight + TMath::Log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E())); + const auto& geom = mCellGeomBuffer[i]; + auto etai = static_cast(geom.ietaShared); + auto phii = static_cast(geom.iphi); + double w = std::max(0., static_cast(mLogWeight + std::log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E()))); - if (w > 0.0) { - phiMean += phii * w; - etaMean += etai * w; - wtot += w; - } + if (w > 0.0) { + cellData.push_back({etai, phii, w}); + phiMean += phii * w; + etaMean += etai * w; + wtot += w; } } @@ -182,40 +213,20 @@ void ClusterFactory::evalDispersion(std::span inputsIndice phiMean /= wtot; etaMean /= wtot; } else { - LOG(error) << Form("Wrong weight %f\n", wtot); + LOG(error) << "Wrong weight " << wtot; } - // Calculate dispersion - for (auto iInput : inputsIndices) { - - if (clusterAnalysis.E() > 0 && mInputsContainer[iInput].getEnergy() > 0) { - auto [nSupMod, nModule, nIphi, nIeta] = mGeomPtr->GetCellIndex(mInputsContainer[iInput].getTower()); - auto [iphi, ieta] = mGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta); - - // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 - // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0 - if (mSharedCluster && nSupMod % 2) { - ieta += EMCAL_COLS; - } - - auto etai = static_cast(ieta); - auto phii = static_cast(iphi); - double w = TMath::Max(0., mLogWeight + TMath::Log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E())); - - if (w > 0.0) { - nstat++; - d += w * ((etai - etaMean) * (etai - etaMean) + (phii - phiMean) * (phii - phiMean)); - } - } + for (const auto& c : cellData) { + d += c.w * ((c.eta - etaMean) * (c.eta - etaMean) + (c.phi - phiMean) * (c.phi - phiMean)); } - if (wtot > 0 && nstat > 1) { + if (wtot > 0 && cellData.size() > 1) { d /= wtot; } else { d = 0.; } - clusterAnalysis.setDispersion(TMath::Sqrt(d)); + clusterAnalysis.setDispersion(std::sqrt(d)); } /// @@ -227,7 +238,7 @@ void ClusterFactory::evalLocalPosition(std::span inputsInd int nstat = 0; - double dist = tMaxInCm(double(clusterAnalysis.E())); + double dist = tMaxInCm(static_cast(clusterAnalysis.E())); std::array clXYZ = {0., 0., 0.}, clRmsXYZ = {0., 0., 0.}, xyzi{}; double wtot = 0., w = 0.; @@ -247,7 +258,7 @@ void ClusterFactory::evalLocalPosition(std::span inputsInd } if (mLogWeight > 0.0) { - w = TMath::Max(0., mLogWeight + TMath::Log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E())); + w = std::max(0., static_cast(mLogWeight + std::log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E()))); } else { w = mInputsContainer[iInput].getEnergy(); // just energy } @@ -266,7 +277,7 @@ void ClusterFactory::evalLocalPosition(std::span inputsInd // cout << " wtot " << wtot << endl; if (wtot > 0) { - // xRMS = TMath::Sqrt(x2m - xMean*xMean); + // xRMS = std::sqrt(x2m - xMean*xMean); for (int i = 0; i < 3; i++) { clXYZ[i] /= wtot; @@ -275,7 +286,7 @@ void ClusterFactory::evalLocalPosition(std::span inputsInd clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i] * clXYZ[i]; if (clRmsXYZ[i] > 0.0) { - clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); + clRmsXYZ[i] = std::sqrt(clRmsXYZ[i]); } else { clRmsXYZ[i] = 0; } @@ -301,7 +312,7 @@ void ClusterFactory::evalGlobalPosition(std::span inputsIn int i = 0, nstat = 0; - double dist = tMaxInCm(double(clusterAnalysis.E())); + double dist = tMaxInCm(static_cast(clusterAnalysis.E())); std::array clXYZ = {0., 0., 0.}, clRmsXYZ = {0., 0., 0.}, lxyzi{}, xyzi{}; double wtot = 0., w = 0.; @@ -320,7 +331,7 @@ void ClusterFactory::evalGlobalPosition(std::span inputsIn mGeomPtr->GetGlobal(lxyzi, xyzi, mGeomPtr->GetSuperModuleNumber(mInputsContainer[iInput].getTower())); if (mLogWeight > 0.0) { - w = TMath::Max(0., mLogWeight + TMath::Log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E())); + w = std::max(0., static_cast(mLogWeight + std::log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E()))); } else { w = mInputsContainer[iInput].getEnergy(); // just energy } @@ -339,7 +350,7 @@ void ClusterFactory::evalGlobalPosition(std::span inputsIn // cout << " wtot " << wtot << endl; if (wtot > 0) { - // xRMS = TMath::Sqrt(x2m - xMean*xMean); + // xRMS = std::sqrt(x2m - xMean*xMean); for (i = 0; i < 3; i++) { clXYZ[i] /= wtot; @@ -348,7 +359,7 @@ void ClusterFactory::evalGlobalPosition(std::span inputsIn clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i] * clXYZ[i]; if (clRmsXYZ[i] > 0.0) { - clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); + clRmsXYZ[i] = std::sqrt(clRmsXYZ[i]); } else { clRmsXYZ[i] = 0; } @@ -386,7 +397,7 @@ void ClusterFactory::evalLocalPositionFit(double deff, double mLogWei } if (mLogWeight > 0.0) { - w = TMath::Max(0., mLogWeight + TMath::Log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E())); + w = std::max(0., static_cast(mLogWeight + std::log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E()))); } else { w = mInputsContainer[iInput].getEnergy(); // just energy } @@ -405,7 +416,7 @@ void ClusterFactory::evalLocalPositionFit(double deff, double mLogWei // cout << " wtot " << wtot << endl; if (wtot > 0) { - // xRMS = TMath::Sqrt(x2m - xMean*xMean); + // xRMS = std::sqrt(x2m - xMean*xMean); for (i = 0; i < 3; i++) { clXYZ[i] /= wtot; @@ -414,7 +425,7 @@ void ClusterFactory::evalLocalPositionFit(double deff, double mLogWei clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i] * clXYZ[i]; if (clRmsXYZ[i] > 0.0) { - clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]); + clRmsXYZ[i] = std::sqrt(clRmsXYZ[i]); } else { clRmsXYZ[i] = 0; } @@ -458,8 +469,8 @@ void ClusterFactory::getDeffW0(const double esum, double& deff, doubl e = esum < 0.5 ? 0.5 : esum; e = e > 100. ? 100. : e; - deff = kdp0 + kdp1 * TMath::Log(e); - w0 = kwp0 / (1. + TMath::Exp(kwp1 * (e + kwp2))); + deff = kdp0 + kdp1 * std::log(e); + w0 = kwp0 / (1. + std::exp(kwp1 * (e + kwp2))); } /// @@ -485,9 +496,9 @@ void ClusterFactory::evalCoreEnergy(std::span inputsIndice for (auto iInput : inputsIndices) { auto [eta, phi] = mGeomPtr->EtaPhiFromIndex(mInputsContainer[iInput].getTower()); - phi = phi * TMath::DegToRad(); + phi = phi * o2::constants::math::Deg2Rad; - double distance = TMath::Sqrt((eta - etaPoint) * (eta - etaPoint) + (phi - phiPoint) * (phi - phiPoint)); + double distance = std::sqrt((eta - etaPoint) * (eta - etaPoint) + (phi - phiPoint) * (phi - phiPoint)); if (distance < mCoreRadius) { coreEnergy += mInputsContainer[iInput].getEnergy(); @@ -502,45 +513,25 @@ void ClusterFactory::evalCoreEnergy(std::span inputsIndice template void ClusterFactory::evalNExMax(std::span inputsIndices, AnalysisCluster& clusterAnalysis) const { - // Pre-compute cell indices and energies for all cells in cluster to avoid multiple expensive geometry lookups const size_t n = inputsIndices.size(); - std::vector rows; - std::vector columns; std::vector energies; - - rows.reserve(n); - columns.reserve(n); energies.reserve(n); - for (auto iInput : inputsIndices) { - auto [nSupMod, nModule, nIphi, nIeta] = mGeomPtr->GetCellIndex(mInputsContainer[iInput].getTower()); - - // get a nice topological indexing that is done in exactly the same way as used by the clusterizer - // this way we can handle the shared cluster cases correctly - const auto [row, column] = mGeomPtr->GetTopologicalRowColumn(nSupMod, nModule, nIphi, nIeta); - - rows.push_back(row); - columns.push_back(column); energies.push_back(mInputsContainer[iInput].getEnergy()); } - // Now find local maxima using pre-computed data int nExMax = 0; for (size_t i = 0; i < n; i++) { - // this cell is assumed to be local maximum unless we find a higher energy cell in the neighborhood bool isExMax = true; + const auto& gi = mCellGeomBuffer[i]; - // loop over all other cells in cluster for (size_t j = 0; j < n; j++) { if (i == j) { continue; } + const auto& gj = mCellGeomBuffer[j]; - // adjacent cell is any cell with adjacent phi or eta index - if (std::abs(rows[i] - rows[j]) <= 1 && - std::abs(columns[i] - columns[j]) <= 1) { - - // if there is a cell with higher energy than the current cell, it is not a local maximum + if (std::abs(gi.row - gj.row) <= 1 && std::abs(gi.col - gj.col) <= 1) { if (energies[j] > energies[i]) { isExMax = false; break; @@ -555,8 +546,9 @@ void ClusterFactory::evalNExMax(std::span inputsIndices, A } /// -/// Calculates the axis of the shower ellipsoid in eta and phi -/// in cell units +/// \brief Calculates the axis of the shower ellipsoid in eta and phi in cell units +/// \param inputsIndices span of the input cell Indices +/// \param clusterAnalysis AnalysisCluster for which the elips axis is calculated //____________________________________________________________________________ template void ClusterFactory::evalElipsAxis(std::span inputsIndices, AnalysisCluster& clusterAnalysis) const @@ -570,30 +562,19 @@ void ClusterFactory::evalElipsAxis(std::span inputsIndices std::array lambda{}; - for (auto iInput : inputsIndices) { + for (size_t i = 0; i < inputsIndices.size(); ++i) { + auto iInput = inputsIndices[i]; + const auto& geom = mCellGeomBuffer[i]; - auto [nSupMod, nModule, nIphi, nIeta] = mGeomPtr->GetCellIndex(mInputsContainer[iInput].getTower()); - auto [iphi, ieta] = mGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod, nModule, nIphi, nIeta); + auto etai = static_cast(geom.ietaShared); + auto phii = static_cast(geom.iphi); - // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2 - // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0 - if (mSharedCluster && nSupMod % 2) { - ieta += EMCAL_COLS; - } - - auto etai = static_cast(ieta); - auto phii = static_cast(iphi); - - double w = TMath::Max(0., mLogWeight + TMath::Log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E())); - // clusterAnalysis.E() summed amplitude of inputs, i.e. energy of cluster - // Gives smaller value of lambda than log weight - // w = mEnergyList[iInput] / clusterAnalysis.E(); // Nov 16, 2006 - try just energy + double w = std::max(0., static_cast(mLogWeight + std::log(mInputsContainer[iInput].getEnergy() / clusterAnalysis.E()))); dxx += w * etai * etai; x += w * etai; dzz += w * phii * phii; z += w * phii; - dxz += w * etai * phii; wtot += w; @@ -609,18 +590,18 @@ void ClusterFactory::evalElipsAxis(std::span inputsIndices dxz /= wtot; dxz -= x * z; - lambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt(0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz); + lambda[0] = 0.5 * (dxx + dzz) + std::sqrt(0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz); if (lambda[0] > 0) { - lambda[0] = TMath::Sqrt(lambda[0]); + lambda[0] = std::sqrt(lambda[0]); } else { lambda[0] = 0; } - lambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt(0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz); + lambda[1] = 0.5 * (dxx + dzz) - std::sqrt(0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz); if (lambda[1] > 0) { // To avoid exception if numerical errors lead to negative lambda. - lambda[1] = TMath::Sqrt(lambda[1]); + lambda[1] = std::sqrt(lambda[1]); } else { lambda[1] = 0.; } @@ -668,7 +649,7 @@ std::tuple ClusterFactory::getMaximalEnergyI /// Look to cell neighbourhood and reject if it seems exotic //____________________________________________________________________________ template -bool ClusterFactory::isExoticCell(short towerId, float ecell, float const exoticTime, float& fCross) const +bool ClusterFactory::isExoticCell(int16_t towerId, float ecell, float const exoticTime, float& fCross) const { if (ecell < mExoticCellMinAmplitude) { return false; // do not reject low energy cells @@ -694,15 +675,15 @@ bool ClusterFactory::isExoticCell(short towerId, float ecell, float c /// Calculate the energy in the cross around the energy of a given cell. //____________________________________________________________________________ template -float ClusterFactory::getECross(short absID, float energy, float const exoticTime) const +float ClusterFactory::getECross(int16_t absID, float energy, float const exoticTime) const { auto [iSM, iMod, iIphi, iIeta] = mGeomPtr->GetCellIndex(absID); auto [iphi, ieta] = mGeomPtr->GetCellPhiEtaIndexInSModule(iSM, iMod, iIphi, iIeta); // Get close cells index, energy and time, not in corners - short towerId1 = -1; - short towerId2 = -1; + int16_t towerId1 = -1; + int16_t towerId2 = -1; if (iphi < o2::emcal::EMCAL_ROWS - 1) { try { @@ -721,8 +702,8 @@ float ClusterFactory::getECross(short absID, float energy, float cons // In case of cell in eta = 0 border, depending on SM shift the cross cell index - short towerId3 = -1; - short towerId4 = -1; + int16_t towerId3 = -1; + int16_t towerId4 = -1; if (ieta == o2::emcal::EMCAL_COLS - 1 && (iSM % 2) == 0) { try { @@ -765,10 +746,10 @@ float ClusterFactory::getECross(short absID, float energy, float cons LOG(debug) << "iSM " << iSM << ", absID " << absID << ", a " << towerId1 << ", b " << towerId2 << ", c " << towerId3 << ", e " << towerId3; - short index1 = (towerId1 > -1) ? mLoolUpTowerToIndex.at(towerId1) : -1; - short index2 = (towerId2 > -1) ? mLoolUpTowerToIndex.at(towerId2) : -1; - short index3 = (towerId3 > -1) ? mLoolUpTowerToIndex.at(towerId3) : -1; - short index4 = (towerId4 > -1) ? mLoolUpTowerToIndex.at(towerId4) : -1; + int16_t index1 = (towerId1 > -1) ? mLoolUpTowerToIndex.at(towerId1) : -1; + int16_t index2 = (towerId2 > -1) ? mLoolUpTowerToIndex.at(towerId2) : -1; + int16_t index3 = (towerId3 > -1) ? mLoolUpTowerToIndex.at(towerId3) : -1; + int16_t index4 = (towerId4 > -1) ? mLoolUpTowerToIndex.at(towerId4) : -1; std::array, 4> cellData = { {{(index1 > -1) ? mInputsContainer[index1].getEnergy() : 0., (index1 > -1) ? mInputsContainer[index1].getTimeStamp() : 0.}, @@ -844,7 +825,7 @@ template void ClusterFactory::evalTime(std::span inputsIndices, AnalysisCluster& clusterAnalysis) const { float maxE = 0; - unsigned short maxAt = 0; + uint16_t maxAt = 0; for (auto iInput : inputsIndices) { if (mInputsContainer[iInput].getEnergy() > maxE) { maxE = mInputsContainer[iInput].getEnergy(); @@ -862,13 +843,13 @@ void ClusterFactory::evalTime(std::span inputsIndices, Ana template double ClusterFactory::tMaxInCm(const double e, const int key) const { - const double ca = 4.82; // shower max parameter - first guess; ca=TMath::Log(1000./8.07) + const double ca = 4.82; // shower max parameter - first guess; ca=std::log(1000./8.07) double tmax = 0.; // position of electromagnetic shower max in cm const double x0 = 1.31; // radiation lenght (cm) if (e > 0.1) { - tmax = TMath::Log(e) + ca; + tmax = std::log(e) + ca; if (key == 0) { tmax += 0.5; } else { @@ -881,21 +862,23 @@ double ClusterFactory::tMaxInCm(const double e, const int key) const } /// -/// Converts Theta (Radians) to Eta (Radians) +/// \brief Converts Eta (Radians) to Theta (Radians) +/// \param eta eta //______________________________________________________________________________ template -float ClusterFactory::etaToTheta(float arg) const +float ClusterFactory::etaToTheta(float eta) const { - return (2. * TMath::ATan(TMath::Exp(-arg))); + return (2.f * std::atan(std::exp(-eta))); } /// -/// Converts Eta (Radians) to Theta (Radians) +/// \brief Converts Theta (Radians) to Eta (Radians) +/// \param theta theta //______________________________________________________________________________ template -float ClusterFactory::thetaToEta(float arg) const +float ClusterFactory::thetaToEta(float theta) const { - return (-1 * TMath::Log(TMath::Tan(0.5 * arg))); + return (-1.f * std::log(std::tan(0.5f * theta))); } template