ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigGepPerf
src
EratioMaker.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
./EratioMaker.h
"
7
#include <algorithm>
8
#include <sstream>
9
#include <iostream>
10
#include "TVector2.h"
11
12
namespace
Gep
{
13
14
15
EratioMaker::EratioMaker
(
const
GepCellMap
& caloCellsMap,
16
unsigned
int
etaWindowHalfSize,
17
unsigned
int
phiWindowHalfSize)
18
:
m_caloCellsMap
{caloCellsMap},
19
m_etaWindowHalfSize
{etaWindowHalfSize},
20
m_phiWindowHalfSize
{phiWindowHalfSize}
21
{
22
23
}
24
25
26
// ==========================================================
27
// Construct window of 17x3 cells around seed
28
// ==========================================================
29
30
std::vector<std::vector<GepCaloCell>>
31
EratioMaker::makeWindow
(
const
ROOT::Math::PtEtaPhiEVector &seed)
const
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
}
97
98
// ==========================================================
99
// Find local maxima within the window
100
// ==========================================================
101
102
std::pair<double, double>
103
EratioMaker::findLocalMaxima
(
const
std::vector<std::vector<GepCaloCell>>& window)
const
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
}
153
154
// ==========================================================
155
// Compute Eratio
156
// ==========================================================
157
158
double
EratioMaker::computeEratio
(
double
E1,
double
E2)
const
159
{
160
return
(E1 + E2 > 0) ? (E1 - E2) / (E1 + E2) : -999;
161
}
162
163
// ==========================================================
164
// Build eratio object
165
// ==========================================================
166
167
const
EratioObj
EratioMaker::makeEratio
(
const
ROOT::Math::PtEtaPhiEVector seed)
const
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
}
182
183
184
}
// namespace Gep
185
186
EratioMaker.h
a
static Double_t a
Definition
LArPhysWaveHECTool.cxx:38
Gep::EratioMaker::m_phiWindowHalfSize
const unsigned int m_phiWindowHalfSize
Definition
EratioMaker.h:47
Gep::EratioMaker::findLocalMaxima
std::pair< double, double > findLocalMaxima(const std::vector< std::vector< GepCaloCell > > &window) const
Definition
EratioMaker.cxx:103
Gep::EratioMaker::computeEratio
double computeEratio(double E1, double E2) const
Definition
EratioMaker.cxx:158
Gep::EratioMaker::makeEratio
const EratioObj makeEratio(const ROOT::Math::PtEtaPhiEVector obj) const
Definition
EratioMaker.cxx:167
Gep::EratioMaker::EratioMaker
EratioMaker(const GepCellMap &caloCellsMap, unsigned int etaWindowHalfSize=8, unsigned int phiWindowHalfSize=1)
Definition
EratioMaker.cxx:15
Gep::EratioMaker::m_etaWindowHalfSize
const unsigned int m_etaWindowHalfSize
Definition
EratioMaker.h:46
Gep::EratioMaker::makeWindow
std::vector< std::vector< GepCaloCell > > makeWindow(const ROOT::Math::PtEtaPhiEVector &obj) const
Definition
EratioMaker.cxx:31
Gep::EratioMaker::m_caloCellsMap
const GepCellMap & m_caloCellsMap
Definition
EratioMaker.h:45
Gep::GepCellMap
Definition
GepCellMap.h:17
Gep
Definition
BasicGepClusterMaker.h:13
std::sort
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
Definition
DVL_algorithms.h:554
Gep::EratioObj
Definition
EratioMaker.h:19
Gep::GepCaloCell
Definition
GepCaloCell.h:13
Generated on
for ATLAS Offline Software by
1.17.0