CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
EcalIsolatedParticleCandidateProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: EcalIsolatedParticleCandidateProducer
4 // Class: EcalIsolatedParticleCandidateProducer
5 //
13 //
14 // Original Author: Grigory Safronov
15 // Created: Thu Jun 7 17:21:58 MSD 2007
16 //
17 //
18 
19 // system include files
20 #include <cmath>
21 #include <memory>
22 
23 // user include files
24 
32 
39 
42 
43 //#define EDM_ML_DEBUG
44 
45 //
46 // class decleration
47 //
48 
50 public:
53 
54  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
55 
56 private:
57  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
58  void beginJob() override {}
59  void endJob() override {}
60 
61  const double InConeSize_;
62  const double OutConeSize_;
63  const double hitCountEthr_;
64  const double hitEthr_;
65 
70 
72 
73  // ----------member data ---------------------------
74 };
75 
77  : InConeSize_(conf.getParameter<double>("EcalInnerConeSize")),
78  OutConeSize_(conf.getParameter<double>("EcalOuterConeSize")),
79  hitCountEthr_(conf.getParameter<double>("ECHitCountEnergyThreshold")),
80  hitEthr_(conf.getParameter<double>("ECHitEnergyThreshold")),
81  tok_l1tau_(consumes<l1extra::L1JetParticleCollection>(conf.getParameter<edm::InputTag>("L1eTauJetsSource"))),
82  tok_hlt_(consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("L1GTSeedLabel"))),
83  tok_EB_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EBrecHitCollectionLabel"))),
84  tok_EE_(consumes<EcalRecHitCollection>(conf.getParameter<edm::InputTag>("EErecHitCollectionLabel"))),
86  //register your products
87  produces<reco::IsolatedPixelTrackCandidateCollection>();
88 }
89 
91  // do anything here that needs to be done at desctruction time
92  // (e.g. close files, deallocate resources etc.)
93 }
94 
95 //
96 // member functions
97 //
98 
99 // ------------ method called to produce the data ------------
102  const edm::EventSetup& iSetup) const {
103 #ifdef EDM_ML_DEBUG
104  edm::LogVerbatim("HcalIsoTrack") << "get tau";
105 #endif
107 
108 #ifdef EDM_ML_DEBUG
109  edm::LogVerbatim("HcalIsoTrack") << "get geom";
110 #endif
111  const CaloGeometry* geo = &iSetup.getData(tok_geom_);
112 
113 #ifdef EDM_ML_DEBUG
114  edm::LogVerbatim("HcalIsoTrack") << "get ec rechit";
115 #endif
116  const edm::Handle<EcalRecHitCollection>& ecalEB = iEvent.getHandle(tok_EB_);
117  const edm::Handle<EcalRecHitCollection>& ecalEE = iEvent.getHandle(tok_EE_);
118 
119 #ifdef EDM_ML_DEBUG
120  edm::LogVerbatim("HcalIsoTrack") << "get l1 trig obj";
121 #endif
122 
124 
125  std::vector<edm::Ref<l1t::TauBxCollection> > l1tauobjref;
126  std::vector<edm::Ref<l1t::JetBxCollection> > l1jetobjref;
127 
128  l1trigobj->getObjects(trigger::TriggerL1Tau, l1tauobjref);
129  l1trigobj->getObjects(trigger::TriggerL1Jet, l1jetobjref);
130 
131  double ptTriggered = -10;
132  double etaTriggered = -100;
133  double phiTriggered = -100;
134 
135 #ifdef EDM_ML_DEBUG
136  edm::LogVerbatim("HcalIsoTrack") << "find highest pT triggered obj";
137 #endif
138  for (unsigned int p = 0; p < l1tauobjref.size(); p++) {
139  if (l1tauobjref[p]->pt() > ptTriggered) {
140  ptTriggered = l1tauobjref[p]->pt();
141  phiTriggered = l1tauobjref[p]->phi();
142  etaTriggered = l1tauobjref[p]->eta();
143  }
144  }
145  for (unsigned int p = 0; p < l1jetobjref.size(); p++) {
146  if (l1jetobjref[p]->pt() > ptTriggered) {
147  ptTriggered = l1jetobjref[p]->pt();
148  phiTriggered = l1jetobjref[p]->phi();
149  etaTriggered = l1jetobjref[p]->eta();
150  }
151  }
152 
153  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
154 
155 #ifdef EDM_ML_DEBUG
156  edm::LogVerbatim("HcalIsoTrack") << "loop over l1taus";
157 #endif
158  for (l1extra::L1JetParticleCollection::const_iterator tit = l1Taus->begin(); tit != l1Taus->end(); tit++) {
159  double dphi = fabs(tit->phi() - phiTriggered);
160  if (dphi > M_PI)
161  dphi = 2 * M_PI - dphi;
162  double Rseed = sqrt(pow(etaTriggered - tit->eta(), 2) + dphi * dphi);
163  if (Rseed < 1.2)
164  continue;
165  int nhitOut = 0;
166  int nhitIn = 0;
167  double OutEnergy = 0;
168  double InEnergy = 0;
169 #ifdef EDM_ML_DEBUG
170  edm::LogVerbatim("HcalIsoTrack") << "loops over rechits";
171 #endif
172  for (EcalRecHitCollection::const_iterator eItr = ecalEB->begin(); eItr != ecalEB->end(); eItr++) {
173  double phiD, R;
174  const GlobalPoint& pos = geo->getPosition(eItr->detid());
175  double phihit = pos.phi();
176  double etahit = pos.eta();
177  phiD = fabs(phihit - tit->phi());
178  if (phiD > M_PI)
179  phiD = 2 * M_PI - phiD;
180  R = sqrt(pow(etahit - tit->eta(), 2) + phiD * phiD);
181 
182  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitCountEthr_) {
183  nhitOut++;
184  }
185  if (R < InConeSize_ && eItr->energy() > hitCountEthr_) {
186  nhitIn++;
187  }
188 
189  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitEthr_) {
190  OutEnergy += eItr->energy();
191  }
192  if (R < InConeSize_ && eItr->energy() > hitEthr_) {
193  InEnergy += eItr->energy();
194  }
195  }
196 
197  for (EcalRecHitCollection::const_iterator eItr = ecalEE->begin(); eItr != ecalEE->end(); eItr++) {
198  double phiD, R;
199  const GlobalPoint& pos = geo->getPosition(eItr->detid());
200  double phihit = pos.phi();
201  double etahit = pos.eta();
202  phiD = fabs(phihit - tit->phi());
203  if (phiD > M_PI)
204  phiD = 2 * M_PI - phiD;
205  R = sqrt(pow(etahit - tit->eta(), 2) + phiD * phiD);
206  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitCountEthr_) {
207  nhitOut++;
208  }
209  if (R < InConeSize_ && eItr->energy() > hitCountEthr_) {
210  nhitIn++;
211  }
212  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitEthr_) {
213  OutEnergy += eItr->energy();
214  }
215  if (R < InConeSize_ && eItr->energy() > hitEthr_) {
216  InEnergy += eItr->energy();
217  }
218  }
219 #ifdef EDM_ML_DEBUG
220  edm::LogVerbatim("HcalIsoTrack") << "create and push_back candidate";
221 #endif
223  l1extra::L1JetParticleRef(l1Taus, tit - l1Taus->begin()), InEnergy, OutEnergy, nhitIn, nhitOut);
224  iptcCollection->push_back(newca);
225  }
226 
227  //Use the ExampleData to create an ExampleData2 which
228  // is put into the Event
229 
230 #ifdef EDM_ML_DEBUG
231  edm::LogVerbatim("HcalIsoTrack") << "put cand into event";
232 #endif
233  iEvent.put(std::move(iptcCollection));
234 }
235 
238  desc.add<double>("ECHitEnergyThreshold", 0.05);
239  desc.add<edm::InputTag>("L1eTauJetsSource", edm::InputTag("l1extraParticles", "Tau"));
240  desc.add<edm::InputTag>("L1GTSeedLabel", edm::InputTag("l1sIsolTrack"));
241  desc.add<edm::InputTag>("EBrecHitCollectionLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
242  desc.add<edm::InputTag>("EErecHitCollectionLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
243  desc.add<double>("ECHitCountEnergyThreshold", 0.5);
244  desc.add<double>("EcalInnerConeSize", 0.3);
245  desc.add<double>("EcalOuterConeSize", 0.7);
246  descriptions.add("ecalIsolPartProd", desc);
247 }
248 
251 
Log< level::Info, true > LogVerbatim
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
const edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_l1tau_
std::vector< EcalRecHit >::const_iterator const_iterator
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
const edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
const edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
int iEvent
Definition: GenABIO.cc:224
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
T sqrt(T t)
Definition: SSEVec.h:19
const edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const_iterator begin() const
#define M_PI
const_iterator end() const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hlt_