CMS 3D CMS Logo

L1ExtraParticlesProd.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1ExtraParticlesProd
4 // Class: L1ExtraParticlesProd
5 //
9 //
10 // Original Author: Werner Sun
11 // Created: Mon Oct 2 22:45:32 EDT 2006
12 //
13 //
14 
15 // system include files
16 #include <memory>
17 
18 // user include files
20 
23 
27 
30 
38 
44 
46 
47 // #include "FWCore/Utilities/interface/EDMException.h"
48 
49 //
50 // class decleration
51 //
52 
53 //
54 // constants, enums and typedefs
55 //
56 
57 //
58 // static data member definitions
59 //
60 
61 double const L1ExtraParticlesProd::muonMassGeV_ = 0.105658369; // PDG06
62 
63 //
64 // constructors and destructor
65 //
67  : produceMuonParticles_(iConfig.getParameter<bool>("produceMuonParticles")),
68  muonSource_(iConfig.getParameter<edm::InputTag>("muonSource")),
69  produceCaloParticles_(iConfig.getParameter<bool>("produceCaloParticles")),
70  isoEmSource_(iConfig.getParameter<edm::InputTag>("isolatedEmSource")),
71  nonIsoEmSource_(
72  iConfig.getParameter<edm::InputTag>("nonIsolatedEmSource")),
73  cenJetSource_(iConfig.getParameter<edm::InputTag>("centralJetSource")),
74  forJetSource_(iConfig.getParameter<edm::InputTag>("forwardJetSource")),
75  tauJetSource_(iConfig.getParameter<edm::InputTag>("tauJetSource")),
76  isoTauJetSource_(iConfig.getParameter<edm::InputTag>("isoTauJetSource")),
77  etTotSource_(iConfig.getParameter<edm::InputTag>("etTotalSource")),
78  etHadSource_(iConfig.getParameter<edm::InputTag>("etHadSource")),
79  etMissSource_(iConfig.getParameter<edm::InputTag>("etMissSource")),
80  htMissSource_(iConfig.getParameter<edm::InputTag>("htMissSource")),
81  hfRingEtSumsSource_(
82  iConfig.getParameter<edm::InputTag>("hfRingEtSumsSource")),
83  hfRingBitCountsSource_(
84  iConfig.getParameter<edm::InputTag>("hfRingBitCountsSource")),
85  centralBxOnly_(iConfig.getParameter<bool>("centralBxOnly")),
86  ignoreHtMiss_(iConfig.getParameter<bool>("ignoreHtMiss")) {
87  using namespace l1extra;
88 
89  // register your products
90  produces<L1EmParticleCollection>("Isolated");
91  produces<L1EmParticleCollection>("NonIsolated");
92  produces<L1JetParticleCollection>("Central");
93  produces<L1JetParticleCollection>("Forward");
94  produces<L1JetParticleCollection>("Tau");
95  produces<L1JetParticleCollection>("IsoTau");
96  produces<L1MuonParticleCollection>();
97  produces<L1EtMissParticleCollection>("MET");
98  produces<L1EtMissParticleCollection>("MHT");
99  produces<L1HFRingsCollection>();
100 
101  // now do what ever other initialization is needed
102  consumes<L1MuGMTReadoutCollection>(muonSource_);
103  consumes<L1GctEmCandCollection>(isoEmSource_);
104  consumes<L1GctEmCandCollection>(nonIsoEmSource_);
105  consumes<L1GctJetCandCollection>(cenJetSource_);
106  consumes<L1GctJetCandCollection>(forJetSource_);
107  consumes<L1GctJetCandCollection>(tauJetSource_);
108  consumes<L1GctJetCandCollection>(isoTauJetSource_);
109  consumes<L1GctEtTotalCollection>(etTotSource_);
110  consumes<L1GctEtMissCollection>(etMissSource_);
111  consumes<L1GctEtHadCollection>(etHadSource_);
112  consumes<L1GctHtMissCollection>(htMissSource_);
113  consumes<L1GctHFRingEtSumsCollection>(hfRingEtSumsSource_);
114  consumes<L1GctHFBitCountsCollection>(hfRingBitCountsSource_);
115 }
116 
118 
119  // do anything here that needs to be done at desctruction time
120  // (e.g. close files, deallocate resources etc.)
121 }
122 
123 //
124 // member functions
125 //
126 
127 // ------------ method called to produce the data ------------
129  const edm::EventSetup &iSetup) {
130  using namespace edm;
131  using namespace l1extra;
132  using namespace std;
133 
134  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
135  // ~~~~~~~~~~~~~~~~~~~~ Muons ~~~~~~~~~~~~~~~~~~~~
136  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
137 
138  unique_ptr<L1MuonParticleCollection> muColl(new L1MuonParticleCollection);
139 
140  if (produceMuonParticles_) {
142  iSetup.get<L1MuTriggerScalesRcd>().get(muScales);
143 
145  iSetup.get<L1MuTriggerPtScaleRcd>().get(muPtScale);
146 
147  Handle<L1MuGMTReadoutCollection> hwMuCollection;
148  iEvent.getByLabel(muonSource_, hwMuCollection);
149 
150  vector<L1MuGMTExtendedCand> hwMuCands;
151 
152  if (!hwMuCollection.isValid()) {
153  LogDebug("L1ExtraParticlesProd")
154  << "\nWarning: L1MuGMTReadoutCollection with " << muonSource_
155  << "\nrequested in configuration, but not found in the event."
156  << std::endl;
157  } else {
158  if (centralBxOnly_) {
159  // Get GMT candidates from central bunch crossing only
160  hwMuCands = hwMuCollection->getRecord().getGMTCands();
161  } else {
162  // Get GMT candidates from all bunch crossings
163  vector<L1MuGMTReadoutRecord> records = hwMuCollection->getRecords();
164  vector<L1MuGMTReadoutRecord>::const_iterator rItr = records.begin();
165  vector<L1MuGMTReadoutRecord>::const_iterator rEnd = records.end();
166 
167  for (; rItr != rEnd; ++rItr) {
168  vector<L1MuGMTExtendedCand> tmpCands = rItr->getGMTCands();
169 
170  hwMuCands.insert(hwMuCands.end(), tmpCands.begin(), tmpCands.end());
171  }
172  }
173 
174  // cout << "HW muons" << endl ;
175  vector<L1MuGMTExtendedCand>::const_iterator muItr = hwMuCands.begin();
176  vector<L1MuGMTExtendedCand>::const_iterator muEnd = hwMuCands.end();
177  for (int i = 0; muItr != muEnd; ++muItr, ++i) {
178  // cout << "#" << i
179  // << " name " << muItr->name()
180  // << " empty " << muItr->empty()
181  // << " pt " << muItr->ptIndex()
182  // << " eta " << muItr->etaIndex()
183  // << " phi " << muItr->phiIndex()
184  // << " iso " << muItr->isol()
185  // << " mip " << muItr->mip()
186  // << " bx " << muItr->bx()
187  // << endl ;
188 
189  if (!muItr->empty()) {
190  // keep x and y components non-zero and protect against roundoff.
191  double pt =
192  muPtScale->getPtScale()->getLowEdge(muItr->ptIndex()) + 1.e-6;
193 
194  // cout << "L1Extra pt " << pt << endl ;
195 
196  double eta = muScales->getGMTEtaScale()->getCenter(muItr->etaIndex());
197 
198  double phi = muScales->getPhiScale()->getLowEdge(muItr->phiIndex());
199 
201 
202  muColl->push_back(
203  L1MuonParticle(muItr->charge(), p4, *muItr, muItr->bx()));
204  }
205  }
206  }
207  }
208 
210  iEvent.put(std::move(muColl));
211 
212  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
213  // ~~~~~~~~~~~~~~~~~~~~ Calorimeter ~~~~~~~~~~~~~~~~~~~~
214  // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
215 
216  unique_ptr<L1EmParticleCollection> isoEmColl(new L1EmParticleCollection);
217 
218  unique_ptr<L1EmParticleCollection> nonIsoEmColl(new L1EmParticleCollection);
219 
220  unique_ptr<L1JetParticleCollection> cenJetColl(new L1JetParticleCollection);
221 
222  unique_ptr<L1JetParticleCollection> forJetColl(new L1JetParticleCollection);
223 
224  unique_ptr<L1JetParticleCollection> tauJetColl(new L1JetParticleCollection);
225 
226  unique_ptr<L1JetParticleCollection> isoTauJetColl(
228 
229  unique_ptr<L1EtMissParticleCollection> etMissColl(
231 
232  unique_ptr<L1EtMissParticleCollection> htMissColl(
234 
235  unique_ptr<L1HFRingsCollection> hfRingsColl(new L1HFRingsCollection);
236 
237  if (produceCaloParticles_) {
238  // ~~~~~~~~~~~~~~~~~~~~ Geometry ~~~~~~~~~~~~~~~~~~~~
239 
240  ESHandle<L1CaloGeometry> caloGeomESH;
241  iSetup.get<L1CaloGeometryRecord>().get(caloGeomESH);
242  const L1CaloGeometry *caloGeom = &(*caloGeomESH);
243 
244  // ~~~~~~~~~~~~~~~~~~~~ EM ~~~~~~~~~~~~~~~~~~~~
245 
246  ESHandle<L1CaloEtScale> emScale;
247  iSetup.get<L1EmEtScaleRcd>().get(emScale);
248 
249  // Isolated EM
250  Handle<L1GctEmCandCollection> hwIsoEmCands;
251  iEvent.getByLabel(isoEmSource_, hwIsoEmCands);
252 
253  if (!hwIsoEmCands.isValid()) {
254  LogDebug("L1ExtraParticlesProd")
255  << "\nWarning: L1GctEmCandCollection with " << isoEmSource_
256  << "\nrequested in configuration, but not found in the event."
257  << std::endl;
258  } else {
259  // cout << "HW iso EM" << endl ;
260 
261  L1GctEmCandCollection::const_iterator emItr = hwIsoEmCands->begin();
262  L1GctEmCandCollection::const_iterator emEnd = hwIsoEmCands->end();
263  for (int i = 0; emItr != emEnd; ++emItr, ++i) {
264  // cout << "#" << i
265  // << " name " << emItr->name()
266  // << " empty " << emItr->empty()
267  // << " rank " << emItr->rank()
268  // << " eta " << emItr->etaIndex()
269  // << " sign " << emItr->etaSign()
270  // << " phi " << emItr->phiIndex()
271  // << " iso " << emItr->isolated()
272  // << " bx " << emItr->bx()
273  // << endl ;
274 
275  if (!emItr->empty() && (!centralBxOnly_ || emItr->bx() == 0)) {
276  double et = emScale->et(emItr->rank());
277 
278  // cout << "L1Extra et " << et << endl ;
279 
280  isoEmColl->push_back(L1EmParticle(
281  gctLorentzVector(et, *emItr, caloGeom, true),
282  Ref<L1GctEmCandCollection>(hwIsoEmCands, i), emItr->bx()));
283  }
284  }
285  }
286 
287  // Non-isolated EM
288  Handle<L1GctEmCandCollection> hwNonIsoEmCands;
289  iEvent.getByLabel(nonIsoEmSource_, hwNonIsoEmCands);
290 
291  if (!hwNonIsoEmCands.isValid()) {
292  LogDebug("L1ExtraParticlesProd")
293  << "\nWarning: L1GctEmCandCollection with " << nonIsoEmSource_
294  << "\nrequested in configuration, but not found in the event."
295  << std::endl;
296  } else {
297  // cout << "HW non-iso EM" << endl ;
298  L1GctEmCandCollection::const_iterator emItr = hwNonIsoEmCands->begin();
299  L1GctEmCandCollection::const_iterator emEnd = hwNonIsoEmCands->end();
300  for (int i = 0; emItr != emEnd; ++emItr, ++i) {
301  // cout << "#" << i
302  // << " name " << emItr->name()
303  // << " empty " << emItr->empty()
304  // << " rank " << emItr->rank()
305  // << " eta " << emItr->etaIndex()
306  // << " sign " << emItr->etaSign()
307  // << " phi " << emItr->phiIndex()
308  // << " iso " << emItr->isolated()
309  // << " bx " << emItr->bx()
310  // << endl ;
311 
312  if (!emItr->empty() && (!centralBxOnly_ || emItr->bx() == 0)) {
313  double et = emScale->et(emItr->rank());
314 
315  // cout << "L1Extra et " << et << endl ;
316 
317  nonIsoEmColl->push_back(L1EmParticle(
318  gctLorentzVector(et, *emItr, caloGeom, true),
319  Ref<L1GctEmCandCollection>(hwNonIsoEmCands, i), emItr->bx()));
320  }
321  }
322  }
323 
324  // ~~~~~~~~~~~~~~~~~~~~ Jets ~~~~~~~~~~~~~~~~~~~~
325 
327  iSetup.get<L1JetEtScaleRcd>().get(jetScale);
328 
329  // Central jets.
330  Handle<L1GctJetCandCollection> hwCenJetCands;
331  iEvent.getByLabel(cenJetSource_, hwCenJetCands);
332 
333  if (!hwCenJetCands.isValid()) {
334  LogDebug("L1ExtraParticlesProd")
335  << "\nWarning: L1GctJetCandCollection with " << cenJetSource_
336  << "\nrequested in configuration, but not found in the event."
337  << std::endl;
338  } else {
339  // cout << "HW central jets" << endl ;
340  L1GctJetCandCollection::const_iterator jetItr = hwCenJetCands->begin();
341  L1GctJetCandCollection::const_iterator jetEnd = hwCenJetCands->end();
342  for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
343  // cout << "#" << i
344  // << " name " << jetItr->name()
345  // << " empty " << jetItr->empty()
346  // << " rank " << jetItr->rank()
347  // << " eta " << jetItr->etaIndex()
348  // << " sign " << jetItr->etaSign()
349  // << " phi " << jetItr->phiIndex()
350  // << " cen " << jetItr->isCentral()
351  // << " for " << jetItr->isForward()
352  // << " tau " << jetItr->isTau()
353  // << " bx " << jetItr->bx()
354  // << endl ;
355 
356  if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
357  double et = jetScale->et(jetItr->rank());
358 
359  // cout << "L1Extra et " << et << endl ;
360 
361  cenJetColl->push_back(L1JetParticle(
362  gctLorentzVector(et, *jetItr, caloGeom, true),
363  Ref<L1GctJetCandCollection>(hwCenJetCands, i), jetItr->bx()));
364  }
365  }
366  }
367 
368  // Forward jets.
369  Handle<L1GctJetCandCollection> hwForJetCands;
370  iEvent.getByLabel(forJetSource_, hwForJetCands);
371 
372  if (!hwForJetCands.isValid()) {
373  LogDebug("L1ExtraParticlesProd")
374  << "\nWarning: L1GctEmCandCollection with " << forJetSource_
375  << "\nrequested in configuration, but not found in the event."
376  << std::endl;
377  } else {
378  // cout << "HW forward jets" << endl ;
379  L1GctJetCandCollection::const_iterator jetItr = hwForJetCands->begin();
380  L1GctJetCandCollection::const_iterator jetEnd = hwForJetCands->end();
381  for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
382  // cout << "#" << i
383  // << " name " << jetItr->name()
384  // << " empty " << jetItr->empty()
385  // << " rank " << jetItr->rank()
386  // << " eta " << jetItr->etaIndex()
387  // << " sign " << jetItr->etaSign()
388  // << " phi " << jetItr->phiIndex()
389  // << " cen " << jetItr->isCentral()
390  // << " for " << jetItr->isForward()
391  // << " tau " << jetItr->isTau()
392  // << " bx " << jetItr->bx()
393  // << endl ;
394 
395  if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
396  double et = jetScale->et(jetItr->rank());
397 
398  // cout << "L1Extra et " << et << endl ;
399 
400  forJetColl->push_back(L1JetParticle(
401  gctLorentzVector(et, *jetItr, caloGeom, false),
402  Ref<L1GctJetCandCollection>(hwForJetCands, i), jetItr->bx()));
403  }
404  }
405  }
406 
407  // Tau jets.
408  // cout << "HW tau jets" << endl ;
409  Handle<L1GctJetCandCollection> hwTauJetCands;
410  iEvent.getByLabel(tauJetSource_, hwTauJetCands);
411 
412  if (!hwTauJetCands.isValid()) {
413  LogDebug("L1ExtraParticlesProd")
414  << "\nWarning: L1GctJetCandCollection with " << tauJetSource_
415  << "\nrequested in configuration, but not found in the event."
416  << std::endl;
417  } else {
418  L1GctJetCandCollection::const_iterator jetItr = hwTauJetCands->begin();
419  L1GctJetCandCollection::const_iterator jetEnd = hwTauJetCands->end();
420  for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
421  // cout << "#" << i
422  // << " name " << jetItr->name()
423  // << " empty " << jetItr->empty()
424  // << " rank " << jetItr->rank()
425  // << " eta " << jetItr->etaIndex()
426  // << " sign " << jetItr->etaSign()
427  // << " phi " << jetItr->phiIndex()
428  // << " cen " << jetItr->isCentral()
429  // << " for " << jetItr->isForward()
430  // << " tau " << jetItr->isTau()
431  // << " bx " << jetItr->bx()
432  // << endl ;
433 
434  if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
435  double et = jetScale->et(jetItr->rank());
436 
437  // cout << "L1Extra et " << et << endl ;
438 
439  tauJetColl->push_back(L1JetParticle(
440  gctLorentzVector(et, *jetItr, caloGeom, true),
441  Ref<L1GctJetCandCollection>(hwTauJetCands, i), jetItr->bx()));
442  }
443  }
444  }
445 
446  // Isolated Tau jets.
447  // cout << "HW tau jets" << endl ;
448  Handle<L1GctJetCandCollection> hwIsoTauJetCands;
449  iEvent.getByLabel(isoTauJetSource_, hwIsoTauJetCands);
450 
451  if (!hwIsoTauJetCands.isValid()) {
452  LogDebug("L1ExtraParticlesProd")
453  << "\nWarning: L1GctJetCandCollection with " << isoTauJetSource_
454  << "\nrequested in configuration, but not found in the event."
455  << std::endl;
456  } else {
457  L1GctJetCandCollection::const_iterator jetItr = hwIsoTauJetCands->begin();
458  L1GctJetCandCollection::const_iterator jetEnd = hwIsoTauJetCands->end();
459  for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
460  // cout << "#" << i
461  // << " name " << jetItr->name()
462  // << " empty " << jetItr->empty()
463  // << " rank " << jetItr->rank()
464  // << " eta " << jetItr->etaIndex()
465  // << " sign " << jetItr->etaSign()
466  // << " phi " << jetItr->phiIndex()
467  // << " cen " << jetItr->isCentral()
468  // << " for " << jetItr->isForward()
469  // << " tau " << jetItr->isTau()
470  // << " bx " << jetItr->bx()
471  // << endl ;
472 
473  if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
474  double et = jetScale->et(jetItr->rank());
475 
476  // cout << "L1Extra et " << et << endl ;
477 
478  isoTauJetColl->push_back(L1JetParticle(
479  gctLorentzVector(et, *jetItr, caloGeom, true),
480  Ref<L1GctJetCandCollection>(hwIsoTauJetCands, i), jetItr->bx()));
481  }
482  }
483  }
484 
485  // ~~~~~~~~~~~~~~~~~~~~ ET Sums ~~~~~~~~~~~~~~~~~~~~
486 
487  double etSumLSB = jetScale->linearLsb();
488 
489  Handle<L1GctEtTotalCollection> hwEtTotColl;
490  iEvent.getByLabel(etTotSource_, hwEtTotColl);
491 
492  Handle<L1GctEtMissCollection> hwEtMissColl;
493  iEvent.getByLabel(etMissSource_, hwEtMissColl);
494 
495  if (!hwEtTotColl.isValid()) {
496  LogDebug("L1ExtraParticlesProd")
497  << "\nWarning: L1GctEtTotalCollection with " << etTotSource_
498  << "\nrequested in configuration, but not found in the event."
499  << std::endl;
500  } else if (!hwEtMissColl.isValid()) {
501  LogDebug("L1ExtraParticlesProd")
502  << "\nWarning: L1GctEtMissCollection with " << etMissSource_
503  << "\nrequested in configuration, but not found in the event."
504  << std::endl;
505  } else {
506  // Make a L1EtMissParticle even if either L1GctEtTotal or L1GctEtMiss
507  // is missing for a given bx. Keep track of which L1GctEtMiss objects
508  // have a corresponding L1GctEtTotal object.
509  std::vector<bool> etMissMatched;
510 
511  L1GctEtMissCollection::const_iterator hwEtMissItr = hwEtMissColl->begin();
512  L1GctEtMissCollection::const_iterator hwEtMissEnd = hwEtMissColl->end();
513  for (; hwEtMissItr != hwEtMissEnd; ++hwEtMissItr) {
514  etMissMatched.push_back(false);
515  }
516 
517  // Collate energy sums by bx
518  L1GctEtTotalCollection::const_iterator hwEtTotItr = hwEtTotColl->begin();
519  L1GctEtTotalCollection::const_iterator hwEtTotEnd = hwEtTotColl->end();
520 
521  int iTot = 0;
522  for (; hwEtTotItr != hwEtTotEnd; ++hwEtTotItr, ++iTot) {
523  int bx = hwEtTotItr->bx();
524 
525  if (!centralBxOnly_ || bx == 0) {
526  // ET bin low edge
527  double etTot =
528  (hwEtTotItr->overFlow() ? (double)L1GctEtTotal::kEtTotalMaxValue
529  : (double)hwEtTotItr->et()) *
530  etSumLSB +
531  1.e-6;
532 
533  int iMiss = 0;
534  hwEtMissItr = hwEtMissColl->begin();
535  hwEtMissEnd = hwEtMissColl->end();
536  for (; hwEtMissItr != hwEtMissEnd; ++hwEtMissItr, ++iMiss) {
537  if (hwEtMissItr->bx() == bx) {
538  etMissMatched[iMiss] = true;
539  break;
540  }
541  }
542 
543  double etMiss = 0.;
544  double phi = 0.;
547 
548  // If a L1GctEtMiss with the right bx is not found, itr == end.
549  if (hwEtMissItr != hwEtMissEnd) {
550  // ET bin low edge
551  etMiss =
552  (hwEtMissItr->overFlow() ? (double)L1GctEtMiss::kEtMissMaxValue
553  : (double)hwEtMissItr->et()) *
554  etSumLSB +
555  1.e-6;
556  // keep x and y components non-zero and
557  // protect against roundoff.
558 
559  phi = caloGeom->etSumPhiBinCenter(hwEtMissItr->phi());
560 
561  p4 = math::PtEtaPhiMLorentzVector(etMiss, 0., phi, 0.);
562 
563  metRef = Ref<L1GctEtMissCollection>(hwEtMissColl, iMiss);
564 
565  // cout << "HW ET Sums " << endl
566  // << "MET: phi " << hwEtMissItr->phi() << " = " << phi
567  // << " et " << hwEtMissItr->et() << " = " << etMiss
568  // << " EtTot " << hwEtTotItr->et() << " = " << etTot
569  // << " bx " << bx
570  // << endl ;
571  }
572  // else
573  // {
574  // cout << "HW ET Sums " << endl
575  // << "MET: phi " << phi
576  // << " et "<< etMiss
577  // << " EtTot " << hwEtTotItr->et() << " = " << etTot
578  // << " bx " << bx
579  // << endl ;
580  // }
581 
582  etMissColl->push_back(L1EtMissParticle(
583  p4, L1EtMissParticle::kMET, etTot, metRef,
584  Ref<L1GctEtTotalCollection>(hwEtTotColl, iTot),
586  }
587  }
588 
589  if (!centralBxOnly_) {
590  // Make L1EtMissParticles for those L1GctEtMiss objects without
591  // a matched L1GctEtTotal object.
592 
593  double etTot = 0.;
594 
595  hwEtMissItr = hwEtMissColl->begin();
596  hwEtMissEnd = hwEtMissColl->end();
597  int iMiss = 0;
598  for (; hwEtMissItr != hwEtMissEnd; ++hwEtMissItr, ++iMiss) {
599  if (!etMissMatched[iMiss]) {
600  int bx = hwEtMissItr->bx();
601 
602  // ET bin low edge
603  double etMiss =
604  (hwEtMissItr->overFlow() ? (double)L1GctEtMiss::kEtMissMaxValue
605  : (double)hwEtMissItr->et()) *
606  etSumLSB +
607  1.e-6;
608  // keep x and y components non-zero and
609  // protect against roundoff.
610 
611  double phi = caloGeom->etSumPhiBinCenter(hwEtMissItr->phi());
612 
613  math::PtEtaPhiMLorentzVector p4(etMiss, 0., phi, 0.);
614 
615  // cout << "HW ET Sums " << endl
616  // << "MET: phi " << hwEtMissItr->phi() << " = " <<
617  // phi
618  // << " et " << hwEtMissItr->et() << " = " << etMiss
619  // << " EtTot " << etTot
620  // << " bx " << bx
621  // << endl ;
622 
623  etMissColl->push_back(L1EtMissParticle(
624  p4, L1EtMissParticle::kMET, etTot,
625  Ref<L1GctEtMissCollection>(hwEtMissColl, iMiss),
628  }
629  }
630  }
631  }
632 
633  // ~~~~~~~~~~~~~~~~~~~~ HT Sums ~~~~~~~~~~~~~~~~~~~~
634 
635  Handle<L1GctEtHadCollection> hwEtHadColl;
636  iEvent.getByLabel(etHadSource_, hwEtHadColl);
637 
638  Handle<L1GctHtMissCollection> hwHtMissColl;
639  if (!ignoreHtMiss_) {
640  iEvent.getByLabel(htMissSource_, hwHtMissColl);
641  }
642 
643  ESHandle<L1GctJetFinderParams> jetFinderParams;
644  iSetup.get<L1GctJetFinderParamsRcd>().get(jetFinderParams);
645  double htSumLSB = jetFinderParams->getHtLsbGeV();
646 
647  ESHandle<L1CaloEtScale> htMissScale;
648  std::vector<bool> htMissMatched;
649  if (!ignoreHtMiss_) {
650  iSetup.get<L1HtMissScaleRcd>().get(htMissScale);
651 
652  if (!hwEtHadColl.isValid()) {
653  LogDebug("L1ExtraParticlesProd")
654  << "\nWarning: L1GctEtHadCollection with " << etHadSource_
655  << "\nrequested in configuration, but not found in the event."
656  << std::endl;
657  } else if (!hwHtMissColl.isValid()) {
658  LogDebug("L1ExtraParticlesProd")
659  << "\nWarning: L1GctHtMissCollection with " << htMissSource_
660  << "\nrequested in configuration, but not found in the event."
661  << std::endl;
662  } else {
663  // Make a L1EtMissParticle even if either L1GctEtHad or L1GctHtMiss
664  // is missing for a given bx. Keep track of which L1GctHtMiss objects
665  // have a corresponding L1GctHtTotal object.
666  L1GctHtMissCollection::const_iterator hwHtMissItr =
667  hwHtMissColl->begin();
668  L1GctHtMissCollection::const_iterator hwHtMissEnd = hwHtMissColl->end();
669  for (; hwHtMissItr != hwHtMissEnd; ++hwHtMissItr) {
670  htMissMatched.push_back(false);
671  }
672  }
673  }
674 
675  if (!hwEtHadColl.isValid()) {
676  LogDebug("L1ExtraParticlesProd")
677  << "\nWarning: L1GctEtHadCollection with " << etHadSource_
678  << "\nrequested in configuration, but not found in the event."
679  << std::endl;
680  } else if (!hwHtMissColl.isValid()) {
681  LogDebug("L1ExtraParticlesProd")
682  << "\nWarning: L1GctHtMissCollection with " << htMissSource_
683  << "\nrequested in configuration, but not found in the event."
684  << std::endl;
685  } else {
686  L1GctEtHadCollection::const_iterator hwEtHadItr = hwEtHadColl->begin();
687  L1GctEtHadCollection::const_iterator hwEtHadEnd = hwEtHadColl->end();
688 
689  int iHad = 0;
690  for (; hwEtHadItr != hwEtHadEnd; ++hwEtHadItr, ++iHad) {
691  int bx = hwEtHadItr->bx();
692 
693  if (!centralBxOnly_ || bx == 0) {
694  // HT bin low edge
695  double htTot =
696  (hwEtHadItr->overFlow() ? (double)L1GctEtHad::kEtHadMaxValue
697  : (double)hwEtHadItr->et()) *
698  htSumLSB +
699  1.e-6;
700 
701  double htMiss = 0.;
702  double phi = 0.;
705 
706  if (!ignoreHtMiss_) {
707  L1GctHtMissCollection::const_iterator hwHtMissItr =
708  hwHtMissColl->begin();
709  L1GctHtMissCollection::const_iterator hwHtMissEnd =
710  hwHtMissColl->end();
711 
712  int iMiss = 0;
713  for (; hwHtMissItr != hwHtMissEnd; ++hwHtMissItr, ++iMiss) {
714  if (hwHtMissItr->bx() == bx) {
715  htMissMatched[iMiss] = true;
716  break;
717  }
718  }
719 
720  // If a L1GctHtMiss with the right bx is not found, itr == end.
721  if (hwHtMissItr != hwHtMissEnd) {
722  // HT bin low edge
723  htMiss = htMissScale->et(hwHtMissItr->overFlow()
724  ? htMissScale->rankScaleMax()
725  : hwHtMissItr->et()) +
726  1.e-6;
727  // keep x and y components non-zero and
728  // protect against roundoff.
729 
730  phi = caloGeom->htSumPhiBinCenter(hwHtMissItr->phi());
731 
732  p4 = math::PtEtaPhiMLorentzVector(htMiss, 0., phi, 0.);
733 
734  mhtRef = Ref<L1GctHtMissCollection>(hwHtMissColl, iMiss);
735 
736  // cout << "HW HT Sums " << endl
737  // << "MHT: phi " << hwHtMissItr->phi() <<
738  // " = " << phi
739  // << " ht " << hwHtMissItr->et() << " = "
740  // << htMiss
741  // << " HtTot " << hwEtHadItr->et() << " =
742  // "
743  // << htTot
744  // << " bx " << bx
745  // << endl ;
746  }
747  // else
748  // {
749  // cout << "HW HT Sums " << endl
750  // << "MHT: phi " << phi
751  // << " ht " << htMiss
752  // << " HtTot " << hwEtHadItr->et() << " = " <<
753  // htTot
754  // << " bx " << bx
755  // << endl ;
756  // }
757  }
758 
759  htMissColl->push_back(L1EtMissParticle(
760  p4, L1EtMissParticle::kMHT, htTot, Ref<L1GctEtMissCollection>(),
761  Ref<L1GctEtTotalCollection>(), mhtRef,
762  Ref<L1GctEtHadCollection>(hwEtHadColl, iHad), bx));
763  }
764  }
765 
766  if (!centralBxOnly_ && !ignoreHtMiss_) {
767  // Make L1EtMissParticles for those L1GctHtMiss objects without
768  // a matched L1GctHtTotal object.
769  double htTot = 0.;
770 
771  L1GctHtMissCollection::const_iterator hwHtMissItr =
772  hwHtMissColl->begin();
773  L1GctHtMissCollection::const_iterator hwHtMissEnd = hwHtMissColl->end();
774 
775  int iMiss = 0;
776  for (; hwHtMissItr != hwHtMissEnd; ++hwHtMissItr, ++iMiss) {
777  if (!htMissMatched[iMiss]) {
778  int bx = hwHtMissItr->bx();
779 
780  // HT bin low edge
781  double htMiss = htMissScale->et(hwHtMissItr->overFlow()
782  ? htMissScale->rankScaleMax()
783  : hwHtMissItr->et()) +
784  1.e-6;
785  // keep x and y components non-zero and
786  // protect against roundoff.
787 
788  double phi = caloGeom->htSumPhiBinCenter(hwHtMissItr->phi());
789 
790  math::PtEtaPhiMLorentzVector p4(htMiss, 0., phi, 0.);
791 
792  // cout << "HW HT Sums " << endl
793  // << "MHT: phi " << hwHtMissItr->phi() << " = " <<
794  // phi
795  // << " ht " << hwHtMissItr->et() << " = " << htMiss
796  // << " HtTot " << htTot
797  // << " bx " << bx
798  // << endl ;
799 
800  htMissColl->push_back(L1EtMissParticle(
801  p4, L1EtMissParticle::kMHT, htTot, Ref<L1GctEtMissCollection>(),
803  Ref<L1GctHtMissCollection>(hwHtMissColl, iMiss),
805  }
806  }
807  }
808  }
809 
810  // ~~~~~~~~~~~~~~~~~~~~ HF Rings ~~~~~~~~~~~~~~~~~~~~
811 
813  iEvent.getByLabel(hfRingEtSumsSource_, hwHFEtSumsColl);
814 
815  Handle<L1GctHFBitCountsCollection> hwHFBitCountsColl;
816  iEvent.getByLabel(hfRingBitCountsSource_, hwHFBitCountsColl);
817 
818  ESHandle<L1CaloEtScale> hfRingEtScale;
819  iSetup.get<L1HfRingEtScaleRcd>().get(hfRingEtScale);
820 
821  if (!hwHFEtSumsColl.isValid()) {
822  LogDebug("L1ExtraParticlesProd")
823  << "\nWarning: L1GctHFRingEtSumsCollection with "
825  << "\nrequested in configuration, but not found in the event."
826  << std::endl;
827  } else if (!hwHFBitCountsColl.isValid()) {
828  LogDebug("L1ExtraParticlesProd")
829  << "\nWarning: L1GctHFBitCountsCollection with "
831  << "\nrequested in configuration, but not found in the event."
832  << std::endl;
833  } else {
834  L1GctHFRingEtSumsCollection::const_iterator hwHFEtSumsItr =
835  hwHFEtSumsColl->begin();
836  L1GctHFRingEtSumsCollection::const_iterator hwHFEtSumsEnd =
837  hwHFEtSumsColl->end();
838 
839  int iEtSums = 0;
840  for (; hwHFEtSumsItr != hwHFEtSumsEnd; ++hwHFEtSumsItr, ++iEtSums) {
841  int bx = hwHFEtSumsItr->bx();
842 
843  if (!centralBxOnly_ || bx == 0) {
844  L1GctHFBitCountsCollection::const_iterator hwHFBitCountsItr =
845  hwHFBitCountsColl->begin();
846  L1GctHFBitCountsCollection::const_iterator hwHFBitCountsEnd =
847  hwHFBitCountsColl->end();
848 
849  int iBitCounts = 0;
850  for (; hwHFBitCountsItr != hwHFBitCountsEnd;
851  ++hwHFBitCountsItr, ++iBitCounts) {
852  if (hwHFBitCountsItr->bx() == bx) {
853  break;
854  }
855  }
856 
857  // If a L1GctHFBitCounts with the right bx is not found, itr == end.
858  if (hwHFBitCountsItr != hwHFBitCountsEnd) {
859  // Construct L1HFRings only if both HW objects are present.
860 
861  // cout << "HF Rings " << endl
862 
863  // HF Et sums
864  double etSums[L1HFRings::kNumRings];
865  etSums[L1HFRings::kRing1PosEta] =
866  hfRingEtScale->et(hwHFEtSumsItr->etSum(0)) + 1.e-6;
867  etSums[L1HFRings::kRing1NegEta] =
868  hfRingEtScale->et(hwHFEtSumsItr->etSum(1)) + 1.e-6;
869  etSums[L1HFRings::kRing2PosEta] =
870  hfRingEtScale->et(hwHFEtSumsItr->etSum(2)) + 1.e-6;
871  etSums[L1HFRings::kRing2NegEta] =
872  hfRingEtScale->et(hwHFEtSumsItr->etSum(3)) + 1.e-6;
873  // protect against roundoff.
874 
875  // cout << "HF Et Sums "
876  // << hwHFEtSumsItr->etSum( 0 ) << " = "
877  // << etSums[ L1HFRings::kRing1PosEta ] << " "
878  // << hwHFEtSumsItr->etSum( 1 ) << " = "
879  // << etSums[ L1HFRings::kRing1NegEta ] << " "
880  // << hwHFEtSumsItr->etSum( 2 ) << " = "
881  // << etSums[ L1HFRings::kRing2PosEta ] << " "
882  // << hwHFEtSumsItr->etSum( 3 ) << " = "
883  // << etSums[ L1HFRings::kRing2NegEta ]
884  // << endl ;
885 
886  // HF bit counts
887  int bitCounts[L1HFRings::kNumRings];
888  bitCounts[L1HFRings::kRing1PosEta] = hwHFBitCountsItr->bitCount(0);
889  bitCounts[L1HFRings::kRing1NegEta] = hwHFBitCountsItr->bitCount(1);
890  bitCounts[L1HFRings::kRing2PosEta] = hwHFBitCountsItr->bitCount(2);
891  bitCounts[L1HFRings::kRing2NegEta] = hwHFBitCountsItr->bitCount(3);
892 
893  // cout << "HF bit counts "
894  // << hwHFBitCountsItr->bitCount( 0 ) << " "
895  // << hwHFBitCountsItr->bitCount( 1 ) << " "
896  // << hwHFBitCountsItr->bitCount( 2 ) << " "
897  // << hwHFBitCountsItr->bitCount( 3 ) << " "
898  // << endl ;
899 
900  hfRingsColl->push_back(L1HFRings(
901  etSums, bitCounts,
902  Ref<L1GctHFRingEtSumsCollection>(hwHFEtSumsColl, iEtSums),
903  Ref<L1GctHFBitCountsCollection>(hwHFBitCountsColl, iBitCounts),
904  bx));
905  }
906  }
907  }
908  }
909  }
910 
912  iEvent.put(std::move(isoEmColl), "Isolated");
913 
914  OrphanHandle<L1EmParticleCollection> nonIsoEmHandle =
915  iEvent.put(std::move(nonIsoEmColl), "NonIsolated");
916 
918  iEvent.put(std::move(cenJetColl), "Central");
919 
921  iEvent.put(std::move(forJetColl), "Forward");
922 
924  iEvent.put(std::move(tauJetColl), "Tau");
925 
926  OrphanHandle<L1JetParticleCollection> IsoTauJetHandle =
927  iEvent.put(std::move(isoTauJetColl), "IsoTau");
928 
930  iEvent.put(std::move(etMissColl), "MET");
931 
933  iEvent.put(std::move(htMissColl), "MHT");
934 
935  OrphanHandle<L1HFRingsCollection> hfRingsCollHandle =
936  iEvent.put(std::move(hfRingsColl));
937 }
938 
939 // math::XYZTLorentzVector
942  const L1CaloGeometry *geom,
943  bool central) {
944  // To keep x and y components non-zero.
945  double etCorr = et + 1.e-6; // protect against roundoff, not only for et=0
946 
947  double eta = geom->etaBinCenter(cand.etaIndex(), central);
948 
949  // double tanThOver2 = exp( -eta ) ;
950  // double ez = etCorr * ( 1. - tanThOver2 * tanThOver2 ) / ( 2. *
951  // tanThOver2 ); double e = etCorr * ( 1. + tanThOver2 * tanThOver2 ) /
952  // ( 2. * tanThOver2 );
953 
954  double phi = geom->emJetPhiBinCenter(cand.phiIndex());
955 
956  // return math::XYZTLorentzVector( etCorr * cos( phi ),
957  // etCorr * sin( phi ),
958  // ez,
959  // e ) ;
960  return math::PtEtaPhiMLorentzVector(etCorr, eta, phi, 0.);
961 }
962 
963 // define this as a plug-in
#define LogDebug(id)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
std::vector< L1MuGMTExtendedCand > getGMTCands() const
get GMT candidates vector
const L1MuScale * getPtScale() const
get the Pt scale
math::PtEtaPhiMLorentzVector gctLorentzVector(const double &et, const L1GctCand &cand, const L1CaloGeometry *geom, bool central)
virtual float getCenter(unsigned packed) const =0
get the center of bin represented by packed
double etaBinCenter(unsigned int etaIndex, bool central=true) const
double getHtLsbGeV() const
double et(const uint16_t rank) const
convert from rank to physically meaningful quantity
double linearLsb() const
get LSB of linear input scale
Definition: L1CaloEtScale.h:53
static const double muonMassGeV_
virtual unsigned phiIndex() const =0
get phi index (0-17)
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
double p4[4]
Definition: TauolaWrapper.h:92
double htSumPhiBinCenter(unsigned int phiIndex) const
edm::InputTag hfRingEtSumsSource_
const L1MuScale * getPhiScale() const
get the phi scale
virtual unsigned etaIndex() const =0
get eta index (bit 3 is sign, 1 for -ve Z, 0 for +ve Z)
edm::InputTag hfRingBitCountsSource_
void produce(edm::Event &, const edm::EventSetup &) override
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
edm::InputTag isoTauJetSource_
et
define resolution functions of each parameter
HLT enums.
std::vector< L1MuGMTReadoutRecord > const & getRecords() const
T get() const
Definition: EventSetup.h:71
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
ABC for GCT EM and jet candidates.
Definition: L1GctCand.h:12
double emJetPhiBinCenter(unsigned int phiIndex) const
const L1MuScale * getGMTEtaScale() const
get the GMT eta scale
std::vector< L1EtMissParticle > L1EtMissParticleCollection
L1MuGMTReadoutRecord const & getRecord(int bx=0) const
L1ExtraParticlesProd(const edm::ParameterSet &)
double etSumPhiBinCenter(unsigned int phiIndex) const
def move(src, dest)
Definition: eostools.py:511
unsigned rankScaleMax() const
Definition: L1CaloEtScale.h:50