1 #ifndef RecoEcal_EgammaCoreTools_EcalClusterTools_h
2 #define RecoEcal_EgammaCoreTools_EcalClusterTools_h
52 #include "CLHEP/Geometry/Transform3D.h"
212 double phiCorrectionFactor = 0.8,
214 bool useLogWeights =
true);
218 double phiCorrectionFactor = 0.8,
220 bool useLogWeights =
true);
222 double phiCorrectionFactor = 0.8,
224 bool useLogWeights =
true);
259 static float getFraction(
const std::vector<std::pair<DetId, float>> &v_id,
DetId id);
261 static std::pair<DetId, float>
getMaximum(
const std::vector<std::pair<DetId, float>> &v_id,
270 int weightedPositionMethod = 0,
276 float energyRHThresh = 0.00000,
277 int weightedPositionMethod = 0);
279 const std::vector<std::pair<const EcalRecHit *, float>> &rhVector,
int weightedPositionMethod = 0);
312 static double f00(
double r) {
return 1; }
313 static double f11(
double r) {
return r; }
314 static double f20(
double r) {
return 2.0 *
r *
r - 1.0; }
315 static double f22(
double r) {
return r *
r; }
316 static double f31(
double r) {
return 3.0 *
r *
r *
r - 2.0 *
r; }
317 static double f33(
double r) {
return r *
r *
r; }
318 static double f40(
double r) {
return 6.0 *
r *
r *
r *
r - 6.0 *
r *
r + 1.0; }
319 static double f42(
double r) {
return 4.0 *
r *
r *
r *
r - 3.0 *
r *
r; }
320 static double f44(
double r) {
return r *
r *
r *
r; }
321 static double f51(
double r) {
return 10.0 *
pow(
r, 5) - 12.0 *
pow(
r, 3) + 3.0 *
r; }
322 static double f53(
double r) {
return 5.0 *
pow(
r, 5) - 4.0 *
pow(
r, 3); }
352 for (
int i = 2;
i <=
n; ++
i)
367 static int deltaIEta(
int seed_ieta,
int rh_ieta);
368 static int deltaIPhi(
int seed_iphi,
int rh_iphi);
369 static std::vector<int>
getSeedPosition(
const std::vector<std::pair<const EcalRecHit *, float>> &RH_ptrs);
370 static float getSumEnergy(
const std::vector<std::pair<const EcalRecHit *, float>> &RH_ptrs_fracs);
371 static float computeWeight(
float eRH,
float energyTotal,
int weightedPositionMethod);
380 for (
size_t i = 0;
i < v_id.size(); ++
i) {
381 if (v_id[
i].
first.rawId() ==
id.rawId()) {
382 frac = v_id[
i].second;
394 for (
size_t i = 0;
i < v_id.size(); ++
i) {
401 return std::pair<DetId, float>(
id,
max);
412 if (
id ==
DetId(0)) {
452 for (
auto const &detId : rectangle(
id, *
topology)) {
453 energy += recHitEnergy(detId,
recHits) * getFraction(vId, detId);
467 for (
auto const &detId : rectangle(
id, *
topology)) {
480 std::vector<DetId>
v;
481 for (
auto const &detId : rectangle(
id, *
topology)) {
482 if (detId !=
DetId(0))
493 std::list<float> energies;
494 float max_E = matrixEnergy(cluster,
recHits,
topology,
id, {-1, 0, -1, 0});
506 float max_E = matrixEnergy(cluster,
recHits,
topology,
id, {-1, 1, -1, 0});
526 float max_E = matrixEnergy(cluster,
recHits,
topology,
id, {-1, 2, -2, 1});
556 std::vector<float> energies;
557 const std::vector<std::pair<DetId, float>> &v_id = cluster.
hitsAndFractions();
558 energies.reserve(v_id.size());
561 for (
size_t i = 0;
i < v_id.size(); ++
i) {
564 std::partial_sort(energies.begin(), energies.begin() + 2, energies.end(), std::greater<float>());
609 float left = matrixEnergy(cluster,
recHits,
topology,
id, {-1, -1, -2, 2});
611 float right = matrixEnergy(cluster,
recHits,
topology,
id, {1, 1, -2, 2});
613 float centre = matrixEnergy(cluster,
recHits,
topology,
id, {0, 0, -2, 2});
616 return left > right ? left + centre : right + centre;
687 float clusterEnergy = cluster.
energy();
688 const std::vector<std::pair<DetId, float>> &v_id = cluster.
hitsAndFractions();
691 <<
"Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel "
692 "basic-clusters. Returning empty vector.";
693 return basketFraction;
695 for (
size_t i = 0;
i < v_id.size(); ++
i) {
697 recHitEnergy(v_id[
i].
first,
recHits) * v_id[
i].second / clusterEnergy;
699 std::sort(basketFraction.rbegin(), basketFraction.rend());
700 return basketFraction;
707 float clusterEnergy = cluster.
energy();
708 const std::vector<std::pair<DetId, float>> &v_id = cluster.
hitsAndFractions();
711 <<
"Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel "
712 "basic-clusters. Returning empty vector.";
713 return basketFraction;
715 for (
size_t i = 0;
i < v_id.size(); ++
i) {
720 std::sort(basketFraction.rbegin(), basketFraction.rend());
721 return basketFraction;
725 std::vector<typename EcalClusterToolsT<noZS>::EcalClusterEnergyDeposition>
731 std::vector<typename EcalClusterToolsT<noZS>::EcalClusterEnergyDeposition> energyDistribution;
735 CLHEP::Hep3Vector clDir(clVect);
736 clDir *= 1.0 / clDir.mag();
738 CLHEP::Hep3Vector theta_axis(clDir.y(), -clDir.x(), 0.0);
739 theta_axis *= 1.0 / theta_axis.mag();
740 CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);
742 const std::vector<std::pair<DetId, float>> &clusterDetIds = cluster.
hitsAndFractions();
746 std::vector<std::pair<DetId, float>>::const_iterator posCurrent;
748 for (posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); ++posCurrent) {
750 testEcalRecHit = *itt;
752 if (((*posCurrent).first !=
DetId(0)) && (
recHits->find((*posCurrent).first) !=
recHits->end())) {
761 <<
" GeV; skipping... ";
766 DetId id_ = (*posCurrent).first;
769 const GlobalPoint &cellPos = this_cell->getPosition();
770 CLHEP::Hep3Vector gblPos(cellPos.
x(), cellPos.
y(), cellPos.
z());
772 CLHEP::Hep3Vector
diff = gblPos - clVect;
776 CLHEP::Hep3Vector DigiVect =
diff -
diff.dot(clDir) * clDir;
777 clEdep.
r = DigiVect.mag();
779 <<
"\tr = " << clEdep.
r;
780 clEdep.
phi = DigiVect.angle(theta_axis);
781 if (DigiVect.dot(phi_axis) < 0)
783 energyDistribution.push_back(clEdep);
786 return energyDistribution;
795 std::vector<EcalClusterToolsT::EcalClusterEnergyDeposition> energyDistribution =
798 std::vector<float> lat;
799 double r, redmoment = 0;
800 double phiRedmoment = 0;
801 double etaRedmoment = 0;
803 int clusterSize = energyDistribution.size();
804 float etaLat_, phiLat_, lat_;
805 if (clusterSize < 3) {
816 if (energyDistribution[1].deposited_energy > energyDistribution[0].deposited_energy) {
821 for (
int i = 2;
i < clusterSize;
i++) {
823 if (energyDistribution[
i].deposited_energy > energyDistribution[n1].deposited_energy) {
829 if (energyDistribution[
i].deposited_energy > energyDistribution[n2].deposited_energy) {
836 r = energyDistribution[
n].r;
837 redmoment +=
r *
r * energyDistribution[
n].deposited_energy;
838 double rphi =
r *
cos(energyDistribution[
n].
phi);
839 phiRedmoment += rphi * rphi * energyDistribution[
n].deposited_energy;
840 double reta =
r *
sin(energyDistribution[
n].
phi);
841 etaRedmoment += reta * reta * energyDistribution[
n].deposited_energy;
843 double e1 = energyDistribution[n1].deposited_energy;
844 double e2 = energyDistribution[n2].deposited_energy;
846 lat_ = redmoment / (redmoment + 2.19 * 2.19 * (
e1 + e2));
847 phiLat_ = phiRedmoment / (phiRedmoment + 2.19 * 2.19 * (
e1 + e2));
848 etaLat_ = etaRedmoment / (etaRedmoment + 2.19 * 2.19 * (
e1 + e2));
850 lat.push_back(etaLat_);
851 lat.push_back(phiLat_);
863 const std::vector<std::pair<DetId, float>> &hsAndFs = cluster.
hitsAndFractions();
865 for (
const std::pair<DetId, float> &hitAndFrac : hsAndFs) {
866 for (std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it) {
867 if (hitAndFrac.first != *it && !
noZS)
872 meanPosition = meanPosition + recHitEnergy(*it,
recHits) *
position * hitAndFrac.second;
896 const std::vector<std::pair<DetId, float>> &hsAndFs = cluster.
hitsAndFractions();
897 std::vector<DetId> v_id = matrixDetId(
topology, seedId, 2);
898 for (
const std::pair<DetId, float> &hAndF : hsAndFs) {
899 for (std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it) {
900 if (hAndF.first != *it && !
noZS)
905 meanDEta +=
energy * getNrCrysDiffInEta(*it, seedId);
906 meanDPhi +=
energy * getNrCrysDiffInPhi(*it, seedId);
914 return std::pair<float, float>(meanDEta, meanDPhi);
929 std::pair<float, float> meanXY(0., 0.);
935 const std::vector<std::pair<DetId, float>> &hsAndFs = cluster.
hitsAndFractions();
936 std::vector<DetId> v_id = matrixDetId(
topology, seedId, 2);
937 for (
const std::pair<DetId, float> &hAndF : hsAndFs) {
938 for (std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it) {
939 if (hAndF.first != *it && !
noZS)
944 meanXY.first +=
energy * getNormedIX(*it);
945 meanXY.second +=
energy * getNormedIY(*it);
963 float covEtaEta, covEtaPhi, covPhiPhi;
966 const std::vector<std::pair<DetId, float>> &v_id = cluster.
hitsAndFractions();
970 double numeratorEtaEta = 0;
971 double numeratorEtaPhi = 0;
972 double numeratorPhiPhi = 0;
977 for (
auto const &detId : rectangle(
id, *
topology)) {
978 float frac = getFraction(v_id, detId);
1022 std::vector<float>
v;
1023 v.push_back(covEtaEta);
1024 v.push_back(covEtaPhi);
1025 v.push_back(covPhiPhi);
1033 template <
bool noZS>
1039 float covEtaEta, covEtaPhi, covPhiPhi;
1043 const std::vector<std::pair<DetId, float>> &v_id = cluster.
hitsAndFractions();
1044 std::pair<float, float> mean5x5PosInNrCrysFromSeed = mean5x5PositionInLocalCrysCoord(cluster,
recHits,
topology);
1045 std::pair<float, float> mean5x5XYPos = mean5x5PositionInXY(cluster,
recHits,
topology);
1048 double numeratorEtaEta = 0;
1049 double numeratorEtaPhi = 0;
1050 double numeratorPhiPhi = 0;
1055 const double barrelCrysSize = 0.01745;
1056 const double endcapCrysSize = 0.0447;
1061 const double crysSize =
isBarrel ? barrelCrysSize : endcapCrysSize;
1064 for (
auto const &detId : rectangle(seedId, *
topology)) {
1065 float frac = getFraction(v_id, detId);
1070 float dEta = getNrCrysDiffInEta(detId, seedId) - mean5x5PosInNrCrysFromSeed.first;
1074 dPhi = getNrCrysDiffInPhi(detId, seedId) - mean5x5PosInNrCrysFromSeed.second;
1076 dPhi = getDPhiEndcap(detId, mean5x5XYPos.first, mean5x5XYPos.second);
1088 covEtaEta = crysSize * crysSize * numeratorEtaEta /
denominator;
1089 covEtaPhi = crysSize * crysSize * numeratorEtaPhi /
denominator;
1090 covPhiPhi = crysSize * crysSize * numeratorPhiPhi /
denominator;
1104 std::vector<float>
v;
1105 v.push_back(covEtaEta);
1106 v.push_back(covEtaPhi);
1107 v.push_back(covPhiPhi);
1111 template <
bool noZS>
1121 template <
bool noZS>
1131 template <
bool noZS>
1141 if ((
m >
n) || ((
n -
m) % 2 != 0) || (
n < 0) || (
m < 0))
1146 if ((
n > 20) || (
R0 <= 2.19))
1154 template <
bool noZS>
1163 double r, ph,
e, Re = 0, Im = 0;
1164 double TotalEnergy = cluster.
energy();
1165 int index = (
n / 2) * (
n / 2) + (
n / 2) +
m;
1166 std::vector<EcalClusterEnergyDeposition> energyDistribution =
1168 int clusterSize = energyDistribution.size();
1169 if (clusterSize < 3)
1172 for (
int i = 0;
i < clusterSize;
i++) {
1173 r = energyDistribution[
i].r /
R0;
1175 std::vector<double> pol;
1176 pol.push_back(f00(
r));
1177 pol.push_back(f11(
r));
1178 pol.push_back(f20(
r));
1179 pol.push_back(f22(
r));
1180 pol.push_back(f31(
r));
1181 pol.push_back(f33(
r));
1182 pol.push_back(f40(
r));
1183 pol.push_back(f42(
r));
1184 pol.push_back(f44(
r));
1185 pol.push_back(f51(
r));
1186 pol.push_back(f53(
r));
1187 pol.push_back(f55(
r));
1188 ph = (energyDistribution[
i]).
phi;
1189 e = energyDistribution[
i].deposited_energy;
1190 Re = Re +
e / TotalEnergy * pol[
index] *
cos((
double)
m * ph);
1191 Im = Im -
e / TotalEnergy * pol[
index] *
sin((
double)
m * ph);
1194 return sqrt(Re * Re + Im * Im);
1197 template <
bool noZS>
1206 double r, ph,
e, Re = 0, Im = 0, f_nm;
1207 double TotalEnergy = cluster.
energy();
1208 std::vector<EcalClusterEnergyDeposition> energyDistribution =
1210 int clusterSize = energyDistribution.size();
1211 if (clusterSize < 3)
1214 for (
int i = 0;
i < clusterSize; ++
i) {
1215 r = energyDistribution[
i].r /
R0;
1217 ph = energyDistribution[
i].phi;
1218 e = energyDistribution[
i].deposited_energy;
1220 for (
int s = 0;
s <= (
n -
m) / 2;
s++) {
1229 Re = Re +
e / TotalEnergy * f_nm *
cos((
double)
m * ph);
1230 Im = Im -
e / TotalEnergy * f_nm *
sin((
double)
m * ph);
1233 return sqrt(Re * Re + Im * Im);
1240 template <
bool noZS>
1247 float iXNorm = getNormedIX(
id);
1248 float iYNorm = getNormedIY(
id);
1250 return std::sqrt(iXNorm * iXNorm + iYNorm * iYNorm);
1260 template <
bool noZS>
1272 template <
bool noZS>
1276 int iXNorm = eeId.
ix() - 50;
1285 template <
bool noZS>
1289 int iYNorm = eeId.
iy() - 50;
1298 template <
bool noZS>
1300 float crysIEta = getIEta(crysId);
1301 float orginIEta = getIEta(orginId);
1304 float nrCrysDiff = crysIEta - orginIEta;
1309 if (crysIEta * orginIEta < 0) {
1320 template <
bool noZS>
1322 float crysIPhi = getIPhi(crysId);
1323 float orginIPhi = getIPhi(orginId);
1326 float nrCrysDiff = crysIPhi - orginIPhi;
1329 if (nrCrysDiff > +180) {
1330 nrCrysDiff = nrCrysDiff - 360;
1332 if (nrCrysDiff < -180) {
1333 nrCrysDiff = nrCrysDiff + 360;
1340 template <
bool noZS>
1342 float iXNorm = getNormedIX(crysId);
1343 float iYNorm = getNormedIY(crysId);
1345 float hitLocalR2 = (iXNorm - meanX) * (iXNorm - meanX) + (iYNorm - meanY) * (iYNorm - meanY);
1346 float hitR2 = iXNorm * iXNorm + iYNorm * iYNorm;
1347 float meanR2 = meanX * meanX + meanY * meanY;
1348 float hitR =
sqrt(hitR2);
1349 float meanR =
sqrt(meanR2);
1351 float tmp = (hitR2 + meanR2 - hitLocalR2) / (2 * hitR * meanR);
1362 template <
bool noZS>
1370 float covEtaEta, covEtaPhi, covPhiPhi;
1373 const std::vector<std::pair<DetId, float>> &v_id = cluster.
hitsAndFractions();
1374 std::pair<float, float> mean5x5PosInNrCrysFromSeed = mean5x5PositionInLocalCrysCoord(bcluster,
recHits,
topology);
1375 std::pair<float, float> mean5x5XYPos = mean5x5PositionInXY(cluster,
recHits,
topology);
1377 double numeratorEtaEta = 0;
1378 double numeratorEtaPhi = 0;
1379 double numeratorPhiPhi = 0;
1382 const double barrelCrysSize = 0.01745;
1383 const double endcapCrysSize = 0.0447;
1388 const double crysSize =
isBarrel ? barrelCrysSize : endcapCrysSize;
1390 for (
size_t i = 0;
i < v_id.size(); ++
i) {
1391 float frac = getFraction(v_id, v_id[
i].
first);
1397 float dEta = getNrCrysDiffInEta(v_id[
i].
first, seedId) - mean5x5PosInNrCrysFromSeed.first;
1400 dPhi = getNrCrysDiffInPhi(v_id[
i].
first, seedId) - mean5x5PosInNrCrysFromSeed.second;
1402 dPhi = getDPhiEndcap(v_id[
i].
first, mean5x5XYPos.first, mean5x5XYPos.second);
1415 covEtaEta = crysSize * crysSize * numeratorEtaEta /
denominator;
1416 covEtaPhi = crysSize * crysSize * numeratorEtaPhi /
denominator;
1417 covPhiPhi = crysSize * crysSize * numeratorPhiPhi /
denominator;
1432 std::vector<float>
v;
1433 v.push_back(covEtaEta);
1434 v.push_back(covEtaPhi);
1435 v.push_back(covPhiPhi);
1445 template <
bool noZS>
1448 double phiCorrectionFactor,
1450 bool useLogWeights) {
1454 std::vector<std::pair<const EcalRecHit *, float>> RH_ptrs_fracs;
1456 const std::vector<std::pair<DetId, float>> &myHitsPair = basicCluster.
hitsAndFractions();
1458 for (
unsigned int i = 0;
i < myHitsPair.size();
i++) {
1462 RH_ptrs_fracs.push_back(std::make_pair(&(*myRH), myHitsPair[
i].
second));
1469 template <
bool noZS>
1472 double phiCorrectionFactor,
1474 bool useLogWeights) {
1476 *(superCluster.
seed()),
recHits, phiCorrectionFactor, w0, useLogWeights);
1479 template <
bool noZS>
1481 const std::vector<std::pair<const EcalRecHit *, float>> &RH_ptrs_fracs,
1482 double phiCorrectionFactor,
1484 bool useLogWeights) {
1485 if (RH_ptrs_fracs.empty())
1488 double mid_eta(0), mid_phi(0), mid_x(0), mid_y(0);
1492 double max_phi = -10.;
1493 double min_phi = 100.;
1495 std::vector<double> etaDetId;
1496 std::vector<double> phiDetId;
1497 std::vector<double> xDetId;
1498 std::vector<double> yDetId;
1499 std::vector<double> wiDetId;
1501 unsigned int nCry = 0;
1506 for (std::vector<std::pair<const EcalRecHit *, float>>::const_iterator rhf_ptr = RH_ptrs_fracs.begin();
1507 rhf_ptr != RH_ptrs_fracs.end();
1512 double temp_eta(0), temp_phi(0), temp_x(0), temp_y(0);
1516 temp_eta = (getIEta(rh_ptr->
detid()) > 0. ? getIEta(rh_ptr->
detid()) + 84.5 : getIEta(rh_ptr->
detid()) + 85.5);
1517 temp_phi = getIPhi(rh_ptr->
detid()) - 0.5;
1519 temp_eta = getIEta(rh_ptr->
detid());
1520 temp_x = getNormedIX(rh_ptr->
detid());
1521 temp_y = getNormedIY(rh_ptr->
detid());
1524 double temp_ene = rh_ptr->
energy() * (
noZS ? 1.0 : rhf_ptr->second);
1528 if (temp_phi > max_phi)
1530 if (temp_phi < min_phi)
1532 etaDetId.push_back(temp_eta);
1533 phiDetId.push_back(temp_phi);
1534 xDetId.push_back(temp_x);
1535 yDetId.push_back(temp_y);
1536 wiDetId.push_back(temp_wi);
1543 if (max_phi == 359.5 && min_phi == 0.5) {
1544 for (
unsigned int i = 0;
i < nCry;
i++) {
1545 if (phiDetId[
i] - 179. > 0.)
1546 phiDetId[
i] -= 360.;
1547 mid_phi += phiDetId[
i] * wiDetId[
i];
1548 mid_eta += etaDetId[
i] * wiDetId[
i];
1551 for (
unsigned int i = 0;
i < nCry;
i++) {
1552 mid_phi += phiDetId[
i] * wiDetId[
i];
1553 mid_eta += etaDetId[
i] * wiDetId[
i];
1557 for (
unsigned int i = 0;
i < nCry;
i++) {
1558 mid_eta += etaDetId[
i] * wiDetId[
i];
1559 mid_x += xDetId[
i] * wiDetId[
i];
1560 mid_y += yDetId[
i] * wiDetId[
i];
1575 double deta(0), dphi(0);
1577 for (
unsigned int i = 0;
i < nCry;
i++) {
1579 deta = etaDetId[
i] - mid_eta;
1580 dphi = phiDetId[
i] - mid_phi;
1582 deta = etaDetId[
i] - mid_eta;
1583 float hitLocalR2 = (xDetId[
i] - mid_x) * (xDetId[
i] - mid_x) + (yDetId[
i] - mid_y) * (yDetId[
i] - mid_y);
1584 float hitR2 = xDetId[
i] * xDetId[
i] + yDetId[
i] * yDetId[
i];
1585 float meanR2 = mid_x * mid_x + mid_y * mid_y;
1586 float hitR =
sqrt(hitR2);
1587 float meanR =
sqrt(meanR2);
1588 float phi = acos((hitR2 + meanR2 - hitLocalR2) / (2 * hitR * meanR));
1592 Spp += phiCorrectionFactor * (wiDetId[
i] * dphi * dphi) /
denominator;
1593 Sep +=
sqrt(phiCorrectionFactor) * (wiDetId[
i] * deta * dphi) /
denominator;
1599 returnMoments.
sMaj = ((See + Spp) +
sqrt((See - Spp) * (See - Spp) + 4. * Sep * Sep)) / 2.;
1600 returnMoments.
sMin = ((See + Spp) -
sqrt((See - Spp) * (See - Spp) + 4. * Sep * Sep)) / 2.;
1602 returnMoments.
alpha = atan((See - Spp +
sqrt((Spp - See) * (Spp - See) + 4. * Sep * Sep)) / (2. * Sep));
1604 return returnMoments;
1614 template <
bool noZS>
1618 int weightedPositionMethod,
1620 std::vector<std::pair<const EcalRecHit *, float>> RH_ptrs_fracs;
1621 const std::vector<std::pair<DetId, float>> &myHitsPair = superCluster.
hitsAndFractions();
1622 for (
unsigned int i = 0;
i < myHitsPair.size(); ++
i) {
1627 RH_ptrs_fracs.push_back(std::make_pair(&(*myRH), myHitsPair[
i].
second));
1630 std::vector<float>
temp =
1639 template <
bool noZS>
1645 float energyRHThresh,
1646 int weightedPositionMethod) {
1647 std::vector<std::pair<const EcalRecHit *, float>> RH_ptrs_fracs;
1648 const std::vector<std::pair<DetId, float>> &myHitsPair = superCluster.
hitsAndFractions();
1649 for (
unsigned int i = 0;
i < myHitsPair.size(); ++
i) {
1652 if (myRH !=
recHits.end() && myRH->energy() * (
noZS ? 1.0 : myHitsPair[
i].second) > energyRHThresh)
1653 RH_ptrs_fracs.push_back(std::make_pair(&(*myRH), myHitsPair[
i].
second));
1659 EBDetId EBdetIdi(rh->detid());
1660 float the_fraction = 0;
1662 bool inEtaWindow = (
abs(deltaIEta(seedPosition[0], EBdetIdi.ieta())) <= ieta_delta);
1663 bool inPhiWindow = (
abs(deltaIPhi(seedPosition[1], EBdetIdi.iphi())) <= iphi_delta);
1664 bool passEThresh = (rh->energy() > energyRHThresh);
1665 bool alreadyCounted =
false;
1668 bool is_SCrh_inside_recHits =
false;
1669 for (
unsigned int i = 0;
i < myHitsPair.size();
i++) {
1672 the_fraction = myHitsPair[
i].second;
1673 is_SCrh_inside_recHits =
true;
1674 if (rh->detid() == SCrh->detid())
1675 alreadyCounted =
true;
1679 if (is_SCrh_inside_recHits && !alreadyCounted && passEThresh && inEtaWindow && inPhiWindow) {
1680 RH_ptrs_fracs.push_back(std::make_pair(&(*rh), the_fraction));
1690 template <
bool noZS>
1692 const std::vector<std::pair<const EcalRecHit *, float>> &RH_ptrs_fracs,
1693 int weightedPositionMethod) {
1696 std::vector<float> shapes;
1699 if (RH_ptrs_fracs.size() < 2) {
1700 shapes.push_back(-3);
1701 shapes.push_back(-3);
1707 int tempInt = seedPosition[0];
1713 float centerIEta = 0.;
1714 float centerIPhi = 0.;
1717 for (std::vector<std::pair<const EcalRecHit *, float>>::const_iterator rhf_ptr = RH_ptrs_fracs.begin();
1718 rhf_ptr != RH_ptrs_fracs.end();
1723 if (fabs(energyTotal) < 0.0001) {
1725 shapes.push_back(-2);
1726 shapes.push_back(-2);
1729 float rh_energy = rh_ptr->
energy() * (
noZS ? 1.0 : rhf_ptr->second);
1731 if (
std::abs(weightedPositionMethod) < 0.0001) {
1732 weight = rh_energy / energyTotal;
1737 centerIEta +=
weight * deltaIEta(seedPosition[0], EBdetIdi.ieta());
1738 centerIPhi +=
weight * deltaIPhi(seedPosition[1], EBdetIdi.iphi());
1742 shapes.push_back(-2);
1743 shapes.push_back(-2);
1750 TMatrixDSym inertia(2);
1751 double inertia00 = 0.;
1752 double inertia01 = 0.;
1753 double inertia11 = 0.;
1755 for (std::vector<std::pair<const EcalRecHit *, float>>::const_iterator rhf_ptr = RH_ptrs_fracs.begin();
1756 rhf_ptr != RH_ptrs_fracs.end();
1762 if (fabs(energyTotal) < 0.0001) {
1764 shapes.push_back(-2);
1765 shapes.push_back(-2);
1768 float rh_energy = rh_ptr->
energy() * (
noZS ? 1.0 : rhf_ptr->second);
1770 if (
std::abs(weightedPositionMethod) < 0.0001) {
1771 weight = rh_energy / energyTotal;
1776 float ieta_rh_to_center = deltaIEta(seedPosition[0], EBdetIdi.ieta()) - centerIEta;
1777 float iphi_rh_to_center = deltaIPhi(seedPosition[1], EBdetIdi.iphi()) - centerIPhi;
1779 inertia00 +=
weight * iphi_rh_to_center * iphi_rh_to_center;
1780 inertia01 -=
weight * iphi_rh_to_center * ieta_rh_to_center;
1781 inertia11 +=
weight * ieta_rh_to_center * ieta_rh_to_center;
1785 inertia[0][0] = inertia00;
1786 inertia[0][1] = inertia01;
1787 inertia[1][0] = inertia01;
1788 inertia[1][1] = inertia11;
1791 TMatrixD eVectors(2, 2);
1792 TVectorD eValues(2);
1794 eVectors = inertia.EigenVectors(eValues);
1799 TVectorD smallerAxis(2);
1800 smallerAxis[0] = eVectors[0][1];
1801 smallerAxis[1] = eVectors[1][1];
1804 Double_t
temp = fabs(smallerAxis[0]);
1805 if (fabs(eValues[0]) < 0.0001) {
1807 shapes.push_back(-2);
1808 shapes.push_back(-2);
1812 float Roundness = eValues[1] / eValues[0];
1815 if (-0.00001 < Roundness && Roundness < 0)
1820 shapes.push_back(Roundness);
1821 shapes.push_back(
Angle);
1825 template <
bool noZS>
1831 for (
auto const &detId : rectangle(
id, *
topology)) {
1832 auto recHitIt =
recHits->find(detId);
1844 template <
bool noZS>
1846 int rel_iphi = rh_iphi - seed_iphi;
1849 rel_iphi = rel_iphi - 360;
1850 if (rel_iphi < -180)
1851 rel_iphi = rel_iphi + 360;
1858 template <
bool noZS>
1865 int rel_ieta = rh_ieta - seed_ieta;
1870 template <
bool noZS>
1872 const std::vector<std::pair<const EcalRecHit *, float>> &RH_ptrs_fracs) {
1873 std::vector<int> seedPosition;
1878 for (
auto const &rhf : RH_ptrs_fracs) {
1882 float rh_energy = rh_ptr->
energy() * (
noZS ? 1.0 : rhf.second);
1884 if (eSeedRH < rh_energy) {
1885 eSeedRH = rh_energy;
1886 iEtaSeedRH = EBdetIdi.ieta();
1887 iPhiSeedRH = EBdetIdi.iphi();
1892 seedPosition.push_back(iEtaSeedRH);
1893 seedPosition.push_back(iPhiSeedRH);
1894 return seedPosition;
1898 template <
bool noZS>
1901 for (
const auto &hAndF : RH_ptrs_fracs) {
1902 sumE += hAndF.first->energy() * (
noZS ? 1.0 : hAndF.second);