00001
00002
00003
00004
00005
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <memory>
00018
00019
00020 #include "L1Trigger/L1ExtraFromDigis/interface/L1ExtraParticlesProd.h"
00021
00022 #include "FWCore/Framework/interface/Frameworkfwd.h"
00023
00024
00025 #include "DataFormats/Common/interface/Handle.h"
00026 #include "FWCore/Framework/interface/ESHandle.h"
00027 #include "DataFormats/Common/interface/OrphanHandle.h"
00028
00029 #include "CondFormats/L1TObjects/interface/L1CaloGeometry.h"
00030 #include "CondFormats/DataRecord/interface/L1CaloGeometryRecord.h"
00031
00032 #include "CondFormats/L1TObjects/interface/L1CaloEtScale.h"
00033 #include "CondFormats/DataRecord/interface/L1EmEtScaleRcd.h"
00034 #include "CondFormats/DataRecord/interface/L1JetEtScaleRcd.h"
00035 #include "CondFormats/L1TObjects/interface/L1GctJetEtCalibrationFunction.h"
00036 #include "CondFormats/DataRecord/interface/L1GctJetCalibFunRcd.h"
00037
00038 #include "CondFormats/L1TObjects/interface/L1MuTriggerScales.h"
00039 #include "CondFormats/DataRecord/interface/L1MuTriggerScalesRcd.h"
00040 #include "CondFormats/L1TObjects/interface/L1MuTriggerPtScale.h"
00041 #include "CondFormats/DataRecord/interface/L1MuTriggerPtScaleRcd.h"
00042 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00043
00044 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 double L1ExtraParticlesProd::muonMassGeV_ = 0.105658369 ;
00062
00063
00064
00065
00066 L1ExtraParticlesProd::L1ExtraParticlesProd(const edm::ParameterSet& iConfig)
00067 : produceMuonParticles_( iConfig.getParameter< bool >(
00068 "produceMuonParticles" ) ),
00069 muonSource_( iConfig.getParameter< edm::InputTag >(
00070 "muonSource" ) ),
00071 produceCaloParticles_( iConfig.getParameter< bool >(
00072 "produceCaloParticles" ) ),
00073 isoEmSource_( iConfig.getParameter< edm::InputTag >(
00074 "isolatedEmSource" ) ),
00075 nonIsoEmSource_( iConfig.getParameter< edm::InputTag >(
00076 "nonIsolatedEmSource" ) ),
00077 cenJetSource_( iConfig.getParameter< edm::InputTag >(
00078 "centralJetSource" ) ),
00079 forJetSource_( iConfig.getParameter< edm::InputTag >(
00080 "forwardJetSource" ) ),
00081 tauJetSource_( iConfig.getParameter< edm::InputTag >(
00082 "tauJetSource" ) ),
00083 etTotSource_( iConfig.getParameter< edm::InputTag >(
00084 "etTotalSource" ) ),
00085 etHadSource_( iConfig.getParameter< edm::InputTag >(
00086 "etHadSource" ) ),
00087 etMissSource_( iConfig.getParameter< edm::InputTag >(
00088 "etMissSource" ) ),
00089 centralBxOnly_( iConfig.getParameter< bool >(
00090 "centralBxOnly" ) )
00091 {
00092 using namespace l1extra ;
00093
00094
00095 produces< L1EmParticleCollection >( "Isolated" ) ;
00096 produces< L1EmParticleCollection >( "NonIsolated" ) ;
00097 produces< L1JetParticleCollection >( "Central" ) ;
00098 produces< L1JetParticleCollection >( "Forward" ) ;
00099 produces< L1JetParticleCollection >( "Tau" ) ;
00100 produces< L1MuonParticleCollection >() ;
00101
00102 produces< L1EtMissParticleCollection >() ;
00103
00104
00105 }
00106
00107
00108 L1ExtraParticlesProd::~L1ExtraParticlesProd()
00109 {
00110
00111
00112
00113
00114 }
00115
00116
00117
00118
00119
00120
00121
00122 void
00123 L1ExtraParticlesProd::produce( edm::Event& iEvent,
00124 const edm::EventSetup& iSetup)
00125 {
00126 using namespace edm ;
00127 using namespace l1extra ;
00128 using namespace std ;
00129
00130
00131
00132
00133
00134 if( produceMuonParticles_ )
00135 {
00136 ESHandle< L1MuTriggerScales > muScales ;
00137 iSetup.get< L1MuTriggerScalesRcd >().get( muScales ) ;
00138
00139 ESHandle< L1MuTriggerPtScale > muPtScale ;
00140 iSetup.get< L1MuTriggerPtScaleRcd >().get( muPtScale ) ;
00141
00142 Handle< L1MuGMTReadoutCollection > hwMuCollection ;
00143 iEvent.getByLabel( muonSource_, hwMuCollection ) ;
00144
00145 vector< L1MuGMTExtendedCand > hwMuCands ;
00146
00147 if( centralBxOnly_ )
00148 {
00149
00150 hwMuCands = hwMuCollection->getRecord().getGMTCands() ;
00151 }
00152 else
00153 {
00154
00155 vector< L1MuGMTReadoutRecord > records = hwMuCollection->getRecords();
00156 vector< L1MuGMTReadoutRecord >::const_iterator rItr = records.begin();
00157 vector< L1MuGMTReadoutRecord >::const_iterator rEnd = records.end();
00158
00159 for( ; rItr != rEnd ; ++rItr )
00160 {
00161 vector< L1MuGMTExtendedCand > tmpCands = rItr->getGMTCands() ;
00162
00163 hwMuCands.insert( hwMuCands.end(),
00164 tmpCands.begin(),
00165 tmpCands.end() ) ;
00166 }
00167 }
00168
00169 auto_ptr< L1MuonParticleCollection > muColl(
00170 new L1MuonParticleCollection );
00171
00172
00173 vector< L1MuGMTExtendedCand >::const_iterator muItr = hwMuCands.begin() ;
00174 vector< L1MuGMTExtendedCand >::const_iterator muEnd = hwMuCands.end() ;
00175 for( int i = 0 ; muItr != muEnd ; ++muItr, ++i )
00176 {
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 if( !muItr->empty() )
00189 {
00190
00191 double pt =
00192 muPtScale->getPtScale()->getLowEdge( muItr->ptIndex() ) + 1.e-6 ;
00193
00194
00195
00196
00197 double eta =
00198 muScales->getGMTEtaScale()->getCenter( muItr->etaIndex() ) ;
00199
00200 double phi =
00201 muScales->getPhiScale()->getLowEdge( muItr->phiIndex() ) ;
00202
00203 math::PtEtaPhiMLorentzVector p4( pt,
00204 eta,
00205 phi,
00206 muonMassGeV_ ) ;
00207
00208 muColl->push_back(
00209 L1MuonParticle( muItr->charge(),
00210 p4,
00211 *muItr,
00212 muItr->bx() )
00213 ) ;
00214 }
00215 }
00216
00217 OrphanHandle< L1MuonParticleCollection > muHandle =
00218 iEvent.put( muColl );
00219 }
00220
00221
00222
00223
00224
00225
00226 if( produceCaloParticles_ )
00227 {
00228
00229
00230 ESHandle< L1CaloGeometry > caloGeomESH ;
00231 iSetup.get< L1CaloGeometryRecord >().get( caloGeomESH ) ;
00232 const L1CaloGeometry* caloGeom = &( *caloGeomESH ) ;
00233
00234
00235
00236 ESHandle< L1CaloEtScale > emScale ;
00237 iSetup.get< L1EmEtScaleRcd >().get( emScale ) ;
00238
00239
00240 Handle< L1GctEmCandCollection > hwIsoEmCands ;
00241 iEvent.getByLabel( isoEmSource_, hwIsoEmCands ) ;
00242
00243 auto_ptr< L1EmParticleCollection > isoEmColl(
00244 new L1EmParticleCollection );
00245
00246
00247
00248 L1GctEmCandCollection::const_iterator emItr = hwIsoEmCands->begin() ;
00249 L1GctEmCandCollection::const_iterator emEnd = hwIsoEmCands->end() ;
00250 for( int i = 0 ; emItr != emEnd ; ++emItr, ++i )
00251 {
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263 if( !emItr->empty() &&
00264 ( !centralBxOnly_ || emItr->bx() == 0 ) )
00265 {
00266 double et = emScale->et( emItr->rank() ) ;
00267
00268
00269
00270 isoEmColl->push_back(
00271 L1EmParticle( gctLorentzVector( et, *emItr, caloGeom, true ),
00272 Ref< L1GctEmCandCollection >( hwIsoEmCands,
00273 i ),
00274 emItr->bx() ) ) ;
00275 }
00276 }
00277
00278 OrphanHandle< L1EmParticleCollection > isoEmHandle =
00279 iEvent.put( isoEmColl, "Isolated" ) ;
00280
00281
00282
00283 Handle< L1GctEmCandCollection > hwNonIsoEmCands ;
00284 iEvent.getByLabel( nonIsoEmSource_, hwNonIsoEmCands ) ;
00285
00286 auto_ptr< L1EmParticleCollection > nonIsoEmColl(
00287 new L1EmParticleCollection );
00288
00289
00290 emItr = hwNonIsoEmCands->begin() ;
00291 emEnd = hwNonIsoEmCands->end() ;
00292 for( int i = 0 ; emItr != emEnd ; ++emItr, ++i )
00293 {
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305 if( !emItr->empty() &&
00306 ( !centralBxOnly_ || emItr->bx() == 0 ) )
00307 {
00308 double et = emScale->et( emItr->rank() ) ;
00309
00310
00311
00312 nonIsoEmColl->push_back(
00313 L1EmParticle( gctLorentzVector( et, *emItr, caloGeom, true ),
00314 Ref< L1GctEmCandCollection >( hwNonIsoEmCands,
00315 i ),
00316 emItr->bx() ) );
00317 }
00318 }
00319
00320 OrphanHandle< L1EmParticleCollection > nonIsoEmHandle =
00321 iEvent.put( nonIsoEmColl, "NonIsolated" ) ;
00322
00323
00324
00325
00326 ESHandle< L1CaloEtScale > jetScale ;
00327 iSetup.get< L1JetEtScaleRcd >().get( jetScale ) ;
00328
00329
00330 Handle< L1GctJetCandCollection > hwCenJetCands ;
00331 iEvent.getByLabel( cenJetSource_, hwCenJetCands ) ;
00332
00333 auto_ptr< L1JetParticleCollection > cenJetColl(
00334 new L1JetParticleCollection );
00335
00336
00337 L1GctJetCandCollection::const_iterator jetItr = hwCenJetCands->begin() ;
00338 L1GctJetCandCollection::const_iterator jetEnd = hwCenJetCands->end() ;
00339 for( int i = 0 ; jetItr != jetEnd ; ++jetItr, ++i )
00340 {
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354 if( !jetItr->empty() &&
00355 ( !centralBxOnly_ || jetItr->bx() == 0 ) )
00356 {
00357 double et = jetScale->et( jetItr->rank() ) ;
00358
00359
00360
00361 cenJetColl->push_back(
00362 L1JetParticle( gctLorentzVector( et, *jetItr, caloGeom, true ),
00363 Ref< L1GctJetCandCollection >( hwCenJetCands,
00364 i ),
00365 jetItr->bx() ) ) ;
00366 }
00367 }
00368
00369 OrphanHandle< L1JetParticleCollection > cenJetHandle =
00370 iEvent.put( cenJetColl, "Central" ) ;
00371
00372
00373
00374 Handle< L1GctJetCandCollection > hwForJetCands ;
00375 iEvent.getByLabel( forJetSource_, hwForJetCands ) ;
00376
00377 auto_ptr< L1JetParticleCollection > forJetColl(
00378 new L1JetParticleCollection );
00379
00380
00381 jetItr = hwForJetCands->begin() ;
00382 jetEnd = hwForJetCands->end() ;
00383 for( int i = 0 ; jetItr != jetEnd ; ++jetItr, ++i )
00384 {
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398 if( !jetItr->empty() &&
00399 ( !centralBxOnly_ || jetItr->bx() == 0 ) )
00400 {
00401 double et = jetScale->et( jetItr->rank() ) ;
00402
00403
00404
00405 forJetColl->push_back(
00406 L1JetParticle( gctLorentzVector( et, *jetItr, caloGeom, false ),
00407 Ref< L1GctJetCandCollection >( hwForJetCands,
00408 i ),
00409 jetItr->bx() ) ) ;
00410 }
00411 }
00412
00413 OrphanHandle< L1JetParticleCollection > forJetHandle =
00414 iEvent.put( forJetColl, "Forward" ) ;
00415
00416
00417
00418
00419 Handle< L1GctJetCandCollection > hwTauJetCands ;
00420 iEvent.getByLabel( tauJetSource_, hwTauJetCands ) ;
00421
00422 auto_ptr< L1JetParticleCollection > tauJetColl(
00423 new L1JetParticleCollection );
00424
00425 jetItr = hwTauJetCands->begin() ;
00426 jetEnd = hwTauJetCands->end() ;
00427 for( int i = 0 ; jetItr != jetEnd ; ++jetItr, ++i )
00428 {
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442 if( !jetItr->empty() &&
00443 ( !centralBxOnly_ || jetItr->bx() == 0 ) )
00444 {
00445 double et = jetScale->et( jetItr->rank() ) ;
00446
00447
00448
00449 tauJetColl->push_back(
00450 L1JetParticle( gctLorentzVector( et, *jetItr, caloGeom, true ),
00451 Ref< L1GctJetCandCollection >( hwTauJetCands,
00452 i ),
00453 jetItr->bx() ) ) ;
00454 }
00455 }
00456
00457 OrphanHandle< L1JetParticleCollection > tauJetHandle =
00458 iEvent.put( tauJetColl, "Tau" ) ;
00459
00460
00461
00462 ESHandle< L1GctJetEtCalibrationFunction > jetCalibFn ;
00463 iSetup.get< L1GctJetCalibFunRcd >().get( jetCalibFn ) ;
00464
00465 double etSumLSB = jetScale->linearLsb() ;
00466 double htSumLSB = jetCalibFn->getHtScaleLSB();
00467
00468 Handle< L1GctEtTotalCollection > hwEtTotColl ;
00469 iEvent.getByLabel( etTotSource_, hwEtTotColl ) ;
00470
00471 Handle< L1GctEtHadCollection > hwEtHadColl ;
00472 iEvent.getByLabel( etHadSource_, hwEtHadColl ) ;
00473
00474 Handle< L1GctEtMissCollection > hwEtMissColl ;
00475 iEvent.getByLabel( etMissSource_, hwEtMissColl ) ;
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485 if( !( hwEtTotColl.isValid() && hwEtHadColl.isValid() &&
00486 hwEtMissColl.isValid() ) )
00487 {
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498 Handle< L1GctEtTotal > hwEtTot ;
00499 iEvent.getByLabel( etTotSource_, hwEtTot ) ;
00500
00501 Handle< L1GctEtHad > hwEtHad ;
00502 iEvent.getByLabel( etHadSource_, hwEtHad ) ;
00503
00504 Handle< L1GctEtMiss > hwEtMiss ;
00505 iEvent.getByLabel( etMissSource_, hwEtMiss ) ;
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516 double etTot = ( hwEtTot->overFlow() ?
00517 ( double ) L1GctEtTotal::kEtTotalMaxValue :
00518 ( double ) hwEtTot->et() ) * etSumLSB + 1.e-6 ;
00519 double etHad = ( hwEtHad->overFlow() ?
00520 ( double ) L1GctEtHad::kEtHadMaxValue :
00521 ( double ) hwEtHad->et() ) * htSumLSB + 1.e-6 ;
00522 double etMiss = ( hwEtMiss->overFlow() ?
00523 ( double ) L1GctEtMiss::kEtMissMaxValue :
00524 ( double ) hwEtMiss->et() ) * etSumLSB + 1.e-6 ;
00525
00526
00527 double phi = caloGeom->etSumPhiBinCenter( hwEtMiss->phi() ) ;
00528
00529 math::PtEtaPhiMLorentzVector p4( etMiss,
00530 0.,
00531 phi,
00532 0. ) ;
00533
00534 auto_ptr< L1EtMissParticleCollection > etMissColl(
00535 new L1EtMissParticleCollection );
00536
00537 etMissColl->push_back(
00538 L1EtMissParticle( p4,
00539 etTot,
00540 etHad ) ) ;
00541
00542 iEvent.put( etMissColl ) ;
00543 return ;
00544 }
00545
00546 auto_ptr< L1EtMissParticleCollection > etMissColl(
00547 new L1EtMissParticleCollection );
00548
00549
00550 L1GctEtTotalCollection::const_iterator hwEtTotItr =
00551 hwEtTotColl->begin() ;
00552 L1GctEtTotalCollection::const_iterator hwEtTotEnd =
00553 hwEtTotColl->end() ;
00554
00555 int iTot = 0 ;
00556 for( ; hwEtTotItr != hwEtTotEnd ; ++hwEtTotItr, ++iTot )
00557 {
00558 int bx = hwEtTotItr->bx() ;
00559
00560 if( !centralBxOnly_ || bx == 0 )
00561 {
00562 L1GctEtHadCollection::const_iterator hwEtHadItr =
00563 hwEtHadColl->begin() ;
00564 L1GctEtHadCollection::const_iterator hwEtHadEnd =
00565 hwEtHadColl->end() ;
00566
00567 int iHad = 0 ;
00568 for( ; hwEtHadItr != hwEtHadEnd ; ++hwEtHadItr, ++iHad )
00569 {
00570 if( hwEtHadItr->bx() == bx )
00571 {
00572 break ;
00573 }
00574 }
00575
00576
00577 if( hwEtHadItr != hwEtHadEnd )
00578 {
00579 L1GctEtMissCollection::const_iterator hwEtMissItr =
00580 hwEtMissColl->begin() ;
00581 L1GctEtMissCollection::const_iterator hwEtMissEnd =
00582 hwEtMissColl->end() ;
00583
00584 int iMiss = 0 ;
00585 for( ; hwEtMissItr != hwEtMissEnd ; ++hwEtMissItr, ++iMiss )
00586 {
00587 if( hwEtMissItr->bx() == bx )
00588 {
00589 break ;
00590 }
00591 }
00592
00593
00594 if( hwEtMissItr != hwEtMissEnd )
00595 {
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608 double etTot =
00609 ( hwEtTotItr->overFlow() ?
00610 ( double ) L1GctEtTotal::kEtTotalMaxValue :
00611 ( double ) hwEtTotItr->et() ) * etSumLSB + 1.e-6 ;
00612 double etHad =
00613 ( hwEtHadItr->overFlow() ?
00614 ( double ) L1GctEtHad::kEtHadMaxValue :
00615 ( double ) hwEtHadItr->et() ) * htSumLSB + 1.e-6 ;
00616 double etMiss =
00617 ( hwEtMissItr->overFlow() ?
00618 ( double ) L1GctEtMiss::kEtMissMaxValue :
00619 ( double ) hwEtMissItr->et() ) * etSumLSB + 1.e-6 ;
00620
00621
00622
00623 double phi =
00624 caloGeom->etSumPhiBinCenter( hwEtMissItr->phi() ) ;
00625
00626 math::PtEtaPhiMLorentzVector p4( etMiss,
00627 0.,
00628 phi,
00629 0. ) ;
00630
00631 etMissColl->push_back(
00632 L1EtMissParticle(
00633 p4,
00634 etTot,
00635 etHad,
00636 Ref< L1GctEtMissCollection >( hwEtMissColl, iMiss ),
00637 Ref< L1GctEtTotalCollection >( hwEtTotColl, iTot ),
00638 Ref< L1GctEtHadCollection >( hwEtHadColl, iHad ),
00639 bx
00640 ) ) ;
00641 }
00642 }
00643 }
00644 }
00645
00646 OrphanHandle< L1EtMissParticleCollection > etMissCollHandle =
00647 iEvent.put( etMissColl ) ;
00648 }
00649 }
00650
00651
00652 math::PtEtaPhiMLorentzVector
00653 L1ExtraParticlesProd::gctLorentzVector( const double& et,
00654 const L1GctCand& cand,
00655 const L1CaloGeometry* geom,
00656 bool central )
00657 {
00658
00659 double etCorr = et + 1.e-6 ;
00660
00661 double eta = geom->etaBinCenter( cand.etaIndex(), central ) ;
00662
00663
00664
00665
00666
00667 double phi = geom->emJetPhiBinCenter( cand.phiIndex() ) ;
00668
00669
00670
00671
00672
00673 return math::PtEtaPhiMLorentzVector( etCorr,
00674 eta,
00675 phi,
00676 0. ) ;
00677 }
00678
00679
00680 void
00681 L1ExtraParticlesProd::beginJob(const edm::EventSetup&)
00682 {
00683 }
00684
00685
00686 void
00687 L1ExtraParticlesProd::endJob() {
00688 }
00689
00690
00691