16 #include "CLHEP/Geometry/Transform3D.h" 17 #include "CLHEP/Units/GlobalSystemOfUnits.h" 74 const std::vector<std::pair<DetId, float> >& clusterDetIds = passedCluster.
hitsAndFractions();
78 for (
auto const& posCurrent : clusterDetIds) {
79 if ((posCurrent.first !=
DetId(0)) && (
hits->find(posCurrent.first) !=
hits->end())) {
81 testEcalRecHit = *itt;
83 if (testEcalRecHit.
energy() * posCurrent.second >
eMax) {
84 eMax = testEcalRecHit.
energy() * posCurrent.second;
85 eMaxId = testEcalRecHit.
id();
98 const std::vector<std::pair<DetId, float> >& clusterDetIds = passedCluster.
hitsAndFractions();
102 for (
auto const& posCurrent : clusterDetIds) {
103 if ((posCurrent.first !=
DetId(0)) && (
hits->find(posCurrent.first) !=
hits->end())) {
105 testEcalRecHit = *itt;
107 if (testEcalRecHit.
energy() * posCurrent.second > e2nd && testEcalRecHit.
id() !=
eMaxId_) {
108 e2nd = testEcalRecHit.
energy() * posCurrent.second;
109 e2ndId = testEcalRecHit.
id();
122 for (
int x = 0;
x < 5;
x++)
123 for (
int y = 0;
y < 5;
y++) {
127 if ((*posCurrent !=
DetId(0)) && (
hits->find(*posCurrent) !=
hits->end())) {
129 tempEcalRecHit = *itt;
140 int deltaX = 0, deltaY = 0;
165 e2x2Test +=
energyMap_[2 + deltaY][2 + deltaX].second;
167 if (e2x2Test > e2x2Max) {
179 double e3x2Ratio = 0.0, e3x2RatioNumerator = 0.0, e3x2RatioDenominator = 0.0;
181 int e2ndX = 2, e2ndY = 2;
182 int deltaY = 0, deltaX = 0;
184 double nextEnergy = -999;
185 int nextEneryDirection = -1;
187 for (
int cardinalDirection = 0; cardinalDirection < 4; cardinalDirection++) {
188 switch (cardinalDirection) {
208 nextEnergy =
energyMap_[2 + deltaY][2 + deltaX].second;
209 nextEneryDirection = cardinalDirection;
216 switch (nextEneryDirection) {
234 energyMap_[e2ndY + deltaY][e2ndX + deltaX].second +
energyMap_[e2ndY - deltaY][e2ndX - deltaX].second;
235 e3x2RatioDenominator = 0.5 +
energyMap_[2 + deltaY][2 + deltaX].second +
energyMap_[2 - deltaY][2 - deltaX].second;
236 e3x2Ratio = e3x2RatioNumerator / e3x2RatioDenominator;
245 for (
int i = 1;
i <= 3;
i++)
246 for (
int j = 1;
j <= 3;
j++)
255 int startX = -1, startY = -1;
275 for (
int i = startX;
i <= startX + 3;
i++)
276 for (
int j = startY;
j <= startY + 3;
j++)
285 for (
int i = 0;
i <= 4;
i++)
286 for (
int j = 0;
j <= 4;
j++)
294 for (
int i = 0;
i <= 4;
i++) {
295 for (
int j = 0;
j <= 4;
j++) {
306 for (
int i = 0;
i <= 4;
i++) {
307 for (
int j = 0;
j <= 4;
j++) {
318 for (
int i = 0;
i <= 4;
i++) {
319 for (
int j = 0;
j <= 4;
j++) {
330 for (
int i = 0;
i <= 4;
i++) {
331 for (
int j = 0;
j <= 4;
j++) {
348 for (
int i = 0;
i < 5; ++
i) {
349 for (
int j = 0;
j < 5; ++
j) {
351 if (
id !=
DetId(0)) {
359 meanPosition /=
e5x5_;
362 double numeratorEtaEta = 0;
363 double numeratorEtaPhi = 0;
364 double numeratorPhiPhi = 0;
367 for (
int i = 0;
i < 5; ++
i) {
368 for (
int j = 0;
j < 5; ++
j) {
370 if (
id !=
DetId(0)) {
415 std::map<int, double> indexedBasketEnergy;
416 const std::vector<std::pair<DetId, float> >& clusterDetIds = passedCluster.
hitsAndFractions();
419 for (
auto const& posCurrent : clusterDetIds) {
420 int basketIndex = 999;
424 std::vector<int> etaBasketSize = subDetGeometry->
getEtaBaskets();
426 for (
unsigned int i = 0;
i < etaBasketSize.size();
i++) {
427 unsignedIEta -= etaBasketSize[
i];
428 if (unsignedIEta - 1 < 0) {
433 basketIndex = (basketIndex + 1) * (
EBDetId(posCurrent.first).
ieta() > 0 ? 1 : -1);
435 }
else if (EtaPhi ==
Phi) {
441 if (basketIndex >= halfNumBasketInPhi)
442 basketIndex -= 2 * halfNumBasketInPhi;
443 else if (basketIndex < -1 * halfNumBasketInPhi)
444 basketIndex += 2 * halfNumBasketInPhi;
447 throw(std::runtime_error(
"\n\nOh No! Calculate_BarrelBasketEnergyFraction called on invalid index.\n\n"));
449 indexedBasketEnergy[basketIndex] += (
hits->find(posCurrent.first))->
energy();
452 std::vector<double> energyFraction;
453 for (std::map<int, double>::iterator posCurrent = indexedBasketEnergy.begin();
454 posCurrent != indexedBasketEnergy.end();
456 energyFraction.push_back(indexedBasketEnergy[posCurrent->first] / passedCluster.
energy());
470 double r, redmoment = 0;
471 double phiRedmoment = 0;
472 double etaRedmoment = 0;
475 if (clusterSize < 3) {
488 for (
int i = 2;
i < clusterSize;
i++) {
513 lat_ = redmoment / (redmoment + 2.19 * 2.19 * (
e1 + e2));
514 phiLat_ = phiRedmoment / (phiRedmoment + 2.19 * 2.19 * (
e1 + e2));
515 etaLat_ = etaRedmoment / (etaRedmoment + 2.19 * 2.19 * (
e1 + e2));
527 if ((
m >
n) || ((
n -
m) % 2 != 0) || (
n < 0) || (
m < 0))
532 if ((
n > 20) || (
R0 <= 2.19))
565 double r, ph,
e, Re = 0, Im = 0,
result;
566 double TotalEnergy = passedCluster.
energy();
567 int index = (
n / 2) * (
n / 2) + (
n / 2) +
m;
572 for (
int i = 0;
i < clusterSize;
i++) {
589 double r, ph,
e, Re = 0, Im = 0, f_nm,
result;
590 double TotalEnergy = passedCluster.
energy();
595 for (
int i = 0;
i < clusterSize;
i++) {
601 for (
int s = 0;
s <= (
n -
m) / 2;
s++) {
610 Re = Re +
e / TotalEnergy * f_nm *
cos((
double)
m * ph);
611 Im = Im -
e / TotalEnergy * f_nm *
sin((
double)
m * ph);
629 CLHEP::Hep3Vector clDir(clVect);
630 clDir *= 1.0 / clDir.mag();
632 CLHEP::Hep3Vector theta_axis(clDir.y(), -clDir.x(), 0.0);
633 theta_axis *= 1.0 / theta_axis.mag();
634 CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);
636 const std::vector<std::pair<DetId, float> >& clusterDetIds = passedCluster.
hitsAndFractions();
641 for (
auto const& posCurrent : clusterDetIds) {
643 testEcalRecHit = *itt;
645 if ((posCurrent.first !=
DetId(0)) && (
hits->find(posCurrent.first) !=
hits->end())) {
653 LogDebug(
"ClusterShapeAlgo") <<
"Crystal has zero energy; skipping... ";
659 <<
" GeV; skipping... ";
664 DetId id_ = posCurrent.first;
665 auto this_cell =
geometry->getGeometry(id_);
666 const GlobalPoint& cellPos = this_cell->getPosition();
667 CLHEP::Hep3Vector gblPos(cellPos.
x(), cellPos.
y(), cellPos.
z());
669 CLHEP::Hep3Vector
diff = gblPos - clVect;
673 CLHEP::Hep3Vector DigiVect =
diff -
diff.dot(clDir) * clDir;
674 clEdep.
r = DigiVect.mag();
676 <<
"\tr = " << clEdep.
r;
677 clEdep.
phi = DigiVect.angle(theta_axis);
678 if (DigiVect.dot(phi_axis) < 0)
702 for (
int i = 2;
i <=
n;
i++)
const math::XYZPoint & position() const
cluster centroid position
int getBasketSizeInPhi() const
T getParameter(std::string const &) const
void home() const
move the navigator back to the starting point
static const int MIN_IPHI
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
void Create_Map(const EcalRecHitCollection *hits, const CaloSubdetectorTopology *topology)
double fast_AbsZernikeMoment(const reco::BasicCluster &passedCluster, int n, int m, double R0)
void Calculate_e2x5Right()
std::vector< double > fcn_
void Calculate_e2x5Left()
std::vector< EcalClusterEnergyDeposition > energyDistribution_
int iphi() const
get the crystal iphi
edm::ParameterSet parameterSet_
Sin< T >::type sin(const T &t)
void Calculate_BarrelBasketEnergyFraction(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const int EtaPhi, const CaloSubdetectorGeometry *geometry)
void Calculate_e2x5Bottom()
std::vector< EcalRecHit >::const_iterator const_iterator
double calc_AbsZernikeMoment(const reco::BasicCluster &passedCluster, int n, int m, double R0)
double factorial(int n) const
std::pair< DetId, double > energyMap_[5][5]
double absZernikeMoment(const reco::BasicCluster &passedCluster, int n, int m, double R0=6.6)
int ieta() const
get the crystal ieta
U second(std::pair< T, U > const &p)
reco::ClusterShape Calculate(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology)
void Calculate_Covariances(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry)
Cos< T >::type cos(const T &t)
void Calculate_EnergyDepTopology(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, bool logW=true)
Abs< T >::type abs(const T &t)
void Calculate_TopEnergy(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits)
double energy() const
cluster energy
void Calculate_Polynomials(double rho)
static const int MAX_IPHI
std::vector< double > energyBasketFractionPhi_
void Calculate_ComplexZernikeMoments(const reco::BasicCluster &passedCluster)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
DetId id() const
get the id
void Calculate_lat(const reco::BasicCluster &passedCluster)
static int position[264][3]
std::vector< double > energyBasketFractionEta_
const std::vector< int > & getEtaBaskets() const
Power< A, B >::type pow(const A &a, const B &b)
void Calculate_2ndEnergy(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits)