CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTHcalPFClusterIsolationProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
6 
7 // Framework
16 
18 
20 
21  recoEcalCandidateProducer_ = consumes<reco::RecoEcalCandidateCollection>(config.getParameter<edm::InputTag>("recoEcalCandidateProducer"));
22  pfClusterProducerHCAL_ = consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHCAL"));
23  useHF_ = config.getParameter<bool>("useHF");
24  if (useHF_) {
25  pfClusterProducerHFEM_ = consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHFEM"));
26  pfClusterProducerHFHAD_ = consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducerHFHAD"));
27  }
28 
29  drMax_ = config.getParameter<double>("drMax");
30  drVetoBarrel_ = config.getParameter<double>("drVetoBarrel");
31  drVetoEndcap_ = config.getParameter<double>("drVetoEndcap");
32  etaStripBarrel_ = config.getParameter<double>("etaStripBarrel");
33  etaStripEndcap_ = config.getParameter<double>("etaStripEndcap");
34  energyBarrel_ = config.getParameter<double>("energyBarrel");
35  energyEndcap_ = config.getParameter<double>("energyEndcap");
36 
37  doRhoCorrection_ = config.getParameter<bool>("doRhoCorrection");
38  if (doRhoCorrection_)
39  rhoProducer_ = consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"));
40 
41  rhoMax_ = config.getParameter<double>("rhoMax");
42  rhoScale_ = config.getParameter<double>("rhoScale");
43  effectiveAreaBarrel_ = config.getParameter<double>("effectiveAreaBarrel");
44  effectiveAreaEndcap_ = config.getParameter<double>("effectiveAreaEndcap");
45 
46  produces < reco::RecoEcalCandidateIsolationMap >();
47 
48 }
49 
51 {}
52 
55  desc.add<edm::InputTag>("recoEcalCandidateProducer", edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
56  desc.add<edm::InputTag>("pfClusterProducerHCAL", edm::InputTag("hltParticleFlowClusterHCAL"));
57  desc.ifValue(edm::ParameterDescription<bool>("useHF", false, true),
58  true >> (edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFEM", edm::InputTag("hltParticleFlowClusterHFEM"), true) and
59  edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFHAD", edm::InputTag("hltParticleFlowClusterHFHAD"), true)) or
60  false >> (edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFEM", edm::InputTag(""), true) and
61  edm::ParameterDescription<edm::InputTag>("pfClusterProducerHFHAD", edm::InputTag(""), true)));
62  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
63  desc.add<bool>("doRhoCorrection", false);
64  desc.add<double>("rhoMax", 9.9999999E7);
65  desc.add<double>("rhoScale", 1.0);
66  desc.add<double>("effectiveAreaBarrel", 0.101);
67  desc.add<double>("effectiveAreaEndcap", 0.046);
68  desc.add<double>("drMax", 0.3);
69  desc.add<double>("drVetoBarrel", 0.0);
70  desc.add<double>("drVetoEndcap", 0.0);
71  desc.add<double>("etaStripBarrel", 0.0);
72  desc.add<double>("etaStripEndcap", 0.0);
73  desc.add<double>("energyBarrel", 0.0);
74  desc.add<double>("energyEndcap", 0.0);
75  descriptions.add(("hltEgammaHLTHcalPFClusterIsolationProducer"), desc);
76 }
77 
79 
80  edm::Handle<double> rhoHandle;
81  double rho = 0.0;
82  if (doRhoCorrection_) {
83  iEvent.getByToken(rhoProducer_, rhoHandle);
84  rho = *(rhoHandle.product());
85  }
86 
87  if (rho > rhoMax_)
88  rho = rhoMax_;
89 
90  rho = rho*rhoScale_;
91 
95  edm::Handle<reco::PFClusterCollection> clusterHfhadHandle;
96 
97  iEvent.getByToken(recoEcalCandidateProducer_,recoecalcandHandle);
98  iEvent.getByToken(pfClusterProducerHCAL_, clusterHcalHandle);
99  const reco::PFClusterCollection* forIsolationHcal = clusterHcalHandle.product();
100 
101  if (useHF_) {
102  iEvent.getByToken(pfClusterProducerHFEM_, clusterHfemHandle);
103  iEvent.getByToken(pfClusterProducerHFHAD_, clusterHfhadHandle);
104  }
105 
106  reco::RecoEcalCandidateIsolationMap recoEcalCandMap;
107 
108  float dRVeto = -1.;
109  float etaStrip = -1;
110 
111  for (unsigned int iReco = 0; iReco < recoecalcandHandle->size(); iReco++) {
112  reco::RecoEcalCandidateRef candRef(recoecalcandHandle, iReco);
113 
114  if (fabs(candRef->eta()) < 1.479) {
115  dRVeto = drVetoBarrel_;
116  etaStrip = etaStripBarrel_;
117  } else {
118  dRVeto = drVetoEndcap_;
119  etaStrip = etaStripEndcap_;
120  }
121 
122  float sum = 0;
123 
124  // Loop over the 3 types of PFClusters
125 
126  for(unsigned i=0; i<forIsolationHcal->size(); i++) {
127  const reco::PFCluster& pfclu = (*forIsolationHcal)[i];
128 
129  if (fabs(candRef->eta()) < 1.479) {
130  if (fabs(pfclu.pt()) < energyBarrel_)
131  continue;
132  } else {
133  if (fabs(pfclu.energy()) < energyEndcap_)
134  continue;
135  }
136 
137  float dEta = fabs(candRef->eta() - pfclu.eta());
138  if(dEta < etaStrip) continue;
139 
140  float dR = deltaR(candRef->eta(), candRef->phi(), pfclu.eta(), pfclu.phi());
141  if(dR > drMax_ || dR < dRVeto) continue;
142 
143  sum += pfclu.pt();
144  }
145 
146  if (useHF_) {
147  const reco::PFClusterCollection* forIsolationHfem = clusterHfemHandle.product();
148  const reco::PFClusterCollection* forIsolationHfhad = clusterHfhadHandle.product();
149 
150  for(unsigned i=0; i<forIsolationHfem->size(); i++) {
151  const reco::PFCluster& pfclu = (*forIsolationHfem)[i];
152 
153  if (fabs(candRef->eta()) < 1.479) {
154  if (fabs(pfclu.pt()) < energyBarrel_)
155  continue;
156  } else {
157  if (fabs(pfclu.energy()) < energyEndcap_)
158  continue;
159  }
160 
161  float dEta = fabs(candRef->eta() - pfclu.eta());
162  if(dEta < etaStrip) continue;
163 
164  float dR = deltaR(candRef->eta(), candRef->phi(), pfclu.eta(), pfclu.phi());
165  if(dR > drMax_ || dR < dRVeto) continue;
166 
167  sum += pfclu.pt();
168  }
169 
170  for(unsigned i=0; i<forIsolationHfhad->size(); i++) {
171  const reco::PFCluster& pfclu = (*forIsolationHfhad)[i];
172 
173  if (fabs(candRef->eta()) < 1.479) {
174  if (fabs(pfclu.pt()) < energyBarrel_)
175  continue;
176  } else {
177  if (fabs(pfclu.energy()) < energyEndcap_)
178  continue;
179  }
180 
181  float dEta = fabs(candRef->eta() - pfclu.eta());
182  if(dEta < etaStrip) continue;
183 
184  float dR = deltaR(candRef->eta(), candRef->phi(), pfclu.eta(), pfclu.phi());
185  if(dR > drMax_ || dR < dRVeto) continue;
186 
187  sum += pfclu.pt();
188  }
189  }
190 
191  if (doRhoCorrection_) {
192  if (fabs(candRef->eta()) < 1.479)
193  sum = sum - rho*effectiveAreaBarrel_;
194  else
195  sum = sum - rho*effectiveAreaEndcap_;
196  }
197 
198  recoEcalCandMap.insert(candRef, sum);
199  }
200 
201  std::auto_ptr<reco::RecoEcalCandidateIsolationMap> mapForEvent(new reco::RecoEcalCandidateIsolationMap(recoEcalCandMap));
202  iEvent.put(mapForEvent);
203 
204 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
Definition: DDAxes.h:10
double pt() const
transverse momentum, massless approximation
Definition: PFCluster.h:132
double eta() const
pseudorapidity of cluster centroid
Definition: CaloCluster.h:161
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHCAL_
double energy() const
cluster energy
Definition: PFCluster.h:79
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
ParameterDescriptionNode * ifValue(ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T const * product() const
Definition: Handle.h:81
edm::EDGetTokenT< reco::RecoEcalCandidateCollection > recoEcalCandidateProducer_
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
double phi() const
azimuthal angle of cluster centroid
Definition: CaloCluster.h:164
edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHFEM_
virtual void produce(edm::Event &, const edm::EventSetup &)
edm::EDGetTokenT< reco::PFClusterCollection > pfClusterProducerHFHAD_