CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTPFNeutralIsolationProducer.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.0);
61  desc.add<double>("etaStripBarrel", 0.0);
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", 5);
66  descriptions.add(("hltEgammaHLTPFNeutralIsolationProducer"), 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  if (fabs(candRef->eta()) < 1.479) {
104  if (fabs(pfc.pt()) < energyBarrel_)
105  continue;
106  } else {
107  if (fabs(pfc.energy()) < energyEndcap_)
108  continue;
109  }
110 
111  // Shift the photon direction vector according to the PF vertex
112  math::XYZPoint pfvtx = pfc.vertex();
113  math::XYZVector photon_directionWrtVtx(candRef->superCluster()->x() - pfvtx.x(),
114  candRef->superCluster()->y() - pfvtx.y(),
115  candRef->superCluster()->z() - pfvtx.z());
116 
117  float dEta = fabs(photon_directionWrtVtx.Eta() - pfc.momentum().Eta());
118  float dR = deltaR(photon_directionWrtVtx.Eta(), photon_directionWrtVtx.Phi(), pfc.momentum().Eta(), pfc.momentum().Phi());
119 
120  if (dEta < etaStrip)
121  continue;
122 
123  if(dR > drMax_ || dR < dRVeto)
124  continue;
125 
126  sum += pfc.pt();
127  }
128  }
129 
130  isoMap.insert(candRef, sum);
131  }
132 
133  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> isolMap(new reco::RecoEcalCandidateIsolationMap(isoMap));
134  iEvent.put(isolMap);
135 }
136 
137 //define this as a plug-in
138 //DEFINE_FWK_MODULE(EgammaHLTPFNeutralIsolationProducer);
virtual void produce(edm::Event &, const edm::EventSetup &)
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
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
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
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 float pt() const GCC11_FINAL
transverse momentum