39 bool cluster_in_barrel =
true;
50 double totalEnergy = 0;
51 double etaEnergyS1 = 0;
54 double energyEta = rtrigEmCluster.
eta();
55 double energyPhi = rtrigEmCluster.
phi();
57 energyEta = caloDDE->
eta();
58 energyPhi = caloDDE->
phi();
64 double z_etamin = energyEta - (0.075 / 2.);
65 double z_etamax = energyEta + (0.075 / 2.);
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;
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;
77 double z_eta = z_etamin + (z_etamax - z_etamin) * 0.5;
78 double z_phi = z_phimin + (z_phimax - z_phimin) * 0.5;
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;
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;
91 if ((z_etamin < 0) && (z_etamax > 0))
signals =
true;
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};
101 for (
int ir = 0;
ir < 5;
ir++) {
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;
109 const double inv_dgra = dgra != 0 ? 1. / dgra : 1;
114 double aeta = std::abs(z_eta);
116 strip_border = (
int)rint(aeta * inv_dgra);
118 etanew = ((
double)strip_border - 0.5) * dgra;
124 strip_border = (
int)rint(aeta * inv_dgra);
126 etanew = ((
double)strip_border - 0.5) * dgra;
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;
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;
140 etanew = (z_eta < 0.) ? -etanew : etanew;
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;
153 if (imax < 4 && z_etamax > etareg[
imax + 1] && z_etamax <= etareg[
imax + 2]) {
154 dgra1 = etagra[
imax + 1];
155 ibin = (
int)rint((etareg[
imax + 1] - 0.5 * dgra - etanew) * inv_dgra) + 20;
161 ibin = (
int)rint((etareg[0] + 0.5 * dgra - etanew) * inv_dgra) + 20;
166 ibin = (
int)rint((etareg[5] - 0.5 * dgra - etanew) * inv_dgra) + 20;
170 const double inv_dgra1 = dgra1 != 0 ? 1. / dgra1 : 1;
174 double z_enecell[40];
175 double z_etacell[40];
177 for (
int iii = 0; iii < 40; iii++) {
186 double etaCell = larcell->caloDDE()->eta_raw();
187 double phiCell = larcell->phi();
188 double energyCell = larcell->energy();
190 if (std::abs(etanew) != 99.) {
192 double eta_cell = etaCell;
196 if (eta_cell >= z_etamin && eta_cell <= z_etamax) {
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) {
204 ieta = (
int)rint((eta_cell - etanew) * inv_dgra) + 20;
207 ieta = (
int)rint((eta_cell - etanew + 0.007) * inv_dgra) + 20;
210 if (eta_cell > etareg[
imax] && eta_cell < etareg[
imax + 1]) {
212 ieta = (
int)rint((eta_cell - etanew) * inv_dgra) + 20;
216 ieta = (
int)rint((eta_cell - etareg[
imax +
iadd] - (0.5 -
iadd) * dgra1) *
222 double z_e = energyCell;
224 if (ieta >= 1 && ieta <= 40) {
225 z_enecell[ieta - 1] += z_e;
226 z_etacell[ieta - 1] = eta_cell;
234 double deta = std::abs(etaCell - energyEta);
235 double dphi = std::abs(phiCell - energyPhi);
236 if (dphi >
M_PI) dphi = 2. *
M_PI - dphi;
238 bool condition37 = cluster_in_barrel && (deta <= 0.0375 && dphi <= 0.0875);
239 bool condition55 = (!cluster_in_barrel) && (deta <= 0.0625 && dphi <= 0.0625);
241 if (condition37 || condition55) {
242 totalEnergy += energyCell;
243 etaEnergyS1 += energyCell * etaCell;
245 samp = larcell->caloDDE()->getSampling();
246 rtrigEmCluster.
setEnergy(samp, rtrigEmCluster.
energy(samp) + energyCell);
253 double z_emax = -999.0;
255 for (
int ic = 0;
ic < 40;
ic++) {
256 if (z_enecell[
ic] > z_emax) {
257 z_emax = z_enecell[
ic];
265 double wstot = -9999.;
266 double wstot_deta = (z_etamax - z_etamin) * 0.5;
268 double eta_center = z_etacell[z_ncmax];
270 eta_center = caloDDE->
eta();
271 wstot_deta = caloDDE->
deta() * 2.5;
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];
283 wstot = wtot > 0 ? sqrt(wtot) : -9999.;
288 double z_esec1 = -999.0;
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) {
304 if ((z_emax + z_esec1) < 0.) z_emax = -(100. / 98.) * z_esec1;
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];
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];
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];
330 else if (z_ncmax == 1) {
331 strip7 = z_enecell[smax - 1] + z_enecell[smax + 1] + z_enecell[smax + 2] + z_enecell[smax + 3] +
333 strip3 = z_enecell[smax - 1] + z_enecell[smax] + z_enecell[smax + 1];
335 else if (z_ncmax == 38) {
336 strip7 = z_enecell[smax - 3] + z_enecell[smax - 2] + z_enecell[smax - 1] + z_enecell[smax + 1] +
338 strip3 = z_enecell[smax - 1] + z_enecell[smax] + z_enecell[smax + 1];
341 frac73 = (strip7 - strip3) / strip3
351 if (totalEnergy != 0.0)
352 rtrigEmCluster.
setEta1(etaEnergyS1 / totalEnergy);
358 return StatusCode::SUCCESS;