2 #include <Math/VectorUtil.h>
19 using namespace ROOT::Math::VectorUtil;
21 #define PI 3.141592653589793238462643383279502884197169399375105820974945
29 fEBclusters_ = pEBclusters.
product();
33 fEEclusters_ = pEEclusters.
product();
38 geometry_ = geometryHandle.
product();
47 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
52 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
57 cluster->position().y(),
58 cluster->position().z());
62 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
65 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
66 iclu != fEBclusters_->end(); ++iclu) {
69 double eta = ClusPoint.eta();
71 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
74 double et = clu->energy()/cosh(eta);
75 if (et<threshold) et=0;
80 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
81 iclu != fEEclusters_->end(); ++iclu) {
83 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
85 double eta = ClusPoint.eta();
87 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
90 double et = clu->energy()/cosh(eta);
91 if (et<threshold) et=0;
104 using namespace reco;
107 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
112 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
117 cluster->position().y(),
118 cluster->position().z());
125 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
126 iclu != fEBclusters_->end(); ++iclu) {
129 double eta = ClusPoint.eta();
131 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
134 bool inSuperCluster = checkUsed(cluster,clu);
136 if (dR<x*0.1&&inSuperCluster==
false) {
137 double et = clu->energy()/cosh(eta);
138 if (et<threshold) et=0;
144 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
145 iclu != fEEclusters_->end(); ++iclu) {
147 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
149 double eta = ClusPoint.eta();
151 double dR = ROOT::Math::VectorUtil::DeltaR(ClusPoint,SClusPoint);
154 bool inSuperCluster = checkUsed(cluster,clu);
156 if (dR<x*0.1&&inSuperCluster==
false) {
157 double et = clu->energy()/cosh(eta);
158 if (et<threshold) et=0;
169 using namespace reco;
173 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
178 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
182 double SClusterEta = cluster->eta();
183 double SClusterPhi = cluster->phi();
186 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
188 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
189 iclu != fEBclusters_->end(); ++iclu) {
192 double eta = ClusPoint.eta();
194 double dEta = fabs(eta-SClusterEta);
197 double et = clu->energy()/cosh(eta);
198 if (et<threshold) et=0;
203 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
204 iclu != fEEclusters_->end(); ++iclu) {
207 double eta = ClusPoint.eta();
208 double phi = ClusPoint.phi();
210 double dEta = fabs(eta-SClusterEta);
211 double dPhi = fabs(phi-SClusterPhi);
212 while (dPhi>2*
PI) dPhi-=2*
PI;
216 double et = clu->energy()/cosh(eta);
217 if (et<threshold) et=0;
222 double Cx = getCx(cluster,x,threshold);
223 double CCx = Cx - TotalEt / 40.0 *
x;
232 using namespace reco;
236 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
241 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
245 double SClusterEta = cluster->eta();
246 double SClusterPhi = cluster->phi();
251 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
252 iclu != fEBclusters_->end(); ++iclu) {
255 double eta = ClusPoint.eta();
257 double dEta = fabs(eta-SClusterEta);
260 bool inSuperCluster = checkUsed(cluster,clu);
262 if (dEta<x*0.1&&inSuperCluster==
false) {
263 double et = clu->energy()/cosh(eta);
264 if (et<threshold) et=0;
269 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
270 iclu != fEEclusters_->end(); ++iclu) {
273 double eta = ClusPoint.eta();
274 double phi = ClusPoint.phi();
276 double dEta = fabs(eta-SClusterEta);
277 double dPhi = fabs(phi-SClusterPhi);
278 while (dPhi>2*
PI) dPhi-=2*
PI;
282 bool inSuperCluster = checkUsed(cluster,clu);
284 if (dEta<x*0.1&&inSuperCluster==
false) {
285 double et = clu->energy()/cosh(eta);
286 if (et<threshold) et=0;
291 double Cx = getCxRemoveSC(cluster,x,threshold);
292 double CCx = Cx - TotalEt / 40.0 *
x;
303 for(;theEclust != sc->clustersEnd(); theEclust++) {
304 if ((**theEclust) == (*bc) )
return true;
313 double energyMax=0,energySecond=0;
315 for(;theEclust != cluster->clustersEnd(); theEclust++) {
316 if ((*theEclust)->energy()>energyMax ) {
317 energySecond=energyMax;
318 energyMax=(*theEclust)->energy();
319 }
else if ((*theEclust)->energy()>energySecond) {
320 energySecond=(*theEclust)->energy();
323 if (i==1)
return energyMax;
331 using namespace reco;
335 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
340 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
344 double SClusterEta = cluster->eta();
345 double SClusterPhi = cluster->phi();
346 double TotalEnergy = 0;
351 double Area =
PI * (-x*x+y*
y) / 100.0;
352 double nCrystal = Area / 0.0174 / 0.0174;
354 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
355 iclu != fEBclusters_->end(); ++iclu) {
357 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
358 double eta = clusPoint.eta();
359 double phi = clusPoint.phi();
360 double dEta = fabs(eta-SClusterEta);
361 double dPhi = fabs(phi-SClusterPhi);
362 while (dPhi>2*
PI) dPhi-=2*
PI;
364 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
366 if (dR>x*0.1&&dR<y*0.1) {
367 double e = clu->energy();
368 if (e<threshold) e=0;
370 if (e!=0) TotalBC+=clu->size();
375 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
376 iclu != fEEclusters_->end(); ++iclu) {
378 const GlobalPoint clusPoint(clu->x(),clu->y(),clu->z());
379 double eta = clusPoint.eta();
380 double phi = clusPoint.phi();
381 double dEta = fabs(eta-SClusterEta);
382 double dPhi = fabs(phi-SClusterPhi);
383 while (dPhi>2*
PI) dPhi-=2*
PI;
385 double dR =
sqrt(dEta*dEta+dPhi*dPhi);
387 if (dR>x*0.1&&dR<y*0.1) {
388 double e = clu->energy();
389 if (e<threshold) e=0;
391 if (e!=0) TotalBC += clu->size();
396 if (TotalBC==0)
return 0;
397 return TotalEnergy/nCrystal;
404 using namespace reco;
408 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
413 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
417 double SClusterEta = cluster->eta();
418 double SClusterPhi = cluster->phi();
423 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
425 if (fabs(SClusterEta) < 1.479) {
427 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
428 iclu != fEBclusters_->end(); ++iclu) {
431 double eta = ClusPoint.eta();
432 double phi = ClusPoint.phi();
434 double dEta = fabs(eta-SClusterEta);
435 double dPhi = fabs(phi-SClusterPhi);
436 while (dPhi>2*
PI) dPhi-=2*
PI;
438 bool inSuperCluster = checkUsed(cluster,clu);
440 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
441 double et = clu->energy()/cosh(eta);
442 if (et<threshold) et=0;
449 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
450 iclu != fEEclusters_->end(); ++iclu) {
453 double eta = ClusPoint.eta();
454 double phi = ClusPoint.phi();
456 double dEta = fabs(eta-SClusterEta);
457 double dPhi = fabs(phi-SClusterPhi);
458 while (dPhi>2*
PI) dPhi-=2*
PI;
460 bool inSuperCluster = checkUsed(cluster,clu);
462 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
463 double et = clu->energy()/cosh(eta);
464 if (et<threshold) et=0;
470 return TotalEt / TotalN;
477 using namespace reco;
481 LogError(
"CxCalculator") <<
"Error! Can't get EBclusters for event.";
486 LogError(
"CxCalculator") <<
"Error! Can't get EEclusters for event.";
490 double SClusterEta = cluster->eta();
491 double SClusterPhi = cluster->phi();
496 TotalEt = - cluster->rawEnergy()/cosh(cluster->eta());
500 if (fabs(SClusterEta) < 1.479) {
502 for(BasicClusterCollection::const_iterator iclu = fEBclusters_->begin();
503 iclu != fEBclusters_->end(); ++iclu) {
506 double eta = ClusPoint.eta();
507 double phi = ClusPoint.phi();
509 double dEta = fabs(eta-SClusterEta);
510 double dPhi = fabs(phi-SClusterPhi);
511 while (dPhi>2*
PI) dPhi-=2*
PI;
513 bool inSuperCluster = checkUsed(cluster,clu);
515 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
516 double et = clu->energy()/cosh(eta);
517 if (et<threshold) et=0;
524 for(BasicClusterCollection::const_iterator iclu = fEEclusters_->begin();
525 iclu != fEEclusters_->end(); ++iclu) {
528 double eta = ClusPoint.eta();
529 double phi = ClusPoint.phi();
531 double dEta = fabs(eta-SClusterEta);
532 double dPhi = fabs(phi-SClusterPhi);
533 while (dPhi>2*
PI) dPhi-=2*
PI;
535 bool inSuperCluster = checkUsed(cluster,clu);
537 if (dEta<x*0.1&&inSuperCluster==false&&dPhi>phi1*0.1&&dPhi<phi2*0.1) {
538 double et = clu->energy()/cosh(eta);
539 if (et<threshold) et=0;
double getAvgBCEt(const reco::SuperClusterRef clus, double eta, double phi1, double phi2, double threshold)
CxCalculator(const edm::Event &iEvent, const edm::EventSetup &iSetup, edm::InputTag barrelLabel, edm::InputTag endcapLabel)
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)
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 getCorrection(const reco::SuperClusterRef clus, double i, double j, double threshold)
double getBCMax(const reco::SuperClusterRef clus, int i)