49 #include <Math/VectorUtil.h>
51 #include "TLorentzVector.h"
58 using namespace ROOT::Math::VectorUtil;
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 std::auto_ptr<reco::BasicClusterCollection>
115 std::auto_ptr<reco::PreshowerClusterCollection>
128 outputSuperClusterCollection.clear();
129 outputOneLegConversionCollection.clear();
130 outputPhotonCoreCollection.clear();
131 outputPhotonCollection.clear();
135 bool status=fetchCandidateCollection(pfCandidates,
136 inputTagPFCandidates_,
140 iEvent.
getByLabel(EGPhotonCollection_, egPhotons);
147 for (
size_t j = 0;
j<inputTagIsoVals_.size(); ++
j) {
148 iEvent.
getByLabel(inputTagIsoVals_[
j], isolationValues[j]);
153 photPFCandidateIndex_.clear();
154 basicClusters_.clear();
156 preshowerClusters_.clear();
157 superClusters_.clear();
158 basicClusterPtr_.clear();
159 preshowerClusterPtr_.clear();
160 CandidatePtr_.clear();
162 egPhotonRef_.clear();
163 pfPhotonMva_.clear();
164 energyRegression_.clear();
165 energyRegressionError_.clear();
167 pfSingleLegConv_.clear();
168 pfSingleLegConvMva_.clear();
169 conv1legPFCandidateIndex_.clear();
170 conv2legPFCandidateIndex_.clear();
177 unsigned ncand=(
status)?pfCandidates->size():0;
180 unsigned iconv1leg=0;
181 unsigned iconv2leg=0;
183 for(
unsigned i=0;
i<ncand; ++
i ) {
188 if(cand. mva_nothing_gamma()>0.001)
200 for (
unsigned int iconv=0; iconv<doubleLegConvColl.
size(); iconv++){
201 pfConv_[iconv2leg].push_back(doubleLegConvColl[iconv]);
204 conv2legPFCandidateIndex_.push_back(iconv2leg);
207 else conv2legPFCandidateIndex_.push_back(-1);
209 const std::vector<reco::TrackRef> & singleLegConvColl = cand.
photonExtraRef()->singleLegConvTrackRef();
210 const std::vector<float>& singleLegConvCollMva = cand.
photonExtraRef()->singleLegConvMva();
214 if (singleLegConvColl.size()>0){
216 pfSingleLegConv_.push_back(std::vector<reco::TrackRef>());
217 pfSingleLegConvMva_.push_back(std::vector<float>());
220 for (
unsigned int itk=0; itk<singleLegConvColl.size(); itk++){
223 pfSingleLegConv_[iconv1leg].push_back(singleLegConvColl[itk]);
224 pfSingleLegConvMva_[iconv1leg].push_back(singleLegConvCollMva[itk]);
228 conv1legPFCandidateIndex_.push_back(iconv1leg);
232 else conv1legPFCandidateIndex_.push_back(-1);
236 photPFCandidateIndex_.push_back(
i);
238 energyRegression_.push_back(cand.
photonExtraRef()->MVAGlobalCorrE());
239 energyRegressionError_.push_back(cand.
photonExtraRef()->MVAGlobalCorrEError());
241 pfClusters_.push_back(std::vector<const reco::PFCluster *>());
246 CandidatePtr_.push_back(ptrToPFPhoton);
251 for (reco::PhotonCollection::const_iterator gamIter = egPhotons->begin(); gamIter != egPhotons->end(); ++gamIter){
254 egPhotonRef_.push_back(PhotRef);
268 if(blockRef.
isNull())
continue;
282 createBasicCluster(pfbe,basicClusters_[iphot],pfClusters_[iphot],correspondingDaughterCandidate(cand,pfbe));
287 createPreshowerCluster(pfbe,preshowerClusters_[iphot],1);
292 createPreshowerCluster(pfbe,preshowerClusters_[iphot],2);
299 basicClusters_p->insert(basicClusters_p->end(),basicClusters_[iphot].begin(), basicClusters_[iphot].end());
301 psClusters_p->insert(psClusters_p->end(),preshowerClusters_[iphot].begin(),preshowerClusters_[iphot].end());
311 iEvent.
put(basicClusters_p,PFBasicClusterCollection_);
315 iEvent.
put(psClusters_p,PFPreshowerClusterCollection_);
318 createBasicClusterPtrs(bcRefProd);
320 createPreshowerClusterPtrs(psRefProd);
324 if(status) createSuperClusters(*pfCandidates,outputSuperClusterCollection);
345 if (status) createOneLegConversions(scRefProd, outputOneLegConversionCollection);
366 if(status) createPhotonCores(scRefProd, ConvRefProd, outputPhotonCoreCollection);
406 bool validVertex=
true;
407 iEvent.
getByLabel(vertexProducer_, vertexHandle);
409 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
412 if (validVertex) vertexCollection = *(vertexHandle.
product());
449 if(status) createPhotons(vertexCollection, egPhotons, pcRefProd, isolationValues, outputPhotonCollection);
512 if(!found && !emptyIsOk_)
514 std::ostringstream err;
515 err<<
" cannot get PFCandidates: "
528 std::vector<const reco::PFCluster *> & pfClusters,
532 if(myPFClusterRef.
isNull())
return;
535 pfClusters.push_back(&myPFCluster);
546 myPFCluster.
seed()));
553 myPFClusterRef->hitsAndFractions(),plane));
558 unsigned size=photPFCandidateIndex_.size();
559 unsigned basicClusterCounter=0;
560 basicClusterPtr_.resize(size);
562 for(
unsigned iphot=0;iphot<
size;++iphot)
564 unsigned nbc=basicClusters_[iphot].size();
565 for(
unsigned ibc=0;ibc<nbc;++ibc)
569 basicClusterPtr_[iphot].push_back(bcPtr);
570 ++basicClusterCounter;
577 unsigned size=photPFCandidateIndex_.size();
578 unsigned psClusterCounter=0;
579 preshowerClusterPtr_.resize(size);
581 for(
unsigned iphot=0;iphot<
size;++iphot)
583 unsigned nbc=preshowerClusters_[iphot].size();
584 for(
unsigned ibc=0;ibc<nbc;++ibc)
588 preshowerClusterPtr_[iphot].push_back(psPtr);
597 unsigned nphot=photPFCandidateIndex_.size();
598 for(
unsigned iphot=0;iphot<nphot;++iphot)
609 unsigned nbasics=basicClusters_[iphot].size();
610 for(
unsigned ibc=0;ibc<nbasics;++ibc)
614 double e = basicClusters_[iphot][ibc].energy();
616 posX += e * basicClusters_[iphot][ibc].position().X();
617 posY += e * basicClusters_[iphot][ibc].position().Y();
618 posZ += e * basicClusters_[iphot][ibc].position().Z();
634 double correctedEnergy=pfCand[photPFCandidateIndex_[iphot]].ecalEnergy();
642 mySuperCluster.
setSeed(basicClusterPtr_[iphot][0]);
655 for(
unsigned ibc=0;ibc<nbasics;++ibc)
657 mySuperCluster.
addCluster(basicClusterPtr_[iphot][ibc]);
659 const std::vector< std::pair<DetId, float> > & v1 = basicClusters_[iphot][ibc].hitsAndFractions();
661 for( std::vector< std::pair<DetId, float> >::const_iterator diIt = v1.begin();
669 unsigned nps=preshowerClusterPtr_[iphot].size();
670 for(
unsigned ips=0;ips<nps;++ips)
678 pfCand[photPFCandidateIndex_[iphot]].pS2Energy());
688 superClusters.push_back(mySuperCluster);
698 unsigned nphot=photPFCandidateIndex_.size();
699 for(
unsigned iphot=0;iphot<nphot;++iphot)
706 if (conv1legPFCandidateIndex_[iphot]>-1){
708 for (
unsigned iConv=0; iConv<pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++){
711 std::vector<reco::CaloClusterPtr>matchingBC;
713 const reco::Vertex * convVtx =
new reco::Vertex(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerPosition(), error);
718 std::vector<reco::TrackRef> OneLegConvVector;
719 OneLegConvVector.push_back(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]);
722 std::vector<reco::TrackRef> tr=OneLegConvVector;
723 std::vector<math::XYZPointF>trackPositionAtEcalVec;
724 std::vector<math::XYZPointF>innPointVec;
725 std::vector<math::XYZVectorF>trackPinVec;
726 std::vector<math::XYZVectorF>trackPoutVec;
727 math::XYZPointF trackPositionAtEcal(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
729 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
731 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
732 outerPosition().
Z());
733 math::XYZPointF innPoint(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
735 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
737 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
738 innerPosition().
Z());
739 math::XYZVectorF trackPin(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
741 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
743 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
744 innerMomentum().
Z());
745 math::XYZVectorF trackPout(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
747 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
749 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
750 outerMomentum().
Z());
751 float DCA=pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->d0();
752 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
753 innPointVec.push_back(innPoint);
754 trackPinVec.push_back(trackPin);
755 trackPoutVec.push_back(trackPout);
756 std::vector< float > OneLegMvaVector;
759 trackPositionAtEcalVec,
766 pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv],
768 OneLegMvaVector.push_back(pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv]);
785 oneLegConversions.push_back(myOneLegConversion);
800 unsigned nphot=photPFCandidateIndex_.size();
802 unsigned i1legtot = 0;
804 for(
unsigned iphot=0;iphot<nphot;++iphot)
827 if (conv1legPFCandidateIndex_[iphot]>-1){
828 for (
unsigned int iConv=0; iConv<pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++){
854 if (conv2legPFCandidateIndex_[iphot]>-1){
855 for(
unsigned int iConv=0; iConv<pfConv_[conv2legPFCandidateIndex_[iphot]].size(); iConv++) {
880 photonCores.push_back(myPhotonCore);
893 unsigned nphot=photPFCandidateIndex_.size();
895 for(
unsigned iphot=0;iphot<nphot;++iphot)
902 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
905 math::XYZVector direction = PCref->parentSuperCluster()->position() - vtx;
908 math::XYZVector P3 = direction.unit() * PCref->parentSuperCluster()->energy();
909 LorentzVector P4(P3.x(), P3.y(), P3.z(), PCref->parentSuperCluster()->energy());
911 reco::Photon myPhoton(P4, PCref->parentSuperCluster()->position(), PCref, vtx);
921 showerShape.e1x5= egPhotonRef_[iphot]->e1x5();
922 showerShape.e2x5= egPhotonRef_[iphot]->e2x5();
923 showerShape.e3x3= egPhotonRef_[iphot]->e3x3();
924 showerShape.e5x5= egPhotonRef_[iphot]->e5x5();
925 showerShape.maxEnergyXtal = egPhotonRef_[iphot]->maxEnergyXtal();
926 showerShape.sigmaEtaEta = egPhotonRef_[iphot]->sigmaEtaEta();
927 showerShape.sigmaIetaIeta = egPhotonRef_[iphot]->sigmaIetaIeta();
928 showerShape.hcalDepth1OverEcal = egPhotonRef_[iphot]->hadronicDepth1OverEm();
929 showerShape.hcalDepth2OverEcal = egPhotonRef_[iphot]->hadronicDepth2OverEm();
930 myPhoton.setShowerShapeVariables ( showerShape );
932 fiducialFlags.
isEB = egPhotonRef_[iphot]->isEB();
933 fiducialFlags.
isEE = egPhotonRef_[iphot]->isEE();
934 fiducialFlags.
isEBEtaGap = egPhotonRef_[iphot]->isEBEtaGap();
935 fiducialFlags.
isEBPhiGap = egPhotonRef_[iphot]->isEBPhiGap();
936 fiducialFlags.
isEERingGap = egPhotonRef_[iphot]->isEERingGap();
937 fiducialFlags.
isEEDeeGap = egPhotonRef_[iphot]->isEEDeeGap();
938 fiducialFlags.
isEBEEGap = egPhotonRef_[iphot]->isEBEEGap();
939 myPhoton.setFiducialVolumeFlags ( fiducialFlags );
941 isolationVariables03.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR03();
942 isolationVariables03.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR03();
943 isolationVariables03.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR03();
944 isolationVariables03.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR03();
945 isolationVariables03.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR03();
946 isolationVariables03.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR03();
947 isolationVariables03.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR03();
948 isolationVariables03.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR03();
949 isolationVariables04.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR04();
950 isolationVariables04.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR04();
951 isolationVariables04.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR04();
952 isolationVariables04.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR04();
953 isolationVariables04.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR04();
954 isolationVariables04.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR04();
955 isolationVariables04.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR04();
956 isolationVariables04.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR04();
957 myPhoton.setIsolationVariables(isolationVariables04, isolationVariables03);
964 myPFIso.
photonIso=(*isolationValues[1])[CandidatePtr_[iphot]];
966 myPhoton.setPflowIsolationVariables(myPFIso);
972 myPFVariables.
mva = pfPhotonMva_[iphot];
973 myPhoton.setPflowIDVariables(myPFVariables);
1036 photons.push_back(myPhoton);
1046 unsigned refindex=pfbe.
index();
1051 for(;myDaughterCandidate!=itend;++myDaughterCandidate)
1062 return *myPFCandidate;
const double Z[kNumberCalorimeter]
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)
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
ROOT::Math::Plane3D::Vector Vector
virtual const_iterator end() const
last daughter const_iterator
math::XYZTLorentzVector LorentzVector
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
std::vector< PFCandidatePtr > pfCandidates(const PFJet &jet, int particleId, bool sort=true)
AlgoId algo() const
algorithm identifier
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
void setEtaWidth(double ew)
bool isNull() const
Checks for null.
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)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
PFPhotonTranslator(const edm::ParameterSet &)
virtual const_iterator begin() const
first daughter const_iterator
virtual PFClusterRef clusterRef() const
std::vector< PreshowerCluster > PreshowerClusterCollection
collection of PreshowerCluster objects
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
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
XYZVectorD XYZVector
spatial vector with cartesian internal representation
XYZPointD XYZPoint
point in space with cartesian internal representation
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
std::vector< Photon > PhotonCollection
collectin of Photon objects
void createOneLegConversions(const edm::OrphanHandle< reco::SuperClusterCollection > &superClustersHandle, reco::ConversionCollection &oneLegConversions)
T const * product() const
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
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
tuple size
Write out results.
int nClusterOutsideMustache
math::PtEtaPhiELorentzVectorF LorentzVector
void setPreshowerEnergy(double preshowerEnergy)
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any