188 else if (
step ==
"oot")
190 else if (
step ==
"ootfinal")
192 else if (
step ==
"tmp")
196 <<
" reconstructStep " <<
step <<
" is invalid, the options are: tmp, final,oot or ootfinal" << std::endl;
202 ecalClusterESGetTokens_{consumesCollector()},
207 if (recoStep_.isFinal()) {
208 photonProducerT_ = consumes(photonProducer_);
215 phoChargedIsolationToken_ = getVMToken(
"chargedHadronIso");
216 phoNeutralHadronIsolationToken_ = getVMToken(
"neutralHadronIso");
217 phoPhotonIsolationToken_ = getVMToken(
"photonIso");
218 phoChargedWorstVtxIsoToken_ = getVMToken(
"chargedHadronWorstVtxIso");
219 phoChargedWorstVtxGeomVetoIsoToken_ = getVMToken(
"chargedHadronWorstVtxGeomVetoIso");
220 phoChargedPFPVIsoToken_ = getVMToken(
"chargedHadronPFPVIso");
224 if (
config.exists(
"pfECALClusIsolation")) {
225 phoPFECALClusIsolationToken_ = consumes(
config.getParameter<
edm::InputTag>(
"pfECALClusIsolation"));
227 if (
config.exists(
"pfHCALClusIsolation")) {
228 phoPFHCALClusIsolationToken_ = consumes(
config.getParameter<
edm::InputTag>(
"pfHCALClusIsolation"));
231 photonCoreProducerT_ = consumes(photonProducer_);
235 if (not pfEg.label().empty()) {
236 pfEgammaCandidates_ = consumes(pfEg);
244 if (not hcTow.label().empty()) {
245 hcalTowers_ = consumes(hcTow);
249 multThresEB_ =
config.getParameter<
double>(
"multThresEB");
250 multThresEE_ =
config.getParameter<
double>(
"multThresEE");
251 hOverEConeSize_ =
config.getParameter<
double>(
"hOverEConeSize");
252 highEt_ =
config.getParameter<
double>(
"highEt");
254 minR9Barrel_ =
config.getParameter<
double>(
"minR9Barrel");
255 minR9Endcap_ =
config.getParameter<
double>(
"minR9Endcap");
256 usePrimaryVertex_ =
config.getParameter<
bool>(
"usePrimaryVertex");
257 runMIPTagger_ =
config.getParameter<
bool>(
"runMIPTagger");
264 auto const& flagnamesEB =
config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB");
265 auto const& flagnamesEE =
config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE");
267 flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
268 flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
270 auto const& severitynamesEB =
config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEB");
271 auto const& severitynamesEE =
config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEE");
273 severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
274 severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
276 photonEnergyCorrector_ = std::make_unique<PhotonEnergyCorrector>(
config, consumesCollector());
281 preselCutValuesBarrel_ = {
config.getParameter<
double>(
"minSCEtBarrel"),
282 config.getParameter<
double>(
"maxHoverEBarrel"),
283 config.getParameter<
double>(
"ecalRecHitSumEtOffsetBarrel"),
284 config.getParameter<
double>(
"ecalRecHitSumEtSlopeBarrel"),
285 config.getParameter<
double>(
"hcalTowerSumEtOffsetBarrel"),
286 config.getParameter<
double>(
"hcalTowerSumEtSlopeBarrel"),
287 config.getParameter<
double>(
"nTrackSolidConeBarrel"),
288 config.getParameter<
double>(
"nTrackHollowConeBarrel"),
289 config.getParameter<
double>(
"trackPtSumSolidConeBarrel"),
290 config.getParameter<
double>(
"trackPtSumHollowConeBarrel"),
291 config.getParameter<
double>(
"sigmaIetaIetaCutBarrel")};
293 preselCutValuesEndcap_ = {
config.getParameter<
double>(
"minSCEtEndcap"),
294 config.getParameter<
double>(
"maxHoverEEndcap"),
295 config.getParameter<
double>(
"ecalRecHitSumEtOffsetEndcap"),
296 config.getParameter<
double>(
"ecalRecHitSumEtSlopeEndcap"),
297 config.getParameter<
double>(
"hcalTowerSumEtOffsetEndcap"),
298 config.getParameter<
double>(
"hcalTowerSumEtSlopeEndcap"),
299 config.getParameter<
double>(
"nTrackSolidConeEndcap"),
300 config.getParameter<
double>(
"nTrackHollowConeEndcap"),
301 config.getParameter<
double>(
"trackPtSumSolidConeEndcap"),
302 config.getParameter<
double>(
"trackPtSumHollowConeEndcap"),
303 config.getParameter<
double>(
"sigmaIetaIetaCutEndcap")};
307 if (!recoStep_.isFinal()) {
308 photonIsoCalculator_ = std::make_unique<PhotonIsolationCalculator>();
315 consumesCollector());
316 photonMIPHaloTagger_ = std::make_unique<PhotonMIPHaloTagger>();
321 checkHcalStatus_ =
config.getParameter<
bool>(
"checkHcalStatus");
324 produces<reco::PhotonCollection>(photonCollection_);
325 if (not pfEgammaCandidates_.isUninitialized()) {
326 produces<edm::ValueMap<reco::PhotonRef>>(valueMapPFCandPhoton_);
339 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
343 bool validPhotonCoreHandle =
false;
345 bool validPhotonHandle =
false;
377 validPhotonHandle =
true;
383 if (photonCoreHandle.
isValid()) {
384 validPhotonCoreHandle =
true;
400 if (!pfEGCandidateHandle.
isValid()) {
401 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfEgammaCandidates";
412 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfCandidates";
441 if (validPhotonCoreHandle)
452 *outputPhotonCollection_p,
464 *outputPhotonCollection_p,
466 phoChargedIsolationMap,
467 phoNeutralHadronIsolationMap,
468 phoPhotonIsolationMap,
469 phoChargedWorstVtxIsoMap,
470 phoChargedWorstVtxGeomVetoIsoMap,
471 phoChargedPFPVIsoMap,
472 phoPFECALClusIsolationMap,
473 phoPFHCALClusIsolationMap);
476 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
481 auto pfEGCandToPhotonMap_p = std::make_unique<edm::ValueMap<reco::PhotonRef>>();
483 unsigned nObj = pfEGCandidateHandle->size();
484 std::vector<reco::PhotonRef>
values(nObj);
486 for (
unsigned int lCand = 0; lCand < nObj; lCand++) {
490 for (
unsigned int lSC = 0; lSC < photonOrphHandle->size(); lSC++) {
493 if (pfScRef != scRef)
495 values[lCand] = photonRef;
518 std::vector<double> preselCutValues;
519 std::vector<int> flags_, severitiesexcl_;
521 for (
unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
529 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
530 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
533 hits = ecalBarrelHits;
538 hits = ecalEndcapHits;
547 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster: " << thedet
553 ptFast(parentSCRef->energy(), parentSCRef->position(), {0, 0, 0}) <= preselCutValues[0])
560 std::vector<CaloTowerDetId> TowersBehindClus;
561 float hcalDepth1OverEcalBc, hcalDepth2OverEcalBc;
562 hcalDepth1OverEcalBc = hcalDepth2OverEcalBc = 0.f;
563 bool invalidHcal =
false;
568 HoE1 = towerIso1.
getTowerESum(&(*scRef)) / scRef->energy();
569 HoE2 = towerIso2.
getTowerESum(&(*scRef)) / scRef->energy();
584 if (
checkHcalStatus_ && hcalDepth1OverEcalBc == 0 && hcalDepth2OverEcalBc == 0) {
596 float e2x5 = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()),
hits, topology) : 0.f);
597 float e3x3 = (
hits !=
nullptr ? EcalClusterTools::e3x3(*(scRef->seed()),
hits, topology) : 0.f);
598 float e5x5 = (
hits !=
nullptr ? EcalClusterTools::e5x5(*(scRef->seed()),
hits, topology) : 0.f);
599 const auto& cov = (
hits !=
nullptr ? EcalClusterTools::covariances(*(scRef->seed()),
hits, topology,
caloGeom_)
600 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
602 const auto& locCov = (
hits !=
nullptr ? EcalClusterTools::localCovariances(*(scRef->seed()),
hits, topology)
603 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
606 float sigmaIetaIeta =
std::sqrt(locCov[0]);
615 const auto& full5x5_cov =
617 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
621 const auto& full5x5_locCov =
629 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
631 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
660 newCandidate.setFiducialVolumeFlags(fiducialFlags);
661 newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
667 showerShape.
e3x3 = e3x3;
668 showerShape.
e5x5 = e5x5;
680 const float sep = locCov[1];
683 showerShape.
e2nd = (
hits !=
nullptr ? EcalClusterTools::e2nd(*(scRef->seed()),
hits) : 0.f);
684 showerShape.
eTop = (
hits !=
nullptr ? EcalClusterTools::eTop(*(scRef->seed()),
hits, topology) : 0.f);
685 showerShape.
eLeft = (
hits !=
nullptr ? EcalClusterTools::eLeft(*(scRef->seed()),
hits, topology) : 0.f);
686 showerShape.
eRight = (
hits !=
nullptr ? EcalClusterTools::eRight(*(scRef->seed()),
hits, topology) : 0.f);
687 showerShape.
eBottom = (
hits !=
nullptr ? EcalClusterTools::eBottom(*(scRef->seed()),
hits, topology) : 0.f);
688 showerShape.
e1x3 = (
hits !=
nullptr ? EcalClusterTools::e1x3(*(scRef->seed()),
hits, topology) : 0.f);
689 showerShape.
e2x2 = (
hits !=
nullptr ? EcalClusterTools::e2x2(*(scRef->seed()),
hits, topology) : 0.f);
690 showerShape.
e2x5Max = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()),
hits, topology) : 0.f);
691 showerShape.
e2x5Left = (
hits !=
nullptr ? EcalClusterTools::e2x5Left(*(scRef->seed()),
hits, topology) : 0.f);
692 showerShape.
e2x5Right = (
hits !=
nullptr ? EcalClusterTools::e2x5Right(*(scRef->seed()),
hits, topology) : 0.f);
693 showerShape.
e2x5Top = (
hits !=
nullptr ? EcalClusterTools::e2x5Top(*(scRef->seed()),
hits, topology) : 0.f);
694 showerShape.
e2x5Bottom = (
hits !=
nullptr ? EcalClusterTools::e2x5Bottom(*(scRef->seed()),
hits, topology) : 0.f);
709 const float sigmaRR = toolsforES.eseffsirir(*scRef);
711 newCandidate.setShowerShapeVariables(showerShape);
715 int nSaturatedXtals = 0;
716 bool isSeedSaturated =
false;
717 if (
hits !=
nullptr) {
718 const auto hitsAndFractions = scRef->hitsAndFractions();
719 for (
auto const& hitFractionPair : hitsAndFractions) {
723 if (
ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
726 isSeedSaturated =
true;
733 newCandidate.setSaturationInfo(saturationInfo);
737 full5x5_showerShape.
e1x5 = full5x5_e1x5;
738 full5x5_showerShape.
e2x5 = full5x5_e2x5;
739 full5x5_showerShape.
e3x3 = full5x5_e3x3;
740 full5x5_showerShape.
e5x5 = full5x5_e5x5;
742 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
746 const float full5x5_sep = full5x5_locCov[1];
751 full5x5_showerShape.
eLeft =
753 full5x5_showerShape.
eRight =
775 full5x5_showerShape.
smMajor = 0.f;
776 full5x5_showerShape.
smMinor = 0.f;
777 full5x5_showerShape.
smAlpha = 0.f;
781 newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
805 newCandidate.setP4(
p4);
809 fiducialFlags.
isEE =
true;
810 newCandidate.setFiducialVolumeFlags(fiducialFlags);
822 newCandidate.setMIPVariables(mipVar);
826 bool isLooseEM =
true;
827 if (newCandidate.pt() <
highEt_) {
828 if (newCandidate.hadronicOverEm() >= preselCutValues[1])
830 if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
832 if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
834 if (newCandidate.nTrkSolidConeDR04() >
int(preselCutValues[6]))
836 if (newCandidate.nTrkHollowConeDR04() >
int(preselCutValues[7]))
838 if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
840 if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
842 if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
867 std::vector<double> preselCutValues;
869 for (
unsigned int lSC = 0; lSC < photonHandle->size(); lSC++) {
873 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
874 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
882 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet <<
' '
888 ptFast(parentSCRef->energy(), parentSCRef->position(), {0, 0, 0}) <= preselCutValues[0])