CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  double InConeSize_;
62  double OutConeSize_;
63  double hitCountEthr_;
64  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"));
85 
86  tok_geom_ = esConsumes<CaloGeometry, CaloGeometryRecord>();
87 
88  //register your products
89  produces<reco::IsolatedPixelTrackCandidateCollection>();
90 }
91 
93  // do anything here that needs to be done at desctruction time
94  // (e.g. close files, deallocate resources etc.)
95 }
96 
97 //
98 // member functions
99 //
100 
101 // ------------ method called to produce the data ------------
104  const edm::EventSetup& iSetup) const {
105 #ifdef EDM_ML_DEBUG
106  edm::LogVerbatim("HcalIsoTrack") << "get tau";
107 #endif
109  iEvent.getByToken(tok_l1tau_, l1Taus);
110 
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("HcalIsoTrack") << "get geom";
113 #endif
114  const CaloGeometry* geo = &iSetup.getData(tok_geom_);
115 
116 #ifdef EDM_ML_DEBUG
117  edm::LogVerbatim("HcalIsoTrack") << "get ec rechit";
118 #endif
120  iEvent.getByToken(tok_EB_, ecalEB);
121 
123  iEvent.getByToken(tok_EE_, ecalEE);
124 
125 #ifdef EDM_ML_DEBUG
126  edm::LogVerbatim("HcalIsoTrack") << "get l1 trig obj";
127 #endif
128 
130  iEvent.getByToken(tok_hlt_, l1trigobj);
131 
132  std::vector<edm::Ref<l1t::TauBxCollection> > l1tauobjref;
133  std::vector<edm::Ref<l1t::JetBxCollection> > l1jetobjref;
134 
135  l1trigobj->getObjects(trigger::TriggerL1Tau, l1tauobjref);
136  l1trigobj->getObjects(trigger::TriggerL1Jet, l1jetobjref);
137 
138  double ptTriggered = -10;
139  double etaTriggered = -100;
140  double phiTriggered = -100;
141 
142 #ifdef EDM_ML_DEBUG
143  edm::LogVerbatim("HcalIsoTrack") << "find highest pT triggered obj";
144 #endif
145  for (unsigned int p = 0; p < l1tauobjref.size(); p++) {
146  if (l1tauobjref[p]->pt() > ptTriggered) {
147  ptTriggered = l1tauobjref[p]->pt();
148  phiTriggered = l1tauobjref[p]->phi();
149  etaTriggered = l1tauobjref[p]->eta();
150  }
151  }
152  for (unsigned int p = 0; p < l1jetobjref.size(); p++) {
153  if (l1jetobjref[p]->pt() > ptTriggered) {
154  ptTriggered = l1jetobjref[p]->pt();
155  phiTriggered = l1jetobjref[p]->phi();
156  etaTriggered = l1jetobjref[p]->eta();
157  }
158  }
159 
160  auto iptcCollection = std::make_unique<reco::IsolatedPixelTrackCandidateCollection>();
161 
162 #ifdef EDM_ML_DEBUG
163  edm::LogVerbatim("HcalIsoTrack") << "loop over l1taus";
164 #endif
165  for (l1extra::L1JetParticleCollection::const_iterator tit = l1Taus->begin(); tit != l1Taus->end(); tit++) {
166  double dphi = fabs(tit->phi() - phiTriggered);
167  if (dphi > M_PI)
168  dphi = 2 * M_PI - dphi;
169  double Rseed = sqrt(pow(etaTriggered - tit->eta(), 2) + dphi * dphi);
170  if (Rseed < 1.2)
171  continue;
172  int nhitOut = 0;
173  int nhitIn = 0;
174  double OutEnergy = 0;
175  double InEnergy = 0;
176 #ifdef EDM_ML_DEBUG
177  edm::LogVerbatim("HcalIsoTrack") << "loops over rechits";
178 #endif
179  for (EcalRecHitCollection::const_iterator eItr = ecalEB->begin(); eItr != ecalEB->end(); eItr++) {
180  double phiD, R;
181  const GlobalPoint& pos = geo->getPosition(eItr->detid());
182  double phihit = pos.phi();
183  double etahit = pos.eta();
184  phiD = fabs(phihit - tit->phi());
185  if (phiD > M_PI)
186  phiD = 2 * M_PI - phiD;
187  R = sqrt(pow(etahit - tit->eta(), 2) + phiD * phiD);
188 
189  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitCountEthr_) {
190  nhitOut++;
191  }
192  if (R < InConeSize_ && eItr->energy() > hitCountEthr_) {
193  nhitIn++;
194  }
195 
196  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitEthr_) {
197  OutEnergy += eItr->energy();
198  }
199  if (R < InConeSize_ && eItr->energy() > hitEthr_) {
200  InEnergy += eItr->energy();
201  }
202  }
203 
204  for (EcalRecHitCollection::const_iterator eItr = ecalEE->begin(); eItr != ecalEE->end(); eItr++) {
205  double phiD, R;
206  const GlobalPoint& pos = geo->getPosition(eItr->detid());
207  double phihit = pos.phi();
208  double etahit = pos.eta();
209  phiD = fabs(phihit - tit->phi());
210  if (phiD > M_PI)
211  phiD = 2 * M_PI - phiD;
212  R = sqrt(pow(etahit - tit->eta(), 2) + phiD * phiD);
213  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitCountEthr_) {
214  nhitOut++;
215  }
216  if (R < InConeSize_ && eItr->energy() > hitCountEthr_) {
217  nhitIn++;
218  }
219  if (R < OutConeSize_ && R > InConeSize_ && eItr->energy() > hitEthr_) {
220  OutEnergy += eItr->energy();
221  }
222  if (R < InConeSize_ && eItr->energy() > hitEthr_) {
223  InEnergy += eItr->energy();
224  }
225  }
226 #ifdef EDM_ML_DEBUG
227  edm::LogVerbatim("HcalIsoTrack") << "create and push_back candidate";
228 #endif
230  l1extra::L1JetParticleRef(l1Taus, tit - l1Taus->begin()), InEnergy, OutEnergy, nhitIn, nhitOut);
231  iptcCollection->push_back(newca);
232  }
233 
234  //Use the ExampleData to create an ExampleData2 which
235  // is put into the Event
236 
237 #ifdef EDM_ML_DEBUG
238  edm::LogVerbatim("HcalIsoTrack") << "put cand into event";
239 #endif
240  iEvent.put(std::move(iptcCollection));
241 }
242 
245  desc.add<double>("ECHitEnergyThreshold", 0.05);
246  desc.add<edm::InputTag>("L1eTauJetsSource", edm::InputTag("l1extraParticles", "Tau"));
247  desc.add<edm::InputTag>("L1GTSeedLabel", edm::InputTag("l1sIsolTrack"));
248  desc.add<edm::InputTag>("EBrecHitCollectionLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEB"));
249  desc.add<edm::InputTag>("EErecHitCollectionLabel", edm::InputTag("ecalRecHit", "EcalRecHitsEE"));
250  desc.add<double>("ECHitCountEnergyThreshold", 0.5);
251  desc.add<double>("EcalInnerConeSize", 0.3);
252  desc.add<double>("EcalOuterConeSize", 0.7);
253  descriptions.add("ecalIsolPartProd", desc);
254 }
255 
258 
Log< level::Info, true > LogVerbatim
edm::EDGetTokenT< EcalRecHitCollection > tok_EB_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< EcalRecHitCollection > tok_EE_
edm::ESGetToken< CaloGeometry, CaloGeometryRecord > tok_geom_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
std::vector< EcalRecHit >::const_iterator const_iterator
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
edm::EDGetTokenT< l1extra::L1JetParticleCollection > tok_l1tau_
bool getData(T &iHolder) const
Definition: EventSetup.h:128
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:19
def move
Definition: eostools.py:511
GlobalPoint getPosition(const DetId &id) const
Get the position of a given detector id.
Definition: CaloGeometry.cc:50
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
#define M_PI
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > tok_hlt_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void add(std::string const &label, ParameterSetDescription const &psetDescription)
T eta() const
Definition: PV3DBase.h:73
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29