16 #include "CLHEP/Geometry/Transform3D.h" 17 #include "CLHEP/Units/GlobalSystemOfUnits.h" 58 const std::vector< std::pair<DetId, float> >& clusterDetIds = passedCluster.hitsAndFractions();
62 for(
auto const& posCurrent : clusterDetIds)
64 if ((posCurrent.first !=
DetId(0)) && (hits->
find(posCurrent.first) != hits->
end()))
67 testEcalRecHit = *itt;
69 if(testEcalRecHit.
energy() * posCurrent.second >
eMax)
71 eMax = testEcalRecHit.
energy() * posCurrent.second;
72 eMaxId = testEcalRecHit.
id();
86 const std::vector< std::pair<DetId, float> >& clusterDetIds = passedCluster.hitsAndFractions();
90 for(
auto const& posCurrent : clusterDetIds)
92 if (( posCurrent.first !=
DetId(0)) && (hits->
find( posCurrent.first ) != hits->
end()))
95 testEcalRecHit = *itt;
97 if(testEcalRecHit.
energy() * posCurrent.second > e2nd && testEcalRecHit.
id() !=
eMaxId_)
99 e2nd = testEcalRecHit.
energy() * posCurrent.second;
100 e2ndId = testEcalRecHit.
id();
114 for(
int x = 0;
x < 5;
x++)
115 for(
int y = 0;
y < 5;
y++)
120 if((*posCurrent !=
DetId(0)) && (hits->
find(*posCurrent) != hits->
end()))
123 tempEcalRecHit = *itt;
136 int deltaX=0, deltaY=0;
142 case 0: deltaX = -1; deltaY = -1;
break;
143 case 1: deltaX = -1; deltaY = 1;
break;
144 case 2: deltaX = 1; deltaY = -1;
break;
145 case 3: deltaX = 1; deltaY = 1;
break;
151 e2x2Test +=
energyMap_[2+deltaY][2+deltaX].second;
153 if(e2x2Test > e2x2Max)
168 double e3x2Ratio = 0.0, e3x2RatioNumerator = 0.0, e3x2RatioDenominator = 0.0;
170 int e2ndX = 2, e2ndY = 2;
171 int deltaY = 0, deltaX = 0;
173 double nextEnergy = -999;
174 int nextEneryDirection = -1;
176 for(
int cardinalDirection = 0; cardinalDirection < 4; cardinalDirection++)
178 switch(cardinalDirection)
180 case 0: deltaX = -1; deltaY = 0;
break;
181 case 1: deltaX = 1; deltaY = 0;
break;
182 case 2: deltaX = 0; deltaY = -1;
break;
183 case 3: deltaX = 0; deltaY = 1;
break;
188 nextEnergy =
energyMap_[2+deltaY][2+deltaX].second;
189 nextEneryDirection = cardinalDirection;
196 switch(nextEneryDirection)
199 case 1: deltaX = 0; deltaY = 1;
break;
201 case 3: deltaX = 1; deltaY = 0;
break;
207 e3x2RatioNumerator =
energyMap_[e2ndY+deltaY][e2ndX+deltaX].second +
energyMap_[e2ndY-deltaY][e2ndX-deltaX].second;
208 e3x2RatioDenominator = 0.5 +
energyMap_[2+deltaY][2+deltaX].second +
energyMap_[2-deltaY][2-deltaX].second;
209 e3x2Ratio = e3x2RatioNumerator / e3x2RatioDenominator;
219 for(
int i = 1;
i <= 3;
i++)
220 for(
int j = 1; j <= 3; j++)
231 int startX=-1, startY=-1;
235 case 1: startX = 0;
break;
236 case 3: startX = 1;
break;
241 case 1: startY = 0;
break;
242 case 3: startY = 1;
break;
245 for(
int i = startX;
i <= startX+3;
i++)
246 for(
int j = startY; j <= startY+3; j++)
256 for(
int i = 0;
i <= 4;
i++)
257 for(
int j = 0; j <= 4; j++)
267 for(
int i = 0;
i <= 4;
i++){
268 for(
int j = 0; j <= 4; j++){
278 for(
int i = 0;
i <= 4;
i++){
279 for(
int j = 0; j <= 4; j++){
289 for(
int i = 0;
i <= 4;
i++){
290 for(
int j = 0; j <= 4; j++){
301 for(
int i = 0;
i <= 4;
i++){
302 for(
int j = 0; j <= 4; j++){
320 for (
int i = 0;
i < 5; ++
i)
322 for (
int j = 0; j < 5; ++j)
334 meanPosition /=
e5x5_;
337 double numeratorEtaEta = 0;
338 double numeratorEtaPhi = 0;
339 double numeratorPhiPhi = 0;
342 for (
int i = 0;
i < 5; ++
i)
344 for (
int j = 0; j < 5; ++j)
351 double dPhi = position.
phi() - meanPosition.phi();
355 double dEta = position.
eta() - meanPosition.eta();
361 numeratorEtaEta += w * dEta *
dEta;
362 numeratorEtaPhi += w * dEta *
dPhi;
363 numeratorPhiPhi += w * dPhi *
dPhi;
387 if( (hits==
nullptr) || ( ((*hits)[0]).
id().subdetId() !=
EcalBarrel ) ) {
392 std::map<int,double> indexedBasketEnergy;
393 const std::vector< std::pair<DetId, float> >& clusterDetIds = passedCluster.hitsAndFractions();
396 for(
auto const& posCurrent : clusterDetIds)
398 int basketIndex = 999;
402 std::vector<int> etaBasketSize = subDetGeometry->
getEtaBaskets();
404 for(
unsigned int i = 0;
i < etaBasketSize.size();
i++) {
405 unsignedIEta -= etaBasketSize[
i];
406 if(unsignedIEta - 1 < 0)
412 basketIndex = (basketIndex+1)*(
EBDetId( posCurrent.first ).
ieta() > 0 ? 1 : -1);
414 }
else if(EtaPhi ==
Phi) {
420 if(basketIndex >= halfNumBasketInPhi) basketIndex -= 2*halfNumBasketInPhi;
421 else if(basketIndex < -1*halfNumBasketInPhi) basketIndex += 2*halfNumBasketInPhi;
423 }
else throw(std::runtime_error(
"\n\nOh No! Calculate_BarrelBasketEnergyFraction called on invalid index.\n\n"));
425 indexedBasketEnergy[basketIndex] += (hits->
find( posCurrent.first ))->energy();
428 std::vector<double> energyFraction;
429 for(std::map<int,double>::iterator posCurrent = indexedBasketEnergy.begin(); posCurrent != indexedBasketEnergy.end(); posCurrent++)
431 energyFraction.push_back(indexedBasketEnergy[posCurrent->first]/passedCluster.energy());
444 double r,redmoment=0;
445 double phiRedmoment = 0 ;
446 double etaRedmoment = 0 ;
459 tmp=n2; n2=n1; n1=
tmp;
461 for (
int i=2;
i<clusterSize;
i++) {
467 n2 = n1; n1 =
i; n=
tmp;
486 lat_ = redmoment/(redmoment+2.19*2.19*(e1+e2));
487 phiLat_ = phiRedmoment/(phiRedmoment+2.19*2.19*(e1+e2));
488 etaLat_ = etaRedmoment/(etaRedmoment+2.19*2.19*(e1+e2));
499 int n,
int m,
double R0) {
501 if ((m>n) || ((n-m)%2 != 0) || (n<0) || (m<0))
return -1;
505 if ((n>20) || (R0<=2.19))
return -1;
535 int n,
int m,
double R0) {
537 double TotalEnergy = passedCluster.energy();
538 int index = (n/2)*(n/2)+(n/2)+m;
540 if(clusterSize<3)
return 0.0;
542 for (
int i=0;
i<clusterSize;
i++)
550 Re = Re + e/TotalEnergy *
fcn_[
index] *
cos( (
double) m * ph);
551 Im = Im - e/TotalEnergy *
fcn_[
index] *
sin( (
double) m * ph);
560 int n,
int m,
double R0) {
561 double r,ph,
e,Re=0,Im=0,f_nm,
result;
562 double TotalEnergy = passedCluster.energy();
564 if(clusterSize<3)
return 0.0;
566 for (
int i=0;
i<clusterSize;
i++)
573 for (
int s=0;
s<=(n-
m)/2;
s++) {
581 Re = Re + e/TotalEnergy * f_nm *
cos( (
double) m*ph);
582 Im = Im - e/TotalEnergy * f_nm *
sin( (
double) m*ph);
585 result =
sqrt(Re*Re+Im*Im);
599 CLHEP::Hep3Vector clVect(passedCluster.position().x(),
600 passedCluster.position().y(),
601 passedCluster.position().z());
602 CLHEP::Hep3Vector clDir(clVect);
603 clDir*=1.0/clDir.mag();
605 CLHEP::Hep3Vector theta_axis(clDir.y(),-clDir.x(),0.0);
606 theta_axis *= 1.0/theta_axis.mag();
607 CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);
609 const std::vector< std::pair<DetId, float> >& clusterDetIds = passedCluster.hitsAndFractions();
614 for(
auto const& posCurrent : clusterDetIds) {
618 if(( posCurrent.first !=
DetId(0)) && (hits->
find( posCurrent.first ) != hits->
end())) {
626 LogDebug(
"ClusterShapeAlgo") <<
"Crystal has zero energy; skipping... ";
631 LogDebug(
"ClusterShapeAlgo") <<
"Crystal has insufficient energy: E = " 637 DetId id_ = posCurrent.first;
639 const GlobalPoint& cellPos = this_cell->getPosition();
640 CLHEP::Hep3Vector gblPos (cellPos.
x(),cellPos.
y(),cellPos.
z());
642 CLHEP::Hep3Vector
diff = gblPos - clVect;
646 CLHEP::Hep3Vector DigiVect = diff - diff.dot(clDir)*clDir;
647 clEdep.
r = DigiVect.mag();
649 <<
"\tdiff = " << diff.mag()
650 <<
"\tr = " << clEdep.
r;
651 clEdep.
phi = DigiVect.angle(theta_axis);
652 if(DigiVect.dot(phi_axis)<0) clEdep.
phi = 2*
M_PI - clEdep.
phi;
675 for(
int i=2;
i<=
n;
i++) res*=(
double)
i;
T getParameter(std::string const &) const
static const int MIN_IPHI
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_
CaloTopology const * topology(0)
void Calculate_e2x5Left()
std::vector< EcalClusterEnergyDeposition > energyDistribution_
edm::ParameterSet parameterSet_
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
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)
std::pair< DetId, double > energyMap_[5][5]
double factorial(int n) const
double absZernikeMoment(const reco::BasicCluster &passedCluster, int n, int m, double R0=6.6)
int iphi() const
get the crystal iphi
U second(std::pair< T, U > const &p)
T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
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)
int ieta() const
get the crystal ieta
const_iterator end() const
void Calculate_Polynomials(double rho)
void home() const
move the navigator back to the starting point
static const int MAX_IPHI
DetId id() const
get the id
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< double > energyBasketFractionPhi_
void Calculate_ComplexZernikeMoments(const reco::BasicCluster &passedCluster)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
const std::vector< int > & getEtaBaskets() const
int getBasketSizeInPhi() const
std::vector< std::vector< double > > tmp
void Calculate_lat(const reco::BasicCluster &passedCluster)
ESHandle< TrackerGeometry > geometry
iterator find(key_type k)
static int position[264][3]
std::vector< double > energyBasketFractionEta_
Power< A, B >::type pow(const A &a, const B &b)
void Calculate_2ndEnergy(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits)