CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTPFPhotonIsolationProducer.cc
Go to the documentation of this file.
1 
8 #include <iostream>
9 #include <vector>
10 #include <memory>
11 
13 
14 // Framework
20 
24 
27 
30 
32 
34 
35  // use configuration file to setup input/output collection names
36  pfCandidates_ = conf_.getParameter<edm::InputTag>("pfCandidatesProducer");
37  recoEcalCandidateProducer_ = conf_.getParameter<edm::InputTag>("recoEcalCandidateProducer");
38 
39  drMax_ = conf_.getParameter<double>("drMax");
40  drVetoBarrel_ = conf_.getParameter<double>("drVetoBarrel");
41  drVetoEndcap_ = conf_.getParameter<double>("drVetoEndcap");
42  etaStripBarrel_ = conf_.getParameter<double>("etaStripBarrel");
43  etaStripEndcap_ = conf_.getParameter<double>("etaStripEndcap");
44  energyBarrel_ = conf_.getParameter<double>("energyBarrel");
45  energyEndcap_ = conf_.getParameter<double>("energyEndcap");
46  pfToUse_ = conf_.getParameter<int>("pfCandidateType");
47 
48  produces < reco::RecoEcalCandidateIsolationMap >();
49 }
50 
52 {}
53 
56  desc.add<edm::InputTag>("pfCandidatesProducer", edm::InputTag("hltParticleFlowReg"));
57  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
58  desc.add<double>("drMax", 0.3);
59  desc.add<double>("drVetoBarrel", 0.0);
60  desc.add<double>("drVetoEndcap", 0.070);
61  desc.add<double>("etaStripBarrel", 0.015);
62  desc.add<double>("etaStripEndcap", 0.0);
63  desc.add<double>("energyBarrel", 0.0);
64  desc.add<double>("energyEndcap", 0.0);
65  desc.add<int>("pfCandidateType", 4);
66  descriptions.add(("hltEgammaHLTPFPhotonIsolationProducer"), desc);
67 }
68 
70 
72  iEvent.getByLabel(pfCandidates_, pfHandle);
73 
75  iEvent.getByLabel(recoEcalCandidateProducer_,recoecalcandHandle);
76 
78 
79  float dRVeto = -1.;
80  float etaStrip = -1;
81 
82  for (unsigned int iReco = 0; iReco < recoecalcandHandle->size(); iReco++) {
83 
84  reco::RecoEcalCandidateRef candRef(recoecalcandHandle, iReco);
85 
86  if (fabs(candRef->eta()) < 1.479) {
87  dRVeto = drVetoBarrel_;
88  etaStrip = etaStripBarrel_;
89  } else {
90  dRVeto = drVetoEndcap_;
91  etaStrip = etaStripEndcap_;
92  }
93 
94  const reco::PFCandidateCollection* forIsolation = pfHandle.product();
95 
96  float sum = 0;
97  for(unsigned i=0; i<forIsolation->size(); i++) {
98 
99  const reco::PFCandidate& pfc = (*forIsolation)[i];
100 
101  if (pfc.particleId() == pfToUse_) {
102 
103  // FIXME
104  // Do not include the PFCandidate associated by SC Ref to the reco::Photon
105  //if(pfc.superClusterRef().isNonnull() && localPho->superCluster().isNonnull()) {
106  // if (pfc.superClusterRef() == localPho->superCluster())
107  // continue;
108  //}
109 
110  if (fabs(candRef->eta()) < 1.479) {
111  if (fabs(pfc.pt()) < energyBarrel_)
112  continue;
113  } else {
114  if (fabs(pfc.energy()) < energyEndcap_)
115  continue;
116  }
117 
118  // Shift the photon direction vector according to the PF vertex
119  math::XYZPoint pfvtx = pfc.vertex();
120  math::XYZVector photon_directionWrtVtx(candRef->superCluster()->x() - pfvtx.x(),
121  candRef->superCluster()->y() - pfvtx.y(),
122  candRef->superCluster()->z() - pfvtx.z());
123 
124  float dEta = fabs(photon_directionWrtVtx.Eta() - pfc.momentum().Eta());
125  float dR = deltaR(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi());
126 
127  if (dEta < etaStrip)
128  continue;
129 
130  if(dR > drMax_ || dR < dRVeto)
131  continue;
132 
133  sum += pfc.pt();
134  }
135  }
136 
137  isoMap.insert(candRef, sum);
138  }
139 
140  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
141  iEvent.put(isolMap);
142 }
143 
144 //define this as a plug-in
145 //DEFINE_FWK_MODULE(EgammaHLTPFPhotonIsolationProducer);
virtual double energy() const GCC11_FINAL
energy
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
int iEvent
Definition: GenABIO.cc:243
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
virtual const Point & vertex() const
vertex position (overwritten by PF...)
Definition: PFCandidate.cc:643
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
std::vector< reco::PFCandidate > PFCandidateCollection
collection of PFCandidates
void insert(const key_type &k, const data_type &v)
insert an association
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
virtual Vector momentum() const GCC11_FINAL
spatial momentum vector
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T const * product() const
Definition: Handle.h:81
Particle reconstructed by the particle flow algorithm.
Definition: PFCandidate.h:38
virtual ParticleType particleId() const
Definition: PFCandidate.h:355
virtual void produce(edm::Event &, const edm::EventSetup &)
virtual float pt() const GCC11_FINAL
transverse momentum