38{
39 bool cluster_in_barrel = true;
41
43
44
45 int sampling = 1;
46
47 LArTT_Selector<LArCellCont>
sel;
49
50 double totalEnergy = 0;
51 double etaEnergyS1 = 0;
53
54 double energyEta = rtrigEmCluster.
eta();
55 double energyPhi = rtrigEmCluster.
phi();
56 if (caloDDE) {
57 energyEta = caloDDE->
eta();
58 energyPhi = caloDDE->
phi();
59 }
60
61
62
63
64 double z_etamin = energyEta - (0.075 / 2.);
65 double z_etamax = energyEta + (0.075 / 2.);
66
67 double z_phimin = energyPhi - (7.0 * 0.09817477 / 4.0) / 2.0;
68 double z_phimax = energyPhi + (7.0 * 0.09817477 / 4.0) / 2.0;
69
70 if (!cluster_in_barrel) {
71 z_etamin = energyEta - (0.125 / 2.);
72 z_etamax = energyEta + (0.125 / 2.);
73 z_phimin = energyPhi - (5.0 * 0.09817477 / 4.0) / 2.0;
74 z_phimax = energyPhi + (5.0 * 0.09817477 / 4.0) / 2.0;
75 }
76
77 double z_eta = z_etamin + (z_etamax - z_etamin) * 0.5;
78 double z_phi = z_phimin + (z_phimax - z_phimin) * 0.5;
79
80
81
82 if (z_etamin < -2.4) z_etamin = -2.4;
83 if (z_etamin < -1.4 && z_etamin > -1.5) z_etamin = -1.4;
84 if (z_etamin > 1.4 && z_etamin < 1.5) z_etamin = 1.5;
85
86 if (z_etamax > 2.4) z_etamax = 2.4;
87 if (z_etamax < -1.4 && z_etamax > -1.5) z_etamax = -1.5;
88 if (z_etamax > 1.4 && z_etamax < 1.5) z_etamax = 1.4;
89
90 bool signals = false;
91 if ((z_etamin < 0) && (z_etamax > 0)) signals = true;
92
93
94
95 double etareg[6] = {-2.4, -2.0, -1.8, 1.8, 2.0, 2.4};
96 double etagra[5] = {0.025 / 4, 0.025 / 6, 0.025 / 8, 0.025 / 6, 0.025 / 4};
98 int icrk = 1;
99 double dgra = 0.;
100
101 for (
int ir = 0;
ir < 5;
ir++) {
102
103 if (std::abs(z_eta) < 2.4 && z_eta >= etareg[
ir] && z_eta <= etareg[
ir + 1]) {
106 if (z_etamin >= etareg[
ir] && z_etamax <= etareg[
ir + 1]) icrk = 0;
107 }
108 }
109 const double inv_dgra = dgra != 0 ? 1. / dgra : 1;
110
111
112 int strip_border;
113 double etanew;
114 double aeta = std::abs(z_eta);
115 if (aeta <= 1.4) {
116 strip_border = (
int)rint(aeta * inv_dgra);
117
118 etanew = ((
double)strip_border - 0.5) * dgra;
119 }
120 if (aeta <= 1.5) {
121 etanew = -99.;
122 }
123 if (aeta <= 1.8) {
124 strip_border = (
int)rint(aeta * inv_dgra);
125
126 etanew = ((
double)strip_border - 0.5) * dgra;
127 }
128 else if (aeta <= 2.0) {
129 strip_border = (
int)rint((aeta - 1.8) * inv_dgra);
130 etanew = 1.8 + ((
double)strip_border - 0.5) * dgra;
131 }
132 else if (aeta <= 2.4) {
133 strip_border = (
int)rint((aeta - 2.0) * inv_dgra);
134 etanew = 2.0 + ((
double)strip_border - 0.5) * dgra;
135 }
136 else {
137 etanew = -99.;
138 }
139
140 etanew = (z_eta < 0.) ? -etanew : etanew;
141
142
143 int ibin = 0;
144 double dgra1 = 0.;
146 if ((icrk == 1) && (
imax != -9)) {
147 if (
imax > 0 && z_etamin > etareg[
imax - 1] && z_etamin <= etareg[
imax]) {
148 dgra1 = etagra[
imax - 1];
149 ibin = (
int)rint((etareg[
imax] + 0.5 * dgra - etanew) * inv_dgra) + 20;
151 }
152 else {
154 dgra1 = etagra[
imax + 1];
155 ibin = (
int)rint((etareg[
imax + 1] - 0.5 * dgra - etanew) * inv_dgra) + 20;
157 }
158 }
160 dgra1 = etagra[0];
161 ibin = (
int)rint((etareg[0] + 0.5 * dgra - etanew) * inv_dgra) + 20;
163 }
165 dgra1 = etagra[4];
166 ibin = (
int)rint((etareg[5] - 0.5 * dgra - etanew) * inv_dgra) + 20;
168 }
169 }
170 const double inv_dgra1 = dgra1 != 0 ? 1. / dgra1 : 1;
171
172
173
174 double z_enecell[40];
175 double z_etacell[40];
176
177 for (int iii = 0; iii < 40; iii++) {
178 z_enecell[iii] = 0.;
179 z_etacell[iii] = 0.;
180 }
181
182 int ncells = 0;
183
184 for (
const LArCell* larcell :
sel) {
185 ncells++;
186 double etaCell = larcell->caloDDE()->eta_raw();
187 double phiCell = larcell->phi();
188 double energyCell = larcell->energy();
189
190 if (std::abs(etanew) != 99.) {
191
192 double eta_cell = etaCell;
193
194
195
196 if (eta_cell >= z_etamin && eta_cell <= z_etamax) {
197
198 double phi_cell0 = larcell->phi();
199 double phi_cell =
proxim(phi_cell0, z_phi);
200 if (phi_cell >= z_phimin && phi_cell <= z_phimax) {
201 int ieta;
202 if (icrk == 0) {
203
204 ieta = (
int)rint((eta_cell - etanew) * inv_dgra) + 20;
205
206 if (signals && eta_cell < 0)
207 ieta = (
int)rint((eta_cell - etanew + 0.007) * inv_dgra) + 20;
208 }
209 else {
210 if (eta_cell > etareg[
imax] && eta_cell < etareg[
imax + 1]) {
211
212 ieta = (
int)rint((eta_cell - etanew) * inv_dgra) + 20;
213 }
214 else {
215
216 ieta = (
int)rint((eta_cell - etareg[
imax + iadd] - (0.5 - iadd) * dgra1) *
217 inv_dgra1) +
218 ibin;
219 }
220 }
221
222 double z_e = energyCell;
223
224 if (ieta >= 1 && ieta <= 40) {
225 z_enecell[ieta - 1] += z_e;
226 z_etacell[ieta - 1] = eta_cell;
227 }
228 }
229 }
230
231 }
232
233
234 double deta = std::abs(etaCell - energyEta);
235 double dphi = std::abs(phiCell - energyPhi);
236 if (dphi >
M_PI) dphi = 2. *
M_PI - dphi;
237
238 bool condition37 = cluster_in_barrel && (deta <= 0.0375 && dphi <= 0.0875);
239 bool condition55 = (!cluster_in_barrel) && (deta <= 0.0625 && dphi <= 0.0625);
240
241 if (condition37 || condition55) {
242 totalEnergy += energyCell;
243 etaEnergyS1 += energyCell * etaCell;
244
245 samp = larcell->caloDDE()->getSampling();
246 rtrigEmCluster.
setEnergy(samp, rtrigEmCluster.
energy(samp) + energyCell);
248 }
249
250 }
251
252
253 double z_emax = -999.0;
254 int z_ncmax = -999;
255 for (
int ic = 0;
ic < 40;
ic++) {
256 if (z_enecell[ic] > z_emax) {
257 z_emax = z_enecell[
ic];
259 }
260 }
261
262
263 double wtot = 0.;
264 double etot = 0.;
265 double wstot = -9999.;
266 double wstot_deta = (z_etamax - z_etamin) * 0.5;
267
268 double eta_center = z_etacell[z_ncmax];
269 if (caloDDE != 0) {
270 eta_center = caloDDE->
eta();
271 wstot_deta = caloDDE->
deta() * 2.5;
272 }
273
274 for (
int ic = 0;
ic < 40;
ic++) {
275 if ((z_etacell[ic] >= (eta_center - wstot_deta)) &&
276 (z_etacell[ic] <= (eta_center + wstot_deta))) {
277 wtot += z_enecell[
ic] * (
ic - z_ncmax) * (ic - z_ncmax);
278 etot += z_enecell[
ic];
279 }
280 }
281 if (etot > 0) {
282 wtot = wtot / etot;
283 wstot = wtot > 0 ? sqrt(wtot) : -9999.;
284 }
285
286
287
288 double z_esec1 = -999.0;
289
290 double ecand1;
291
292 for (int iic = 1; iic < 39; iic++) {
293 if ((z_enecell[iic] > z_enecell[iic - 1]) && (z_enecell[iic] > z_enecell[iic + 1])) {
294 if (iic != z_ncmax) {
295 ecand1 = z_enecell[iic];
296 if (ecand1 > z_esec1) {
297 z_esec1 = ecand1;
298
299 }
300 }
301 }
302 }
303
304 if ((z_emax + z_esec1) < 0.) z_emax = -(100. / 98.) * z_esec1;
305
306
307
308 double strip7 = 0.;
309 double strip3 = 0.;
310 double frac73 = 0.;
311
312
313
314 int smax = z_ncmax;
315 if (z_ncmax > 2 && z_ncmax < 37) {
316 strip7 = z_enecell[smax - 3] + z_enecell[smax - 2] + z_enecell[smax - 1] + z_enecell[smax + 1] +
317 z_enecell[smax + 2] + z_enecell[smax + 3] + z_enecell[smax];
318 strip3 = z_enecell[smax - 1] + z_enecell[smax] + z_enecell[smax + 1];
319 }
320 else if (z_ncmax == 2) {
321 strip7 = z_enecell[smax - 2] + z_enecell[smax - 1] + z_enecell[smax + 1] + z_enecell[smax + 2] +
322 z_enecell[smax + 3] + z_enecell[smax];
323 strip3 = z_enecell[smax - 1] + z_enecell[smax] + z_enecell[smax + 1];
324 }
325 else if (z_ncmax == 37) {
326 strip7 = z_enecell[smax - 3] + z_enecell[smax - 2] + z_enecell[smax - 1] + z_enecell[smax + 1] +
327 z_enecell[smax + 2] + z_enecell[smax];
328 strip3 = z_enecell[smax - 1] + z_enecell[smax] + z_enecell[smax + 1];
329 }
330 else if (z_ncmax == 1) {
331 strip7 = z_enecell[smax - 1] + z_enecell[smax + 1] + z_enecell[smax + 2] + z_enecell[smax + 3] +
332 z_enecell[smax];
333 strip3 = z_enecell[smax - 1] + z_enecell[smax] + z_enecell[smax + 1];
334 }
335 else if (z_ncmax == 38) {
336 strip7 = z_enecell[smax - 3] + z_enecell[smax - 2] + z_enecell[smax - 1] + z_enecell[smax + 1] +
337 z_enecell[smax];
338 strip3 = z_enecell[smax - 1] + z_enecell[smax] + z_enecell[smax + 1];
339 }
340 strip3 > 1.e-6 ?
341 frac73 = (strip7 - strip3) / strip3
342 : frac73 = 99.;
343
344
345
351 if (totalEnergy != 0.0)
352 rtrigEmCluster.
setEta1(etaEnergyS1 / totalEnergy);
353 else
356
357
358 return StatusCode::SUCCESS;
359}
#define ATH_CHECK
Evaluate an expression and check for errors.
float eta() const
cell eta
float phi() const
cell phi
float deta() const
cell deta
bool is_lar_em_barrel() const
cell belongs to EM barrel
void setNCells(int)
set number of cells used from RoI
float rawEnergy() const
get Raw Energy (no calibration)
int nCells() const
get number of cells used from RoI
void setRawEnergy(float)
set Raw Energy (no calibration)
float eta() const
get Eta (calibrated)
void setEnergy(float energy)
set Energy (calibrated)
void setE2tsts1(float)
set second maximum energy in sampling 1 (strip layer)
float phi() const
get Phi (calibrated)
void setEmaxs1(float)
set maximum energy in sampling 1 (strip layer)
void setFracs1(float)
set Energy in a 7 strips (around hottest strip) minus energy in 3 strips divided by energy in 3 strip...
void setWstot(float)
set width in first layer
float energy() const
get Energy (calibrated)
void setEta1(float)
set Eta sampling 1 (strip layer)
int ir
counter of the current depth
iadd(self, tool)
associator for public tools -------------------------------------------—
setEt setPhi setE277 setWeta2 setEta1 setE2tsts1 wstot
double proxim(double b, double a)