47 #include <Math/VectorUtil.h>
49 #include "TLorentzVector.h"
56 using namespace ROOT::Math::VectorUtil;
71 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfChargedHadrons"));
72 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfPhotons"));
73 inputTagIsoVals_.push_back(isoVals.getParameter<
edm::InputTag>(
"pfNeutralHadrons"));
76 PFBasicClusterCollection_ = iConfig.
getParameter<std::string>(
"PFBasicClusters");
77 PFPreshowerClusterCollection_ = iConfig.
getParameter<std::string>(
"PFPreshowerClusters");
78 PFSuperClusterCollection_ = iConfig.
getParameter<std::string>(
"PFSuperClusters");
80 PFPhotonCoreCollection_ = iConfig.
getParameter<std::string>(
"PFPhotonCores");
81 PFPhotonCollection_ = iConfig.
getParameter<std::string>(
"PFPhotons");
83 vertexProducer_ = iConfig.
getParameter<std::string>(
"primaryVertexProducer");
89 hOverEConeSize_ = iConfig.
getParameter<
double>(
"hOverEConeSize");
92 else emptyIsOk_=
false;
94 produces<reco::BasicClusterCollection>(PFBasicClusterCollection_);
95 produces<reco::PreshowerClusterCollection>(PFPreshowerClusterCollection_);
96 produces<reco::SuperClusterCollection>(PFSuperClusterCollection_);
97 produces<reco::PhotonCoreCollection>(PFPhotonCoreCollection_);
98 produces<reco::PhotonCollection>(PFPhotonCollection_);
111 std::auto_ptr<reco::BasicClusterCollection>
114 std::auto_ptr<reco::PreshowerClusterCollection>
122 outputSuperClusterCollection.clear();
123 outputPhotonCoreCollection.clear();
124 outputPhotonCollection.clear();
128 bool status=fetchCandidateCollection(pfCandidates,
129 inputTagPFCandidates_,
136 for (
size_t j = 0;
j<inputTagIsoVals_.size(); ++
j) {
137 iEvent.
getByLabel(inputTagIsoVals_[
j], isolationValues[j]);
142 photPFCandidateIndex_.clear();
143 basicClusters_.clear();
145 preshowerClusters_.clear();
146 superClusters_.clear();
147 basicClusterPtr_.clear();
148 preshowerClusterPtr_.clear();
149 CandidatePtr_.clear();
159 unsigned ncand=(
status)?pfCandidates->size():0;
162 for(
unsigned i=0;
i<ncand; ++
i ) {
167 photPFCandidateIndex_.push_back(
i);
170 pfClusters_.push_back(std::vector<const reco::PFCluster *>());
175 CandidatePtr_.push_back(ptrToPFPhoton);
187 if(blockRef.
isNull())
continue;
201 createBasicCluster(pfbe,basicClusters_[iphot],pfClusters_[iphot],correspondingDaughterCandidate(cand,pfbe));
206 createPreshowerCluster(pfbe,preshowerClusters_[iphot],1);
211 createPreshowerCluster(pfbe,preshowerClusters_[iphot],2);
217 basicClusters_p->insert(basicClusters_p->end(),basicClusters_[iphot].begin(), basicClusters_[iphot].end());
219 psClusters_p->insert(psClusters_p->end(),preshowerClusters_[iphot].begin(),preshowerClusters_[iphot].end());
229 iEvent.
put(basicClusters_p,PFBasicClusterCollection_);
233 iEvent.
put(psClusters_p,PFPreshowerClusterCollection_);
236 createBasicClusterPtrs(bcRefProd);
238 createPreshowerClusterPtrs(psRefProd);
242 if(status) createSuperClusters(*pfCandidates,outputSuperClusterCollection);
261 if(status) createPhotonCores(scRefProd, outputPhotonCoreCollection);
281 bool validVertex=
true;
282 iEvent.
getByLabel(vertexProducer_, vertexHandle);
284 edm::LogWarning(
"PhotonProducer") <<
"Error! Can't get the product primary Vertex Collection "<<
"\n";
287 if (validVertex) vertexCollection = *(vertexHandle.
product());
290 bool validEcalRecHits=
true;
293 iEvent.
getByLabel(barrelEcalHits_, barrelHitHandle);
294 if (!barrelHitHandle.
isValid()) {
295 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the product "<<barrelEcalHits_.label();
296 validEcalRecHits=
false;
298 if ( validEcalRecHits) barrelRecHits = *(barrelHitHandle.
product());
301 iEvent.
getByLabel(endcapEcalHits_, endcapHitHandle);
303 if (!endcapHitHandle.
isValid()) {
304 edm::LogError(
"PhotonProducer") <<
"Error! Can't get the product "<<endcapEcalHits_.label();
305 validEcalRecHits=
false;
307 if( validEcalRecHits) endcapRecHits = *(endcapHitHandle.
product());
318 iEvent.
getByLabel(hcalTowers_, hcalTowersHandle);
321 if(status) createPhotons(vertexCollection, pcRefProd, topology, &barrelRecHits, &endcapRecHits, hcalTowersHandle, isolationValues, outputPhotonCollection);
347 if(!found && !emptyIsOk_)
349 std::ostringstream err;
350 err<<
" cannot get PFCandidates: "
363 std::vector<const reco::PFCluster *> & pfClusters,
367 if(myPFClusterRef.
isNull())
return;
370 pfClusters.push_back(&myPFCluster);
380 myPFCluster.
seed()));
387 myPFClusterRef->hitsAndFractions(),plane));
392 unsigned size=photPFCandidateIndex_.size();
393 unsigned basicClusterCounter=0;
394 basicClusterPtr_.resize(size);
396 for(
unsigned iphot=0;iphot<
size;++iphot)
398 unsigned nbc=basicClusters_[iphot].size();
399 for(
unsigned ibc=0;ibc<nbc;++ibc)
403 basicClusterPtr_[iphot].push_back(bcPtr);
404 ++basicClusterCounter;
411 unsigned size=photPFCandidateIndex_.size();
412 unsigned psClusterCounter=0;
413 preshowerClusterPtr_.resize(size);
415 for(
unsigned iphot=0;iphot<
size;++iphot)
417 unsigned nbc=preshowerClusters_[iphot].size();
418 for(
unsigned ibc=0;ibc<nbc;++ibc)
422 preshowerClusterPtr_[iphot].push_back(psPtr);
431 unsigned nphot=photPFCandidateIndex_.size();
432 for(
unsigned iphot=0;iphot<nphot;++iphot)
443 unsigned nbasics=basicClusters_[iphot].size();
444 for(
unsigned ibc=0;ibc<nbasics;++ibc)
448 double e = basicClusters_[iphot][ibc].energy();
450 posX += e * basicClusters_[iphot][ibc].position().X();
451 posY += e * basicClusters_[iphot][ibc].position().Y();
452 posZ += e * basicClusters_[iphot][ibc].position().Z();
468 double correctedEnergy=pfCand[photPFCandidateIndex_[iphot]].ecalEnergy();
476 mySuperCluster.
setSeed(basicClusterPtr_[iphot][0]);
489 for(
unsigned ibc=0;ibc<nbasics;++ibc)
491 mySuperCluster.
addCluster(basicClusterPtr_[iphot][ibc]);
493 const std::vector< std::pair<DetId, float> > & v1 = basicClusters_[iphot][ibc].hitsAndFractions();
495 for( std::vector< std::pair<DetId, float> >::const_iterator diIt = v1.begin();
503 unsigned nps=preshowerClusterPtr_[iphot].size();
504 for(
unsigned ips=0;ips<nps;++ips)
512 pfCand[photPFCandidateIndex_[iphot]].pS2Energy());
522 superClusters.push_back(mySuperCluster);
532 unsigned nphot=photPFCandidateIndex_.size();
534 for(
unsigned iphot=0;iphot<nphot;++iphot)
546 photonCores.push_back(myPhotonCore);
558 unsigned nphot=photPFCandidateIndex_.size();
560 for(
unsigned iphot=0;iphot<nphot;++iphot)
567 if (vertexCollection.size()>0) vtx = vertexCollection.begin()->position();
573 math::XYZVector P3 = direction.unit() * PCref->pfSuperCluster()->energy();
574 LorentzVector P4(P3.x(), P3.y(), P3.z(), PCref->pfSuperCluster()->energy());
576 reco::Photon myPhoton(P4, PCref->pfSuperCluster()->position(), PCref, vtx);
582 myPFIso.photonIso=(*isolationValues[1])[CandidatePtr_[iphot]];
583 myPFIso.neutralHadronIso=(*isolationValues[2])[CandidatePtr_[iphot]];
584 myPhoton.setPflowIsolationVariables(myPFIso);
589 if (basicClusters_[iphot].
size()>0){
594 int subdet = PCref->pfSuperCluster()->seed()->hitsAndFractions()[0].first.subdetId();
596 else if (subdet==
EcalEndcap) hits = endcapRecHits;
610 float sigmaEtaEta =
sqrt(cov[0]);
613 float sigmaIetaIeta =
sqrt(locCov[0]);
622 double HoE1=towerIso1.
getTowerESum(&(*PCref->pfSuperCluster()))/PCref->pfSuperCluster()->energy();
623 double HoE2=towerIso2.
getTowerESum(&(*PCref->pfSuperCluster()))/PCref->pfSuperCluster()->energy();
628 showerShape.
e1x5= e1x5;
629 showerShape.
e2x5= e2x5;
630 showerShape.
e3x3= e3x3;
631 showerShape.
e5x5= e5x5;
637 myPhoton.setShowerShapeVariables ( showerShape );
641 photons.push_back(myPhoton);
651 unsigned refindex=pfbe.
index();
656 for(;myDaughterCandidate!=itend;++myDaughterCandidate)
667 return *myPFCandidate;
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
void setSuperCluster(const reco::SuperClusterRef &r)
set reference to SuperCluster
double rawEcalEnergy() const
return corrected Ecal energy
void createBasicClusterPtrs(const edm::OrphanHandle< reco::BasicClusterCollection > &basicClustersHandle)
void addHitAndFraction(DetId id, float fraction)
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
ROOT::Math::Plane3D::Vector Vector
void createPhotons(reco::VertexCollection &vertexCollection, const edm::OrphanHandle< reco::PhotonCoreCollection > &superClustersHandle, const CaloTopology *topology, const EcalRecHitCollection *barrelRecHits, const EcalRecHitCollection *endcapRecHits, const edm::Handle< CaloTowerCollection > &hcalTowersHandle, const IsolationValueMaps &isolationValues, reco::PhotonCollection &photons)
virtual const_iterator end() const
last daughter const_iterator
double getTowerESum(const reco::Candidate *) const
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
void createSuperClusters(const reco::PFCandidateCollection &, reco::SuperClusterCollection &superClusters) const
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
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 createPreshowerCluster(const reco::PFBlockElement &PFBE, reco::PreshowerClusterCollection &preshowerClusters, unsigned plane) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
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
T const * product() const
std::vector< edm::Handle< edm::ValueMap< double > > > IsolationValueMaps
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
std::vector< Photon > PhotonCollection
collectin of Photon objects
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
ESHandle< TrackerGeometry > geometry
Particle reconstructed by the particle flow algorithm.
virtual void beginRun(edm::Run &run, const edm::EventSetup &c)
void createPhotonCores(const edm::OrphanHandle< reco::SuperClusterCollection > &superClustersHandle, reco::PhotonCoreCollection &photonCores)
virtual ParticleType particleId() const
tuple size
Write out results.
math::PtEtaPhiELorentzVectorF LorentzVector
void setPreshowerEnergy(double preshowerEnergy)
reco::SuperClusterRef superClusterRef() const
return a reference to the corresponding SuperCluster if any