From aafaf01ced81b5828dfe1c7fea71d2c0573cd489 Mon Sep 17 00:00:00 2001 From: Marvin Hemmer Date: Thu, 5 Jun 2025 11:50:57 +0200 Subject: [PATCH] [EMCAL-1154] Add functionality for cross talk emulation Geometry: - Add `areAbsIDsFromSameTCard` which checks if two cells are within the same T-Card CellLabel: - Add `GetLabels` which returns the span of all labels - Add `GetAmplitudeFractions` which return the span of all amplitude fractions - Add `GetLeadingMCLabel` which returns the label with the largest amplitude fraction --- .../include/DataFormatsEMCAL/CellLabel.h | 14 ++++- DataFormats/Detectors/EMCAL/src/CellLabel.cxx | 18 ++++++ .../EMCAL/base/include/EMCALBase/Geometry.h | 16 +++-- Detectors/EMCAL/base/src/Geometry.cxx | 61 ++++++++++++++++++- 4 files changed, 101 insertions(+), 8 deletions(-) diff --git a/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h b/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h index f0181e01f84c5..81766a3a59cdc 100644 --- a/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h +++ b/DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h @@ -12,10 +12,9 @@ #ifndef ALICEO2_EMCAL_CELLLABEL_H_ #define ALICEO2_EMCAL_CELLLABEL_H_ -#include +#include +#include #include -#include -#include "Rtypes.h" namespace o2 { @@ -52,10 +51,19 @@ class CellLabel /// \param index index which label to get int32_t GetLabel(size_t index) const { return mLabels[index]; } + /// \brief Getter for labels + gsl::span GetLabels() const { return mLabels; } + /// \brief Getter for amplitude fraction /// \param index index which amplitude fraction to get float GetAmplitudeFraction(size_t index) const { return mAmplitudeFraction[index]; } + /// \brief Getter for amplitude fractions + gsl::span GetAmplitudeFractions() const { return mAmplitudeFraction; } + + /// \brief Getter for label with leading amplitude fraction + int32_t GetLeadingMCLabel() const; + protected: gsl::span mLabels; ///< List of MC particles that generated the cluster, ordered in deposited energy. gsl::span mAmplitudeFraction; ///< List of the fraction of the cell energy coming from a MC particle. Index aligns with mLabels! diff --git a/DataFormats/Detectors/EMCAL/src/CellLabel.cxx b/DataFormats/Detectors/EMCAL/src/CellLabel.cxx index 8dde7ea90c435..e37368ea181d7 100644 --- a/DataFormats/Detectors/EMCAL/src/CellLabel.cxx +++ b/DataFormats/Detectors/EMCAL/src/CellLabel.cxx @@ -12,6 +12,10 @@ /// \file CellLabel.cxx #include "DataFormatsEMCAL/CellLabel.h" +#include "fairlogger/Logger.h" +#include +#include +#include using namespace o2::emcal; @@ -21,3 +25,17 @@ CellLabel::CellLabel(const gsl::span labels, const gsl::span maxFraction) { + maxFraction = mAmplitudeFraction[i]; + maxIndex = i; + } + } + return mLabels[maxIndex]; +} diff --git a/Detectors/EMCAL/base/include/EMCALBase/Geometry.h b/Detectors/EMCAL/base/include/EMCALBase/Geometry.h index 4d4a947de88ca..b4621d4b6e434 100644 --- a/Detectors/EMCAL/base/include/EMCALBase/Geometry.h +++ b/Detectors/EMCAL/base/include/EMCALBase/Geometry.h @@ -12,19 +12,19 @@ #ifndef ALICEO2_EMCAL_GEOMETRY_H_ #define ALICEO2_EMCAL_GEOMETRY_H_ -#include +#include #include +#include #include #include #include +#include #include -#include +#include #include #include -#include -#include "CCDB/BasicCCDBManager.h" #include "DataFormatsEMCAL/Constants.h" #include "EMCALBase/GeometryBase.h" #include "MathUtils/Cartesian.h" @@ -515,6 +515,14 @@ class Geometry /// \return col std::tuple getOnlineID(int towerID); + /// \brief Check if 2 cells belong to the same T-Card + /// \param absId1: Reference absId cell + /// \param absId2: Cross checked cell absId + /// \return true if belong to same TCard else false + /// \return rowDiff: Distance in rows + /// \return colDiff: Distance in columns + std::tuple areAbsIDsFromSameTCard(int absId1, int absId2) const; + /// \brief Temporary link assignment (till final link assignment is known - /// \brief eventually taken from CCDB) /// \brief Current mapping can be found under https://alice.its.cern.ch/jira/browse/EMCAL-660 diff --git a/Detectors/EMCAL/base/src/Geometry.cxx b/Detectors/EMCAL/base/src/Geometry.cxx index 6eff6c161f2a1..6039c18dd34e4 100644 --- a/Detectors/EMCAL/base/src/Geometry.cxx +++ b/Detectors/EMCAL/base/src/Geometry.cxx @@ -10,20 +10,38 @@ // or submit itself to any jurisdiction. #include "EMCALBase/Geometry.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include +#include +#include #include +#include #include #include #include +#include #include #include #include #include -#include +#include "DataFormatsEMCAL/Constants.h" +#include "EMCALBase/GeometryBase.h" +#include "CCDB/CcdbApi.h" #include "EMCALBase/ShishKebabTrd1Module.h" +#include "GPUROOTCartesianFwd.h" #include @@ -1859,3 +1877,44 @@ std::tuple Geometry::getOnlineID(int towerID) return std::make_tuple(supermoduleID * 2 + ddlInSupermoudel, row, col); } + +std::tuple Geometry::areAbsIDsFromSameTCard(int absId1, int absId2) const +{ + + int rowDiff = -100; + int colDiff = -100; + + if (absId1 == absId2) { + return {false, rowDiff, colDiff}; + } + + // Check if in same SM, if not for sure not same TCard + const int sm1 = GetSuperModuleNumber(absId1); + const int sm2 = GetSuperModuleNumber(absId2); + if (sm1 != sm2) { + return {false, rowDiff, colDiff}; + } + + // Get the column and row of each absId + const auto [_, iTower1, iIphi1, iIeta1] = GetCellIndex(absId1); + const auto [row1, col1] = GetCellPhiEtaIndexInSModule(sm1, iTower1, iIphi1, iIeta1); + + const auto [__, iTower2, iIphi2, iIeta2] = GetCellIndex(absId2); + const auto [row2, col2] = GetCellPhiEtaIndexInSModule(sm2, iTower2, iIphi2, iIeta2); + + // Define corner of TCard for absId1 + const int tcardRow0 = row1 - row1 % 8; + const int tcardCol0 = col1 - col1 % 2; + + // Difference of absId2 from corner of absId1's TCard + const int rowOffset = row2 - tcardRow0; + const int colOffset = col2 - tcardCol0; + + // Differences between the two cells directly + rowDiff = row1 - row2; + colDiff = col1 - col2; + + const bool sameTCard = (rowOffset >= 0 && rowOffset < 8 && + colOffset >= 0 && colOffset < 2); + return {sameTCard, rowDiff, colDiff}; +}