00001
00002 #include <Math/VectorUtil.h>
00003
00004 #include "RecoHI/HiEgammaAlgos/interface/CxCalculator.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00008 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00009
00010 #include "DataFormats/Common/interface/Handle.h"
00011 #include "DataFormats/EgammaReco/interface/BasicCluster.h"
00012 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00013 #include "DataFormats/Math/interface/Vector3D.h"
00014
00015
00016 using namespace edm;
00017 using namespace reco;
00018 using namespace std;
00019 using namespace ROOT::Math::VectorUtil;
00020
00021 #define PI 3.141592653589793238462643383279502884197169399375105820974945
00022
00023
00024 double CxCalculator::getJurassicArea( double r1, double r2, double width) {
00025
00026 float theta1 = asin( width / r1);
00027 float theta2 = asin( width / r2);
00028 float theA = sqrt ( r1*r1 + r2*r2 - 2 * r1 * r2 * cos ( theta1 - theta2) );
00029 float area1 = 0.5 * r1*r1 * ( 3.141592 - 2 * theta1 ) ;
00030 float area2 = 0.5 * r2*r2 * ( 3.141592 - 2 * theta2 ) ;
00031 float area3 = width * theA;
00032 float finalArea = 2 * ( area1 - area2 - area3);
00033 return finalArea;
00034 }
00035
00036
00037
00038 CxCalculator::CxCalculator (const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag barrelLabel, edm::InputTag endcapLabel)
00039 {
00040
00041
00042 Handle<BasicClusterCollection> pEBclusters;
00043 iEvent.getByLabel(barrelLabel, pEBclusters);
00044 if(pEBclusters.isValid())
00045 fEBclusters_ = pEBclusters.product();
00046 else
00047 fEBclusters_ = NULL;
00048
00049 Handle<BasicClusterCollection> pEEclusters;
00050 iEvent.getByLabel(endcapLabel, pEEclusters);
00051 if(pEEclusters.isValid())
00052 fEEclusters_ = pEEclusters.product();
00053 else
00054 fEEclusters_ = NULL;
00055
00056 ESHandle<CaloGeometry> geometryHandle;
00057 iSetup.get<CaloGeometryRecord>().get(geometryHandle);
00058 if(geometryHandle.isValid())
00059 geometry_ = geometryHandle.product();
00060 else
00061 geometry_ = NULL;
00062
00063 }
00064
00065 double CxCalculator::getCx(const reco::SuperClusterRef cluster, double x, double threshold)
00066 {
00067 using namespace edm;
00068 using namespace reco;
00069
00070 if(!fEBclusters_) {
00071
00072 return -100;
00073 }
00074
00075 if(!fEEclusters_) {
00076
00077 return -100;
00078 }
00079
00080 math::XYZVector SClusPoint(cluster->position().x(),
00081 cluster->position().y(),
00082 cluster->position().z());
00083
00084 double TotalEt = 0;
00085
00086 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
00087
00088
00089 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00090 iclu != fEBclusters_->end(); ++iclu) {
00091 const BasicCluster *clu = &(*iclu);
00092 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00093 double eta = ClusPoint.eta();
00094
00095 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
00096
00097 if (dR<x*0.1) {
00098 double et = clu->energy()/cosh(eta);
00099 if (et<threshold) et=0;
00100 TotalEt += et;
00101 }
00102 }
00103
00104 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00105 iclu != fEEclusters_->end(); ++iclu) {
00106 const BasicCluster *clu = &(*iclu);
00107 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
00108 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00109 double eta = ClusPoint.eta();
00110
00111 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
00112
00113 if (dR<x*0.1) {
00114 double et = clu->energy()/cosh(eta);
00115 if (et<threshold) et=0;
00116 TotalEt += et;
00117 }
00118 }
00119
00120 return TotalEt;
00121 }
00122
00123 double CxCalculator::getCxRemoveSC(const reco::SuperClusterRef cluster, double x, double threshold)
00124 {
00125
00126
00127 using namespace edm;
00128 using namespace reco;
00129
00130 if(!fEBclusters_) {
00131 LogError("CxCalculator") << "Error! Can't get EBclusters for event.";
00132 return -100;
00133 }
00134
00135 if(!fEEclusters_) {
00136 LogError("CxCalculator") << "Error! Can't get EEclusters for event.";
00137 return -100;
00138 }
00139
00140 math::XYZVector SClusPoint(cluster->position().x(),
00141 cluster->position().y(),
00142 cluster->position().z());
00143
00144 double TotalEt = 0;
00145
00146 TotalEt = 0;
00147
00148
00149 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00150 iclu != fEBclusters_->end(); ++iclu) {
00151 const BasicCluster *clu = &(*iclu);
00152 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00153 double eta = ClusPoint.eta();
00154
00155 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
00156
00157
00158 bool inSuperCluster = checkUsed(cluster,clu);
00159
00160 if (dR<x*0.1&&inSuperCluster==false) {
00161 double et = clu->energy()/cosh(eta);
00162 if (et<threshold) et=0;
00163 TotalEt += et;
00164 }
00165
00166 }
00167
00168 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00169 iclu != fEEclusters_->end(); ++iclu) {
00170 const BasicCluster *clu = &(*iclu);
00171 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
00172 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00173 double eta = ClusPoint.eta();
00174
00175 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
00176
00177
00178 bool inSuperCluster = checkUsed(cluster,clu);
00179
00180 if (dR<x*0.1&&inSuperCluster==false) {
00181 double et = clu->energy()/cosh(eta);
00182 if (et<threshold) et=0;
00183 TotalEt += et;
00184 }
00185 }
00186
00187 return TotalEt;
00188 }
00189
00190 double CxCalculator::getCCx(const reco::SuperClusterRef cluster, double x, double threshold)
00191 {
00192 using namespace edm;
00193 using namespace reco;
00194
00195
00196 if(!fEBclusters_) {
00197
00198 return -100;
00199 }
00200
00201 if(!fEEclusters_) {
00202
00203 return -100;
00204 }
00205
00206 double SClusterEta = cluster->eta();
00207 double SClusterPhi = cluster->phi();
00208 double TotalEt = 0;
00209
00210 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
00211
00212 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00213 iclu != fEBclusters_->end(); ++iclu) {
00214 const BasicCluster *clu = &(*iclu);
00215 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00216 double eta = ClusPoint.eta();
00217
00218 double dEta = fabs(eta-SClusterEta);
00219
00220 if (dEta<x*0.1) {
00221 double et = clu->energy()/cosh(eta);
00222 if (et<threshold) et=0;
00223 TotalEt += et;
00224 }
00225 }
00226
00227 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00228 iclu != fEEclusters_->end(); ++iclu) {
00229 const BasicCluster *clu = &(*iclu);
00230 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00231 double eta = ClusPoint.eta();
00232 double phi = ClusPoint.phi();
00233
00234 double dEta = fabs(eta-SClusterEta);
00235 double dPhi = fabs(phi-SClusterPhi);
00236 while (dPhi>2*PI) dPhi-=2*PI;
00237 if (dPhi>PI) dPhi=2*PI-dPhi;
00238
00239 if (dEta<x*0.1) {
00240 double et = clu->energy()/cosh(eta);
00241 if (et<threshold) et=0;
00242 TotalEt += et;
00243 }
00244 }
00245
00246 double Cx = getCx(cluster,x,threshold);
00247 double CCx = Cx - TotalEt / 40.0 * x;
00248
00249 return CCx;
00250 }
00251
00252
00253
00254
00255 double CxCalculator::getJc(const reco::SuperClusterRef cluster, double r1, double r2, double jWidth, double threshold)
00256 {
00257 using namespace edm;
00258 using namespace reco;
00259 if(!fEBclusters_) {
00260
00261 return -100;
00262 }
00263 if(!fEEclusters_) {
00264 return -100;
00265 }
00266 double SClusterEta = cluster->eta();
00267 double SClusterPhi = cluster->phi();
00268 double TotalEt = 0;
00269
00270 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00271 iclu != fEBclusters_->end(); ++iclu) {
00272 const BasicCluster *clu = &(*iclu);
00273 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00274 double eta = ClusPoint.eta();
00275 double phi = ClusPoint.phi();
00276
00277 double dEta = fabs(eta-SClusterEta);
00278 double dPhi = phi-SClusterPhi;
00279 if ( dPhi < -PI ) dPhi = dPhi + 2*PI ;
00280 if ( dPhi > PI ) dPhi = dPhi - 2*PI ;
00281 if ( fabs(dPhi) > PI ) cout << " error!!! dphi > 2pi : " << dPhi << endl;
00282 double dR = sqrt(dEta*dEta+dPhi*dPhi);
00283
00284
00285 if ( dR > r1 ) continue;
00286 if ( dR < r2 ) continue;
00287 if ( fabs(dEta) < jWidth) continue;
00289 double theEt = clu->energy()/cosh(eta);
00290 if (theEt<threshold) continue;
00291 TotalEt += theEt;
00292 }
00293
00294 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00295 iclu != fEEclusters_->end(); ++iclu) {
00296 const BasicCluster *clu = &(*iclu);
00297 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00298 double eta = ClusPoint.eta();
00299 double phi = ClusPoint.phi();
00300 double dEta = fabs(eta-SClusterEta);
00301 double dPhi = phi-SClusterPhi;
00302 if ( dPhi < -PI ) dPhi = dPhi + 2*PI ;
00303 if ( dPhi > PI ) dPhi = dPhi - 2*PI ;
00304 if ( fabs(dPhi) >PI ) cout << " error!!! dphi > 2pi : " << dPhi << endl;
00305 double dR = sqrt(dEta*dEta+dPhi*dPhi);
00306
00307 if ( dR > r1 ) continue;
00308 if ( dR < r2 ) continue;
00309 if ( fabs(dEta) < jWidth) continue;
00311 double theEt = clu->energy()/cosh(eta);
00312 if (theEt<threshold) continue;
00313 TotalEt += theEt;
00314 }
00315 return TotalEt;
00316 }
00317
00318
00319 double CxCalculator::getJcc(const reco::SuperClusterRef cluster, double r1, double r2, double jWidth, double threshold)
00320 {
00321
00322 using namespace edm;
00323 using namespace reco;
00324 if(!fEBclusters_) {
00325
00326 return -100;
00327 }
00328 if(!fEEclusters_) {
00329 return -100;
00330 }
00331 double SClusterEta = cluster->eta();
00332 double SClusterPhi = cluster->phi();
00333 double TotalEt = 0;
00334
00335 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00336 iclu != fEBclusters_->end(); ++iclu) {
00337 const BasicCluster *clu = &(*iclu);
00338 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00339 double eta = ClusPoint.eta();
00340 double phi = ClusPoint.phi();
00341
00342 double dEta = fabs(eta-SClusterEta);
00343 double dPhi = phi-SClusterPhi;
00344 if ( dPhi < -PI ) dPhi = dPhi + 2*PI ;
00345 if ( dPhi > PI ) dPhi = dPhi - 2*PI ;
00346
00347
00349 if ( fabs(dEta) > r1 ) continue;
00350 if ( fabs(dPhi) <r1 ) continue;
00352
00353 double theEt = clu->energy()/cosh(eta);
00354 if (theEt<threshold) continue;
00355 TotalEt += theEt;
00356 }
00357 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00358 iclu != fEEclusters_->end(); ++iclu) {
00359 const BasicCluster *clu = &(*iclu);
00360 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00361 double eta = ClusPoint.eta();
00362 double phi = ClusPoint.phi();
00363 double dEta = fabs(eta-SClusterEta);
00364 double dPhi = phi-SClusterPhi;
00365 if ( dPhi < -PI ) dPhi = dPhi + 2*PI ;
00366 if ( dPhi > PI ) dPhi = dPhi - 2*PI ;
00367
00368
00370 if ( fabs(dEta) > r1 ) continue;
00371 if ( fabs(dPhi) < r1 ) continue;
00373
00374 double theEt = clu->energy()/cosh(eta);
00375 if (theEt<threshold) continue;
00376 TotalEt += theEt;
00377 }
00378
00379 double areaStrip = 4*PI*r1 - 4*r1*r1;
00380 double areaJura = getJurassicArea(r1,r2, jWidth) ;
00381 double theCJ = getJc(cluster,r1, r2, jWidth, threshold);
00382
00383
00384 double theCCJ = theCJ - TotalEt * areaJura / areaStrip ;
00385 return theCCJ;
00386 }
00387
00388
00389
00390 double CxCalculator::getCCxRemoveSC(const reco::SuperClusterRef cluster, double x, double threshold)
00391 {
00392 using namespace edm;
00393 using namespace reco;
00394
00395
00396 if(!fEBclusters_) {
00397 LogError("CxCalculator") << "Error! Can't get EBclusters for event.";
00398 return -100;
00399 }
00400
00401 if(!fEEclusters_) {
00402 LogError("CxCalculator") << "Error! Can't get EEclusters for event.";
00403 return -100;
00404 }
00405
00406 double SClusterEta = cluster->eta();
00407 double SClusterPhi = cluster->phi();
00408 double TotalEt = 0;
00409
00410 TotalEt = 0;
00411
00412 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00413 iclu != fEBclusters_->end(); ++iclu) {
00414 const BasicCluster *clu = &(*iclu);
00415 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00416 double eta = ClusPoint.eta();
00417
00418 double dEta = fabs(eta-SClusterEta);
00419
00420
00421 bool inSuperCluster = checkUsed(cluster,clu);
00422
00423 if (dEta<x*0.1&&inSuperCluster==false) {
00424 double et = clu->energy()/cosh(eta);
00425 if (et<threshold) et=0;
00426 TotalEt += et;
00427 }
00428 }
00429
00430 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00431 iclu != fEEclusters_->end(); ++iclu) {
00432 const BasicCluster *clu = &(*iclu);
00433 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00434 double eta = ClusPoint.eta();
00435 double phi = ClusPoint.phi();
00436
00437 double dEta = fabs(eta-SClusterEta);
00438 double dPhi = fabs(phi-SClusterPhi);
00439 while (dPhi>2*PI) dPhi-=2*PI;
00440 if (dPhi>PI) dPhi=2*PI-dPhi;
00441
00442
00443 bool inSuperCluster = checkUsed(cluster,clu);
00444
00445 if (dEta<x*0.1&&inSuperCluster==false) {
00446 double et = clu->energy()/cosh(eta);
00447 if (et<threshold) et=0;
00448 TotalEt += et;
00449 }
00450 }
00451
00452 double Cx = getCxRemoveSC(cluster,x,threshold);
00453 double CCx = Cx - TotalEt / 40.0 * x;
00454
00455 return CCx;
00456 }
00457
00458
00459 bool CxCalculator::checkUsed(const reco::SuperClusterRef sc, const reco::BasicCluster* bc)
00460 {
00461 reco::CaloCluster_iterator theEclust = sc->clustersBegin();
00462
00463
00464 for(;theEclust != sc->clustersEnd(); theEclust++) {
00465 if ((**theEclust) == (*bc) ) return true;
00466 }
00467 return false;
00468 }
00469
00470 double CxCalculator::getBCMax(const reco::SuperClusterRef cluster,int i)
00471 {
00472 reco::CaloCluster_iterator theEclust = cluster->clustersBegin();
00473
00474 double energyMax=0,energySecond=0;
00475
00476 for(;theEclust != cluster->clustersEnd(); theEclust++) {
00477 if ((*theEclust)->energy()>energyMax ) {
00478 energySecond=energyMax;
00479 energyMax=(*theEclust)->energy();
00480 } else if ((*theEclust)->energy()>energySecond) {
00481 energySecond=(*theEclust)->energy();
00482 }
00483 }
00484 if (i==1) return energyMax;
00485 return energySecond;
00486 }
00487
00488
00489 double CxCalculator::getCorrection(const reco::SuperClusterRef cluster, double x, double y,double threshold)
00490 {
00491 using namespace edm;
00492 using namespace reco;
00493
00494
00495 if(!fEBclusters_) {
00496 LogError("CxCalculator") << "Error! Can't get EBclusters for event.";
00497 return -100;
00498 }
00499
00500 if(!fEEclusters_) {
00501 LogError("CxCalculator") << "Error! Can't get EEclusters for event.";
00502 return -100;
00503 }
00504
00505 double SClusterEta = cluster->eta();
00506 double SClusterPhi = cluster->phi();
00507 double TotalEnergy = 0;
00508 double TotalBC = 0;
00509
00510 TotalEnergy = 0;
00511
00512 double Area = PI * (-x*x+y*y) / 100.0;
00513 double nCrystal = Area / 0.0174 / 0.0174;
00514
00515 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00516 iclu != fEBclusters_->end(); ++iclu) {
00517 const BasicCluster *clu = &(*iclu);
00518 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
00519 double eta = clusPoint.eta();
00520 double phi = clusPoint.phi();
00521 double dEta = fabs(eta-SClusterEta);
00522 double dPhi = fabs(phi-SClusterPhi);
00523 while (dPhi>2*PI) dPhi-=2*PI;
00524 if (dPhi>PI) dPhi=2*PI-dPhi;
00525 double dR = sqrt(dEta*dEta+dPhi*dPhi);
00526
00527 if (dR>x*0.1&&dR<y*0.1) {
00528 double e = clu->energy();
00529 if (e<threshold) e=0;
00530 TotalEnergy += e;
00531 if (e!=0) TotalBC+=clu->size();
00532
00533 }
00534 }
00535
00536 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00537 iclu != fEEclusters_->end(); ++iclu) {
00538 const BasicCluster *clu = &(*iclu);
00539 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
00540 double eta = clusPoint.eta();
00541 double phi = clusPoint.phi();
00542 double dEta = fabs(eta-SClusterEta);
00543 double dPhi = fabs(phi-SClusterPhi);
00544 while (dPhi>2*PI) dPhi-=2*PI;
00545 if (dPhi>PI) dPhi=2*PI-dPhi;
00546 double dR = sqrt(dEta*dEta+dPhi*dPhi);
00547
00548 if (dR>x*0.1&&dR<y*0.1) {
00549 double e = clu->energy();
00550 if (e<threshold) e=0;
00551 TotalEnergy += e;
00552 if (e!=0) TotalBC += clu->size();
00553 }
00554 }
00555
00556
00557 if (TotalBC==0) return 0;
00558 return TotalEnergy/nCrystal;
00559 }
00560
00561 double CxCalculator::getAvgBCEt(const reco::SuperClusterRef cluster, double x,double phi1,double phi2, double threshold)
00562
00563 {
00564 using namespace edm;
00565 using namespace reco;
00566
00567
00568 if(!fEBclusters_) {
00569 LogError("CxCalculator") << "Error! Can't get EBclusters for event.";
00570 return -100;
00571 }
00572
00573 if(!fEEclusters_) {
00574 LogError("CxCalculator") << "Error! Can't get EEclusters for event.";
00575 return -100;
00576 }
00577
00578 double SClusterEta = cluster->eta();
00579 double SClusterPhi = cluster->phi();
00580
00581 double TotalEt = 0;
00582 double TotalN = 0;
00583
00584 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
00585
00586 if (fabs(SClusterEta) < 1.479) {
00587
00588 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00589 iclu != fEBclusters_->end(); ++iclu) {
00590 const BasicCluster *clu = &(*iclu);
00591 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00592 double eta = ClusPoint.eta();
00593 double phi = ClusPoint.phi();
00594
00595 double dEta = fabs(eta-SClusterEta);
00596 double dPhi = fabs(phi-SClusterPhi);
00597 while (dPhi>2*PI) dPhi-=2*PI;
00598
00599 bool inSuperCluster = checkUsed(cluster,clu);
00600
00601 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
00602 double et = clu->energy()/cosh(eta);
00603 if (et<threshold) et=0;
00604 TotalEt += et;
00605 TotalN ++;
00606 }
00607 }
00608 } else {
00609
00610 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00611 iclu != fEEclusters_->end(); ++iclu) {
00612 const BasicCluster *clu = &(*iclu);
00613 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00614 double eta = ClusPoint.eta();
00615 double phi = ClusPoint.phi();
00616
00617 double dEta = fabs(eta-SClusterEta);
00618 double dPhi = fabs(phi-SClusterPhi);
00619 while (dPhi>2*PI) dPhi-=2*PI;
00620
00621 bool inSuperCluster = checkUsed(cluster,clu);
00622
00623 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
00624 double et = clu->energy()/cosh(eta);
00625 if (et<threshold) et=0;
00626 TotalEt += et;
00627 TotalN ++;
00628 }
00629 }
00630 }
00631 return TotalEt / TotalN;
00632 }
00633
00634 double CxCalculator::getNBC(const reco::SuperClusterRef cluster, double x,double phi1,double phi2, double threshold)
00635
00636 {
00637 using namespace edm;
00638 using namespace reco;
00639
00640
00641 if(!fEBclusters_) {
00642 LogError("CxCalculator") << "Error! Can't get EBclusters for event.";
00643 return -100;
00644 }
00645
00646 if(!fEEclusters_) {
00647 LogError("CxCalculator") << "Error! Can't get EEclusters for event.";
00648 return -100;
00649 }
00650
00651 double SClusterEta = cluster->eta();
00652 double SClusterPhi = cluster->phi();
00653
00654 double TotalEt = 0;
00655 double TotalN = 0;
00656
00657 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
00658
00659
00660
00661 if (fabs(SClusterEta) < 1.479) {
00662
00663 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
00664 iclu != fEBclusters_->end(); ++iclu) {
00665 const BasicCluster *clu = &(*iclu);
00666 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00667 double eta = ClusPoint.eta();
00668 double phi = ClusPoint.phi();
00669
00670 double dEta = fabs(eta-SClusterEta);
00671 double dPhi = fabs(phi-SClusterPhi);
00672 while (dPhi>2*PI) dPhi-=2*PI;
00673
00674 bool inSuperCluster = checkUsed(cluster,clu);
00675
00676 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
00677 double et = clu->energy()/cosh(eta);
00678 if (et<threshold) et=0;
00679 TotalEt += et;
00680 TotalN ++;
00681 }
00682 }
00683 } else {
00684
00685 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
00686 iclu != fEEclusters_->end(); ++iclu) {
00687 const BasicCluster *clu = &(*iclu);
00688 math::XYZVector ClusPoint(clu->x(),clu->y(),clu->z());
00689 double eta = ClusPoint.eta();
00690 double phi = ClusPoint.phi();
00691
00692 double dEta = fabs(eta-SClusterEta);
00693 double dPhi = fabs(phi-SClusterPhi);
00694 while (dPhi>2*PI) dPhi-=2*PI;
00695
00696 bool inSuperCluster = checkUsed(cluster,clu);
00697
00698 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
00699 double et = clu->energy()/cosh(eta);
00700 if (et<threshold) et=0;
00701 TotalEt += et;
00702 TotalN ++;
00703 }
00704 }
00705 }
00706 return TotalN;
00707 }