53 else if (
step ==
"oot")
55 else if (
step ==
"ootfinal")
57 else if (
step ==
"tmp")
61 <<
" reconstructStep " <<
step <<
" is invalid, the options are: tmp, final,oot or ootfinal" << std::endl;
101 if (not pfEg.label().empty())
109 if (not hcTow.label().empty())
110 hcalTowers_ = consumes<CaloTowerCollection>(hcTow);
129 const std::vector<std::string> flagnamesEB =
130 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB");
132 const std::vector<std::string> flagnamesEE =
133 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE");
135 flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
137 flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
139 const std::vector<std::string> severitynamesEB =
140 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEB");
142 severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
144 const std::vector<std::string> severitynamesEE =
145 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEE");
147 severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
199 consumesCollector());
237 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
241 bool validPhotonCoreHandle =
false;
243 bool validPhotonHandle =
false;
275 validPhotonHandle =
true;
281 if (photonCoreHandle.
isValid()) {
282 validPhotonCoreHandle =
true;
290 bool validEcalRecHits =
true;
294 if (!barrelHitHandle.
isValid()) {
295 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the barrelEcalHits";
302 if (!endcapHitHandle.
isValid()) {
303 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the endcapEcalHits";
307 bool validPreshowerRecHits =
true;
311 if (!preshowerHitHandle.
isValid()) {
312 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the preshowerEcalHits";
314 if (validPreshowerRecHits)
315 preshowerRecHits = *(preshowerHitHandle.
product());
321 if (!pfEGCandidateHandle.
isValid()) {
322 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfEgammaCandidates";
333 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfCandidates";
363 bool validVertex =
true;
367 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the product primary Vertex Collection";
385 if (validPhotonCoreHandle)
410 phoChargedIsolationMap,
411 phoNeutralHadronIsolationMap,
412 phoPhotonIsolationMap,
413 phoChargedWorstVtxIsoMap,
414 phoChargedWorstVtxGeomVetoIsoMap,
415 phoChargedPFPVIsoMap,
416 phoPFECALClusIsolationMap,
417 phoPFHCALClusIsolationMap);
420 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
427 auto pfEGCandToPhotonMap_p = std::make_unique<edm::ValueMap<reco::PhotonRef>>();
429 unsigned nObj = pfEGCandidateHandle->size();
430 std::vector<reco::PhotonRef>
values(nObj);
432 for (
unsigned int lCand = 0; lCand < nObj; lCand++) {
436 for (
unsigned int lSC = 0; lSC < photonOrphHandle->size(); lSC++) {
439 if (pfScRef != scRef)
441 values[lCand] = photonRef;
464 std::vector<double> preselCutValues;
465 std::vector<int> flags_, severitiesexcl_;
467 for (
unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
475 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
476 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
479 hits = ecalBarrelHits;
484 hits = ecalEndcapHits;
493 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster: " << thedet
499 ptFast(parentSCRef->energy(), parentSCRef->position(),
math::XYZPoint(0, 0, 0)) <= preselCutValues[0])
506 std::vector<CaloTowerDetId> TowersBehindClus;
507 float hcalDepth1OverEcalBc, hcalDepth2OverEcalBc;
508 hcalDepth1OverEcalBc = hcalDepth2OverEcalBc = 0.f;
509 bool invalidHcal =
false;
514 HoE1 = towerIso1.
getTowerESum(&(*scRef)) / scRef->energy();
515 HoE2 = towerIso2.
getTowerESum(&(*scRef)) / scRef->energy();
518 TowersBehindClus = towerIsoBehindClus.
towersOf(*scRef);
522 if (
checkHcalStatus_ && hcalDepth1OverEcalBc == 0 && hcalDepth2OverEcalBc == 0) {
523 invalidHcal = !towerIsoBehindClus.
hasActiveHcal(TowersBehindClus);
534 float e2x5 = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
535 float e3x3 = (
hits !=
nullptr ? EcalClusterTools::e3x3(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
536 float e5x5 = (
hits !=
nullptr ? EcalClusterTools::e5x5(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
537 std::vector<float> cov =
538 (
hits !=
nullptr ? EcalClusterTools::covariances(*(scRef->seed()), &(*
hits), &(*topology),
geometry)
539 : std::vector<float>({0.f, 0.f, 0.f}));
540 std::vector<float> locCov =
541 (
hits !=
nullptr ? EcalClusterTools::localCovariances(*(scRef->seed()), &(*
hits), &(*topology))
542 : std::vector<float>({0.f, 0.f, 0.f}));
545 float sigmaIetaIeta =
sqrt(locCov[0]);
558 std::vector<float> full5x5_cov =
560 : std::vector<float>({0.f, 0.f, 0.f}));
561 std::vector<float> full5x5_locCov =
563 : std::vector<float>({0.f, 0.f, 0.f}));
565 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
594 newCandidate.setFiducialVolumeFlags(fiducialFlags);
595 newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
601 showerShape.
e3x3 = e3x3;
602 showerShape.
e5x5 = e5x5;
614 const float sep = locCov[1];
617 showerShape.
e2nd = (
hits !=
nullptr ? EcalClusterTools::e2nd(*(scRef->seed()), &(*
hits)) : 0.
f);
618 showerShape.
eTop = (
hits !=
nullptr ? EcalClusterTools::eTop(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
619 showerShape.
eLeft = (
hits !=
nullptr ? EcalClusterTools::eLeft(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
620 showerShape.
eRight = (
hits !=
nullptr ? EcalClusterTools::eRight(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
621 showerShape.
eBottom = (
hits !=
nullptr ? EcalClusterTools::eBottom(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
622 showerShape.
e1x3 = (
hits !=
nullptr ? EcalClusterTools::e1x3(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
623 showerShape.
e2x2 = (
hits !=
nullptr ? EcalClusterTools::e2x2(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
624 showerShape.
e2x5Max = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
626 (
hits !=
nullptr ? EcalClusterTools::e2x5Left(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
628 (
hits !=
nullptr ? EcalClusterTools::e2x5Right(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
629 showerShape.
e2x5Top = (
hits !=
nullptr ? EcalClusterTools::e2x5Top(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
631 (
hits !=
nullptr ? EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
645 const float sigmaRR = toolsforES.eseffsirir(*scRef);
647 newCandidate.setShowerShapeVariables(showerShape);
652 int nSaturatedXtals = 0;
653 bool isSeedSaturated =
false;
654 if (
hits !=
nullptr) {
655 const auto hitsAndFractions = scRef->hitsAndFractions();
656 for (
auto&& hitFractionPair : hitsAndFractions) {
660 if (
ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
663 isSeedSaturated =
true;
669 newCandidate.setSaturationInfo(saturationInfo);
673 full5x5_showerShape.
e1x5 = full5x5_e1x5;
674 full5x5_showerShape.
e2x5 = full5x5_e2x5;
675 full5x5_showerShape.
e3x3 = full5x5_e3x3;
676 full5x5_showerShape.
e5x5 = full5x5_e5x5;
678 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
681 const float full5x5_spp = (!
edm::isFinite(full5x5_locCov[2]) ? 0. :
sqrt(full5x5_locCov[2]));
682 const float full5x5_sep = full5x5_locCov[1];
686 full5x5_showerShape.
eTop =
688 full5x5_showerShape.
eLeft =
690 full5x5_showerShape.
eRight =
694 full5x5_showerShape.
e1x3 =
696 full5x5_showerShape.
e2x2 =
714 full5x5_showerShape.
smMajor = 0.f;
715 full5x5_showerShape.
smMinor = 0.f;
716 full5x5_showerShape.
smAlpha = 0.f;
720 newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
744 newCandidate.setP4(
p4);
748 fiducialFlags.
isEE =
true;
749 newCandidate.setFiducialVolumeFlags(fiducialFlags);
761 newCandidate.setMIPVariables(mipVar);
765 bool isLooseEM =
true;
766 if (newCandidate.pt() <
highEt_) {
767 if (newCandidate.hadronicOverEm() >= preselCutValues[1])
769 if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
771 if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
773 if (newCandidate.nTrkSolidConeDR04() >
int(preselCutValues[6]))
775 if (newCandidate.nTrkHollowConeDR04() >
int(preselCutValues[7]))
777 if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
779 if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
781 if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
807 std::vector<double> preselCutValues;
809 for (
unsigned int lSC = 0; lSC < photonHandle->size(); lSC++) {
813 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
814 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
822 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet <<
' '
828 ptFast(parentSCRef->energy(), parentSCRef->position(),
math::XYZPoint(0, 0, 0)) <= preselCutValues[0])