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"));
77 PFBasicClusterCollection_ = iConfig.
getParameter<std::string>(
"PFBasicClusters");
78 PFPreshowerClusterCollection_ = iConfig.
getParameter<std::string>(
"PFPreshowerClusters");
79 PFSuperClusterCollection_ = iConfig.
getParameter<std::string>(
"PFSuperClusters");
80 PFConversionCollection_ = iConfig.
getParameter<std::string>(
"PFConversionCollection");
81 PFPhotonCoreCollection_ = iConfig.
getParameter<std::string>(
"PFPhotonCores");
82 PFPhotonCollection_ = iConfig.
getParameter<std::string>(
"PFPhotons");
84 EGPhotonCollection_ = iConfig.
getParameter<std::string>(
"EGPhotons");
86 vertexProducer_ = iConfig.
getParameter<std::string>(
"primaryVertexProducer");
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_);
116 std::auto_ptr<reco::BasicClusterCollection>
119 std::auto_ptr<reco::PreshowerClusterCollection>
132 outputSuperClusterCollection.clear();
133 outputOneLegConversionCollection.clear();
134 outputPhotonCoreCollection.clear();
135 outputPhotonCollection.clear();
139 bool status=fetchCandidateCollection(pfCandidates,
140 inputTagPFCandidates_,
144 iEvent.
getByLabel(EGPhotonCollection_, egPhotons);
151 for (
size_t j = 0;
j<inputTagIsoVals_.size(); ++
j) {
152 iEvent.
getByLabel(inputTagIsoVals_[
j], isolationValues[j]);
157 photPFCandidateIndex_.clear();
158 basicClusters_.clear();
160 preshowerClusters_.clear();
161 superClusters_.clear();
162 basicClusterPtr_.clear();
163 preshowerClusterPtr_.clear();
164 CandidatePtr_.clear();
166 egPhotonRef_.clear();
167 pfPhotonMva_.clear();
168 energyRegression_.clear();
169 energyRegressionError_.clear();
171 pfSingleLegConv_.clear();
172 pfSingleLegConvMva_.clear();
173 conv1legPFCandidateIndex_.clear();
174 conv2legPFCandidateIndex_.clear();
181 unsigned ncand=(
status)?pfCandidates->size():0;
184 unsigned iconv1leg=0;
185 unsigned iconv2leg=0;
187 for(
unsigned i=0;
i<ncand; ++
i ) {
192 if(cand. mva_nothing_gamma()>0.001)
204 for (
unsigned int iconv=0; iconv<doubleLegConvColl.
size(); iconv++){
205 pfConv_[iconv2leg].push_back(doubleLegConvColl[iconv]);
208 conv2legPFCandidateIndex_.push_back(iconv2leg);
211 else conv2legPFCandidateIndex_.push_back(-1);
213 const std::vector<reco::TrackRef> & singleLegConvColl = cand.
photonExtraRef()->singleLegConvTrackRef();
214 const std::vector<float>& singleLegConvCollMva = cand.
photonExtraRef()->singleLegConvMva();
218 if (singleLegConvColl.size()>0){
220 pfSingleLegConv_.push_back(std::vector<reco::TrackRef>());
221 pfSingleLegConvMva_.push_back(std::vector<float>());
224 for (
unsigned int itk=0; itk<singleLegConvColl.size(); itk++){
227 pfSingleLegConv_[iconv1leg].push_back(singleLegConvColl[itk]);
228 pfSingleLegConvMva_[iconv1leg].push_back(singleLegConvCollMva[itk]);
232 conv1legPFCandidateIndex_.push_back(iconv1leg);
236 else conv1legPFCandidateIndex_.push_back(-1);
240 photPFCandidateIndex_.push_back(
i);
242 energyRegression_.push_back(cand.
photonExtraRef()->MVAGlobalCorrE());
243 energyRegressionError_.push_back(cand.
photonExtraRef()->MVAGlobalCorrEError());
245 pfClusters_.push_back(std::vector<const reco::PFCluster *>());
250 CandidatePtr_.push_back(ptrToPFPhoton);
255 for (reco::PhotonCollection::const_iterator gamIter = egPhotons->begin(); gamIter != egPhotons->end(); ++gamIter){
258 egPhotonRef_.push_back(PhotRef);
272 if(blockRef.
isNull())
continue;
286 createBasicCluster(pfbe,basicClusters_[iphot],pfClusters_[iphot],correspondingDaughterCandidate(cand,pfbe));
291 createPreshowerCluster(pfbe,preshowerClusters_[iphot],1);
296 createPreshowerCluster(pfbe,preshowerClusters_[iphot],2);
303 basicClusters_p->insert(basicClusters_p->end(),basicClusters_[iphot].begin(), basicClusters_[iphot].end());
305 psClusters_p->insert(psClusters_p->end(),preshowerClusters_[iphot].begin(),preshowerClusters_[iphot].end());
315 iEvent.
put(basicClusters_p,PFBasicClusterCollection_);
319 iEvent.
put(psClusters_p,PFPreshowerClusterCollection_);
322 createBasicClusterPtrs(bcRefProd);
324 createPreshowerClusterPtrs(psRefProd);
328 if(status) createSuperClusters(*pfCandidates,outputSuperClusterCollection);
349 if (status) createOneLegConversions(scRefProd, outputOneLegConversionCollection);
370 if(status) createPhotonCores(scRefProd, ConvRefProd, outputPhotonCoreCollection);
410 bool validVertex=
true;
411 iEvent.
getByLabel(vertexProducer_, vertexHandle);
413 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
416 if (validVertex) vertexCollection = *(vertexHandle.
product());
453 if(status) createPhotons(vertexCollection, egPhotons, pcRefProd, isolationValues, outputPhotonCollection);
516 if(!found && !emptyIsOk_)
518 std::ostringstream err;
519 err<<
" cannot get PFCandidates: "
532 std::vector<const reco::PFCluster *> & pfClusters,
536 if(myPFClusterRef.
isNull())
return;
539 pfClusters.push_back(&myPFCluster);
550 myPFCluster.
seed()));
557 myPFClusterRef->hitsAndFractions(),plane));
562 unsigned size=photPFCandidateIndex_.size();
563 unsigned basicClusterCounter=0;
564 basicClusterPtr_.resize(size);
566 for(
unsigned iphot=0;iphot<
size;++iphot)
568 unsigned nbc=basicClusters_[iphot].size();
569 for(
unsigned ibc=0;ibc<nbc;++ibc)
573 basicClusterPtr_[iphot].push_back(bcPtr);
574 ++basicClusterCounter;
581 unsigned size=photPFCandidateIndex_.size();
582 unsigned psClusterCounter=0;
583 preshowerClusterPtr_.resize(size);
585 for(
unsigned iphot=0;iphot<
size;++iphot)
587 unsigned nbc=preshowerClusters_[iphot].size();
588 for(
unsigned ibc=0;ibc<nbc;++ibc)
592 preshowerClusterPtr_[iphot].push_back(psPtr);
601 unsigned nphot=photPFCandidateIndex_.size();
602 for(
unsigned iphot=0;iphot<nphot;++iphot)
613 unsigned nbasics=basicClusters_[iphot].size();
614 for(
unsigned ibc=0;ibc<nbasics;++ibc)
618 double e = basicClusters_[iphot][ibc].energy();
620 posX += e * basicClusters_[iphot][ibc].position().X();
621 posY += e * basicClusters_[iphot][ibc].position().Y();
622 posZ += e * basicClusters_[iphot][ibc].position().Z();
638 double correctedEnergy=pfCand[photPFCandidateIndex_[iphot]].ecalEnergy();
646 mySuperCluster.
setSeed(basicClusterPtr_[iphot][0]);
659 for(
unsigned ibc=0;ibc<nbasics;++ibc)
661 mySuperCluster.
addCluster(basicClusterPtr_[iphot][ibc]);
663 const std::vector< std::pair<DetId, float> > & v1 = basicClusters_[iphot][ibc].hitsAndFractions();
665 for( std::vector< std::pair<DetId, float> >::const_iterator diIt = v1.begin();
673 unsigned nps=preshowerClusterPtr_[iphot].size();
674 for(
unsigned ips=0;ips<nps;++ips)
682 pfCand[photPFCandidateIndex_[iphot]].pS2Energy());
692 superClusters.push_back(mySuperCluster);
702 unsigned nphot=photPFCandidateIndex_.size();
703 for(
unsigned iphot=0;iphot<nphot;++iphot)
710 if (conv1legPFCandidateIndex_[iphot]>-1){
712 for (
unsigned iConv=0; iConv<pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++){
715 std::vector<reco::CaloClusterPtr>matchingBC;
717 const reco::Vertex * convVtx =
new reco::Vertex(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->innerPosition(), error);
722 std::vector<reco::TrackRef> OneLegConvVector;
723 OneLegConvVector.push_back(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]);
726 std::vector<reco::TrackRef> tr=OneLegConvVector;
727 std::vector<math::XYZPointF>trackPositionAtEcalVec;
728 std::vector<math::XYZPointF>innPointVec;
729 std::vector<math::XYZVectorF>trackPinVec;
730 std::vector<math::XYZVectorF>trackPoutVec;
731 math::XYZPointF trackPositionAtEcal(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
733 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
735 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
736 outerPosition().
Z());
737 math::XYZPointF innPoint(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
739 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
741 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
742 innerPosition().
Z());
743 math::XYZVectorF trackPin(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
745 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
747 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
748 innerMomentum().
Z());
749 math::XYZVectorF trackPout(pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
751 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
753 pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->
754 outerMomentum().
Z());
755 float DCA=pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]][iConv]->d0();
756 trackPositionAtEcalVec.push_back(trackPositionAtEcal);
757 innPointVec.push_back(innPoint);
758 trackPinVec.push_back(trackPin);
759 trackPoutVec.push_back(trackPout);
760 std::vector< float > OneLegMvaVector;
763 trackPositionAtEcalVec,
770 pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv],
772 OneLegMvaVector.push_back(pfSingleLegConvMva_[conv1legPFCandidateIndex_[iphot]][iConv]);
789 oneLegConversions.push_back(myOneLegConversion);
804 unsigned nphot=photPFCandidateIndex_.size();
806 unsigned i1legtot = 0;
808 for(
unsigned iphot=0;iphot<nphot;++iphot)
831 if (conv1legPFCandidateIndex_[iphot]>-1){
832 for (
unsigned int iConv=0; iConv<pfSingleLegConv_[conv1legPFCandidateIndex_[iphot]].size(); iConv++){
858 if (conv2legPFCandidateIndex_[iphot]>-1){
859 for(
unsigned int iConv=0; iConv<pfConv_[conv2legPFCandidateIndex_[iphot]].size(); iConv++) {
884 photonCores.push_back(myPhotonCore);
897 unsigned nphot=photPFCandidateIndex_.size();
899 for(
unsigned iphot=0;iphot<nphot;++iphot)
906 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
912 math::XYZVector P3 = direction.unit() * PCref->pfSuperCluster()->energy();
913 LorentzVector P4(P3.x(), P3.y(), P3.z(), PCref->pfSuperCluster()->energy());
915 reco::Photon myPhoton(P4, PCref->pfSuperCluster()->position(), PCref, vtx);
925 showerShape.e1x5= egPhotonRef_[iphot]->e1x5();
926 showerShape.e2x5= egPhotonRef_[iphot]->e2x5();
927 showerShape.e3x3= egPhotonRef_[iphot]->e3x3();
928 showerShape.e5x5= egPhotonRef_[iphot]->e5x5();
929 showerShape.maxEnergyXtal = egPhotonRef_[iphot]->maxEnergyXtal();
930 showerShape.sigmaEtaEta = egPhotonRef_[iphot]->sigmaEtaEta();
931 showerShape.sigmaIetaIeta = egPhotonRef_[iphot]->sigmaIetaIeta();
932 showerShape.hcalDepth1OverEcal = egPhotonRef_[iphot]->hadronicDepth1OverEm();
933 showerShape.hcalDepth2OverEcal = egPhotonRef_[iphot]->hadronicDepth2OverEm();
934 myPhoton.setShowerShapeVariables ( showerShape );
936 fiducialFlags.
isEB = egPhotonRef_[iphot]->isEB();
937 fiducialFlags.
isEE = egPhotonRef_[iphot]->isEE();
938 fiducialFlags.
isEBEtaGap = egPhotonRef_[iphot]->isEBEtaGap();
939 fiducialFlags.
isEBPhiGap = egPhotonRef_[iphot]->isEBPhiGap();
940 fiducialFlags.
isEERingGap = egPhotonRef_[iphot]->isEERingGap();
941 fiducialFlags.
isEEDeeGap = egPhotonRef_[iphot]->isEEDeeGap();
942 fiducialFlags.
isEBEEGap = egPhotonRef_[iphot]->isEBEEGap();
943 myPhoton.setFiducialVolumeFlags ( fiducialFlags );
945 isolationVariables03.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR03();
946 isolationVariables03.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR03();
947 isolationVariables03.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR03();
948 isolationVariables03.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR03();
949 isolationVariables03.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR03();
950 isolationVariables03.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR03();
951 isolationVariables03.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR03();
952 isolationVariables03.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR03();
953 isolationVariables04.
ecalRecHitSumEt = egPhotonRef_[iphot]->ecalRecHitSumEtConeDR04();
954 isolationVariables04.
hcalTowerSumEt = egPhotonRef_[iphot]->hcalTowerSumEtConeDR04();
955 isolationVariables04.
hcalDepth1TowerSumEt = egPhotonRef_[iphot]->hcalDepth1TowerSumEtConeDR04();
956 isolationVariables04.
hcalDepth2TowerSumEt = egPhotonRef_[iphot]->hcalDepth2TowerSumEtConeDR04();
957 isolationVariables04.
trkSumPtSolidCone = egPhotonRef_[iphot]->trkSumPtSolidConeDR04();
958 isolationVariables04.
trkSumPtHollowCone = egPhotonRef_[iphot]->trkSumPtHollowConeDR04();
959 isolationVariables04.
nTrkSolidCone = egPhotonRef_[iphot]->nTrkSolidConeDR04();
960 isolationVariables04.
nTrkHollowCone = egPhotonRef_[iphot]->nTrkHollowConeDR04();
961 myPhoton.setIsolationVariables(isolationVariables04, isolationVariables03);
968 myPFIso.
photonIso=(*isolationValues[1])[CandidatePtr_[iphot]];
970 myPhoton.setPflowIsolationVariables(myPFIso);
976 myPFVariables.
mva = pfPhotonMva_[iphot];
977 myPhoton.setPflowIDVariables(myPFVariables);
1040 photons.push_back(myPhoton);
1050 unsigned refindex=pfbe.
index();
1055 for(;myDaughterCandidate!=itend;++myDaughterCandidate)
1066 return *myPFCandidate;
const double Z[kNumberCalorimeter]
void setPflowSuperCluster(const reco::SuperClusterRef &r)
set reference to PFlow SuperCluster
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 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
const ElementsInBlocks & elementsInBlocks() const
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.
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
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)
void MustacheID(CaloClusterPtrVector &clusters, int &nclusters, float &EoutsideMustache)
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
virtual void produce(edm::Event &, const edm::EventSetup &)
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
virtual void beginRun(edm::Run &run, const edm::EventSetup &c)
size_type size() const
Size of the RefVector.
void addElectronPixelSeed(const reco::ElectronSeedRef &r)
set electron pixel seed ref
virtual ParticleType particleId() 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