46 else if (
step ==
"oot")
48 else if (
step ==
"ootfinal")
50 else if (
step ==
"tmp")
54 <<
" reconstructStep " <<
step <<
" is invalid, the options are: tmp, final,oot or ootfinal" << std::endl;
64 photonProducer_ = conf_.getParameter<
edm::InputTag>(
"photonProducer");
66 if (recoStep_.isFinal()) {
67 photonProducerT_ = consumes<reco::PhotonCollection>(photonProducer_);
68 pfCandidates_ = consumes<reco::PFCandidateCollection>(conf_.getParameter<
edm::InputTag>(
"pfCandidates"));
74 phoChargedIsolationToken_ = getVMToken(
"chargedHadronIso");
75 phoNeutralHadronIsolationToken_ = getVMToken(
"neutralHadronIso");
76 phoPhotonIsolationToken_ = getVMToken(
"photonIso");
77 phoChargedWorstVtxIsoToken_ = getVMToken(
"chargedHadronWorstVtxIso");
78 phoChargedWorstVtxGeomVetoIsoToken_ = getVMToken(
"chargedHadronWorstVtxGeomVetoIso");
79 phoChargedPFPVIsoToken_ = getVMToken(
"chargedHadronPFPVIso");
83 if (conf_.exists(
"pfECALClusIsolation")) {
84 phoPFECALClusIsolationToken_ =
85 consumes<edm::ValueMap<float>>(conf_.getParameter<
edm::InputTag>(
"pfECALClusIsolation"));
87 if (conf_.exists(
"pfHCALClusIsolation")) {
88 phoPFHCALClusIsolationToken_ =
89 consumes<edm::ValueMap<float>>(conf_.getParameter<
edm::InputTag>(
"pfHCALClusIsolation"));
92 photonCoreProducerT_ = consumes<reco::PhotonCoreCollection>(photonProducer_);
95 auto pfEg = conf_.getParameter<
edm::InputTag>(
"pfEgammaCandidates");
96 if (not pfEg.label().empty())
97 pfEgammaCandidates_ = consumes<reco::PFCandidateCollection>(pfEg);
98 barrelEcalHits_ = consumes<EcalRecHitCollection>(conf_.getParameter<
edm::InputTag>(
"barrelEcalHits"));
99 endcapEcalHits_ = consumes<EcalRecHitCollection>(conf_.getParameter<
edm::InputTag>(
"endcapEcalHits"));
100 preshowerHits_ = consumes<EcalRecHitCollection>(conf_.getParameter<
edm::InputTag>(
"preshowerHits"));
101 vertexProducer_ = consumes<reco::VertexCollection>(conf_.getParameter<
edm::InputTag>(
"primaryVertexProducer"));
103 auto hcTow = conf_.getParameter<
edm::InputTag>(
"hcalTowers");
104 if (not hcTow.label().empty())
105 hcalTowers_ = consumes<CaloTowerCollection>(hcTow);
107 photonCollection_ = conf_.getParameter<
std::string>(
"outputPhotonCollection");
108 hOverEConeSize_ = conf_.getParameter<
double>(
"hOverEConeSize");
109 highEt_ = conf_.getParameter<
double>(
"highEt");
111 minR9Barrel_ = conf_.getParameter<
double>(
"minR9Barrel");
112 minR9Endcap_ = conf_.getParameter<
double>(
"minR9Endcap");
113 usePrimaryVertex_ = conf_.getParameter<
bool>(
"usePrimaryVertex");
114 runMIPTagger_ = conf_.getParameter<
bool>(
"runMIPTagger");
124 const std::vector<std::string> flagnamesEB =
125 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEB");
127 const std::vector<std::string> flagnamesEE =
128 config.getParameter<std::vector<std::string>>(
"RecHitFlagToBeExcludedEE");
130 flagsexclEB_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEB);
132 flagsexclEE_ = StringToEnumValue<EcalRecHit::Flags>(flagnamesEE);
134 const std::vector<std::string> severitynamesEB =
135 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEB");
137 severitiesexclEB_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEB);
139 const std::vector<std::string> severitynamesEE =
140 config.getParameter<std::vector<std::string>>(
"RecHitSeverityToBeExcludedEE");
142 severitiesexclEE_ = StringToEnumValue<EcalSeverityLevel::SeverityLevel>(severitynamesEE);
160 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"minSCEtBarrel"));
161 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"maxHoverEBarrel"));
162 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"ecalRecHitSumEtOffsetBarrel"));
163 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"ecalRecHitSumEtSlopeBarrel"));
164 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"hcalTowerSumEtOffsetBarrel"));
165 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"hcalTowerSumEtSlopeBarrel"));
166 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"nTrackSolidConeBarrel"));
167 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"nTrackHollowConeBarrel"));
168 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"trackPtSumSolidConeBarrel"));
169 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"trackPtSumHollowConeBarrel"));
170 preselCutValuesBarrel_.push_back(conf_.getParameter<
double>(
"sigmaIetaIetaCutBarrel"));
172 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"minSCEtEndcap"));
173 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"maxHoverEEndcap"));
174 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"ecalRecHitSumEtOffsetEndcap"));
175 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"ecalRecHitSumEtSlopeEndcap"));
176 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"hcalTowerSumEtOffsetEndcap"));
177 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"hcalTowerSumEtSlopeEndcap"));
178 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"nTrackSolidConeEndcap"));
179 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"nTrackHollowConeEndcap"));
180 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"trackPtSumSolidConeEndcap"));
181 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"trackPtSumHollowConeEndcap"));
182 preselCutValuesEndcap_.push_back(conf_.getParameter<
double>(
"sigmaIetaIetaCutEndcap"));
186 if (!recoStep_.isFinal()) {
194 consumesCollector());
197 thePhotonMIPHaloTagger_->setup(
mipVariableSet, consumesCollector());
200 thePhotonIsolationCalculator_ =
nullptr;
201 thePhotonMIPHaloTagger_ =
nullptr;
204 checkHcalStatus_ = conf_.
getParameter<
bool>(
"checkHcalStatus");
207 produces<reco::PhotonCollection>(photonCollection_);
208 if (not pfEgammaCandidates_.isUninitialized())
232 auto outputPhotonCollection_p = std::make_unique<reco::PhotonCollection>();
236 bool validPhotonCoreHandle =
false;
238 bool validPhotonHandle =
false;
270 validPhotonHandle =
true;
276 if (photonCoreHandle.
isValid()) {
277 validPhotonCoreHandle =
true;
285 bool validEcalRecHits =
true;
289 if (!barrelHitHandle.
isValid()) {
290 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the barrelEcalHits";
297 if (!endcapHitHandle.
isValid()) {
298 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the endcapEcalHits";
302 bool validPreshowerRecHits =
true;
306 if (!preshowerHitHandle.
isValid()) {
307 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the preshowerEcalHits";
309 if (validPreshowerRecHits)
310 preshowerRecHits = *(preshowerHitHandle.
product());
316 if (!pfEGCandidateHandle.
isValid()) {
317 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfEgammaCandidates";
328 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the pfCandidates";
360 bool validVertex =
true;
364 throw cms::Exception(
"GEDPhotonProducer") <<
"Error! Can't get the product primary Vertex Collection";
382 if (validPhotonCoreHandle)
407 phoChargedIsolationMap,
408 phoNeutralHadronIsolationMap,
409 phoPhotonIsolationMap,
410 phoChargedWorstVtxIsoMap,
411 phoChargedWorstVtxGeomVetoIsoMap,
412 phoChargedPFPVIsoMap,
413 phoPFECALClusIsolationMap,
414 phoPFHCALClusIsolationMap);
417 edm::LogInfo(
"GEDPhotonProducer") <<
" Put in the event " << iSC <<
" Photon Candidates \n";
424 auto pfEGCandToPhotonMap_p = std::make_unique<edm::ValueMap<reco::PhotonRef>>();
426 unsigned nObj = pfEGCandidateHandle->size();
427 std::vector<reco::PhotonRef>
values(nObj);
429 for (
unsigned int lCand = 0; lCand < nObj; lCand++) {
433 for (
unsigned int lSC = 0; lSC < photonOrphHandle->size(); lSC++) {
436 if (pfScRef != scRef)
438 values[lCand] = photonRef;
461 std::vector<double> preselCutValues;
462 std::vector<int> flags_, severitiesexcl_;
464 for (
unsigned int lSC = 0; lSC < photonCoreHandle->size(); lSC++) {
472 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
473 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
476 hits = ecalBarrelHits;
481 hits = ecalEndcapHits;
490 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster: " << thedet
496 ptFast(parentSCRef->energy(), parentSCRef->position(),
math::XYZPoint(0, 0, 0)) <= preselCutValues[0])
503 std::vector<CaloTowerDetId> TowersBehindClus;
504 float hcalDepth1OverEcalBc, hcalDepth2OverEcalBc;
505 hcalDepth1OverEcalBc = hcalDepth2OverEcalBc = 0.f;
506 bool invalidHcal =
false;
511 HoE1 = towerIso1.
getTowerESum(&(*scRef)) / scRef->energy();
512 HoE2 = towerIso2.
getTowerESum(&(*scRef)) / scRef->energy();
527 if (
checkHcalStatus_ && hcalDepth1OverEcalBc == 0 && hcalDepth2OverEcalBc == 0) {
539 float e2x5 = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
540 float e3x3 = (
hits !=
nullptr ? EcalClusterTools::e3x3(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
541 float e5x5 = (
hits !=
nullptr ? EcalClusterTools::e5x5(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
542 std::vector<float> cov =
543 (
hits !=
nullptr ? EcalClusterTools::covariances(*(scRef->seed()), &(*
hits), &(*topology),
geometry)
544 : std::vector<float>({0.f, 0.f, 0.f}));
545 std::vector<float> locCov =
546 (
hits !=
nullptr ? EcalClusterTools::localCovariances(*(scRef->seed()), &(*
hits), &(*topology))
547 : std::vector<float>({0.f, 0.f, 0.f}));
550 float sigmaIetaIeta =
sqrt(locCov[0]);
563 std::vector<float> full5x5_cov =
565 : std::vector<float>({0.f, 0.f, 0.f}));
566 std::vector<float> full5x5_locCov =
568 : std::vector<float>({0.f, 0.f, 0.f}));
570 float full5x5_sigmaEtaEta =
sqrt(full5x5_cov[0]);
599 newCandidate.setFiducialVolumeFlags(fiducialFlags);
600 newCandidate.setIsolationVariables(isolVarR04, isolVarR03);
606 showerShape.
e3x3 = e3x3;
607 showerShape.
e5x5 = e5x5;
619 const float sep = locCov[1];
622 showerShape.
e2nd = (
hits !=
nullptr ? EcalClusterTools::e2nd(*(scRef->seed()), &(*
hits)) : 0.
f);
623 showerShape.
eTop = (
hits !=
nullptr ? EcalClusterTools::eTop(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
624 showerShape.
eLeft = (
hits !=
nullptr ? EcalClusterTools::eLeft(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
625 showerShape.
eRight = (
hits !=
nullptr ? EcalClusterTools::eRight(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
626 showerShape.
eBottom = (
hits !=
nullptr ? EcalClusterTools::eBottom(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
627 showerShape.
e1x3 = (
hits !=
nullptr ? EcalClusterTools::e1x3(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
628 showerShape.
e2x2 = (
hits !=
nullptr ? EcalClusterTools::e2x2(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
629 showerShape.
e2x5Max = (
hits !=
nullptr ? EcalClusterTools::e2x5Max(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
631 (
hits !=
nullptr ? EcalClusterTools::e2x5Left(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
633 (
hits !=
nullptr ? EcalClusterTools::e2x5Right(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
634 showerShape.
e2x5Top = (
hits !=
nullptr ? EcalClusterTools::e2x5Top(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
636 (
hits !=
nullptr ? EcalClusterTools::e2x5Bottom(*(scRef->seed()), &(*
hits), &(*topology)) : 0.
f);
651 const float sigmaRR = toolsforES.eseffsirir(*scRef);
653 newCandidate.setShowerShapeVariables(showerShape);
658 int nSaturatedXtals = 0;
659 bool isSeedSaturated =
false;
660 if (
hits !=
nullptr) {
661 const auto hitsAndFractions = scRef->hitsAndFractions();
662 for (
auto&& hitFractionPair : hitsAndFractions) {
666 if (
ecalRecHit->checkFlag(EcalRecHit::Flags::kSaturated)) {
669 isSeedSaturated =
true;
675 newCandidate.setSaturationInfo(saturationInfo);
679 full5x5_showerShape.
e1x5 = full5x5_e1x5;
680 full5x5_showerShape.
e2x5 = full5x5_e2x5;
681 full5x5_showerShape.
e3x3 = full5x5_e3x3;
682 full5x5_showerShape.
e5x5 = full5x5_e5x5;
684 full5x5_showerShape.
sigmaEtaEta = full5x5_sigmaEtaEta;
687 const float full5x5_spp = (!
edm::isFinite(full5x5_locCov[2]) ? 0. :
sqrt(full5x5_locCov[2]));
688 const float full5x5_sep = full5x5_locCov[1];
692 full5x5_showerShape.
eTop =
694 full5x5_showerShape.
eLeft =
696 full5x5_showerShape.
eRight =
700 full5x5_showerShape.
e1x3 =
702 full5x5_showerShape.
e2x2 =
720 full5x5_showerShape.
smMajor = 0.f;
721 full5x5_showerShape.
smMinor = 0.f;
722 full5x5_showerShape.
smAlpha = 0.f;
726 newCandidate.full5x5_setShowerShapeVariables(full5x5_showerShape);
750 newCandidate.setP4(
p4);
754 fiducialFlags.
isEE =
true;
755 newCandidate.setFiducialVolumeFlags(fiducialFlags);
767 newCandidate.setMIPVariables(mipVar);
771 bool isLooseEM =
true;
772 if (newCandidate.pt() <
highEt_) {
773 if (newCandidate.hadronicOverEm() >= preselCutValues[1])
775 if (newCandidate.ecalRecHitSumEtConeDR04() > preselCutValues[2] + preselCutValues[3] * newCandidate.pt())
777 if (newCandidate.hcalTowerSumEtConeDR04() > preselCutValues[4] + preselCutValues[5] * newCandidate.pt())
779 if (newCandidate.nTrkSolidConeDR04() >
int(preselCutValues[6]))
781 if (newCandidate.nTrkHollowConeDR04() >
int(preselCutValues[7]))
783 if (newCandidate.trkSumPtSolidConeDR04() > preselCutValues[8])
785 if (newCandidate.trkSumPtHollowConeDR04() > preselCutValues[9])
787 if (newCandidate.sigmaIetaIeta() > preselCutValues[10])
813 std::vector<double> preselCutValues;
815 for (
unsigned int lSC = 0; lSC < photonHandle->size(); lSC++) {
819 DetId::Detector thedet = scRef->seed()->hitsAndFractions()[0].first.det();
820 int subdet = scRef->seed()->hitsAndFractions()[0].first.subdetId();
828 edm::LogWarning(
"") <<
"GEDPhotonProducer: do not know if it is a barrel or endcap SuperCluster" << thedet <<
' '
834 ptFast(parentSCRef->energy(), parentSCRef->position(),
math::XYZPoint(0, 0, 0)) <= preselCutValues[0])