30 #include <Math/Point3D.h>
80 bool originalCtfTrackCollectionRetreived =
false;
81 bool originalGsfTrackCollectionRetreived =
false;
104 void calculateMode();
124 if ((!originalCtfTrackCollectionRetreived) && (ctfTrack.
isNonnull())) {
125 event->get(ctfTrack.
id(), originalCtfTracks);
126 originalCtfTrackCollectionRetreived =
true;
128 if ((!originalGsfTrackCollectionRetreived) && (gsfTrack.
isNonnull())) {
129 event->get(gsfTrack.
id(), originalGsfTracks);
130 originalGsfTrackCollectionRetreived =
true;
136 gsfTrackRef(coreRef->gsfTrack()),
137 superClusterRef(coreRef->superCluster()),
138 ctfTrackRef(coreRef->ctfTrack()),
139 shFracInnerHits(coreRef->ctfGsfOverlap()),
152 info.scPixCharge = -1;
154 info.scPixCharge = 1;
157 int chargeGsf = gsfTrackRef->charge();
158 info.isGsfScPixConsistent = ((chargeGsf *
info.scPixCharge) > 0);
159 info.isGsfCtfConsistent = (ctfTrackRef.isNonnull() && ((chargeGsf * ctfTrackRef->charge()) > 0));
160 info.isGsfCtfScPixConsistent = (
info.isGsfScPixConsistent &&
info.isGsfCtfConsistent);
163 if (
info.isGsfScPixConsistent || ctfTrackRef.isNull()) {
166 charge = ctfTrackRef->charge();
174 float dphimin = 1.e30;
175 for (
auto const& bc : superClusterRef->clusters()) {
176 GlobalPoint posclu(bc->position().x(), bc->position().y(), bc->position().z());
178 if (!tempTSOS.isValid())
195 if (!innTSOS.isValid())
203 if (!vtxTSOS.isValid())
208 if (!outTSOS.isValid())
213 GlobalPoint(superClusterRef->seed()->position().x(),
214 superClusterRef->seed()->position().y(),
215 superClusterRef->seed()->position().z()));
216 if (!seedTSOS.isValid())
221 innTSOS,
GlobalPoint(superClusterRef->x(), superClusterRef->y(), superClusterRef->z()));
222 if (!sclTSOS.isValid())
248 double scale = superClusterRef->energy() / vtxMom.mag();
250 vtxMom.x() *
scale, vtxMom.y() *
scale, vtxMom.z() *
scale, superClusterRef->energy());
266 int nSaturatedXtals = 0;
267 bool isSeedSaturated =
false;
268 for (
auto&& hitFractionPair : theClus->hitsAndFractions()) {
272 if (
ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
275 isSeedSaturated =
true;
284 template <
bool full5x5>
299 std::vector<int> recHitFlagsToBeExcluded;
300 std::vector<int> recHitSeverityToBeExcluded;
312 std::vector<float> localCovariances = ClusterTools::localCovariances(seedCluster,
recHits, &
topology);
320 showerShape.
r9 = ClusterTools::e3x3(seedCluster,
recHits, &
topology) / theClus->rawEnergy();
322 const float scale = full5x5 ? showerShape.
e5x5 : theClus->energy();
336 if (see_by_spp > 0) {
337 showerShape.
sigmaIetaIphi = localCovariances[1] / see_by_spp;
338 }
else if (localCovariances[1] > 0) {
344 showerShape.
e2nd = ClusterTools::e2nd(seedCluster,
recHits);
368 std::unique_ptr<EcalClusterFunctionBaseClass>&& superClusterErrorFunction,
369 std::unique_ptr<EcalClusterFunctionBaseClass>&& crackCorrectionFunction,
377 tkIsol03Calc_(tkIsol03),
378 tkIsol04Calc_(tkIsol04),
379 tkIsolHEEP03Calc_(tkIsolHEEP03),
380 tkIsolHEEP04Calc_(tkIsolHEEP04),
387 superClusterErrorFunction_{
388 std::forward<std::unique_ptr<EcalClusterFunctionBaseClass>>(superClusterErrorFunction)},
389 crackCorrectionFunction_{std::forward<std::unique_ptr<EcalClusterFunctionBaseClass>>(crackCorrectionFunction)},
416 float egHcalIsoConeSizeOutSmall = 0.3, egHcalIsoConeSizeOutLarge = 0.4;
418 int egHcalDepth1 = 1, egHcalDepth2 = 2;
420 float egIsoConeSizeOutSmall = 0.3, egIsoConeSizeOutLarge = 0.4, egIsoJurassicWidth =
cfg_.
iso.
jurassicWidth;
440 .hadDepth1Isolation03 =
442 .hadDepth1Isolation04 =
444 .hadDepth2Isolation03 =
446 .hadDepth2Isolation04 =
448 .hadDepth1Isolation03Bc =
450 .hadDepth1Isolation04Bc =
452 .hadDepth2Isolation03Bc =
454 .hadDepth2Isolation04Bc =
457 egIsoConeSizeInBarrel,
463 &ecalSeveretyLevelAlgo,
466 egIsoConeSizeInBarrel,
472 &ecalSeveretyLevelAlgo,
475 egIsoConeSizeInEndcap,
481 &ecalSeveretyLevelAlgo,
484 egIsoConeSizeInEndcap,
490 &ecalSeveretyLevelAlgo,
492 .originalCtfTracks = {},
493 .originalGsfTracks = {}};
497 eventData.ecalBarrelIsol03.doSeverityChecks(eventData.barrelRecHits.product(),
502 eventData.ecalBarrelIsol04.doSeverityChecks(eventData.barrelRecHits.product(),
507 eventData.ecalEndcapIsol03.doSeverityChecks(eventData.endcapRecHits.product(),
512 eventData.ecalEndcapIsol04.doSeverityChecks(eventData.endcapRecHits.product(),
531 auto eventData =
beginEvent(
event, caloGeometry, ecalSeveretyLevelAlgo);
538 for (
unsigned int i = 0;
i < coreCollection->size(); ++
i) {
541 bool coreFound =
false;
543 if (ele.core() == coreRef) {
552 if (coreRef->superCluster().
isNull())
556 ElectronData electronData(coreRef, *eventData.beamspot);
559 if (!electronData.
calculateTSOS(mtsTransform, constraintAtVtx))
563 electrons, electronData, eventData, caloTopology, caloGeometry, mtsTransform, magneticFieldInTesla, hoc);
574 bool eg = ele.
core()->ecalDrivenSeed();
575 bool pf = ele.
core()->trackerDrivenSeed() && !ele.
core()->ecalDrivenSeed();
577 throw cms::Exception(
"GsfElectronAlgo|BothEcalAndPureTrackerDriven")
578 <<
"An electron cannot be both egamma and purely pflow";
580 if ((!eg) && (!
pf)) {
581 throw cms::Exception(
"GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")
582 <<
"An electron cannot be neither egamma nor purely pflow";
589 double etValue = ele.
superCluster()->energy() / cosh(etaValue);
590 LogTrace(
"GsfElectronAlgo") <<
"Et : " << etValue;
591 if (ele.
isEB() && (etValue <
cfg.minSCEtBarrel))
593 if (ele.
isEE() && (etValue <
cfg.minSCEtEndcaps))
595 LogTrace(
"GsfElectronAlgo") <<
"Et criteria are satisfied";
599 LogTrace(
"GsfElectronAlgo") <<
"E/p : " << eopValue;
600 if (ele.
isEB() && (eopValue >
cfg.maxEOverPBarrel))
602 if (ele.
isEE() && (eopValue >
cfg.maxEOverPEndcaps))
604 if (ele.
isEB() && (eopValue <
cfg.minEOverPBarrel))
606 if (ele.
isEE() && (eopValue <
cfg.minEOverPEndcaps))
608 LogTrace(
"GsfElectronAlgo") <<
"E/p criteria are satisfied";
616 bool HoEveto =
false;
620 HoEveto = hoeCone * scle <
cfg.maxHBarrelCone || hoeTower * scle <
cfg.maxHBarrelTower ||
621 hoeCone <
cfg.maxHOverEBarrelCone || hoeTower <
cfg.maxHOverEBarrelTower;
623 HoEveto = hoeCone * scle <
cfg.maxHEndcapsCone || hoeTower * scle <
cfg.maxHEndcapsTower ||
624 hoeCone <
cfg.maxHOverEEndcapsCone || hoeTower <
cfg.maxHOverEEndcapsTower;
628 LogTrace(
"GsfElectronAlgo") <<
"H/E criteria are satisfied";
632 LogTrace(
"GsfElectronAlgo") <<
"delta eta : " << deta;
637 LogTrace(
"GsfElectronAlgo") <<
"Delta eta criteria are satisfied";
641 LogTrace(
"GsfElectronAlgo") <<
"delta phi : " << dphi;
646 LogTrace(
"GsfElectronAlgo") <<
"Delta phi criteria are satisfied";
654 LogTrace(
"GsfElectronAlgo") <<
"Sigma ieta ieta criteria are satisfied";
657 if (!ele.
isEB() &&
cfg.isBarrel)
659 if (!ele.
isEE() &&
cfg.isEndcaps)
661 if (
cfg.isFiducial &&
664 LogTrace(
"GsfElectronAlgo") <<
"Fiducial flags criteria are satisfied";
671 throw cms::Exception(
"GsfElectronAlgo|NotElectronSeed") <<
"The GsfTrack seed is not an ElectronSeed ?!";
673 if (elseed->subDet(1) == 6)
681 LogTrace(
"GsfElectronAlgo") <<
"TIP criterion is satisfied";
683 LogTrace(
"GsfElectronAlgo") <<
"All cut based criteria are satisfied";
693 double magneticFieldInTesla,
781 fiducialFlags.
isEB =
true;
794 fiducialFlags.
isEE =
true;
807 fiducialFlags.
isEE =
true;
812 <<
"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!";
829 full5x5_showerShape =
854 conversionVars.
flags = conversionInfo.
flag;
855 conversionVars.
dist = conversionInfo.
dist;
856 conversionVars.
dcot = conversionInfo.
dcot;
868 if ((conversionVars.
flags == 0)
or (conversionVars.
flags == 1))
870 else if ((conversionVars.
flags == 2)
or (conversionVars.
flags == 3))
891 ele.setP4(GsfElectron::P4_FROM_SUPER_CLUSTER, momentum, 0,
true);
906 if (sc->clustersSize() > 1) {
907 float pf_fbrem = (sc->energy() -
cl->energy()) / sc->energy();
908 ele.setSuperClusterFbrem(pf_fbrem);
910 ele.setSuperClusterFbrem(0);
919 ele.setClassification(elClass);
922 if (unexpectedClassification) {
933 if (ele.core()->ecalDrivenSeed()) {
935 if (ele.isEcalEnergyCorrected()) {
936 edm::LogWarning(
"ElectronEnergyCorrector::classBasedElectronEnergy") <<
"already done";
938 ele.setCorrectedEcalEnergy(
957 edm::LogWarning(
"ElectronMomentumCorrector::correct") <<
"already done";
960 ele.correctMomentum(
p.momentum,
p.trackError,
p.finalError);
996 ele.setIsolation03(dr03);
997 ele.setIsolation04(dr04);
1016 LogTrace(
"GsfElectronAlgo") <<
"Constructed new electron with energy " << ele.p4().e();
1029 if (
seed.isNull()) {
1033 sd1 = elseed->subDet(0);
1034 sd2 = elseed->subDet(1);
1035 dPhi1 = (ele.
charge() > 0) ? elseed->dPhiPos(0) : elseed->dPhiNeg(0);
1036 dPhi2 = (ele.
charge() > 0) ? elseed->dPhiPos(1) : elseed->dPhiNeg(1);
1037 dRz1 = (ele.
charge() > 0) ? elseed->dRZPos(0) : elseed->dRZNeg(0);
1038 dRz2 = (ele.
charge() > 0) ? elseed->dRZPos(1) : elseed->dRZNeg(1);