ATLAS Offline Software
Loading...
Searching...
No Matches
Gep::EratioMaker Class Reference

#include <EratioMaker.h>

Collaboration diagram for Gep::EratioMaker:

Public Member Functions

 EratioMaker (const GepCellMap &caloCellsMap, unsigned int etaWindowHalfSize=8, unsigned int phiWindowHalfSize=1)
const EratioObj makeEratio (const ROOT::Math::PtEtaPhiEVector obj) const

Private Member Functions

std::vector< std::vector< GepCaloCell > > makeWindow (const ROOT::Math::PtEtaPhiEVector &obj) const
std::pair< double, double > findLocalMaxima (const std::vector< std::vector< GepCaloCell > > &window) const
double computeEratio (double E1, double E2) const

Private Attributes

const GepCellMapm_caloCellsMap
const unsigned int m_etaWindowHalfSize
const unsigned int m_phiWindowHalfSize

Detailed Description

Definition at line 27 of file EratioMaker.h.

Constructor & Destructor Documentation

◆ EratioMaker()

Gep::EratioMaker::EratioMaker ( const GepCellMap & caloCellsMap,
unsigned int etaWindowHalfSize = 8,
unsigned int phiWindowHalfSize = 1 )

Definition at line 15 of file EratioMaker.cxx.

18 : m_caloCellsMap{caloCellsMap},
19 m_etaWindowHalfSize{etaWindowHalfSize},
20 m_phiWindowHalfSize{phiWindowHalfSize}
21{
22
23}
const unsigned int m_phiWindowHalfSize
Definition EratioMaker.h:47
const unsigned int m_etaWindowHalfSize
Definition EratioMaker.h:46
const GepCellMap & m_caloCellsMap
Definition EratioMaker.h:45

Member Function Documentation

◆ computeEratio()

double Gep::EratioMaker::computeEratio ( double E1,
double E2 ) const
private

Definition at line 158 of file EratioMaker.cxx.

159{
160 return (E1 + E2 > 0) ? (E1 - E2) / (E1 + E2) : -999;
161}

◆ findLocalMaxima()

std::pair< double, double > Gep::EratioMaker::findLocalMaxima ( const std::vector< std::vector< GepCaloCell > > & window) const
private

Definition at line 103 of file EratioMaker.cxx.

104{
105
106 struct LocalMax {
107 double energy;
108 int i;
109 int j;
110 };
111
112 std::vector<LocalMax> localMaxima;
113
114 int rows = window.size();
115 int cols = window[0].size();
116
117 for (int i = 0; i < rows; ++i) {
118 for (int j = 0; j < cols; ++j) {
119 double current = window[i][j].e;
120 bool isMax = true;
121
122 for (int di = -1; di <= 1; ++di) {
123 for (int dj = -1; dj <= 1; ++dj) {
124 if (di == 0 && dj == 0) continue;
125 int ni = i + di;
126 int nj = j + dj;
127 if (ni >= 0 && ni < rows && nj >= 0 && nj < cols) {
128 if (window[ni][nj].e >= current) {
129 isMax = false;
130 break;
131 }
132 }
133 }
134 if (!isMax) break;
135 }
136
137 if (isMax) localMaxima.push_back({current, i, j });
138 }
139 }
140
141 if (localMaxima.empty()) return {0., 0.};
142
143 // Sort local maximas in descendent fashion
144 std::sort(localMaxima.begin(), localMaxima.end(),
145 [](const LocalMax& a, const LocalMax& b){ return a.energy > b.energy; });
146
147 double E1 = localMaxima[0].energy;
148 double E2 = (localMaxima.size() > 1) ? localMaxima[1].energy : 0.0;
149
150 return {E1, E2};
151
152}
static Double_t a
float j(const xAOD::IParticle &, const xAOD::TrackMeasurementValidation &hit, const Eigen::Matrix3d &jab_inv)
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.

◆ makeEratio()

const EratioObj Gep::EratioMaker::makeEratio ( const ROOT::Math::PtEtaPhiEVector obj) const

Definition at line 167 of file EratioMaker.cxx.

