16 #include "CLHEP/Geometry/Transform3D.h"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
58 std::vector< std::pair<DetId, float> > clusterDetIds = passedCluster.hitsAndFractions();
59 std::vector< std::pair<DetId, float> >::iterator posCurrent;
63 for(posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
65 if (((*posCurrent).first !=
DetId(0)) && (hits->
find((*posCurrent).first) != hits->
end()))
68 testEcalRecHit = *itt;
70 if(testEcalRecHit.
energy() * (*posCurrent).second >
eMax)
72 eMax = testEcalRecHit.
energy() * (*posCurrent).second;
73 eMaxId = testEcalRecHit.
id();
87 std::vector< std::pair<DetId, float> > clusterDetIds = passedCluster.hitsAndFractions();
88 std::vector< std::pair<DetId, float> >::iterator posCurrent;
92 for(posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
94 if (( (*posCurrent).first !=
DetId(0)) && (hits->
find( (*posCurrent).first ) != hits->
end()))
97 testEcalRecHit = *itt;
99 if(testEcalRecHit.
energy() * (*posCurrent).second > e2nd && testEcalRecHit.
id() !=
eMaxId_)
101 e2nd = testEcalRecHit.
energy() * (*posCurrent).second;
102 e2ndId = testEcalRecHit.
id();
116 for(
int x = 0;
x < 5;
x++)
117 for(
int y = 0;
y < 5;
y++)
122 if((*posCurrent !=
DetId(0)) && (hits->
find(*posCurrent) != hits->
end()))
125 tempEcalRecHit = *itt;
138 int deltaX=0, deltaY=0;
140 for(
int corner = 0; corner < 4; corner++)
144 case 0: deltaX = -1; deltaY = -1;
break;
145 case 1: deltaX = -1; deltaY = 1;
break;
146 case 2: deltaX = 1; deltaY = -1;
break;
147 case 3: deltaX = 1; deltaY = 1;
break;
153 e2x2Test +=
energyMap_[2+deltaY][2+deltaX].second;
155 if(e2x2Test > e2x2Max)
170 double e3x2Ratio = 0.0, e3x2RatioNumerator = 0.0, e3x2RatioDenominator = 0.0;
172 int e2ndX = 2, e2ndY = 2;
173 int deltaY = 0, deltaX = 0;
175 double nextEnergy = -999;
176 int nextEneryDirection = -1;
178 for(
int cardinalDirection = 0; cardinalDirection < 4; cardinalDirection++)
180 switch(cardinalDirection)
182 case 0: deltaX = -1; deltaY = 0;
break;
183 case 1: deltaX = 1; deltaY = 0;
break;
184 case 2: deltaX = 0; deltaY = -1;
break;
185 case 3: deltaX = 0; deltaY = 1;
break;
190 nextEnergy =
energyMap_[2+deltaY][2+deltaX].second;
191 nextEneryDirection = cardinalDirection;
198 switch(nextEneryDirection)
201 case 1: deltaX = 0; deltaY = 1;
break;
203 case 3: deltaX = 1; deltaY = 0;
break;
206 for(
int sign = -1; sign <= 1; sign++)
209 e3x2RatioNumerator =
energyMap_[e2ndY+deltaY][e2ndX+deltaX].second +
energyMap_[e2ndY-deltaY][e2ndX-deltaX].second;
210 e3x2RatioDenominator = 0.5 +
energyMap_[2+deltaY][2+deltaX].second +
energyMap_[2-deltaY][2-deltaX].second;
211 e3x2Ratio = e3x2RatioNumerator / e3x2RatioDenominator;
221 for(
int i = 1;
i <= 3;
i++)
222 for(
int j = 1;
j <= 3;
j++)
233 int startX=-1, startY=-1;
237 case 1: startX = 0;
break;
238 case 3: startX = 1;
break;
243 case 1: startY = 0;
break;
244 case 3: startY = 1;
break;
247 for(
int i = startX;
i <= startX+3;
i++)
248 for(
int j = startY;
j <= startY+3;
j++)
258 for(
int i = 0;
i <= 4;
i++)
259 for(
int j = 0;
j <= 4;
j++)
269 for(
int i = 0;
i <= 4;
i++){
270 for(
int j = 0;
j <= 4;
j++){
280 for(
int i = 0;
i <= 4;
i++){
281 for(
int j = 0;
j <= 4;
j++){
291 for(
int i = 0;
i <= 4;
i++){
292 for(
int j = 0;
j <= 4;
j++){
303 for(
int i = 0;
i <= 4;
i++){
304 for(
int j = 0;
j <= 4;
j++){
322 for (
int i = 0;
i < 5; ++
i)
324 for (
int j = 0;
j < 5; ++
j)
336 meanPosition /=
e5x5_;
339 double numeratorEtaEta = 0;
340 double numeratorEtaPhi = 0;
341 double numeratorPhiPhi = 0;
344 for (
int i = 0;
i < 5; ++
i)
346 for (
int j = 0;
j < 5; ++
j)
353 double dPhi = position.
phi() - meanPosition.phi();
357 double dEta = position.
eta() - meanPosition.eta();
363 numeratorEtaEta += w * dEta * dEta;
364 numeratorEtaPhi += w * dEta *
dPhi;
365 numeratorPhiPhi += w * dPhi *
dPhi;
389 if( (hits!=0) && ( ((*hits)[0]).
id().subdetId() !=
EcalBarrel ) ) {
394 std::map<int,double> indexedBasketEnergy;
395 std::vector< std::pair<DetId, float> > clusterDetIds = passedCluster.hitsAndFractions();
398 for(std::vector< std::pair<DetId, float> >::iterator posCurrent = clusterDetIds.begin(); posCurrent != clusterDetIds.end(); posCurrent++)
400 int basketIndex = 999;
404 std::vector<int> etaBasketSize = subDetGeometry->
getEtaBaskets();
406 for(
unsigned int i = 0;
i < etaBasketSize.size();
i++) {
407 unsignedIEta -= etaBasketSize[
i];
408 if(unsignedIEta - 1 < 0)
414 basketIndex = (basketIndex+1)*(
EBDetId( (*posCurrent).first ).
ieta() > 0 ? 1 : -1);
416 }
else if(EtaPhi ==
Phi) {
422 if(basketIndex >= halfNumBasketInPhi) basketIndex -= 2*halfNumBasketInPhi;
423 else if(basketIndex < -1*halfNumBasketInPhi) basketIndex += 2*halfNumBasketInPhi;
425 }
else throw(std::runtime_error(
"\n\nOh No! Calculate_BarrelBasketEnergyFraction called on invalid index.\n\n"));
427 indexedBasketEnergy[basketIndex] += (hits->
find( (*posCurrent).first ))->
energy();
430 std::vector<double> energyFraction;
431 for(std::map<int,double>::iterator posCurrent = indexedBasketEnergy.begin(); posCurrent != indexedBasketEnergy.end(); posCurrent++)
433 energyFraction.push_back(indexedBasketEnergy[posCurrent->first]/passedCluster.energy());
446 double r,redmoment=0;
447 double phiRedmoment = 0 ;
448 double etaRedmoment = 0 ;
461 tmp=n2; n2=n1; n1=
tmp;
463 for (
int i=2;
i<clusterSize;
i++) {
469 n2 = n1; n1 =
i; n=
tmp;
488 lat_ = redmoment/(redmoment+2.19*2.19*(e1+e2));
489 phiLat_ = phiRedmoment/(phiRedmoment+2.19*2.19*(e1+e2));
490 etaLat_ = etaRedmoment/(etaRedmoment+2.19*2.19*(e1+e2));
501 int n,
int m,
double R0) {
503 if ((m>n) || ((n-m)%2 != 0) || (n<0) || (m<0))
return -1;
507 if ((n>20) || (R0<=2.19))
return -1;
537 int n,
int m,
double R0) {
539 double TotalEnergy = passedCluster.energy();
540 int index = (n/2)*(n/2)+(n/2)+m;
542 if(clusterSize<3)
return 0.0;
544 for (
int i=0;
i<clusterSize;
i++)
552 Re = Re + e/TotalEnergy *
fcn_[
index] *
cos( (
double) m * ph);
553 Im = Im - e/TotalEnergy *
fcn_[
index] *
sin( (
double) m * ph);
562 int n,
int m,
double R0) {
563 double r,ph,
e,Re=0,Im=0,f_nm,
result;
564 double TotalEnergy = passedCluster.energy();
565 std::vector< std::pair<DetId, float> > clusterDetIds = passedCluster.hitsAndFractions();
567 if(clusterSize<3)
return 0.0;
569 for (
int i=0;
i<clusterSize;
i++)
576 for (
int s=0;
s<=(n-
m)/2;
s++) {
584 Re = Re + e/TotalEnergy * f_nm *
cos( (
double) m*ph);
585 Im = Im - e/TotalEnergy * f_nm *
sin( (
double) m*ph);
588 result =
sqrt(Re*Re+Im*Im);
602 CLHEP::Hep3Vector clVect(passedCluster.position().x(),
603 passedCluster.position().y(),
604 passedCluster.position().z());
605 CLHEP::Hep3Vector clDir(clVect);
606 clDir*=1.0/clDir.mag();
608 CLHEP::Hep3Vector theta_axis(clDir.y(),-clDir.x(),0.0);
609 theta_axis *= 1.0/theta_axis.mag();
610 CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);
612 std::vector< std::pair<DetId, float> > clusterDetIds = passedCluster.hitsAndFractions();
616 std::vector< std::pair<DetId, float> >::iterator posCurrent;
618 for(posCurrent=clusterDetIds.begin(); posCurrent!=clusterDetIds.end(); ++posCurrent) {
622 if(( (*posCurrent).first !=
DetId(0)) && (hits->
find( (*posCurrent).first ) != hits->
end())) {
630 LogDebug(
"ClusterShapeAlgo") <<
"Crystal has zero energy; skipping... ";
635 LogDebug(
"ClusterShapeAlgo") <<
"Crystal has insufficient energy: E = "
641 DetId id_ = (*posCurrent).first;
644 CLHEP::Hep3Vector gblPos (cellPos.
x(),cellPos.
y(),cellPos.
z());
646 CLHEP::Hep3Vector
diff = gblPos - clVect;
650 CLHEP::Hep3Vector DigiVect = diff - diff.dot(clDir)*clDir;
651 clEdep.
r = DigiVect.mag();
653 <<
"\tdiff = " << diff.mag()
654 <<
"\tr = " << clEdep.
r;
655 clEdep.
phi = DigiVect.angle(theta_axis);
656 if(DigiVect.dot(phi_axis)<0) clEdep.
phi = 2*
M_PI - clEdep.
phi;
679 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 home() const
move the navigator back to the starting point
void Calculate_e2x5Right()
std::vector< double > fcn_
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)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
static int position[TOTALCHAMBERS][3]
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
int iphi() const
get the crystal iphi
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)
double dPhi(double phi1, double phi2)
const T & max(const T &a, const T &b)
virtual T offsetBy(int deltaX, int deltaY) const
Free movement of arbitray steps.
Cos< T >::type cos(const T &t)
void Calculate_EnergyDepTopology(const reco::BasicCluster &passedCluster, const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, bool logW=true)
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)
static const int MAX_IPHI
DetId id() const
get the id
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)
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)