11 #include "CLHEP/Geometry/Transform3D.h"
22 for (
size_t i = 0;
i < v_id.size(); ++
i ) {
29 return std::pair<DetId, float>(
id,
max);
36 return getMaximum( cluster.hitsAndFractions(), recHits );
43 if (
id ==
DetId(0) ) {
47 if ( it != recHits->
end() ) {
48 return (*it).energy();
76 for (
int i = ixMin;
i <= ixMax; ++
i ) {
77 for (
int j = iyMin;
j <= iyMax; ++
j ) {
98 for (
int i = ixMin;
i <= ixMax; ++
i ) {
99 for (
int j = iyMin;
j <= iyMax; ++
j ) {
102 if ( *cursor !=
DetId(0) ) v.push_back( *cursor );
113 std::list<float> energies;
114 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -1, 0, -1, 0 ) );
115 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -1, 0, 0, 1 ) );
116 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, 0, 1, 0, 1 ) );
117 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, 0, 1, -1, 0 ) );
120 return *std::max_element(energies.begin(),energies.end());
129 std::list<float> energies;
130 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -1, 1, -1, 0 ) );
131 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, 0, 1, -1, 1 ) );
132 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -1, 1, 0, 1 ) );
133 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -1, 0, -1, 1 ) );
134 return *std::max_element(energies.begin(),energies.end());
142 return matrixEnergy( cluster, recHits, topology,
id, -1, 1, -1, 1 );
150 std::list<float> energies;
151 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -1, 2, -2, 1 ) );
152 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -2, 1, -2, 1 ) );
153 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -2, 1, -1, 2 ) );
154 energies.push_back(
matrixEnergy( cluster, recHits, topology,
id, -1, 2, -1, 2 ) );
155 return *std::max_element(energies.begin(),energies.end());
163 return matrixEnergy( cluster, recHits, topology,
id, -2, 2, -2, 2 );
177 std::list<float> energies;
178 std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
179 if ( v_id.size() < 2 )
return 0;
180 for (
size_t i = 0;
i < v_id.size(); ++
i ) {
184 return *--(--energies.end());
194 return matrixEnergy( cluster, recHits, topology,
id, 1, 2, -2, 2 );
202 return matrixEnergy( cluster, recHits, topology,
id, -2, -1, -2, 2 );
210 return matrixEnergy( cluster, recHits, topology,
id, -2, 2, 1, 2 );
218 return matrixEnergy( cluster, recHits, topology,
id, -2, 2, -2, -1 );
228 float left =
matrixEnergy( cluster, recHits, topology,
id, -1, -1, -2, 2 );
230 float right =
matrixEnergy( cluster, recHits, topology,
id, 1, 1, -2, 2 );
232 float centre =
matrixEnergy( cluster, recHits, topology,
id, 0, 0, -2, 2 );
235 return left > right ? left+centre : right+centre;
242 return matrixEnergy( cluster, recHits, topology,
id, 0, 0, -2, 2 );
250 return matrixEnergy( cluster, recHits, topology,
id, -2, 2, 0, 0 );
258 return matrixEnergy( cluster, recHits, topology,
id, 0, 0, -1, 1 );
266 return matrixEnergy( cluster, recHits, topology,
id, -1, 1, 0, 0 );
274 return matrixEnergy( cluster, recHits, topology,
id, -1, -1, 0, 0 );
282 return matrixEnergy( cluster, recHits, topology,
id, 1, 1, 0, 0 );
290 return matrixEnergy( cluster, recHits, topology,
id, 0, 0, 1, 1 );
298 return matrixEnergy( cluster, recHits, topology,
id, 0, 0, -1, -1 );
306 float clusterEnergy = cluster.energy();
307 std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
309 edm::LogWarning(
"EcalClusterTools::energyBasketFractionEta") <<
"Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel basic-clusters. Returning empty vector.";
310 return basketFraction;
312 for (
size_t i = 0;
i < v_id.size(); ++
i ) {
315 std::sort( basketFraction.rbegin(), basketFraction.rend() );
316 return basketFraction;
324 float clusterEnergy = cluster.energy();
325 std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
327 edm::LogWarning(
"EcalClusterTools::energyBasketFractionPhi") <<
"Trying to get basket fraction for endcap basic-clusters. Basket fractions can be obtained ONLY for barrel basic-clusters. Returning empty vector.";
328 return basketFraction;
330 for (
size_t i = 0;
i < v_id.size(); ++
i ) {
333 std::sort( basketFraction.rbegin(), basketFraction.rend() );
334 return basketFraction;
341 std::vector<EcalClusterTools::EcalClusterEnergyDeposition> energyDistribution;
344 CLHEP::Hep3Vector clVect(cluster.position().x(), cluster.position().y(), cluster.position().z());
345 CLHEP::Hep3Vector clDir(clVect);
346 clDir*=1.0/clDir.mag();
348 CLHEP::Hep3Vector theta_axis(clDir.y(),-clDir.x(),0.0);
349 theta_axis *= 1.0/theta_axis.mag();
350 CLHEP::Hep3Vector phi_axis = theta_axis.cross(clDir);
352 std::vector< std::pair<DetId, float> > clusterDetIds = cluster.hitsAndFractions();
356 std::vector< std::pair<DetId, float> >::iterator posCurrent;
358 for(posCurrent=clusterDetIds.begin(); posCurrent!=clusterDetIds.end(); ++posCurrent) {
362 if(( (*posCurrent).first !=
DetId(0)) && (recHits->
find( (*posCurrent).first ) != recHits->
end())) {
370 LogDebug(
"ClusterShapeAlgo") <<
"Crystal has insufficient energy: E = "
376 DetId id_ = (*posCurrent).first;
379 CLHEP::Hep3Vector gblPos (cellPos.
x(),cellPos.
y(),cellPos.
z());
381 CLHEP::Hep3Vector
diff = gblPos - clVect;
385 CLHEP::Hep3Vector DigiVect = diff - diff.dot(clDir)*clDir;
386 clEdep.
r = DigiVect.mag();
388 <<
"\tdiff = " << diff.mag()
389 <<
"\tr = " << clEdep.
r;
390 clEdep.
phi = DigiVect.angle(theta_axis);
391 if(DigiVect.dot(phi_axis)<0) clEdep.
phi = 2 *
M_PI - clEdep.
phi;
392 energyDistribution.push_back(clEdep);
395 return energyDistribution;
402 std::vector<EcalClusterTools::EcalClusterEnergyDeposition> energyDistribution =
getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
404 std::vector<float>
lat;
405 double r, redmoment=0;
406 double phiRedmoment = 0 ;
407 double etaRedmoment = 0 ;
409 int clusterSize=energyDistribution.size();
410 float etaLat_, phiLat_, lat_;
421 if (energyDistribution[1].deposited_energy >
422 energyDistribution[0].deposited_energy)
424 tmp=n2; n2=n1; n1=
tmp;
426 for (
int i=2;
i<clusterSize;
i++) {
428 if (energyDistribution[
i].deposited_energy >
429 energyDistribution[n1].deposited_energy)
432 n2 = n1; n1 =
i; n=
tmp;
434 if (energyDistribution[
i].deposited_energy >
435 energyDistribution[n2].deposited_energy)
441 r = energyDistribution[
n].r;
442 redmoment += r*r* energyDistribution[
n].deposited_energy;
443 double rphi = r *
cos (energyDistribution[n].
phi) ;
444 phiRedmoment += rphi * rphi * energyDistribution[
n].deposited_energy;
445 double reta = r *
sin (energyDistribution[n].phi) ;
446 etaRedmoment += reta * reta * energyDistribution[
n].deposited_energy;
448 double e1 = energyDistribution[n1].deposited_energy;
449 double e2 = energyDistribution[n2].deposited_energy;
451 lat_ = redmoment/(redmoment+2.19*2.19*(e1+e2));
452 phiLat_ = phiRedmoment/(phiRedmoment+2.19*2.19*(e1+e2));
453 etaLat_ = etaRedmoment/(etaRedmoment+2.19*2.19*(e1+e2));
455 lat.push_back(etaLat_);
456 lat.push_back(phiLat_);
468 for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
473 return meanPosition /
e5x5( cluster, recHits, topology );
492 std::vector<DetId> v_id =
matrixDetId( topology,seedId, -2, 2, -2, 2 );
493 for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
495 if(energy<0.)
continue;
502 return std::pair<float,float>(meanDEta,meanDPhi);
515 std::pair<float,float> meanXY(0.,0.);
520 std::vector<DetId> v_id =
matrixDetId( topology,seedId, -2, 2, -2, 2 );
521 for ( std::vector<DetId>::const_iterator it = v_id.begin(); it != v_id.end(); ++it ) {
523 if(energy<0.)
continue;
536 float e_5x5 =
e5x5( cluster, recHits, topology );
537 float covEtaEta, covEtaPhi, covPhiPhi;
540 std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
544 double numeratorEtaEta = 0;
545 double numeratorEtaPhi = 0;
546 double numeratorPhiPhi = 0;
551 for (
int i = -2;
i <= 2; ++
i ) {
552 for (
int j = -2;
j <= 2; ++
j ) {
557 if ( energy <= 0 )
continue;
561 double dPhi = position.
phi() - meanPosition.phi();
565 double dEta = position.
eta() - meanPosition.eta();
570 numeratorEtaEta += w * dEta * dEta;
571 numeratorEtaPhi += w * dEta *
dPhi;
572 numeratorPhiPhi += w * dPhi *
dPhi;
576 if (denominator != 0.0) {
593 std::vector<float>
v;
594 v.push_back( covEtaEta );
595 v.push_back( covEtaPhi );
596 v.push_back( covPhiPhi );
612 float e_5x5 =
e5x5( cluster, recHits, topology );
613 float covEtaEta, covEtaPhi, covPhiPhi;
617 std::vector< std::pair<DetId, float> > v_id = cluster.hitsAndFractions();
622 double numeratorEtaEta = 0;
623 double numeratorEtaPhi = 0;
624 double numeratorPhiPhi = 0;
629 const double barrelCrysSize = 0.01745;
630 const double endcapCrysSize = 0.0447;
635 const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;
639 for (
int eastNr = -2; eastNr <= 2; ++eastNr ) {
640 for (
int northNr = -2; northNr <= 2; ++northNr ) {
644 if ( energy <= 0 )
continue;
649 if(isBarrel) dPhi =
getNrCrysDiffInPhi(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.second;
650 else dPhi =
getDPhiEndcap(*cursor,mean5x5XYPos.first,mean5x5XYPos.second);
653 double w =
std::max(0.0, w0 +
log( energy / e_5x5 ));
656 numeratorEtaEta += w * dEta * dEta;
657 numeratorEtaPhi += w * dEta *
dPhi;
658 numeratorPhiPhi += w * dPhi *
dPhi;
664 if (denominator != 0.0) {
665 covEtaEta = crysSize*crysSize* numeratorEtaEta /
denominator;
666 covEtaPhi = crysSize*crysSize* numeratorEtaPhi /
denominator;
667 covPhiPhi = crysSize*crysSize* numeratorPhiPhi /
denominator;
682 std::vector<float>
v;
683 v.push_back( covEtaEta );
684 v.push_back( covEtaPhi );
685 v.push_back( covPhiPhi );
709 if ((m>n) || ((n-m)%2 != 0) || (n<0) || (m<0))
return -1;
713 if ((n>20) || (R0<=2.19))
return -1;
721 double r,ph,
e,Re=0,Im=0;
722 double TotalEnergy = cluster.energy();
723 int index = (n/2)*(n/2)+(n/2)+m;
724 std::vector<EcalClusterEnergyDeposition> energyDistribution =
getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
725 int clusterSize = energyDistribution.size();
726 if(clusterSize < 3)
return 0.0;
728 for (
int i=0;
i<clusterSize;
i++)
730 r = energyDistribution[
i].r / R0;
732 std::vector<double> pol;
733 pol.push_back(
f00(r) );
734 pol.push_back(
f11(r) );
735 pol.push_back(
f20(r) );
736 pol.push_back(
f22(r) );
737 pol.push_back(
f31(r) );
738 pol.push_back(
f33(r) );
739 pol.push_back(
f40(r) );
740 pol.push_back(
f42(r) );
741 pol.push_back(
f44(r) );
742 pol.push_back(
f51(r) );
743 pol.push_back(
f53(r) );
744 pol.push_back(
f55(r) );
745 ph = (energyDistribution[
i]).
phi;
746 e = energyDistribution[
i].deposited_energy;
747 Re = Re + e/TotalEnergy * pol[
index] *
cos( (
double) m * ph);
748 Im = Im - e/TotalEnergy * pol[
index] *
sin( (
double) m * ph);
751 return sqrt(Re*Re+Im*Im);
758 double r, ph,
e, Re=0, Im=0, f_nm;
759 double TotalEnergy = cluster.energy();
760 std::vector<EcalClusterEnergyDeposition> energyDistribution =
getEnergyDepTopology( cluster, recHits, geometry, logW, w0 );
761 int clusterSize=energyDistribution.size();
762 if(clusterSize<3)
return 0.0;
764 for (
int i = 0;
i < clusterSize; ++
i)
766 r = energyDistribution[
i].r / R0;
768 ph = energyDistribution[
i].phi;
769 e = energyDistribution[
i].deposited_energy;
771 for (
int s=0;
s<=(n-
m)/2;
s++) {
778 Re = Re + e/TotalEnergy * f_nm *
cos( (
double) m*ph);
779 Im = Im - e/TotalEnergy * f_nm *
sin( (
double) m*ph);
782 return sqrt(Re*Re+Im*Im);
799 return std::sqrt(iXNorm*iXNorm+iYNorm*iYNorm);
826 int iXNorm = eeId.
ix()-50;
827 if(iXNorm<=0) iXNorm--;
838 int iYNorm = eeId.
iy()-50;
839 if(iYNorm<=0) iYNorm--;
848 float crysIEta =
getIEta(crysId);
849 float orginIEta =
getIEta(orginId);
852 float nrCrysDiff = crysIEta-orginIEta;
857 if(crysIEta*orginIEta<0){
858 if(crysIEta>0) nrCrysDiff--;
868 float crysIPhi =
getIPhi(crysId);
869 float orginIPhi =
getIPhi(orginId);
872 float nrCrysDiff = crysIPhi-orginIPhi;
875 if (nrCrysDiff > + 180) { nrCrysDiff = nrCrysDiff - 360; }
876 if (nrCrysDiff < - 180) { nrCrysDiff = nrCrysDiff + 360; }
887 float hitLocalR2 = (iXNorm-meanX)*(iXNorm-meanX)+(iYNorm-meanY)*(iYNorm-meanY);
888 float hitR2 = iXNorm*iXNorm+iYNorm*iYNorm;
889 float meanR2 = meanX*meanX+meanY*meanY;
890 float hitR =
sqrt(hitR2);
891 float meanR =
sqrt(meanR2);
893 float phi = acos((hitR2+meanR2-hitLocalR2)/(2*hitR*meanR));
903 float e_5x5 =
e5x5(bcluster, recHits, topology);
904 float covEtaEta, covEtaPhi, covPhiPhi;
911 double numeratorEtaEta = 0;
912 double numeratorEtaPhi = 0;
913 double numeratorPhiPhi = 0;
916 const double barrelCrysSize = 0.01745;
917 const double endcapCrysSize = 0.0447;
922 const double crysSize = isBarrel ? barrelCrysSize : endcapCrysSize;
924 for (
size_t i = 0;
i < v_id.size(); ++
i) {
928 if (energy <= 0)
continue;
932 if(isBarrel) dPhi =
getNrCrysDiffInPhi(*cursor,seedId) - mean5x5PosInNrCrysFromSeed.second;
933 else dPhi =
getDPhiEndcap(*cursor,mean5x5XYPos.first,mean5x5XYPos.second);
941 numeratorEtaEta += w * dEta * dEta;
942 numeratorEtaPhi += w * dEta *
dPhi;
943 numeratorPhiPhi += w * dPhi *
dPhi;
947 if (denominator != 0.0) {
948 covEtaEta = crysSize*crysSize* numeratorEtaEta /
denominator;
949 covEtaPhi = crysSize*crysSize* numeratorEtaPhi /
denominator;
950 covPhiPhi = crysSize*crysSize* numeratorPhiPhi /
denominator;
965 std::vector<float>
v;
966 v.push_back( covEtaEta );
967 v.push_back( covEtaPhi );
968 v.push_back( covPhiPhi );
983 returnMoments.
sMaj = -1.;
984 returnMoments.
sMin = -1.;
985 returnMoments.
alpha = 0.;
988 if( fabs( basicCluster.eta() ) < 1.479 ) {
990 std::vector<const EcalRecHit*> RH_ptrs;
992 std::vector< std::pair<DetId, float> > myHitsPair = basicCluster.hitsAndFractions();
993 std::vector<DetId> usedCrystals;
994 for(
unsigned int i=0;
i< myHitsPair.size();
i++){
995 usedCrystals.push_back(myHitsPair[
i].
first);
998 for(
unsigned int i=0;
i<usedCrystals.size();
i++){
1001 RH_ptrs.push_back( &(*myRH) );
1008 return returnMoments;
1017 returnMoments.
sMaj = -1.;
1018 returnMoments.
sMin = -1.;
1019 returnMoments.
alpha = 0.;
1022 if( fabs( superCluster.
eta() ) < 1.479 ) {
1026 return returnMoments;
1033 double mid_eta,mid_phi;
1038 double max_phi=-10.;
1039 double min_phi=100.;
1041 std::vector<double> etaDetId;
1042 std::vector<double> phiDetId;
1043 std::vector<double> wiDetId;
1050 for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1053 EBDetId temp_EBDetId( (*rh_ptr)->detid() );
1054 double temp_eta=(temp_EBDetId.ieta() > 0. ? temp_EBDetId.ieta() + 84.5 : temp_EBDetId.ieta() + 85.5);
1055 double temp_phi=temp_EBDetId.
iphi() - 0.5;
1056 double temp_ene=(*rh_ptr)->energy();
1058 double temp_wi=((useLogWeights) ?
1062 if(temp_phi>max_phi) max_phi=temp_phi;
1063 if(temp_phi<min_phi) min_phi=temp_phi;
1064 etaDetId.push_back(temp_eta);
1065 phiDetId.push_back(temp_phi);
1066 wiDetId.push_back(temp_wi);
1067 denominator+=temp_wi;
1073 if(max_phi==359.5 && min_phi==0.5){
1074 for(
int i=0;
i<nCry;
i++){
1075 if(phiDetId[
i] - 179. > 0.) phiDetId[
i]-=360.;
1076 mid_phi+=phiDetId[
i]*wiDetId[
i];
1077 mid_eta+=etaDetId[
i]*wiDetId[
i];
1082 for(
int i=0;
i<nCry;
i++){
1083 mid_phi+=phiDetId[
i]*wiDetId[
i];
1084 mid_eta+=etaDetId[
i]*wiDetId[
i];
1099 for(
int i=0;
i<nCry;
i++) {
1100 See += (wiDetId[
i]*(etaDetId[
i]-mid_eta)*(etaDetId[
i]-mid_eta)) / denominator;
1101 Spp += phiCorrectionFactor*(wiDetId[
i]*(phiDetId[
i]-mid_phi)*(phiDetId[
i]-mid_phi)) / denominator;
1102 Sep +=
sqrt(phiCorrectionFactor)*(wiDetId[
i]*(etaDetId[
i]-mid_eta)*(phiDetId[
i]-mid_phi)) / denominator;
1108 returnMoments.
sMaj = ((See + Spp) +
sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;
1109 returnMoments.
sMin = ((See + Spp) -
sqrt((See - Spp)*(See - Spp) + 4.*Sep*Sep)) / 2.;
1111 returnMoments.
alpha = atan( (See - Spp +
sqrt( (Spp - See)*(Spp - See) + 4.*Sep*Sep )) / (2.*Sep));
1113 return returnMoments;
1127 std::vector<const EcalRecHit*>RH_ptrs;
1128 std::vector< std::pair<DetId, float> > myHitsPair = superCluster.
hitsAndFractions();
1129 std::vector<DetId> usedCrystals;
1130 for(
unsigned int i=0;
i< myHitsPair.size();
i++){
1131 usedCrystals.push_back(myHitsPair[
i].
first);
1133 for(
unsigned int i=0;
i<usedCrystals.size();
i++){
1137 RH_ptrs.push_back( &(*myRH) );
1151 std::vector<const EcalRecHit*>RH_ptrs;
1152 std::vector< std::pair<DetId, float> > myHitsPair = superCluster.
hitsAndFractions();
1153 std::vector<DetId> usedCrystals;
1154 for(
unsigned int i=0;
i< myHitsPair.size();
i++){
1155 usedCrystals.push_back(myHitsPair[
i].
first);
1158 for(
unsigned int i=0;
i<usedCrystals.size();
i++){
1161 if(myRH != recHits.
end() && myRH->energy() > energyRHThresh)
1162 RH_ptrs.push_back( &(*myRH) );
1169 EBDetId EBdetIdi( rh->detid() );
1171 bool inEtaWindow = (
abs(
deltaIEta(seedPosition[0],EBdetIdi.ieta()) ) <= ieta_delta );
1172 bool inPhiWindow = (
abs(
deltaIPhi(seedPosition[1],EBdetIdi.iphi()) ) <= iphi_delta );
1173 bool passEThresh = ( rh->energy() > energyRHThresh );
1174 bool alreadyCounted =
false;
1177 bool is_SCrh_inside_recHits =
false;
1178 for(
unsigned int i=0;
i<usedCrystals.size();
i++){
1180 if(SCrh != recHits.
end()){
1181 is_SCrh_inside_recHits =
true;
1182 if( rh->detid() == SCrh->detid() ) alreadyCounted =
true;
1186 if( is_SCrh_inside_recHits && !alreadyCounted && passEThresh && inEtaWindow && inPhiWindow){
1187 RH_ptrs.push_back( &(*rh) );
1200 std::vector<float> shapes;
1203 if(RH_ptrs.size()<2){
1204 shapes.push_back( -3 );
1205 shapes.push_back( -3 );
1211 int tempInt = seedPosition[0];
1212 if(tempInt <0) tempInt++;
1216 float centerIEta = 0.;
1217 float centerIPhi = 0.;
1220 for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1222 EBDetId EBdetIdi( (*rh_ptr)->detid() );
1223 if(fabs(energyTotal) < 0.0001){
1225 shapes.push_back( -2 );
1226 shapes.push_back( -2 );
1230 if(fabs(weightedPositionMethod)<0.0001){
1231 weight = (*rh_ptr)->energy()/energyTotal;
1233 weight =
std::max(0.0, 4.2 +
log((*rh_ptr)->energy()/energyTotal));
1236 centerIEta += weight*
deltaIEta(seedPosition[0],EBdetIdi.ieta());
1237 centerIPhi += weight*
deltaIPhi(seedPosition[1],EBdetIdi.iphi());
1239 if(fabs(denominator) < 0.0001){
1241 shapes.push_back( -2 );
1242 shapes.push_back( -2 );
1250 TMatrixDSym inertia(2);
1251 double inertia00 = 0.;
1252 double inertia01 = 0.;
1253 double inertia11 = 0.;
1255 for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1257 EBDetId EBdetIdi( (*rh_ptr)->detid() );
1259 if(fabs(energyTotal) < 0.0001){
1261 shapes.push_back( -2 );
1262 shapes.push_back( -2 );
1266 if(fabs(weightedPositionMethod) < 0.0001){
1267 weight = (*rh_ptr)->energy()/energyTotal;
1269 weight =
std::max(0.0, 4.2 +
log((*rh_ptr)->energy()/energyTotal));
1272 float ieta_rh_to_center =
deltaIEta(seedPosition[0],EBdetIdi.ieta()) - centerIEta;
1273 float iphi_rh_to_center =
deltaIPhi(seedPosition[1],EBdetIdi.iphi()) - centerIPhi;
1275 inertia00 += weight*iphi_rh_to_center*iphi_rh_to_center;
1276 inertia01 -= weight*iphi_rh_to_center*ieta_rh_to_center;
1277 inertia11 += weight*ieta_rh_to_center*ieta_rh_to_center;
1281 inertia[0][0] = inertia00;
1282 inertia[0][1] = inertia01;
1283 inertia[1][0] = inertia01;
1284 inertia[1][1] = inertia11;
1288 TMatrixD eVectors(2,2);
1289 TVectorD eValues(2);
1291 eVectors=inertia.EigenVectors(eValues);
1298 TVectorD smallerAxis(2);
1299 smallerAxis[0]=eVectors[0][1];
1300 smallerAxis[1]=eVectors[1][1];
1303 Double_t
temp = fabs(smallerAxis[0]);
1304 if(fabs(eValues[0]) < 0.0001){
1306 shapes.push_back( -2 );
1307 shapes.push_back( -2 );
1311 float Roundness = eValues[1]/eValues[0];
1312 float Angle=acos(temp);
1314 if( -0.00001 < Roundness && Roundness < 0) Roundness = 0.;
1315 if( -0.00001 < Angle && Angle < 0 ) Angle = 0.;
1317 shapes.push_back( Roundness );
1318 shapes.push_back( Angle );
1327 int rel_iphi = rh_iphi - seed_iphi;
1329 if(rel_iphi > 180) rel_iphi = rel_iphi - 360;
1330 if(rel_iphi < -180) rel_iphi = rel_iphi + 360;
1339 if(seed_ieta < 0) seed_ieta++;
1340 if(rh_ieta < 0) rh_ieta++;
1341 int rel_ieta = rh_ieta - seed_ieta;
1347 std::vector<int> seedPosition;
1352 for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1355 EBDetId EBdetIdi( (*rh_ptr)->detid() );
1357 if(eSeedRH < (*rh_ptr)->energy()){
1358 eSeedRH = (*rh_ptr)->energy();
1359 iEtaSeedRH = EBdetIdi.
ieta();
1360 iPhiSeedRH = EBdetIdi.iphi();
1365 seedPosition.push_back(iEtaSeedRH);
1366 seedPosition.push_back(iPhiSeedRH);
1367 return seedPosition;
1375 for(std::vector<const EcalRecHit*>::const_iterator rh_ptr = RH_ptrs.begin(); rh_ptr != RH_ptrs.end(); rh_ptr++){
1376 sumE += (*rh_ptr)->energy();
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
void home() const
move the navigator back to the starting point
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
std::vector< T >::const_iterator const_iterator
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
static const int kTowersInPhi
static int position[TOTALCHAMBERS][3]
double eta() const
pseudorapidity of cluster centroid
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)
int im() const
get the number of module inside the SM (1-4)
static const int kCrystalsInPhi
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)
static const int kModulesPerSM
int ieta() const
get the crystal ieta
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
const_iterator end() const
Log< T >::type log(const T &t)
static const int MAX_IPHI
XYZVectorD XYZVector
spatial vector with cartesian internal representation
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
std::vector< std::vector< double > > tmp
ESHandle< TrackerGeometry > geometry
iterator find(key_type k)
const CaloClusterPtr & seed() const
seed BasicCluster
double energySum(const DataFrame &df, int fs, int ls)
const GlobalPoint & getPosition() const
Power< A, B >::type pow(const A &a, const B &b)
const_iterator begin() const