189 else if (
step ==
"oot")
191 else if (
step ==
"ootfinal")
193 else if (
step ==
"tmp")
197 <<
" reconstructStep " <<
step <<
" is invalid, the options are: tmp, final,oot or ootfinal" << std::endl;
203 ecalClusterESGetTokens_{consumesCollector()},
208 hcalHelperCone_(
nullptr),
209 hcalHelperBc_(
nullptr) {
210 if (recoStep_.isFinal()) {
211 photonProducerT_ = consumes(photonProducer_);
218 phoChargedIsolationToken_ = getVMToken(
"chargedHadronIso");
219 phoNeutralHadronIsolationToken_ = getVMToken(
"neutralHadronIso");
220 phoPhotonIsolationToken_ = getVMToken(
"photonIso");
221 phoChargedWorstVtxIsoToken_ = getVMToken(
"chargedHadronWorstVtxIso");
222 phoChargedWorstVtxGeomVetoIsoToken_ = getVMToken(
"chargedHadronWorstVtxGeomVetoIso");
223 phoChargedPFPVIsoToken_ = getVMToken(
"chargedHadronPFPVIso");
227 if (
config.exists(
"pfECALClusIsolation")) {
228 phoPFECALClusIsolationToken_ = consumes(
config.getParameter<
edm::InputTag>(
"pfECALClusIsolation"));
230 if (
config.exists(
"pfHCALClusIsolation")) {
231 phoPFHCALClusIsolationToken_ = consumes(
config.getParameter<
edm::InputTag>(
"pfHCALClusIsolation"));
234 photonCoreProducerT_ = consumes(photonProducer_);
238 if (not pfEg.label().empty()) {
239 pfEgammaCandidates_ = consumes(pfEg);
247 if (not hbhetag.label().empty())
248 hbheRecHits_ = consumes<HBHERecHitCollection>(hbhetag);
252 multThresEB_ =
config.getParameter<
double>(
"multThresEB");
253 multThresEE_ =
config.getParameter<
double>(
"multThresEE");
254 hOverEConeSize_ =
config.getParameter<
double>(
"hOverEConeSize");
255 highEt_ =
config.getParameter<
double>(
"highEt");
257 minR9Barrel_ =
config.getParameter<
double>(
"minR9Barrel");
258 minR9Endcap_ =
config.getParameter<
double>(
"minR9Endcap");
259 usePrimaryVertex_ =
config.getParameter<
bool>(
"usePrimaryVertex");
260 runMIPTagger_ =
config.getParameter<
bool>(
"runMIPTagger");
267 auto const& flagnamesEB =
config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB");
268 auto const& flagnamesEE =
config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE");
270 flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
271 flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
273 auto const& severitynamesEB =
config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEB");
274 auto const& severitynamesEE =
config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEE");
276 severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
277 severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
279 photonEnergyCorrector_ = std::make_unique<PhotonEnergyCorrector>(
config, consumesCollector());
281 checkHcalStatus_ =
config.getParameter<
bool>(
"checkHcalStatus");
282 if (not hbheRecHits_.isUninitialized()) {
307 hcalHelperCone_ = std::make_unique<ElectronHcalHelper>(cfgCone, consumesCollector());
308 hcalHelperBc_ = std::make_unique<ElectronHcalHelper>(cfgBc, consumesCollector());
311 hcalRun2EffDepth_ =
config.getParameter<
bool>(
"hcalRun2EffDepth");
316 preselCutValuesBarrel_ = {
config.getParameter<
double>(
"minSCEtBarrel"),
317 config.getParameter<
double>(
"maxHoverEBarrel"),
318 config.getParameter<
double>(
"ecalRecHitSumEtOffsetBarrel"),
319 config.getParameter<
double>(
"ecalRecHitSumEtSlopeBarrel"),
320 config.getParameter<
double>(
"hcalRecHitSumEtOffsetBarrel"),
321 config.getParameter<
double>(
"hcalRecHitSumEtSlopeBarrel"),
322 config.getParameter<
double>(
"nTrackSolidConeBarrel"),
323 config.getParameter<
double>(
"nTrackHollowConeBarrel"),
324 config.getParameter<
double>(
"trackPtSumSolidConeBarrel"),
325 config.getParameter<
double>(
"trackPtSumHollowConeBarrel"),
326 config.getParameter<
double>(
"sigmaIetaIetaCutBarrel")};
328 preselCutValuesEndcap_ = {
config.getParameter<
double>(
"minSCEtEndcap"),
329 config.getParameter<
double>(
"maxHoverEEndcap"),
330 config.getParameter<
double>(
"ecalRecHitSumEtOffsetEndcap"),
331 config.getParameter<
double>(
"ecalRecHitSumEtSlopeEndcap"),
332 config.getParameter<
double>(
"hcalRecHitSumEtOffsetEndcap"),
333 config.getParameter<
double>(
"hcalRecHitSumEtSlopeEndcap"),
334 config.getParameter<
double>(
"nTrackSolidConeEndcap"),
335 config.getParameter<
double>(
"nTrackHollowConeEndcap"),
336 config.getParameter<
double>(
"trackPtSumSolidConeEndcap"),
337 config.getParameter<
double>(
"trackPtSumHollowConeEndcap"),
338 config.getParameter<
double>(
"sigmaIetaIetaCutEndcap")};
342 if (!recoStep_.isFinal()) {
343 photonIsoCalculator_ = std::make_unique<PhotonIsolationCalculator>();
350 consumesCollector());
351 photonMIPHaloTagger_ = std::make_unique<PhotonMIPHaloTagger>();
357 produces<reco::PhotonCollection>(photonCollection_);
358 if (not pfEgammaCandidates_.isUninitialized()) {
359 produces<edm::ValueMap<reco::PhotonRef>>(valueMapPFCandPhoton_);
372 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
376 bool validPhotonCoreHandle =
false;
378 bool validPhotonHandle =
false;
410 validPhotonHandle =
true;
416 if (photonCoreHandle.
isValid()) {
417 validPhotonCoreHandle =
true;
433 if (!pfEGCandidateHandle.
isValid()) {
434 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfEgammaCandidates";
445 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfCandidates";
477 if (validPhotonCoreHandle)
489 *outputPhotonCollection_p,
501 *outputPhotonCollection_p,
503 phoChargedIsolationMap,
504 phoNeutralHadronIsolationMap,
505 phoPhotonIsolationMap,
506 phoChargedWorstVtxIsoMap,
507 phoChargedWorstVtxGeomVetoIsoMap,
508 phoChargedPFPVIsoMap,
509 phoPFECALClusIsolationMap,
510 phoPFHCALClusIsolationMap);
513 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
517 for (
auto& pho : *outputPhotonCollection_p)
518 pho.hcalToRun2EffDepth();
524 auto pfEGCandToPhotonMap_p = std::make_unique<edm::ValueMap<reco::PhotonRef>>();
526 unsigned nObj = pfEGCandidateHandle->size();
527 std::vector<reco::PhotonRef>
values(nObj);
529 for (
unsigned int lCand = 0; lCand < nObj; lCand++) {
533 for (
unsigned int lSC = 0; lSC < photonOrphHandle->size(); lSC++) {
536 if (pfScRef != scRef)
538 values[lCand] = photonRef;
562 std::vector<double> preselCutValues;
563 std::vector<int> flags_, severitiesexcl_;
565 for (
unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
573 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
574 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
577 hits = ecalBarrelHits;
582 hits = ecalEndcapHits;
591 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster: " << thedet
597 ptFast(parentSCRef->energy(), parentSCRef->position(), {0, 0, 0}) <= preselCutValues[0])
605 float e2x5 = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()),
hits, topology) : 0.f);
606 float e3x3 = (
hits !=
nullptr ? EcalClusterTools::e3x3(*(scRef->seed()),
hits, topology) : 0.f);
607 float e5x5 = (
hits !=
nullptr ? EcalClusterTools::e5x5(*(scRef->seed()),
hits, topology) : 0.f);
608 const auto& cov = (
hits !=
nullptr ? EcalClusterTools::covariances(*(scRef->seed()),
hits, topology,
caloGeom_)
609 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
611 const auto& locCov = (
hits !=
nullptr ? EcalClusterTools::localCovariances(*(scRef->seed()),
hits, topology)
612 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
615 float sigmaIetaIeta =
std::sqrt(locCov[0]);
624 const auto& full5x5_cov =
626 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
630 const auto& full5x5_locCov =
638 : std::array<float, 3>({{0.f, 0.f, 0.f}}));
640 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
669 newCandidate.setFiducialVolumeFlags(fiducialFlags);
670 newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
676 showerShape.
e3x3 = e3x3;
677 showerShape.
e5x5 = e5x5;
683 (hcalHelperCone !=
nullptr) ? hcalHelperCone->
hcalESum(*scRef,
id + 1) / scRef->energy() : 0.f;
685 (hcalHelperBc !=
nullptr) ? hcalHelperBc->
hcalESum(*scRef,
id + 1) / scRef->energy() : 0.f;
688 if (hcalHelperBc !=
nullptr)
694 const float sep = locCov[1];
697 showerShape.
e2nd = (
hits !=
nullptr ? EcalClusterTools::e2nd(*(scRef->seed()),
hits) : 0.f);
698 showerShape.
eTop = (
hits !=
nullptr ? EcalClusterTools::eTop(*(scRef->seed()),
hits, topology) : 0.f);
699 showerShape.
eLeft = (
hits !=
nullptr ? EcalClusterTools::eLeft(*(scRef->seed()),
hits, topology) : 0.f);
700 showerShape.
eRight = (
hits !=
nullptr ? EcalClusterTools::eRight(*(scRef->seed()),
hits, topology) : 0.f);
701 showerShape.
eBottom = (
hits !=
nullptr ? EcalClusterTools::eBottom(*(scRef->seed()),
hits, topology) : 0.f);
702 showerShape.
e1x3 = (
hits !=
nullptr ? EcalClusterTools::e1x3(*(scRef->seed()),
hits, topology) : 0.f);
703 showerShape.
e2x2 = (
hits !=
nullptr ? EcalClusterTools::e2x2(*(scRef->seed()),
hits, topology) : 0.f);
704 showerShape.
e2x5Max = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()),
hits, topology) : 0.f);
705 showerShape.
e2x5Left = (
hits !=
nullptr ? EcalClusterTools::e2x5Left(*(scRef->seed()),
hits, topology) : 0.f);
706 showerShape.
e2x5Right = (
hits !=
nullptr ? EcalClusterTools::e2x5Right(*(scRef->seed()),
hits, topology) : 0.f);
707 showerShape.
e2x5Top = (
hits !=
nullptr ? EcalClusterTools::e2x5Top(*(scRef->seed()),
hits, topology) : 0.f);
708 showerShape.
e2x5Bottom = (
hits !=
nullptr ? EcalClusterTools::e2x5Bottom(*(scRef->seed()),
hits, topology) : 0.f);
723 const float sigmaRR = toolsforES.eseffsirir(*scRef);
725 newCandidate.setShowerShapeVariables(showerShape);
729 int nSaturatedXtals = 0;
730 bool isSeedSaturated =
false;
731 if (
hits !=
nullptr) {
732 const auto hitsAndFractions = scRef->hitsAndFractions();
733 for (
auto const& hitFractionPair : hitsAndFractions) {
737 if (
ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
740 isSeedSaturated =
true;
747 newCandidate.setSaturationInfo(saturationInfo);
751 full5x5_showerShape.
e1x5 = full5x5_e1x5;
752 full5x5_showerShape.
e2x5 = full5x5_e2x5;
753 full5x5_showerShape.
e3x3 = full5x5_e3x3;
754 full5x5_showerShape.
e5x5 = full5x5_e5x5;
756 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
760 const float full5x5_sep = full5x5_locCov[1];
765 full5x5_showerShape.
eLeft =
767 full5x5_showerShape.
eRight =
789 full5x5_showerShape.
smMajor = 0.f;
790 full5x5_showerShape.
smMinor = 0.f;
791 full5x5_showerShape.
smAlpha = 0.f;
797 (hcalHelperCone !=
nullptr) ? hcalHelperCone->
hcalESum(*scRef,
id + 1) / full5x5_e5x5 : 0.f;
799 (hcalHelperBc !=
nullptr) ? hcalHelperBc->
hcalESum(*scRef,
id + 1) / full5x5_e5x5 : 0.f;
802 newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
826 newCandidate.setP4(
p4);
830 fiducialFlags.
isEE =
true;
831 newCandidate.setFiducialVolumeFlags(fiducialFlags);
838 newCandidate.setMIPVariables(mipVar);
842 bool isLooseEM =
true;
843 if (newCandidate.pt() <
highEt_) {
844 if (newCandidate.hadronicOverEm() >= preselCutValues[1])
846 if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
848 if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
850 if (newCandidate.nTrkSolidConeDR04() >
int(preselCutValues[6]))
852 if (newCandidate.nTrkHollowConeDR04() >
int(preselCutValues[7]))
854 if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
856 if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
858 if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
883 std::vector<double> preselCutValues;
885 for (
unsigned int lSC = 0; lSC < photonHandle->size(); lSC++) {
889 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
890 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
898 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet <<
' '
904 ptFast(parentSCRef->energy(), parentSCRef->position(), {0, 0, 0}) <= preselCutValues[0])