49 #include <Math/VectorUtil.h> 51 #include "TLorentzVector.h" 72 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfChargedHadrons"));
73 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfPhotons"));
74 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfNeutralHadrons"));
92 hOverEConeSize_ = iConfig.
getParameter<
double>(
"hOverEConeSize");
95 else emptyIsOk_=
false;
97 produces<reco::BasicClusterCollection>(PFBasicClusterCollection_);
98 produces<reco::PreshowerClusterCollection>(PFPreshowerClusterCollection_);
99 produces<reco::SuperClusterCollection>(PFSuperClusterCollection_);
100 produces<reco::PhotonCoreCollection>(PFPhotonCoreCollection_);
101 produces<reco::PhotonCollection>(PFPhotonCollection_);
102 produces<reco::ConversionCollection>(PFConversionCollection_);
112 auto basicClusters_p = std::make_unique<reco::BasicClusterCollection>();
114 auto psClusters_p = std::make_unique<reco::PreshowerClusterCollection>();
125 outputSuperClusterCollection.clear();
126 outputOneLegConversionCollection.clear();
127 outputPhotonCoreCollection.clear();
128 outputPhotonCollection.clear();
132 bool status=fetchCandidateCollection(pfCandidates,
133 inputTagPFCandidates_,
137 iEvent.
getByLabel(EGPhotonCollection_, egPhotons);
144 for (
size_t j = 0; j<inputTagIsoVals_.size(); ++j) {
150 photPFCandidateIndex_.clear();
151 basicClusters_.clear();
153 preshowerClusters_.clear();
154 superClusters_.clear();
155 basicClusterPtr_.clear();
156 preshowerClusterPtr_.clear();
157 CandidatePtr_.clear();
159 egPhotonRef_.clear();
160 pfPhotonMva_.clear();
161 energyRegression_.clear();
162 energyRegressionError_.clear();
164 pfSingleLegConv_.clear();
165 pfSingleLegConvMva_.clear();
166 conv1legPFCandidateIndex_.clear();
167 conv2legPFCandidateIndex_.clear();
174 unsigned ncand=(
status)?pfCandidates->size():0;
177 unsigned iconv1leg=0;
178 unsigned iconv2leg=0;
180 for(
unsigned i=0;
i<ncand; ++
i ) {
185 if(cand. mva_nothing_gamma()>0.001)
197 for (
unsigned int iconv=0; iconv<doubleLegConvColl.
size(); iconv++){
198 pfConv_[iconv2leg].push_back(doubleLegConvColl[iconv]);
201 conv2legPFCandidateIndex_.push_back(iconv2leg);
204 else conv2legPFCandidateIndex_.push_back(-1);
206 const std::vector<reco::TrackRef> & singleLegConvColl = cand.
photonExtraRef()->singleLegConvTrackRef();
207 const std::vector<float>& singleLegConvCollMva = cand.
photonExtraRef()->singleLegConvMva();
211 if (singleLegConvColl.size()>0){
213 pfSingleLegConv_.push_back(std::vector<reco::TrackRef>());
214 pfSingleLegConvMva_.push_back(std::vector<float>());
217 for (
unsigned int itk=0; itk<singleLegConvColl.size(); itk++){
220 pfSingleLegConv_[iconv1leg].push_back(singleLegConvColl[itk]);
221 pfSingleLegConvMva_[iconv1leg].push_back(singleLegConvCollMva[itk]);
225 conv1legPFCandidateIndex_.push_back(iconv1leg);
229 else conv1legPFCandidateIndex_.push_back(-1);
233 photPFCandidateIndex_.push_back(
i);
235 energyRegression_.push_back(cand.
photonExtraRef()->MVAGlobalCorrE());
236 energyRegressionError_.push_back(cand.
photonExtraRef()->MVAGlobalCorrEError());
238 pfClusters_.push_back(std::vector<const reco::PFCluster *>());
243 CandidatePtr_.push_back(ptrToPFPhoton);
248 for (reco::PhotonCollection::const_iterator gamIter = egPhotons->begin(); gamIter != egPhotons->end(); ++gamIter){
251 egPhotonRef_.push_back(PhotRef);
265 if(blockRef.
isNull())
continue;
279 createBasicCluster(pfbe,basicClusters_[iphot],pfClusters_[iphot],correspondingDaughterCandidate(cand,pfbe));
284 createPreshowerCluster(pfbe,preshowerClusters_[iphot],1);
289 createPreshowerCluster(pfbe,preshowerClusters_[iphot],2);
296 basicClusters_p->insert(basicClusters_p->end(),basicClusters_[iphot].begin(), basicClusters_[iphot].end());
298 psClusters_p->insert(psClusters_p->end(),preshowerClusters_[iphot].begin(),preshowerClusters_[iphot].end());
308 iEvent.
put(
std::move(basicClusters_p),PFBasicClusterCollection_);
312 iEvent.
put(
std::move(psClusters_p),PFPreshowerClusterCollection_);
315 createBasicClusterPtrs(bcRefProd);
317 createPreshowerClusterPtrs(psRefProd);
321 if(status) createSuperClusters(*pfCandidates,outputSuperClusterCollection);
326 auto superClusters_p = std::make_unique<reco::SuperClusterCollection>(outputSuperClusterCollection);
342 if (status) createOneLegConversions(scRefProd, outputOneLegConversionCollection);
345 auto SingleLeg_p = std::make_unique<reco::ConversionCollection>(outputOneLegConversionCollection);
363 if(status) createPhotonCores(scRefProd, ConvRefProd, outputPhotonCoreCollection);
368 auto photonCores_p = std::make_unique<reco::PhotonCoreCollection>(outputPhotonCoreCollection);
403 bool validVertex=
true;
404 iEvent.
getByLabel(vertexProducer_, vertexHandle);
406 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
409 if (validVertex) vertexCollection = *(vertexHandle.
product());
446 if(status) createPhotons(vertexCollection, egPhotons, pcRefProd,
isolationValues, outputPhotonCollection);
509 if(!found && !emptyIsOk_)
511 std::ostringstream err;
512 err<<
" cannot get PFCandidates: " 525 std::vector<const reco::PFCluster *> & pfClusters,
529 if(myPFClusterRef.
isNull())
return;
532 pfClusters.push_back(&myPFCluster);
543 myPFCluster.
seed()));
550 myPFClusterRef->hitsAndFractions(),plane));
555 unsigned size=photPFCandidateIndex_.size();
556 unsigned basicClusterCounter=0;
557 basicClusterPtr_.resize(size);
559 for(
unsigned iphot=0;iphot<
size;++iphot)
561 unsigned nbc=basicClusters_[iphot].size();
562 for(
unsigned ibc=0;ibc<nbc;++ibc)
566 basicClusterPtr_[iphot].push_back(bcPtr);
567 ++basicClusterCounter;
574 unsigned size=photPFCandidateIndex_.size();
575 unsigned psClusterCounter=0;
576 preshowerClusterPtr_.resize(size);
578 for(
unsigned iphot=0;iphot<
size;++iphot)
580 unsigned nbc=preshowerClusters_[iphot].size();
581 for(
unsigned ibc=0;ibc<nbc;++ibc)
585 preshowerClusterPtr_[iphot].push_back(psPtr);
594 unsigned nphot=photPFCandidateIndex_.size();
595 for(
unsigned iphot=0;iphot<nphot;++iphot)
606 unsigned nbasics=basicClusters_[iphot].size();
607 for(
unsigned ibc=0;ibc<nbasics;++ibc)
611 double e = basicClusters_[iphot][ibc].energy();
613 posX += e * basicClusters_[iphot][ibc].position().X();
614 posY += e * basicClusters_[iphot][ibc].position().Y();
615 posZ += e * basicClusters_[iphot][ibc].position().Z();
631 double correctedEnergy=pfCand[photPFCandidateIndex_[iphot]].ecalEnergy();
639 mySuperCluster.
setSeed(basicClusterPtr_[iphot][0]);
652 for(
unsigned ibc=0;ibc<nbasics;++ibc)
654 mySuperCluster.
addCluster(basicClusterPtr_[iphot][ibc]);
656 const std::vector< std::pair<DetId, float> > & v1 = basicClusters_[iphot][ibc].hitsAndFractions();
658 for( std::vector< std::pair<DetId, float> >::const_iterator diIt = v1.begin();
666 unsigned nps=preshowerClusterPtr_[iphot].size();
667 for(
unsigned ips=0;ips<nps;++ips)
675 pfCand[photPFCandidateIndex_[iphot]].pS2Energy());
685 superClusters.push_back(mySuperCluster);
695 unsigned nphot=photPFCandidateIndex_.size();
696 for(
unsigned iphot=0;iphot<nphot;++iphot)
703 if (conv1legPFCandidateIndex_[iphot]>-1){
705 for (
unsigned iConv=0; iConv<pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++){
708 std::vector<reco::CaloClusterPtr>matchingBC;
710 const reco::Vertex * convVtx =
new reco::Vertex(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerPosition(), error);
715 std::vector<reco::TrackRef> OneLegConvVector;
716 OneLegConvVector.push_back(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]);
719 std::vector<reco::TrackRef> tr=OneLegConvVector;
720 std::vector<math::XYZPointF>trackPositionAtEcalVec;
721 std::vector<math::XYZPointF>innPointVec;
722 std::vector<math::XYZVectorF>trackPinVec;
723 std::vector<math::XYZVectorF>trackPoutVec;
724 math::XYZPointF trackPositionAtEcal(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
726 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
728 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
729 outerPosition().
Z());
730 math::XYZPointF innPoint(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
732 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
734 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
735 innerPosition().
Z());
736 math::XYZVectorF trackPin(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
738 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
740 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
741 innerMomentum().
Z());
742 math::XYZVectorF trackPout(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
744 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
746 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
747 outerMomentum().
Z());
748 float DCA=pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->d0();
749 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
750 innPointVec.push_back(innPoint);
751 trackPinVec.push_back(trackPin);
752 trackPoutVec.push_back(trackPout);
753 std::vector< float > OneLegMvaVector;
756 trackPositionAtEcalVec,
763 pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv],
765 OneLegMvaVector.push_back(pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv]);
782 oneLegConversions.push_back(myOneLegConversion);
797 unsigned nphot=photPFCandidateIndex_.size();
799 unsigned i1legtot = 0;
801 for(
unsigned iphot=0;iphot<nphot;++iphot)
824 if (conv1legPFCandidateIndex_[iphot]>-1){
825 for (
unsigned int iConv=0; iConv<pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++){
851 if (conv2legPFCandidateIndex_[iphot]>-1){
852 for(
unsigned int iConv=0; iConv<pfConv_[conv2legPFCandidateIndex_[iphot]].size(); iConv++) {
877 photonCores.push_back(myPhotonCore);
890 unsigned nphot=photPFCandidateIndex_.size();
892 for(
unsigned iphot=0;iphot<nphot;++iphot)
899 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
905 math::XYZVector P3 = direction.unit() * PCref->parentSuperCluster()->energy();
906 LorentzVector P4(P3.x(), P3.y(), P3.z(), PCref->parentSuperCluster()->energy());
908 reco::Photon myPhoton(P4, PCref->parentSuperCluster()->position(), PCref,
vtx);
919 showerShape.e1x5= egPhotonRef_[iphot]->e1x5();
920 showerShape.e2x5= egPhotonRef_[iphot]->e2x5();
921 showerShape.e3x3= egPhotonRef_[iphot]->e3x3();
922 showerShape.e5x5= egPhotonRef_[iphot]->e5x5();
923 showerShape.maxEnergyXtal = egPhotonRef_[iphot]->maxEnergyXtal();
924 showerShape.sigmaEtaEta = egPhotonRef_[iphot]->sigmaEtaEta();
925 showerShape.sigmaIetaIeta = egPhotonRef_[iphot]->sigmaIetaIeta();
926 showerShape.hcalDepth1OverEcal = egPhotonRef_[iphot]->hadronicDepth1OverEm();
927 showerShape.hcalDepth2OverEcal = egPhotonRef_[iphot]->hadronicDepth2OverEm();
928 myPhoton.setShowerShapeVariables ( showerShape );
931 saturationInfo.
nSaturatedXtals = egPhotonRef_[iphot]->nSaturatedXtals();
932 saturationInfo.
isSeedSaturated = egPhotonRef_[iphot]->isSeedSaturated();
933 myPhoton.setSaturationInfo(saturationInfo);
935 fiducialFlags.
isEB = egPhotonRef_[iphot]->isEB();
936 fiducialFlags.
isEE = egPhotonRef_[iphot]->isEE();
937 fiducialFlags.
isEBEtaGap = egPhotonRef_[iphot]->isEBEtaGap();
938 fiducialFlags.
isEBPhiGap = egPhotonRef_[iphot]->isEBPhiGap();
939 fiducialFlags.
isEERingGap = egPhotonRef_[iphot]->isEERingGap();
940 fiducialFlags.
isEEDeeGap = egPhotonRef_[iphot]->isEEDeeGap();
941 fiducialFlags.
isEBEEGap = egPhotonRef_[iphot]->isEBEEGap();
942 myPhoton.setFiducialVolumeFlags ( fiducialFlags );
944 isolationVariables03.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR03();
945 isolationVariables03.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR03();
946 isolationVariables03.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR03();
947 isolationVariables03.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR03();
948 isolationVariables03.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR03();
949 isolationVariables03.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR03();
950 isolationVariables03.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR03();
951 isolationVariables03.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR03();
952 isolationVariables04.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR04();
953 isolationVariables04.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR04();
954 isolationVariables04.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR04();
955 isolationVariables04.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR04();
956 isolationVariables04.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR04();
957 isolationVariables04.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR04();
958 isolationVariables04.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR04();
959 isolationVariables04.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR04();
960 myPhoton.setIsolationVariables(isolationVariables04, isolationVariables03);
967 myPFIso.
photonIso=(*isolationValues[1])[CandidatePtr_[iphot]];
969 myPhoton.setPflowIsolationVariables(myPFIso);
975 myPFVariables.
mva = pfPhotonMva_[iphot];
976 myPhoton.setPflowIDVariables(myPFVariables);
1039 photons.push_back(myPhoton);
1049 unsigned refindex=pfbe.
index();
1054 for(;myDaughterCandidate!=itend;++myDaughterCandidate)
1065 return *myPFCandidate;
T getParameter(std::string const &) const
Abstract base class for a PFBlock element (track, cluster...)
const math::XYZPoint & position() const
cluster centroid position
float hcalDepth1TowerSumEt
void setSuperCluster(const reco::SuperClusterRef &r)
set reference to SuperCluster
void addOneLegConversion(const reco::ConversionRef &r)
add single ConversionRef to the vector of Refs
void MustacheID(const CaloClusterPtrVector &clusters, int &nclusters, float &EoutsideMustache)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
void addConversion(const reco::ConversionRef &r)
add single ConversionRef to the vector of Refs
void createBasicClusterPtrs(const edm::OrphanHandle< reco::BasicClusterCollection > &basicClustersHandle)
void addHitAndFraction(DetId id, float fraction)
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
float mva_nothing_gamma() const
mva for gamma detection
virtual const PFClusterRef & clusterRef() const
double pflowPhiWidth() const
bool exists(std::string const ¶meterName) const
checks if a parameter exists
std::vector< Vertex > VertexCollection
collection of Vertex objects
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
void setSeed(const CaloClusterPtr &r)
list of used xtals by DetId // now inherited by CaloCluster
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
void createSuperClusters(const reco::PFCandidateCollection &, reco::SuperClusterCollection &superClusters) const
reco::PFCandidatePhotonExtraRef photonExtraRef() const
return a reference to the photon extra
float hcalDepth2TowerSumEt
void setPhiWidth(double pw)
double pflowEtaWidth() const
void createBasicCluster(const reco::PFBlockElement &, reco::BasicClusterCollection &basicClusters, std::vector< const reco::PFCluster * > &, const reco::PFCandidate &coCandidate) const
std::vector< Conversion > ConversionCollection
collectin of Conversion objects
AlgoId algo() const
algorithm identifier
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void setEtaWidth(double ew)
math::XYZTLorentzVector LorentzVector
void setParentSuperCluster(const reco::SuperClusterRef &r)
set reference to PFlow SuperCluster
const CaloID & caloID() const
std::vector< SuperCluster > SuperClusterCollection
collection of SuperCluser objectr
void setStandardPhoton(const bool prov)
PFPhotonTranslator(const edm::ParameterSet &)
const_iterator end() const
last daughter const_iterator
std::vector< PreshowerCluster > PreshowerClusterCollection
collection of PreshowerCluster objects
math::XYZTLorentzVector LorentzVector
void createPhotonCores(const edm::OrphanHandle< reco::SuperClusterCollection > &superClustersHandle, const edm::OrphanHandle< reco::ConversionCollection > &oneLegConversionHandle, reco::PhotonCoreCollection &photonCores)
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< float > > XYZVectorF
spatial vector with cartesian internal representation
void createPreshowerCluster(const reco::PFBlockElement &PFBE, reco::PreshowerClusterCollection &preshowerClusters, unsigned plane) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
bool isNull() const
Checks for null.
double energy() const
cluster energy
virtual void produce(edm::Event &, const edm::EventSetup &) override
void createPreshowerClusterPtrs(const edm::OrphanHandle< reco::PreshowerClusterCollection > &preshowerClustersHandle)
bool fetchCandidateCollection(edm::Handle< reco::PFCandidateCollection > &c, const edm::InputTag &tag, const edm::Event &iEvent) const
void setPFlowPhoton(const bool prov)
set the provenance
const reco::PFCandidate & correspondingDaughterCandidate(const reco::PFCandidate &cand, const reco::PFBlockElement &pfbe) const
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
double rawEnergy() const
raw uncorrected energy (sum of energies of component BasicClusters)
DetId seed() const
return DetId of seed
T const * product() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< Photon > PhotonCollection
collectin of Photon objects
void addPreshowerCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
void createPhotons(reco::VertexCollection &vertexCollection, edm::Handle< reco::PhotonCollection > &egPhotons, const edm::OrphanHandle< reco::PhotonCoreCollection > &photonCoresHandle, const IsolationValueMaps &isolationValues, reco::PhotonCollection &photons)
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
void createOneLegConversions(const edm::OrphanHandle< reco::SuperClusterCollection > &superClustersHandle, reco::ConversionCollection &oneLegConversions)
std::vector< PhotonCore > PhotonCoreCollection
collectin of PhotonCore objects
void addCluster(const CaloClusterPtr &r)
add reference to constituent BasicCluster
Particle reconstructed by the particle flow algorithm.
void setOneLegMVA(const std::vector< float > &mva)
set the MVS output from PF for one leg conversions
const_iterator begin() const
first daughter const_iterator
size_type size() const
Size of the RefVector.
void addElectronPixelSeed(const reco::ElectronSeedRef &r)
set electron pixel seed ref
virtual ParticleType particleId() const
const ElementsInBlocks & elementsInBlocks() const
int nClusterOutsideMustache
void setPreshowerEnergy(double preshowerEnergy)
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any