Skip to content

Commit d5e0618

Browse files
authored
[EMCAL-1154] Add functionality for cross talk emulation (#14369)
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
1 parent 6c94101 commit d5e0618

File tree

4 files changed

+101
-8
lines changed

4 files changed

+101
-8
lines changed

DataFormats/Detectors/EMCAL/include/DataFormatsEMCAL/CellLabel.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
#ifndef ALICEO2_EMCAL_CELLLABEL_H_
1313
#define ALICEO2_EMCAL_CELLLABEL_H_
1414

15-
#include <fairlogger/Logger.h>
15+
#include <cstddef>
16+
#include <cstdint>
1617
#include <gsl/span>
17-
#include <vector>
18-
#include "Rtypes.h"
1918

2019
namespace o2
2120
{
@@ -52,10 +51,19 @@ class CellLabel
5251
/// \param index index which label to get
5352
int32_t GetLabel(size_t index) const { return mLabels[index]; }
5453

54+
/// \brief Getter for labels
55+
gsl::span<const int32_t> GetLabels() const { return mLabels; }
56+
5557
/// \brief Getter for amplitude fraction
5658
/// \param index index which amplitude fraction to get
5759
float GetAmplitudeFraction(size_t index) const { return mAmplitudeFraction[index]; }
5860

61+
/// \brief Getter for amplitude fractions
62+
gsl::span<const float> GetAmplitudeFractions() const { return mAmplitudeFraction; }
63+
64+
/// \brief Getter for label with leading amplitude fraction
65+
int32_t GetLeadingMCLabel() const;
66+
5967
protected:
6068
gsl::span<const int32_t> mLabels; ///< List of MC particles that generated the cluster, ordered in deposited energy.
6169
gsl::span<const float> mAmplitudeFraction; ///< List of the fraction of the cell energy coming from a MC particle. Index aligns with mLabels!

DataFormats/Detectors/EMCAL/src/CellLabel.cxx

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
/// \file CellLabel.cxx
1313

1414
#include "DataFormatsEMCAL/CellLabel.h"
15+
#include "fairlogger/Logger.h"
16+
#include <cstddef>
17+
#include <cstdint>
18+
#include <gsl/span>
1519

1620
using namespace o2::emcal;
1721

@@ -21,3 +25,17 @@ CellLabel::CellLabel(const gsl::span<const int> labels, const gsl::span<const fl
2125
LOG(error) << "Size of labels " << labels.size() << " does not match size of amplitude fraction " << amplitudeFractions.size() << " !";
2226
}
2327
}
28+
29+
int32_t CellLabel::GetLeadingMCLabel() const
30+
{
31+
size_t maxIndex = 0;
32+
float maxFraction = mAmplitudeFraction[0];
33+
34+
for (size_t i = 1; i < mAmplitudeFraction.size(); ++i) {
35+
if (mAmplitudeFraction[i] > maxFraction) {
36+
maxFraction = mAmplitudeFraction[i];
37+
maxIndex = i;
38+
}
39+
}
40+
return mLabels[maxIndex];
41+
}

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
#ifndef ALICEO2_EMCAL_GEOMETRY_H_
1313
#define ALICEO2_EMCAL_GEOMETRY_H_
1414

15-
#include <exception>
15+
#include <array>
1616
#include <string>
17+
#include <string_view>
1718
#include <tuple>
1819
#include <vector>
1920

2021
#include <RStringView.h>
22+
#include <RtypesCore.h>
2123
#include <TGeoMatrix.h>
22-
#include <TNamed.h>
24+
#include <TMath.h>
2325
#include <TParticle.h>
2426
#include <TVector3.h>
25-
#include <TObjArray.h>
2627

27-
#include "CCDB/BasicCCDBManager.h"
2828
#include "DataFormatsEMCAL/Constants.h"
2929
#include "EMCALBase/GeometryBase.h"
3030
#include "MathUtils/Cartesian.h"
@@ -515,6 +515,14 @@ class Geometry
515515
/// \return col
516516
std::tuple<int, int, int> getOnlineID(int towerID);
517517

518+
/// \brief Check if 2 cells belong to the same T-Card
519+
/// \param absId1: Reference absId cell
520+
/// \param absId2: Cross checked cell absId
521+
/// \return true if belong to same TCard else false
522+
/// \return rowDiff: Distance in rows
523+
/// \return colDiff: Distance in columns
524+
std::tuple<bool, int, int> areAbsIDsFromSameTCard(int absId1, int absId2) const;
525+
518526
/// \brief Temporary link assignment (till final link assignment is known -
519527
/// \brief eventually taken from CCDB)
520528
/// \brief Current mapping can be found under https://alice.its.cern.ch/jira/browse/EMCAL-660

Detectors/EMCAL/base/src/Geometry.cxx

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,38 @@
1010
// or submit itself to any jurisdiction.
1111
#include "EMCALBase/Geometry.h"
1212

13+
#include <RtypesCore.h>
14+
#include <TMath.h>
15+
#include <TVector3.h>
16+
#include <TMathBase.h>
17+
#include <TVector2.h>
18+
#include <TParticle.h>
19+
#include <TString.h>
20+
#include <TGeoNode.h>
21+
#include <TJAlienCredentials.h>
22+
#include <TObjArray.h>
1323
#include <fairlogger/Logger.h>
1424

25+
#include <cstring>
26+
#include <cctype>
27+
#include <cmath>
1528
#include <iomanip>
29+
#include <ostream>
1630
#include <string>
1731
#include <algorithm>
1832
#include <cstdio>
33+
#include <string_view>
1934
#include <tuple>
2035

2136
#include <TGeoBBox.h>
2237
#include <TGeoManager.h>
2338
#include <TGeoMatrix.h>
24-
#include <TList.h>
2539

40+
#include "DataFormatsEMCAL/Constants.h"
41+
#include "EMCALBase/GeometryBase.h"
42+
#include "CCDB/CcdbApi.h"
2643
#include "EMCALBase/ShishKebabTrd1Module.h"
44+
#include "GPUROOTCartesianFwd.h"
2745

2846
#include <boost/algorithm/string/predicate.hpp>
2947

@@ -1859,3 +1877,44 @@ std::tuple<int, int, int> Geometry::getOnlineID(int towerID)
18591877

18601878
return std::make_tuple(supermoduleID * 2 + ddlInSupermoudel, row, col);
18611879
}
1880+
1881+
std::tuple<bool, int, int> Geometry::areAbsIDsFromSameTCard(int absId1, int absId2) const
1882+
{
1883+
1884+
int rowDiff = -100;
1885+
int colDiff = -100;
1886+
1887+
if (absId1 == absId2) {
1888+
return {false, rowDiff, colDiff};
1889+
}
1890+
1891+
// Check if in same SM, if not for sure not same TCard
1892+
const int sm1 = GetSuperModuleNumber(absId1);
1893+
const int sm2 = GetSuperModuleNumber(absId2);
1894+
if (sm1 != sm2) {
1895+
return {false, rowDiff, colDiff};
1896+
}
1897+
1898+
// Get the column and row of each absId
1899+
const auto [_, iTower1, iIphi1, iIeta1] = GetCellIndex(absId1);
1900+
const auto [row1, col1] = GetCellPhiEtaIndexInSModule(sm1, iTower1, iIphi1, iIeta1);
1901+
1902+
const auto [__, iTower2, iIphi2, iIeta2] = GetCellIndex(absId2);
1903+
const auto [row2, col2] = GetCellPhiEtaIndexInSModule(sm2, iTower2, iIphi2, iIeta2);
1904+
1905+
// Define corner of TCard for absId1
1906+
const int tcardRow0 = row1 - row1 % 8;
1907+
const int tcardCol0 = col1 - col1 % 2;
1908+
1909+
// Difference of absId2 from corner of absId1's TCard
1910+
const int rowOffset = row2 - tcardRow0;
1911+
const int colOffset = col2 - tcardCol0;
1912+
1913+
// Differences between the two cells directly
1914+
rowDiff = row1 - row2;
1915+
colDiff = col1 - col2;
1916+
1917+
const bool sameTCard = (rowOffset >= 0 && rowOffset < 8 &&
1918+
colOffset >= 0 && colOffset < 2);
1919+
return {sameTCard, rowDiff, colDiff};
1920+
}

0 commit comments

Comments
 (0)