2 #include <Math/VectorUtil.h>
19 using namespace ROOT::Math::VectorUtil;
21 #define PI 3.141592653589793238462643383279502884197169399375105820974945
26 float theta1 = asin( width / r1);
27 float theta2 = asin( width / r2);
28 float theA =
sqrt ( r1*r1 + r2*r2 - 2 * r1 * r2 *
cos ( theta1 - theta2) );
29 float area1 = 0.5 * r1*r1 * ( 3.141592 - 2 * theta1 ) ;
30 float area2 = 0.5 * r2*r2 * ( 3.141592 - 2 * theta2 ) ;
31 float area3 = width * theA;
32 float finalArea = 2 * ( area1 - area2 - area3);
45 fEBclusters_ = pEBclusters.
product();
52 fEEclusters_ = pEEclusters.
product();
59 geometry_ = geometryHandle.
product();
81 cluster->position().y(),
82 cluster->position().z());
86 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
89 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
90 iclu != fEBclusters_->end(); ++iclu) {
93 double eta = ClusPoint.eta();
95 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
98 double et = clu->energy()/cosh(eta);
99 if (et<threshold) et=0;
104 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
105 iclu != fEEclusters_->end(); ++iclu) {
107 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
109 double eta = ClusPoint.eta();
111 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
114 double et = clu->energy()/cosh(eta);
115 if (et<threshold) et=0;
128 using namespace reco;
131 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
136 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
141 cluster->position().y(),
142 cluster->position().z());
149 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
150 iclu != fEBclusters_->end(); ++iclu) {
153 double eta = ClusPoint.eta();
155 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
158 bool inSuperCluster = checkUsed(cluster,clu);
160 if (dR<x*0.1&&inSuperCluster==
false) {
161 double et = clu->energy()/cosh(eta);
162 if (et<threshold) et=0;
168 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
169 iclu != fEEclusters_->end(); ++iclu) {
171 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
173 double eta = ClusPoint.eta();
175 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
178 bool inSuperCluster = checkUsed(cluster,clu);
180 if (dR<x*0.1&&inSuperCluster==
false) {
181 double et = clu->energy()/cosh(eta);
182 if (et<threshold) et=0;
193 using namespace reco;
206 double SClusterEta = cluster->eta();
207 double SClusterPhi = cluster->phi();
210 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
212 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
213 iclu != fEBclusters_->end(); ++iclu) {
216 double eta = ClusPoint.eta();
218 double dEta = fabs(eta-SClusterEta);
221 double et = clu->energy()/cosh(eta);
222 if (et<threshold) et=0;
227 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
228 iclu != fEEclusters_->end(); ++iclu) {
231 double eta = ClusPoint.eta();
232 double phi = ClusPoint.phi();
234 double dEta = fabs(eta-SClusterEta);
235 double dPhi = fabs(phi-SClusterPhi);
236 while (dPhi>2*
PI) dPhi-=2*
PI;
240 double et = clu->energy()/cosh(eta);
241 if (et<threshold) et=0;
246 double Cx = getCx(cluster,x,threshold);
247 double CCx = Cx - TotalEt / 40.0 *
x;
258 using namespace reco;
266 double SClusterEta = cluster->eta();
267 double SClusterPhi = cluster->phi();
270 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
271 iclu != fEBclusters_->end(); ++iclu) {
274 double eta = ClusPoint.eta();
275 double phi = ClusPoint.phi();
277 double dEta = fabs(eta-SClusterEta);
278 double dPhi = phi-SClusterPhi;
279 if ( dPhi < -
PI ) dPhi = dPhi + 2*
PI ;
280 if ( dPhi > PI ) dPhi = dPhi - 2*
PI ;
281 if ( fabs(dPhi) > PI )
cout <<
" error!!! dphi > 2pi : " << dPhi << endl;
282 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
285 if ( dR > r1 )
continue;
286 if ( dR < r2 )
continue;
287 if ( fabs(dEta) < jWidth)
continue;
289 double theEt = clu->energy()/cosh(eta);
290 if (theEt<threshold)
continue;
294 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
295 iclu != fEEclusters_->end(); ++iclu) {
298 double eta = ClusPoint.eta();
299 double phi = ClusPoint.phi();
300 double dEta = fabs(eta-SClusterEta);
301 double dPhi = phi-SClusterPhi;
302 if ( dPhi < -
PI ) dPhi = dPhi + 2*
PI ;
303 if ( dPhi > PI ) dPhi = dPhi - 2*
PI ;
304 if ( fabs(dPhi) >PI )
cout <<
" error!!! dphi > 2pi : " << dPhi << endl;
305 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
307 if ( dR > r1 )
continue;
308 if ( dR < r2 )
continue;
309 if ( fabs(dEta) < jWidth)
continue;
311 double theEt = clu->energy()/cosh(eta);
312 if (theEt<threshold)
continue;
323 using namespace reco;
331 double SClusterEta = cluster->eta();
332 double SClusterPhi = cluster->phi();
335 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
336 iclu != fEBclusters_->end(); ++iclu) {
339 double eta = ClusPoint.eta();
340 double phi = ClusPoint.phi();
342 double dEta = fabs(eta-SClusterEta);
343 double dPhi = phi-SClusterPhi;
344 if ( dPhi < -
PI ) dPhi = dPhi + 2*
PI ;
345 if ( dPhi > PI ) dPhi = dPhi - 2*
PI ;
349 if ( fabs(dEta) > r1 )
continue;
350 if ( fabs(dPhi) <r1 )
continue;
353 double theEt = clu->energy()/cosh(eta);
354 if (theEt<threshold)
continue;
357 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
358 iclu != fEEclusters_->end(); ++iclu) {
361 double eta = ClusPoint.eta();
362 double phi = ClusPoint.phi();
363 double dEta = fabs(eta-SClusterEta);
364 double dPhi = phi-SClusterPhi;
365 if ( dPhi < -
PI ) dPhi = dPhi + 2*
PI ;
366 if ( dPhi > PI ) dPhi = dPhi - 2*
PI ;
370 if ( fabs(dEta) > r1 )
continue;
371 if ( fabs(dPhi) < r1 )
continue;
374 double theEt = clu->energy()/cosh(eta);
375 if (theEt<threshold)
continue;
379 double areaStrip = 4*
PI*r1 - 4*r1*
r1;
380 double areaJura = getJurassicArea(r1,r2, jWidth) ;
381 double theCJ = getJc(cluster,r1, r2, jWidth, threshold);
384 double theCCJ = theCJ - TotalEt * areaJura / areaStrip ;
393 using namespace reco;
397 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
402 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
406 double SClusterEta = cluster->eta();
407 double SClusterPhi = cluster->phi();
412 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
413 iclu != fEBclusters_->end(); ++iclu) {
416 double eta = ClusPoint.eta();
418 double dEta = fabs(eta-SClusterEta);
421 bool inSuperCluster = checkUsed(cluster,clu);
423 if (dEta<x*0.1&&inSuperCluster==
false) {
424 double et = clu->energy()/cosh(eta);
425 if (et<threshold) et=0;
430 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
431 iclu != fEEclusters_->end(); ++iclu) {
434 double eta = ClusPoint.eta();
435 double phi = ClusPoint.phi();
437 double dEta = fabs(eta-SClusterEta);
438 double dPhi = fabs(phi-SClusterPhi);
439 while (dPhi>2*
PI) dPhi-=2*
PI;
443 bool inSuperCluster = checkUsed(cluster,clu);
445 if (dEta<x*0.1&&inSuperCluster==
false) {
446 double et = clu->energy()/cosh(eta);
447 if (et<threshold) et=0;
452 double Cx = getCxRemoveSC(cluster,x,threshold);
453 double CCx = Cx - TotalEt / 40.0 *
x;
464 for(;theEclust != sc->clustersEnd(); theEclust++) {
465 if ((**theEclust) == (*bc) )
return true;
474 double energyMax=0,energySecond=0;
476 for(;theEclust != cluster->clustersEnd(); theEclust++) {
477 if ((*theEclust)->energy()>energyMax ) {
478 energySecond=energyMax;
479 energyMax=(*theEclust)->energy();
480 }
else if ((*theEclust)->energy()>energySecond) {
481 energySecond=(*theEclust)->energy();
484 if (i==1)
return energyMax;
492 using namespace reco;
496 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
501 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
505 double SClusterEta = cluster->eta();
506 double SClusterPhi = cluster->phi();
507 double TotalEnergy = 0;
512 double Area =
PI * (-x*x+y*
y) / 100.0;
513 double nCrystal = Area / 0.0174 / 0.0174;
515 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
516 iclu != fEBclusters_->end(); ++iclu) {
518 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
519 double eta = clusPoint.eta();
520 double phi = clusPoint.phi();
521 double dEta = fabs(eta-SClusterEta);
522 double dPhi = fabs(phi-SClusterPhi);
523 while (dPhi>2*
PI) dPhi-=2*
PI;
525 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
527 if (dR>x*0.1&&dR<y*0.1) {
528 double e = clu->energy();
529 if (e<threshold) e=0;
531 if (e!=0) TotalBC+=clu->size();
536 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
537 iclu != fEEclusters_->end(); ++iclu) {
539 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
540 double eta = clusPoint.eta();
541 double phi = clusPoint.phi();
542 double dEta = fabs(eta-SClusterEta);
543 double dPhi = fabs(phi-SClusterPhi);
544 while (dPhi>2*
PI) dPhi-=2*
PI;
546 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
548 if (dR>x*0.1&&dR<y*0.1) {
549 double e = clu->energy();
550 if (e<threshold) e=0;
552 if (e!=0) TotalBC += clu->size();
557 if (TotalBC==0)
return 0;
558 return TotalEnergy/nCrystal;
565 using namespace reco;
569 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
574 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
578 double SClusterEta = cluster->eta();
579 double SClusterPhi = cluster->phi();
584 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
586 if (fabs(SClusterEta) < 1.479) {
588 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
589 iclu != fEBclusters_->end(); ++iclu) {
592 double eta = ClusPoint.eta();
593 double phi = ClusPoint.phi();
595 double dEta = fabs(eta-SClusterEta);
596 double dPhi = fabs(phi-SClusterPhi);
597 while (dPhi>2*
PI) dPhi-=2*
PI;
599 bool inSuperCluster = checkUsed(cluster,clu);
601 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
602 double et = clu->energy()/cosh(eta);
603 if (et<threshold) et=0;
610 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
611 iclu != fEEclusters_->end(); ++iclu) {
614 double eta = ClusPoint.eta();
615 double phi = ClusPoint.phi();
617 double dEta = fabs(eta-SClusterEta);
618 double dPhi = fabs(phi-SClusterPhi);
619 while (dPhi>2*
PI) dPhi-=2*
PI;
621 bool inSuperCluster = checkUsed(cluster,clu);
623 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
624 double et = clu->energy()/cosh(eta);
625 if (et<threshold) et=0;
631 return TotalEt / TotalN;
638 using namespace reco;
642 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
647 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
651 double SClusterEta = cluster->eta();
652 double SClusterPhi = cluster->phi();
657 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
661 if (fabs(SClusterEta) < 1.479) {
663 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
664 iclu != fEBclusters_->end(); ++iclu) {
667 double eta = ClusPoint.eta();
668 double phi = ClusPoint.phi();
670 double dEta = fabs(eta-SClusterEta);
671 double dPhi = fabs(phi-SClusterPhi);
672 while (dPhi>2*
PI) dPhi-=2*
PI;
674 bool inSuperCluster = checkUsed(cluster,clu);
676 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
677 double et = clu->energy()/cosh(eta);
678 if (et<threshold) et=0;
685 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
686 iclu != fEEclusters_->end(); ++iclu) {
689 double eta = ClusPoint.eta();
690 double phi = ClusPoint.phi();
692 double dEta = fabs(eta-SClusterEta);
693 double dPhi = fabs(phi-SClusterPhi);
694 while (dPhi>2*
PI) dPhi-=2*
PI;
696 bool inSuperCluster = checkUsed(cluster,clu);
698 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
699 double et = clu->energy()/cosh(eta);
700 if (et<threshold) et=0;
CxCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, const edm::InputTag &barrelLabel, const edm::InputTag &endcapLabel)
double getJc(const reco::SuperClusterRef cluster, double r1=0.4, double r2=0.06, double jWidth=0.04, double threshold=0)
double getAvgBCEt(const reco::SuperClusterRef clus, double eta, double phi1, double phi2, double threshold)
double getJcc(const reco::SuperClusterRef cluster, double r1=0.4, double r2=0.06, double jWidth=0.04, double threshold=0)
double getNBC(const reco::SuperClusterRef clus, double eta, double phi1, double phi2, double threshold)
double getCCxRemoveSC(const reco::SuperClusterRef clus, double i, double threshold)
double dPhi(double phi1, double phi2)
bool checkUsed(const reco::SuperClusterRef clus, const reco::BasicCluster *clu)
Cos< T >::type cos(const T &t)
double getCCx(const reco::SuperClusterRef clus, double i, double threshold)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
double getCxRemoveSC(const reco::SuperClusterRef clus, double i, double threshold)
T const * product() const
double getCx(const reco::SuperClusterRef clus, double i, double threshold)
T const * product() const
double getJurassicArea(double r1, double r2, double width)
double getCorrection(const reco::SuperClusterRef clus, double i, double j, double threshold)
double getBCMax(const reco::SuperClusterRef clus, int i)