CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTEcalPFClusterIsolationProducer.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <vector>
3 #include <memory>
4 
6 
7 // Framework
16 
19 
22 
24 
26 
28 
29 template<typename T1>
31  std::string recoCandidateProducerName = "recoCandidateProducer";
32  if ((typeid(HLTEcalPFClusterIsolationProducer<T1>) == typeid(HLTEcalPFClusterIsolationProducer<reco::RecoEcalCandidate>))) recoCandidateProducerName = "recoEcalCandidateProducer";
33 
34  recoCandidateProducer_ = consumes<T1Collection>(config.getParameter<edm::InputTag>(recoCandidateProducerName));
35  pfClusterProducer_ = consumes<reco::PFClusterCollection>(config.getParameter<edm::InputTag>("pfClusterProducer"));
36 
37  drMax_ = config.getParameter<double>("drMax");
38  drVetoBarrel_ = config.getParameter<double>("drVetoBarrel");
39  drVetoEndcap_ = config.getParameter<double>("drVetoEndcap");
40  etaStripBarrel_ = config.getParameter<double>("etaStripBarrel");
41  etaStripEndcap_ = config.getParameter<double>("etaStripEndcap");
42  energyBarrel_ = config.getParameter<double>("energyBarrel");
43  energyEndcap_ = config.getParameter<double>("energyEndcap");
44 
45  doRhoCorrection_ = config.getParameter<bool>("doRhoCorrection");
46  if (doRhoCorrection_)
47  rhoProducer_ = consumes<double>(config.getParameter<edm::InputTag>("rhoProducer"));
48 
49  rhoMax_ = config.getParameter<double>("rhoMax");
50  rhoScale_ = config.getParameter<double>("rhoScale");
51  effectiveAreaBarrel_ = config.getParameter<double>("effectiveAreaBarrel");
52  effectiveAreaEndcap_ = config.getParameter<double>("effectiveAreaEndcap");
53 
54  produces <T1IsolationMap>();
55 
56 }
57 
58 template<typename T1>
60 {}
61 
62 template<typename T1>
64 
65  std::string recoCandidateProducerName = "recoCandidateProducer";
66  if ((typeid(HLTEcalPFClusterIsolationProducer<T1>) == typeid(HLTEcalPFClusterIsolationProducer<reco::RecoEcalCandidate>))) recoCandidateProducerName = "recoEcalCandidateProducer";
67 
69  desc.add<edm::InputTag>(recoCandidateProducerName, edm::InputTag("hltL1SeededRecoEcalCandidatePF"));
70  desc.add<edm::InputTag>("pfClusterProducer", edm::InputTag("hltParticleFlowClusterECAL"));
71  desc.add<edm::InputTag>("rhoProducer", edm::InputTag("fixedGridRhoFastjetAllCalo"));
72  desc.add<bool>("doRhoCorrection", false);
73  desc.add<double>("rhoMax", 9.9999999E7);
74  desc.add<double>("rhoScale", 1.0);
75  desc.add<double>("effectiveAreaBarrel", 0.101);
76  desc.add<double>("effectiveAreaEndcap", 0.046);
77  desc.add<double>("drMax", 0.3);
78  desc.add<double>("drVetoBarrel", 0.0);
79  desc.add<double>("drVetoEndcap", 0.0);
80  desc.add<double>("etaStripBarrel", 0.0);
81  desc.add<double>("etaStripEndcap", 0.0);
82  desc.add<double>("energyBarrel", 0.0);
83  desc.add<double>("energyEndcap", 0.0);
84  descriptions.add(std::string("hlt")+std::string(typeid(HLTEcalPFClusterIsolationProducer<T1>).name()), desc);
85 }
86 
87 template<>
89 
90  float dR2 = deltaR2(candRef->eta(), candRef->phi(), pfclu->eta(), pfclu->phi());
91  if(dR2 > (drMax_*drMax_))
92  return false;
93 
94  if (candRef->superCluster().isNonnull()) {
95  // Exclude clusters that are part of the candidate
96  for (reco::CaloCluster_iterator it = candRef->superCluster()->clustersBegin(); it != candRef->superCluster()->clustersEnd(); ++it) {
97  if ((*it)->seed() == pfclu->seed()) {
98  return false;
99  }
100  }
101  }
102 
103  return true;
104 }
105 
106 template<typename T1>
108 
109  float dR2 = deltaR2(candRef->eta(), candRef->phi(), pfclu->eta(), pfclu->phi());
110  if(dR2 > (drMax_*drMax_) || dR2 < drVeto2_)
111  return false;
112  else
113  return true;
114 }
115 
116 template<typename T1>
118 
119  edm::Handle<double> rhoHandle;
120  double rho = 0.0;
121  if (doRhoCorrection_) {
122  iEvent.getByToken(rhoProducer_, rhoHandle);
123  rho = *(rhoHandle.product());
124  }
125 
126  if (rho > rhoMax_)
127  rho = rhoMax_;
128 
129  rho = rho*rhoScale_;
130 
131  edm::Handle<T1Collection> recoCandHandle;
133 
134  iEvent.getByToken(recoCandidateProducer_,recoCandHandle);
135  iEvent.getByToken(pfClusterProducer_, clusterHandle);
136 
137  T1IsolationMap recoCandMap;
138 
139  drVeto2_ = -1.;
140  float etaStrip = -1;
141 
142  for (unsigned int iReco = 0; iReco < recoCandHandle->size(); iReco++) {
143  T1Ref candRef(recoCandHandle, iReco);
144 
145  if (fabs(candRef->eta()) < 1.479) {
146  drVeto2_ = drVetoBarrel_*drVetoBarrel_;
147  etaStrip = etaStripBarrel_;
148  } else {
149  drVeto2_ = drVetoEndcap_*drVetoEndcap_;
150  etaStrip = etaStripEndcap_;
151  }
152 
153  float sum = 0;
154  for (size_t i=0; i<clusterHandle->size(); i++) {
155  reco::PFClusterRef pfclu(clusterHandle, i);
156 
157  if (fabs(candRef->eta()) < 1.479) {
158  if (fabs(pfclu->pt()) < energyBarrel_)
159  continue;
160  } else {
161  if (fabs(pfclu->energy()) < energyEndcap_)
162  continue;
163  }
164 
165  float dEta = fabs(candRef->eta() - pfclu->eta());
166  if(dEta < etaStrip) continue;
167  if (not computedRVeto(candRef, pfclu))
168  continue;
169 
170  sum += pfclu->pt();
171  }
172 
173  if (doRhoCorrection_) {
174  if (fabs(candRef->eta()) < 1.479)
175  sum = sum - rho*effectiveAreaBarrel_;
176  else
177  sum = sum - rho*effectiveAreaEndcap_;
178  }
179 
180  recoCandMap.insert(candRef, sum);
181  }
182 
183  std::auto_ptr<T1IsolationMap> mapForEvent(new T1IsolationMap(recoCandMap));
184  iEvent.put(mapForEvent);
185 }
186 
189 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:446
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
Definition: DDAxes.h:10
bool computedRVeto(T1Ref candRef, reco::PFClusterRef pfclu)
int iEvent
Definition: GenABIO.cc:230
HLTEcalPFClusterIsolationProducer< reco::RecoChargedCandidate > MuonHLTEcalPFClusterIsolationProducer
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
HLTEcalPFClusterIsolationProducer(const edm::ParameterSet &)
double deltaR2(const T1 &t1, const T2 &t2)
Definition: deltaR.h:36
ParameterDescriptionBase * add(U const &iLabel, T const &value)
T const * product() const
Definition: Handle.h:81
void insert(const key_type &k, const data_type &v)
insert an association
void add(std::string const &label, ParameterSetDescription const &psetDescription)
virtual void produce(edm::Event &, const edm::EventSetup &)
HLTEcalPFClusterIsolationProducer< reco::RecoEcalCandidate > EgammaHLTEcalPFClusterIsolationProducer