53 std::vector<const reco::PFCluster *> &,
58 unsigned plane)
const;
127 std::vector<reco::ConversionRefVector>
pfConv_;
148 using namespace reco;
160 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfChargedHadrons"));
161 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfPhotons"));
162 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfNeutralHadrons"));
179 hOverEConeSize_ = iConfig.
getParameter<
double>(
"hOverEConeSize");
181 if (iConfig.
exists(
"emptyIsOk"))
186 ecalMustacheSCParametersToken_ = esConsumes<EcalMustacheSCParameters, EcalMustacheSCParametersRcd>();
188 produces<reco::BasicClusterCollection>(PFBasicClusterCollection_);
189 produces<reco::PreshowerClusterCollection>(PFPreshowerClusterCollection_);
190 produces<reco::SuperClusterCollection>(PFSuperClusterCollection_);
191 produces<reco::PhotonCoreCollection>(PFPhotonCoreCollection_);
192 produces<reco::PhotonCollection>(PFPhotonCollection_);
193 produces<reco::ConversionCollection>(PFConversionCollection_);
200 mustacheSCParams_ = &iSetup.
getData(ecalMustacheSCParametersToken_);
202 auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
204 auto psClusters_p = std::make_unique<reco::PreshowerClusterCollection>();
215 outputSuperClusterCollection.clear();
216 outputOneLegConversionCollection.clear();
217 outputPhotonCoreCollection.clear();
224 iEvent.getByLabel(EGPhotonCollection_, egPhotons);
229 for (
size_t j = 0;
j < inputTagIsoVals_.size(); ++
j) {
234 photPFCandidateIndex_.clear();
235 basicClusters_.clear();
237 preshowerClusters_.clear();
238 superClusters_.clear();
239 basicClusterPtr_.clear();
240 preshowerClusterPtr_.clear();
241 CandidatePtr_.clear();
243 egPhotonRef_.clear();
244 pfPhotonMva_.clear();
245 energyRegression_.clear();
246 energyRegressionError_.clear();
248 pfSingleLegConv_.clear();
249 pfSingleLegConvMva_.clear();
250 conv1legPFCandidateIndex_.clear();
251 conv2legPFCandidateIndex_.clear();
261 unsigned iconv1leg = 0;
262 unsigned iconv2leg = 0;
264 for (
unsigned i = 0;
i < ncand; ++
i) {
269 if (
cand.mva_nothing_gamma() > 0.001)
275 if (!
cand.photonExtraRef()->conversionRef().empty()) {
279 for (
unsigned int iconv = 0; iconv < doubleLegConvColl.
size(); iconv++) {
280 pfConv_[iconv2leg].push_back(doubleLegConvColl[iconv]);
283 conv2legPFCandidateIndex_.push_back(iconv2leg);
286 conv2legPFCandidateIndex_.push_back(-1);
288 const std::vector<reco::TrackRef> &singleLegConvColl =
cand.photonExtraRef()->singleLegConvTrackRef();
289 const std::vector<float> &singleLegConvCollMva =
cand.photonExtraRef()->singleLegConvMva();
293 if (!singleLegConvColl.empty()) {
294 pfSingleLegConv_.push_back(std::vector<reco::TrackRef>());
295 pfSingleLegConvMva_.push_back(std::vector<float>());
298 for (
unsigned int itk = 0; itk < singleLegConvColl.size(); itk++) {
301 pfSingleLegConv_[iconv1leg].push_back(singleLegConvColl[itk]);
302 pfSingleLegConvMva_[iconv1leg].push_back(singleLegConvCollMva[itk]);
305 conv1legPFCandidateIndex_.push_back(iconv1leg);
309 conv1legPFCandidateIndex_.push_back(-1);
312 photPFCandidateIndex_.push_back(
i);
313 pfPhotonMva_.push_back(
cand.mva_nothing_gamma());
314 energyRegression_.push_back(
cand.photonExtraRef()->MVAGlobalCorrE());
315 energyRegressionError_.push_back(
cand.photonExtraRef()->MVAGlobalCorrEError());
317 pfClusters_.push_back(std::vector<const reco::PFCluster *>());
322 CandidatePtr_.push_back(ptrToPFPhoton);
323 egSCRef_.push_back(
cand.superClusterRef());
327 for (reco::PhotonCollection::const_iterator gamIter = egPhotons->begin(); gamIter != egPhotons->end(); ++gamIter) {
328 if (
cand.superClusterRef() == gamIter->superCluster()) {
330 egPhotonRef_.push_back(PhotRef);
337 for (
unsigned iele = 0; iele <
cand.elementsInBlocks().size(); ++iele) {
341 unsigned elementIndex =
cand.elementsInBlocks()[iele].second;
356 createBasicCluster(pfbe, basicClusters_[iphot], pfClusters_[iphot], correspondingDaughterCandidate(
cand, pfbe));
360 createPreshowerCluster(pfbe, preshowerClusters_[iphot], 1);
364 createPreshowerCluster(pfbe, preshowerClusters_[iphot], 2);
370 basicClusters_p->insert(basicClusters_p->end(), basicClusters_[iphot].begin(), basicClusters_[iphot].end());
372 psClusters_p->insert(psClusters_p->end(), preshowerClusters_[iphot].begin(), preshowerClusters_[iphot].end());
388 createBasicClusterPtrs(bcRefProd);
390 createPreshowerClusterPtrs(psRefProd);
395 createSuperClusters(*
pfCandidates, outputSuperClusterCollection);
400 auto superClusters_p = std::make_unique<reco::SuperClusterCollection>(outputSuperClusterCollection);
415 createOneLegConversions(scRefProd, outputOneLegConversionCollection);
417 auto SingleLeg_p = std::make_unique<reco::ConversionCollection>(outputOneLegConversionCollection);
437 createPhotonCores(scRefProd, ConvRefProd, outputPhotonCoreCollection);
442 auto photonCores_p = std::make_unique<reco::PhotonCoreCollection>(outputPhotonCoreCollection);
478 bool validVertex =
true;
479 iEvent.getByLabel(vertexProducer_, vertexHandle);
481 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection "
586 if (!
found && !emptyIsOk_) {
587 std::ostringstream
err;
588 err <<
" cannot get PFCandidates: " <<
tag << std::endl;
599 std::vector<const reco::PFCluster *> &pfClusters,
602 if (myPFClusterRef.
isNull())
606 pfClusters.push_back(&myPFCluster);
617 myPFCluster.
seed()));
622 unsigned plane)
const {
625 myPFClusterRef->energy(), myPFClusterRef->position(), myPFClusterRef->hitsAndFractions(), plane));
630 unsigned size = photPFCandidateIndex_.size();
631 unsigned basicClusterCounter = 0;
632 basicClusterPtr_.resize(
size);
634 for (
unsigned iphot = 0; iphot <
size; ++iphot)
636 unsigned nbc = basicClusters_[iphot].size();
637 for (
unsigned ibc = 0; ibc < nbc; ++ibc)
641 basicClusterPtr_[iphot].push_back(bcPtr);
642 ++basicClusterCounter;
649 unsigned size = photPFCandidateIndex_.size();
650 unsigned psClusterCounter = 0;
651 preshowerClusterPtr_.resize(
size);
653 for (
unsigned iphot = 0; iphot <
size; ++iphot)
655 unsigned nbc = preshowerClusters_[iphot].size();
656 for (
unsigned ibc = 0; ibc < nbc; ++ibc)
660 preshowerClusterPtr_[iphot].push_back(psPtr);
668 unsigned nphot = photPFCandidateIndex_.size();
669 for (
unsigned iphot = 0; iphot < nphot; ++iphot) {
673 double sclusterE = 0;
678 unsigned nbasics = basicClusters_[iphot].size();
679 for (
unsigned ibc = 0; ibc < nbasics; ++ibc) {
682 double e = basicClusters_[iphot][ibc].energy();
684 posX +=
e * basicClusters_[iphot][ibc].position().X();
685 posY +=
e * basicClusters_[iphot][ibc].position().Y();
686 posZ +=
e * basicClusters_[iphot][ibc].position().Z();
702 double correctedEnergy = pfCand[photPFCandidateIndex_[iphot]].ecalEnergy();
709 mySuperCluster.
setSeed(basicClusterPtr_[iphot][0]);
720 for (
unsigned ibc = 0; ibc < nbasics; ++ibc) {
721 mySuperCluster.
addCluster(basicClusterPtr_[iphot][ibc]);
723 const std::vector<std::pair<DetId, float> > &v1 = basicClusters_[iphot][ibc].hitsAndFractions();
725 for (
std::vector<std::pair<DetId, float> >::const_iterator diIt = v1.begin(); diIt != v1.end(); ++diIt) {
731 unsigned nps = preshowerClusterPtr_[iphot].size();
732 for (
unsigned ips = 0; ips < nps; ++ips) {
738 pfCand[photPFCandidateIndex_[iphot]].pS2Energy());
758 unsigned nphot = photPFCandidateIndex_.size();
759 for (
unsigned iphot = 0; iphot < nphot; ++iphot) {
763 if (conv1legPFCandidateIndex_[iphot] > -1) {
764 for (
unsigned iConv = 0; iConv < pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++) {
766 std::vector<reco::CaloClusterPtr> matchingBC;
769 new reco::Vertex(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerPosition(),
error);
774 std::vector<reco::TrackRef> OneLegConvVector;
775 OneLegConvVector.push_back(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]);
777 std::vector<reco::TrackRef> tr = OneLegConvVector;
778 std::vector<math::XYZPointF> trackPositionAtEcalVec;
779 std::vector<math::XYZPointF> innPointVec;
780 std::vector<math::XYZVectorF> trackPinVec;
781 std::vector<math::XYZVectorF> trackPoutVec;
783 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->outerPosition().
X(),
784 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->outerPosition().
Y(),
785 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->outerPosition().
Z());
786 math::XYZPointF innPoint(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerPosition().
X(),
787 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerPosition().
Y(),
788 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerPosition().
Z());
789 math::XYZVectorF trackPin(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerMomentum().
X(),
790 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerMomentum().
Y(),
791 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerMomentum().
Z());
792 math::XYZVectorF trackPout(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->outerMomentum().
X(),
793 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->outerMomentum().
Y(),
794 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->outerMomentum().
Z());
795 float DCA = pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->d0();
796 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
797 innPointVec.push_back(innPoint);
798 trackPinVec.push_back(trackPin);
799 trackPoutVec.push_back(trackPout);
800 std::vector<float> OneLegMvaVector;
803 trackPositionAtEcalVec,
810 pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv],
812 OneLegMvaVector.push_back(pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv]);
829 oneLegConversions.push_back(myOneLegConversion);
842 unsigned nphot = photPFCandidateIndex_.size();
844 unsigned i1legtot = 0;
846 for (
unsigned iphot = 0; iphot < nphot; ++iphot) {
868 if (conv1legPFCandidateIndex_[iphot] > -1) {
869 for (
unsigned int iConv = 0; iConv < pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++) {
894 if (conv2legPFCandidateIndex_[iphot] > -1) {
895 for (
unsigned int iConv = 0; iConv < pfConv_[conv2legPFCandidateIndex_[iphot]].size(); iConv++) {
918 photonCores.push_back(myPhotonCore);
931 unsigned nphot = photPFCandidateIndex_.size();
933 for (
unsigned iphot = 0; iphot < nphot; ++iphot) {
946 math::XYZVector P3 = direction.unit() * PCref->parentSuperCluster()->energy();
947 LorentzVector P4(P3.x(), P3.y(), P3.z(), PCref->parentSuperCluster()->energy());
949 reco::Photon myPhoton(P4, PCref->parentSuperCluster()->position(), PCref,
vtx);
958 showerShape.e1x5 = egPhotonRef_[iphot]->e1x5();
959 showerShape.e2x5 = egPhotonRef_[iphot]->e2x5();
960 showerShape.e3x3 = egPhotonRef_[iphot]->e3x3();
961 showerShape.e5x5 = egPhotonRef_[iphot]->e5x5();
962 showerShape.maxEnergyXtal = egPhotonRef_[iphot]->maxEnergyXtal();
963 showerShape.sigmaEtaEta = egPhotonRef_[iphot]->sigmaEtaEta();
964 showerShape.sigmaIetaIeta = egPhotonRef_[iphot]->sigmaIetaIeta();
965 showerShape.hcalDepth1OverEcal = egPhotonRef_[iphot]->hadronicDepth1OverEm();
966 showerShape.hcalDepth2OverEcal = egPhotonRef_[iphot]->hadronicDepth2OverEm();
967 myPhoton.setShowerShapeVariables(showerShape);
969 saturationInfo.
nSaturatedXtals = egPhotonRef_[iphot]->nSaturatedXtals();
970 saturationInfo.
isSeedSaturated = egPhotonRef_[iphot]->isSeedSaturated();
971 myPhoton.setSaturationInfo(saturationInfo);
973 fiducialFlags.
isEB = egPhotonRef_[iphot]->isEB();
974 fiducialFlags.
isEE = egPhotonRef_[iphot]->isEE();
975 fiducialFlags.
isEBEtaGap = egPhotonRef_[iphot]->isEBEtaGap();
976 fiducialFlags.
isEBPhiGap = egPhotonRef_[iphot]->isEBPhiGap();
977 fiducialFlags.
isEERingGap = egPhotonRef_[iphot]->isEERingGap();
978 fiducialFlags.
isEEDeeGap = egPhotonRef_[iphot]->isEEDeeGap();
979 fiducialFlags.
isEBEEGap = egPhotonRef_[iphot]->isEBEEGap();
980 myPhoton.setFiducialVolumeFlags(fiducialFlags);
982 isolationVariables03.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR03();
983 isolationVariables03.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR03();
984 isolationVariables03.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR03();
985 isolationVariables03.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR03();
986 isolationVariables03.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR03();
987 isolationVariables03.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR03();
988 isolationVariables03.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR03();
989 isolationVariables03.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR03();
990 isolationVariables04.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR04();
991 isolationVariables04.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR04();
992 isolationVariables04.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR04();
993 isolationVariables04.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR04();
994 isolationVariables04.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR04();
995 isolationVariables04.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR04();
996 isolationVariables04.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR04();
997 isolationVariables04.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR04();
998 myPhoton.setIsolationVariables(isolationVariables04, isolationVariables03);
1004 myPhoton.setPflowIsolationVariables(myPFIso);
1011 myPFVariables.
mva = pfPhotonMva_[iphot];
1012 myPhoton.setPflowIDVariables(myPFVariables);
1017 myPhoton.setCorrectedEnergy(
1082 unsigned refindex = pfbe.
index();
1087 for (; myDaughterCandidate != itend; ++myDaughterCandidate) {
1095 return *myPFCandidate;