168{
169 auto window = makeWindow(seed);
170 auto [E1, E2] = findLocalMaxima(window);
171 double eratio = computeEratio(E1, E2);
172
173 EratioObj obj;
174 obj.seedEta = seed.eta();
175 obj.seedPhi = seed.phi();
176 obj.E1 = E1;
177 obj.E2 = E2;
178 obj.Eratio = eratio;
179
180 return obj;
181}
std::pair< double, double > findLocalMaxima(const std::vector< std::vector< GepCaloCell > > &window) const
double computeEratio(double E1, double E2) const
std::vector< std::vector< GepCaloCell > > makeWindow(const ROOT::Math::PtEtaPhiEVector &obj) const
setCharge setNTRTHiThresholdHits eratio

◆ makeWindow()

std::vector< std::vector< GepCaloCell > > Gep::EratioMaker::makeWindow ( const ROOT::Math::PtEtaPhiEVector & obj) const
private

Definition at line 31 of file EratioMaker.cxx.

32{
33
34 // Window dimensions set based on configured half sizes
35 unsigned int etaWindowSize = 2 * m_etaWindowHalfSize + 1;
36 unsigned int phiWindowSize = 2 * m_phiWindowHalfSize + 1;
37
38 std::vector<std::vector<GepCaloCell>> window(etaWindowSize, std::vector<GepCaloCell>(phiWindowSize));
39
40 auto cellMap = m_caloCellsMap.getCellMap();
41
42 // 1. Find cell that contains the seed
43 const GepCaloCell* centerCell = nullptr;
44 unsigned int centerCellId = 0;
45 bool exactMatchFound = false;
46
47 for (auto it = cellMap->begin(); it != cellMap->end(); ++it) {
48 const auto& cell = it->second;
49 if (cell.sampling != 1) continue; // Only ECAL layer 1
50
51 // Verify if seed coordinates fall inside the limits of some cell
52 if (cell.etaMin < seed.eta() && seed.eta() < cell.etaMax &&
53 cell.phiMin < seed.phi() && seed.phi() < cell.phiMax) {
54 centerCell = &cell;
55 centerCellId = cell.id;
56 exactMatchFound = true;
57 break;
58 }
59 }
60
61 // If not exact match, return empty window
62 if (!exactMatchFound || !centerCell) {
63 return window;
64 }
65
66 // 2. Construct 17x3 (rows x cols) window based on cell ID relations starting from seed
67 // Rows: -8 to +8 from central cell in eta (17 total)
68 // Columns: -1, 0, +1 from central cell in phi (3 total)
69
70 // Construct each window row
71 for (int etaOffset = -8; etaOffset <= 8; etaOffset++) {
72 unsigned int windowRow = etaOffset + 8; // Convertir a índice 0..16
73
74 // Get base ID for this row (central cell of the phi column)
75 unsigned int baseId = static_cast<unsigned int>(static_cast<int>(centerCellId) + (etaOffset * 512));
76
77 // Loop phi columns (-1, 0, +1)
78 for (int phiOffset = -1; phiOffset <= 1; phiOffset++) {
79 int windowCol = phiOffset + 1;
80
81 // Compute desired cell ID
82 unsigned int cellId = static_cast<unsigned int>(static_cast<int>(baseId) + phiOffset * 2);
83
84 // Look for that cell within the map
85 auto it = cellMap->find(cellId);
86 if (it != cellMap->end()) {
87 const auto& cell = it->second;
88 if (cell.sampling == 1) {
89 window[windowRow][windowCol] = cell;
90 }
91 }
92 }
93 }
94
95 return window;
96}

Member Data Documentation

◆ m_caloCellsMap

const GepCellMap& Gep::EratioMaker::m_caloCellsMap
private

Definition at line 45 of file EratioMaker.h.

◆ m_etaWindowHalfSize

const unsigned int Gep::EratioMaker::m_etaWindowHalfSize
private

Definition at line 46 of file EratioMaker.h.

◆ m_phiWindowHalfSize

const unsigned int Gep::EratioMaker::m_phiWindowHalfSize
private

Definition at line 47 of file EratioMaker.h.


The documentation for this class was generated from the following files: