28 #include <Math/Point3D.h>
41 sElectronMVAEstimator = std::make_unique<SoftElectronMVAEstimator>(sconfig);
45 iElectronMVAEstimator = std::make_unique<ElectronMVAEstimator>(iconfig);
85 bool originalCtfTrackCollectionRetreived =
false;
86 bool originalGsfTrackCollectionRetreived =
false;
109 void calculateMode();
129 if ((!originalCtfTrackCollectionRetreived) && (ctfTrack.
isNonnull())) {
130 event->get(ctfTrack.
id(), originalCtfTracks);
131 originalCtfTrackCollectionRetreived =
true;
133 if ((!originalGsfTrackCollectionRetreived) && (gsfTrack.
isNonnull())) {
134 event->get(gsfTrack.
id(), originalGsfTracks);
135 originalGsfTrackCollectionRetreived =
true;
141 gsfTrackRef(coreRef->gsfTrack()),
142 superClusterRef(coreRef->superCluster()),
143 ctfTrackRef(coreRef->ctfTrack()),
144 shFracInnerHits(coreRef->ctfGsfOverlap()),
157 info.scPixCharge = -1;
159 info.scPixCharge = 1;
162 int chargeGsf = gsfTrackRef->charge();
163 info.isGsfScPixConsistent = ((chargeGsf *
info.scPixCharge) > 0);
164 info.isGsfCtfConsistent = (ctfTrackRef.isNonnull() && ((chargeGsf * ctfTrackRef->charge()) > 0));
165 info.isGsfCtfScPixConsistent = (
info.isGsfScPixConsistent &&
info.isGsfCtfConsistent);
168 if (
info.isGsfScPixConsistent || ctfTrackRef.isNull()) {
171 charge = ctfTrackRef->charge();
179 float dphimin = 1.e30;
180 for (
auto const& bc : superClusterRef->clusters()) {
181 GlobalPoint posclu(bc->position().x(), bc->position().y(), bc->position().z());
183 if (!tempTSOS.isValid())
200 if (!innTSOS.isValid())
208 if (!vtxTSOS.isValid())
213 if (!outTSOS.isValid())
218 GlobalPoint(superClusterRef->seed()->position().x(),
219 superClusterRef->seed()->position().y(),
220 superClusterRef->seed()->position().z()));
221 if (!seedTSOS.isValid())
226 innTSOS,
GlobalPoint(superClusterRef->x(), superClusterRef->y(), superClusterRef->z()));
227 if (!sclTSOS.isValid())
253 double scale = superClusterRef->energy() / vtxMom.mag();
255 vtxMom.x() *
scale, vtxMom.y() *
scale, vtxMom.z() *
scale, superClusterRef->energy());
271 int nSaturatedXtals = 0;
272 bool isSeedSaturated =
false;
273 for (
auto&& hitFractionPair : theClus->hitsAndFractions()) {
277 if (
ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
280 isSeedSaturated =
true;
289 template <
bool full5x5>
304 std::vector<int> recHitFlagsToBeExcluded;
305 std::vector<int> recHitSeverityToBeExcluded;
317 std::vector<float> localCovariances = ClusterTools::localCovariances(seedCluster,
recHits, &
topology);
325 showerShape.
r9 = ClusterTools::e3x3(seedCluster,
recHits, &
topology) / theClus->rawEnergy();
327 const float scale = full5x5 ? showerShape.
e5x5 : theClus->energy();
341 if (see_by_spp > 0) {
342 showerShape.
sigmaIetaIphi = localCovariances[1] / see_by_spp;
343 }
else if (localCovariances[1] > 0) {
349 showerShape.
e2nd = ClusterTools::e2nd(seedCluster,
recHits);
373 std::unique_ptr<EcalClusterFunctionBaseClass>&& superClusterErrorFunction,
374 std::unique_ptr<EcalClusterFunctionBaseClass>&& crackCorrectionFunction,
382 tkIsol03CalcCfg_(tkIsol03),
383 tkIsol04CalcCfg_(tkIsol04),
384 tkIsolHEEP03CalcCfg_(tkIsolHEEP03),
385 tkIsolHEEP04CalcCfg_(tkIsolHEEP04),
386 magneticFieldToken_{
cc.esConsumes()},
387 caloGeometryToken_{
cc.esConsumes()},
388 caloTopologyToken_{
cc.esConsumes()},
389 trackerGeometryToken_{
cc.esConsumes()},
390 ecalSeveretyLevelAlgoToken_{
cc.esConsumes()},
392 superClusterErrorFunction_{
393 std::forward<std::unique_ptr<EcalClusterFunctionBaseClass>>(superClusterErrorFunction)},
394 crackCorrectionFunction_{std::forward<std::unique_ptr<EcalClusterFunctionBaseClass>>(crackCorrectionFunction)},
395 regHelper_{reg, cfg_.strategy.useEcalRegression, cfg_.strategy.useCombinationRegression,
cc}
417 float egHcalIsoConeSizeOutSmall = 0.3, egHcalIsoConeSizeOutLarge = 0.4;
419 int egHcalDepth1 = 1, egHcalDepth2 = 2;
421 float egIsoConeSizeOutSmall = 0.3, egIsoConeSizeOutLarge = 0.4, egIsoJurassicWidth =
cfg_.
iso.
jurassicWidth;
443 .hadDepth1Isolation03 =
445 .hadDepth1Isolation04 =
447 .hadDepth2Isolation03 =
449 .hadDepth2Isolation04 =
451 .hadDepth1Isolation03Bc =
453 .hadDepth1Isolation04Bc =
455 .hadDepth2Isolation03Bc =
457 .hadDepth2Isolation04Bc =
460 egIsoConeSizeInBarrel,
466 &ecalSeveretyLevelAlgo,
469 egIsoConeSizeInBarrel,
475 &ecalSeveretyLevelAlgo,
478 egIsoConeSizeInEndcap,
484 &ecalSeveretyLevelAlgo,
487 egIsoConeSizeInEndcap,
493 &ecalSeveretyLevelAlgo,
499 .originalCtfTracks = {},
500 .originalGsfTracks = {}};
504 eventData.ecalBarrelIsol03.doSeverityChecks(eventData.barrelRecHits.product(),
509 eventData.ecalBarrelIsol04.doSeverityChecks(eventData.barrelRecHits.product(),
514 eventData.ecalEndcapIsol03.doSeverityChecks(eventData.endcapRecHits.product(),
519 eventData.ecalEndcapIsol04.doSeverityChecks(eventData.endcapRecHits.product(),
541 auto eventData =
beginEvent(
event, caloGeometry, ecalSeveretyLevelAlgo);
547 std::optional<egamma::conv::TrackTable> ctfTrackTable = std::nullopt;
548 std::optional<egamma::conv::TrackTable> gsfTrackTable = std::nullopt;
551 for (
unsigned int i = 0;
i < coreCollection->size(); ++
i) {
556 if (coreRef->superCluster().
isNull())
560 ElectronData electronData(coreRef, *eventData.beamspot);
563 if (!electronData.
calculateTSOS(mtsTransform, constraintAtVtx))
566 eventData.retreiveOriginalTrackCollections(electronData.
ctfTrackRef, electronData.
coreRef->gsfTrack());
568 if (!eventData.originalCtfTracks.isValid()) {
569 eventData.originalCtfTracks = eventData.currentCtfTracks;
572 if (ctfTrackTable == std::nullopt) {
575 if (gsfTrackTable == std::nullopt) {
585 magneticFieldInTesla,
587 ctfTrackTable.value(),
588 gsfTrackTable.value());
599 bool eg = ele.
core()->ecalDrivenSeed();
600 bool pf = ele.
core()->trackerDrivenSeed() && !ele.
core()->ecalDrivenSeed();
602 throw cms::Exception(
"GsfElectronAlgo|BothEcalAndPureTrackerDriven")
603 <<
"An electron cannot be both egamma and purely pflow";
605 if ((!eg) && (!
pf)) {
606 throw cms::Exception(
"GsfElectronAlgo|NeitherEcalNorPureTrackerDriven")
607 <<
"An electron cannot be neither egamma nor purely pflow";
614 double etValue = ele.
superCluster()->energy() / cosh(etaValue);
615 LogTrace(
"GsfElectronAlgo") <<
"Et : " << etValue;
616 if (ele.
isEB() && (etValue <
cfg.minSCEtBarrel))
618 if (ele.
isEE() && (etValue <
cfg.minSCEtEndcaps))
620 LogTrace(
"GsfElectronAlgo") <<
"Et criteria are satisfied";
624 LogTrace(
"GsfElectronAlgo") <<
"E/p : " << eopValue;
625 if (ele.
isEB() && (eopValue >
cfg.maxEOverPBarrel))
627 if (ele.
isEE() && (eopValue >
cfg.maxEOverPEndcaps))
629 if (ele.
isEB() && (eopValue <
cfg.minEOverPBarrel))
631 if (ele.
isEE() && (eopValue <
cfg.minEOverPEndcaps))
633 LogTrace(
"GsfElectronAlgo") <<
"E/p criteria are satisfied";
641 bool HoEveto =
false;
645 HoEveto = hoeCone * scle <
cfg.maxHBarrelCone || hoeTower * scle <
cfg.maxHBarrelTower ||
646 hoeCone <
cfg.maxHOverEBarrelCone || hoeTower <
cfg.maxHOverEBarrelTower;
648 HoEveto = hoeCone * scle <
cfg.maxHEndcapsCone || hoeTower * scle <
cfg.maxHEndcapsTower ||
649 hoeCone <
cfg.maxHOverEEndcapsCone || hoeTower <
cfg.maxHOverEEndcapsTower;
653 LogTrace(
"GsfElectronAlgo") <<
"H/E criteria are satisfied";
657 LogTrace(
"GsfElectronAlgo") <<
"delta eta : " << deta;
662 LogTrace(
"GsfElectronAlgo") <<
"Delta eta criteria are satisfied";
666 LogTrace(
"GsfElectronAlgo") <<
"delta phi : " << dphi;
671 LogTrace(
"GsfElectronAlgo") <<
"Delta phi criteria are satisfied";
679 LogTrace(
"GsfElectronAlgo") <<
"Sigma ieta ieta criteria are satisfied";
682 if (!ele.
isEB() &&
cfg.isBarrel)
684 if (!ele.
isEE() &&
cfg.isEndcaps)
686 if (
cfg.isFiducial &&
689 LogTrace(
"GsfElectronAlgo") <<
"Fiducial flags criteria are satisfied";
696 throw cms::Exception(
"GsfElectronAlgo|NotElectronSeed") <<
"The GsfTrack seed is not an ElectronSeed ?!";
698 if (elseed->subDet(1) == 6)
706 LogTrace(
"GsfElectronAlgo") <<
"TIP criterion is satisfied";
708 LogTrace(
"GsfElectronAlgo") <<
"All cut based criteria are satisfied";
718 double magneticFieldInTesla,
803 fiducialFlags.
isEB =
true;
816 fiducialFlags.
isEE =
true;
829 fiducialFlags.
isEE =
true;
834 <<
"createElectron(): do not know if it is a barrel or endcap seed cluster !!!!";
851 full5x5_showerShape =
873 <<
"ProductID of ctf track collection does not match ProductID of electron's CTF track! \n";
876 <<
"ProductID of gsf track collection does not match ProductID of electron's GSF track! \n";
888 conversionVars.
flags = conversionInfo.flag;
889 conversionVars.
dist = conversionInfo.dist;
890 conversionVars.
dcot = conversionInfo.dcot;
891 conversionVars.
radius = conversionInfo.radiusOfConversion;
902 if (conversionInfo.conversionPartnerCtfTkIdx) {
904 }
else if (conversionInfo.conversionPartnerGsfTkIdx) {
927 ele.setP4(GsfElectron::P4_FROM_SUPER_CLUSTER, momentum, 0,
true);
942 if (sc->clustersSize() > 1) {
943 float pf_fbrem = (sc->energy() -
cl->energy()) / sc->energy();
944 ele.setSuperClusterFbrem(pf_fbrem);
946 ele.setSuperClusterFbrem(0);
955 ele.setClassification(elClass);
958 if (unexpectedClassification) {
969 if (ele.core()->ecalDrivenSeed()) {
971 if (ele.isEcalEnergyCorrected()) {
972 edm::LogWarning(
"ElectronEnergyCorrector::classBasedElectronEnergy") <<
"already done";
974 ele.setCorrectedEcalEnergy(
993 edm::LogWarning(
"ElectronMomentumCorrector::correct") <<
"already done";
996 ele.correctMomentum(
p.momentum,
p.trackError,
p.finalError);
1031 ele.setIsolation03(dr03);
1032 ele.setIsolation04(dr04);
1051 LogTrace(
"GsfElectronAlgo") <<
"Constructed new electron with energy " << ele.p4().e();
1064 if (
seed.isNull()) {
1068 sd1 = elseed->subDet(0);
1069 sd2 = elseed->subDet(1);
1070 dPhi1 = (ele.
charge() > 0) ? elseed->dPhiPos(0) : elseed->dPhiNeg(0);
1071 dPhi2 = (ele.
charge() > 0) ? elseed->dPhiPos(1) : elseed->dPhiNeg(1);
1072 dRz1 = (ele.
charge() > 0) ? elseed->dRZPos(0) : elseed->dRZNeg(0);
1073 dRz2 = (ele.
charge() > 0) ? elseed->dRZPos(1) : elseed->dRZNeg(1);