CMS 3D CMS Logo

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