8 #include "CLHEP/Units/SystemOfUnits.h"
20 constexpr
int neta = 5;
22 constexpr
int nphi = 2;
24 constexpr
int STRIP_ARRAY_SIZE = 8 * neta;
27 proxim(
const double b,
const double a)
33 dim(
const double a,
const double b)
38 struct StripArrayHelper
47 bool operator<(
const StripArrayHelper& cell2)
const
49 return etaraw < cell2.etaraw;
94 double etamin = etaraw - deta;
95 double etamax = etaraw + deta;
96 double phimin = phiraw - dphi;
97 double phimax = phiraw + dphi;
103 std::vector<StripArrayHelper> stripArray;
104 stripArray.reserve(2 * STRIP_ARRAY_SIZE);
106 double eta_cell = 0.;
107 double phi_cell0 = 0.;
108 double phi_cell = 0.;
121 phi_cell =
proxim(phi_cell0, phiraw);
123 if (eta_cell >=
etamin && eta_cell <= etamax) {
124 if (phi_cell >= phimin && phi_cell <= phimax) {
125 StripArrayHelper stripHelp;
127 stripHelp.energy = theCell->
energy() * (
first.weight());
129 stripHelp.eta = theCell->
eta();
136 stripArray.push_back(stripHelp);
141 const size_t elementCount = stripArray.size();
143 if (elementCount == 0) {
147 std::sort(stripArray.begin(), stripArray.end());
152 for (
size_t i = 0;
i < (elementCount - 1); ++
i) {
154 if (ieta < STRIP_ARRAY_SIZE) {
156 enecell[ieta] += stripArray[
i].energy;
158 etacell[ieta] = stripArray[
i].eta;
160 gracell[ieta] = stripArray[
i].deta;
165 if (std::abs(stripArray[
i].etaraw - stripArray[
i + 1].etaraw) > 1
e-05)
176 int index = elementCount - 1;
179 if (
index == 0 || std::abs(stripArray[
index].etaraw -
180 stripArray[
index - 1].etaraw) > 1
e-05) {
182 enecell[ieta] = stripArray[
index].energy;
184 if (
index != 0 && std::abs(stripArray[
index].etaraw -
185 stripArray[
index - 1].etaraw) < 1
e-05) {
187 enecell[ieta] += stripArray[
index].energy;
190 etacell[ieta] = stripArray[
index].eta;
192 gracell[ieta] = stripArray[
index].deta;
200 const double* etacell,
201 const double* gracell)
206 double demi_eta = 0.;
209 for (
int ieta = 0; ieta < STRIP_ARRAY_SIZE - 1; ieta++) {
212 demi_eta = gracell[ieta] / 2.;
213 eta_min = etacell[ieta] - demi_eta;
214 eta_max = etacell[ieta] + demi_eta;
216 if ((std::abs(
info.etaseed) > std::abs(eta_min) &&
217 std::abs(
info.etaseed) <= std::abs(eta_max)) ||
218 (std::abs(
info.etaseed) <= std::abs(eta_min) &&
219 std::abs(
info.etaseed) > std::abs(eta_max)))
220 info.ncetaseed = ieta;
228 const double* enecell,
229 const double* etacell,
237 double etamax =
info.etamax + deta / 2.;
242 for (
int ieta = 0; ieta < STRIP_ARRAY_SIZE; ieta++) {
243 if (
ncell[ieta] == 0)
245 if (etacell[ieta] >=
etamin && etacell[ieta] <= etamax) {
246 wtot += enecell[ieta] * (ieta -
info.ncetamax) * (ieta -
info.ncetamax);
247 mean += enecell[ieta] * (ieta -
info.ncetamax);
248 etot += enecell[ieta];
256 info.wstot = wtot > 0 ? std::sqrt(wtot) : -9999.;
263 const double* enecell,
264 const double eallsamples)
271 double eleft =
info.ncetamax > 0 ? enecell[
info.ncetamax - 1] : 0;
274 info.ncetamax < STRIP_ARRAY_SIZE - 1 ? enecell[
info.ncetamax + 1] : 0;
278 info.f2 = eallsamples > 0. ? (
e1 +
e2) / eallsamples : 0.;
289 if (
info.ncetamax < 0 ||
info.ncetamax > STRIP_ARRAY_SIZE)
293 int nhi =
std::min(
info.ncetamax + 1, STRIP_ARRAY_SIZE - 1);
294 for (
int ieta = nlo; ieta <= nhi; ieta++) {
301 nhi =
std::min(
info.ncetamax + 7, STRIP_ARRAY_SIZE - 1);
302 for (
int ieta = nlo; ieta <= nhi; ieta++) {
316 if (
info.ncetamax < 0 ||
info.ncetamax > STRIP_ARRAY_SIZE)
324 int nhi =
std::min(
info.ncetamax + 1, STRIP_ARRAY_SIZE - 1);
325 for (
int ieta = nlo; ieta <=
info.ncetamax; ieta++)
326 asl += enecell[ieta];
327 for (
int ieta =
info.ncetamax; ieta <= nhi; ieta++)
328 asr += enecell[ieta];
331 info.asymmetrys3 = (asl - asr) / (asl + asr);
339 const double* enecell,
340 const double* etacell,
352 int nhi =
std::min(
info.ncetamax + 1, STRIP_ARRAY_SIZE - 1);
353 for (
int ieta = nlo; ieta <= nhi; ieta++) {
354 if (
ncell[ieta] == 0)
356 width3 += enecell[ieta] * (ieta -
info.ncetamax) * (ieta -
info.ncetamax);
357 eta1 += enecell[ieta] * etacell[ieta];
377 setDeltaEtaTrackShower(
int nstrips,
int ieta,
const double* enecell)
389 int nlo =
std::max(ieta - nstrips, 0);
391 int nhi =
std::min(ieta + nstrips, STRIP_ARRAY_SIZE - 1);
393 for (
int i = nlo;
i <= nhi;
i++) {
395 pos += enecell[
i] * (
i - ieta);
416 double Small = 1.e-10;
423 int nhi =
std::min(
info.ncetamax + 2, STRIP_ARRAY_SIZE - 1);
425 for (
int ieta = nlo; ieta <= nhi; ieta++) {
426 if (ieta >= 0 && ieta < STRIP_ARRAY_SIZE) {
428 eall += enecell[ieta];
430 eave += enecell[ieta] * (ieta -
info.ncetamax);
432 width5 += enecell[ieta] * (ieta -
info.ncetamax) * (ieta -
info.ncetamax);
440 width5 = width5 / eall;
441 width5 = width5 - eave * eave;
446 info.widths5 = std::sqrt(width5);
456 for (
int ieta = 0; ieta < STRIP_ARRAY_SIZE; ieta++) {
457 if (enecell[ieta] >
info.emaxs1) {
458 info.emaxs1 = enecell[ieta];
459 info.ncetamax = ieta;
467 const double* enecell,
468 const double* gracell,
478 double escalesec = 0;
479 double escalesec1 = 0;
481 for (
int ieta = 1; ieta < STRIP_ARRAY_SIZE - 1; ieta++) {
482 if (
ncell[ieta] == 0)
485 int ieta_left = ieta - 1;
486 while (ieta_left >= 0 &&
ncell[ieta_left] == 0) {
493 int ieta_right = ieta + 1;
494 while (ieta_right < STRIP_ARRAY_SIZE &&
ncell[ieta_right] == 0) {
497 if (ieta_right >= STRIP_ARRAY_SIZE) {
501 double e = enecell[ieta] / gracell[ieta];
502 double e_left = enecell[ieta_left] / gracell[ieta_left];
503 double e_right = enecell[ieta_right] / gracell[ieta_right];
505 if (
e > e_left &&
e > e_right) {
509 if (ieta !=
info.ncetamax) {
510 ecand = enecell[ieta] + enecell[ieta_left] + enecell[ieta_right];
511 double escalecand =
e + e_left + e_right;
512 ecand1 = enecell[ieta];
515 if (escalecand > escalesec) {
516 escalesec = escalecand;
521 if (
e > escalesec1) {
536 const double* enecell,
537 const double* gracell,
546 double escalemin =
info.emaxs1 / 0.001;
556 for (
int ieta = nlo; ieta <= nhi; ieta++) {
557 if (
ncell[ieta] == 0)
562 double escale = enecell[ieta] / gracell[ieta];
563 if (escale < escalemin) {
565 info.emins1 = enecell[ieta];
579 double Ehsthr = 0.06 *
GeV;
583 for (
int ieta =
info.ncetamax + 2; ieta < STRIP_ARRAY_SIZE - 1; ieta++) {
584 if (enecell[ieta] > Ehsthr &&
585 enecell[ieta] >
std::max(enecell[ieta - 1], enecell[ieta + 1])) {
587 for (
int jc =
info.ncetamax; jc <= ieta - 1; jc++) {
588 valley +=
dim(enecell[ieta], enecell[jc]);
596 for (
int ieta = 1; ieta <=
info.ncetamax - 2; ieta++) {
597 if (enecell[ieta] > Ehsthr &&
598 enecell[ieta] >
std::max(enecell[ieta - 1], enecell[ieta + 1])) {
600 for (
int jc = ieta + 1; jc <=
info.ncetamax; jc++) {
601 valley +=
dim(enecell[ieta], enecell[jc]);
611 double eleft =
info.ncetamax > 0 ? enecell[
info.ncetamax - 1] : 0;
614 info.ncetamax < STRIP_ARRAY_SIZE - 1 ? enecell[
info.ncetamax + 1] : 0;
618 if (std::abs(
e1 +
e2) > 0.)
626 const double* enecell,
627 const double* gracell,
636 double Ehsthr = 0.06 *
GeV;
640 int ileft =
info.ncetamax - 1;
641 while (ileft > 0 &&
ncell[ileft] == 0) {
644 double eleft = ileft >= 0 ? enecell[ileft] : 0;
647 int iright =
info.ncetamax + 1;
648 while (iright < STRIP_ARRAY_SIZE - 1 &&
ncell[iright] == 0) {
651 double eright = iright < STRIP_ARRAY_SIZE ? enecell[iright] : 0;
658 int nhi =
std::min(
info.ncetamax + 3, STRIP_ARRAY_SIZE - 1);
661 for (
int ieta = nlo; ieta <= nhi; ieta++) {
662 if (
ncell[ieta] == 0)
664 fracm += (gracell[ieta] > DBL_MIN) ? (enecell[ieta] / gracell[ieta]) : 0.;
666 if (std::abs(eleft + eright +
e1) > 0.) {
667 if ((
e1 != 0) && (gracell[
info.ncetamax] > DBL_MIN))
668 e1 /= gracell[
info.ncetamax];
670 eleft /= gracell[ileft];
672 eright /= gracell[iright];
674 info.fside = (std::abs(eleft + eright +
e1) > 0.)
675 ? fracm / (eleft + eright +
e1) - 1.
705 bool ExecAllVariables)
715 return StatusCode::SUCCESS;
743 if ((
info.etamax == 0. &&
info.phimax == 0.) ||
744 std::abs(
info.etamax) > 100.) {
745 return StatusCode::SUCCESS;
748 if (std::abs(
info.etamax) > 2.4) {
749 return StatusCode::SUCCESS;
751 if (std::abs(
info.etamax) > 1.4 && std::abs(
info.etamax) < 1.5) {
752 return StatusCode::SUCCESS;
759 int sampling_or_module = 0;
766 return StatusCode::SUCCESS;
769 deta = dde->
deta() * neta / 2.0;
777 return StatusCode::SUCCESS;
780 dphi = dde->
dphi() * nphi / 2.0;
783 double enecell[STRIP_ARRAY_SIZE] = { 0 };
784 double etacell[STRIP_ARRAY_SIZE] = { 0 };
785 double gracell[STRIP_ARRAY_SIZE] = { 0 };
786 int ncell[STRIP_ARRAY_SIZE] = { 0 };
803 setIndexSeed(
info, etacell, gracell);
805 info.f1 = std::abs(eallsamples) > 0. ?
e1 / eallsamples : 0.;
807 setEmax(
info, enecell);
809 setWstot(
info, deta, enecell, etacell,
ncell);
811 setWs3(
info, sam, cluster, enecell, etacell,
ncell);
813 if (ExecAllVariables) {
814 setEnergy(
info, enecell);
815 setF1core(
info, cluster);
817 setAsymmetry(
info, enecell);
820 info.deltaEtaTrackShower =
821 setDeltaEtaTrackShower(1,
info.ncetamax, enecell);
824 info.deltaEtaTrackShower7 =
825 setDeltaEtaTrackShower(7,
info.ncetaseed, enecell);
827 setF2(
info, enecell, eallsamples);
829 setWidths5(
info, enecell);
831 int ncsec1 = setEmax2(
info, enecell, gracell,
ncell);
833 setEmin(ncsec1,
info, enecell, gracell,
ncell);
835 setValley(
info, enecell);
840 return StatusCode::SUCCESS;