File indexing completed on 2024-04-06 12:20:12
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <memory>
0017
0018
0019 #include "L1Trigger/L1ExtraFromDigis/interface/L1ExtraParticlesProd.h"
0020
0021 #include "FWCore/Framework/interface/Frameworkfwd.h"
0022 #include "FWCore/Framework/interface/MakerMacros.h"
0023
0024 #include "DataFormats/Common/interface/Handle.h"
0025 #include "DataFormats/Common/interface/OrphanHandle.h"
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027
0028 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
0029
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 double const L1ExtraParticlesProd::muonMassGeV_ = 0.105658369;
0047
0048
0049
0050
0051 L1ExtraParticlesProd::L1ExtraParticlesProd(const edm::ParameterSet &iConfig)
0052 : produceMuonParticles_(iConfig.getParameter<bool>("produceMuonParticles")),
0053 muonSource_(iConfig.getParameter<edm::InputTag>("muonSource")),
0054 produceCaloParticles_(iConfig.getParameter<bool>("produceCaloParticles")),
0055 isoEmSource_(iConfig.getParameter<edm::InputTag>("isolatedEmSource")),
0056 nonIsoEmSource_(iConfig.getParameter<edm::InputTag>("nonIsolatedEmSource")),
0057 cenJetSource_(iConfig.getParameter<edm::InputTag>("centralJetSource")),
0058 forJetSource_(iConfig.getParameter<edm::InputTag>("forwardJetSource")),
0059 tauJetSource_(iConfig.getParameter<edm::InputTag>("tauJetSource")),
0060 isoTauJetSource_(iConfig.getParameter<edm::InputTag>("isoTauJetSource")),
0061 etTotSource_(iConfig.getParameter<edm::InputTag>("etTotalSource")),
0062 etHadSource_(iConfig.getParameter<edm::InputTag>("etHadSource")),
0063 etMissSource_(iConfig.getParameter<edm::InputTag>("etMissSource")),
0064 htMissSource_(iConfig.getParameter<edm::InputTag>("htMissSource")),
0065 hfRingEtSumsSource_(iConfig.getParameter<edm::InputTag>("hfRingEtSumsSource")),
0066 hfRingBitCountsSource_(iConfig.getParameter<edm::InputTag>("hfRingBitCountsSource")),
0067 centralBxOnly_(iConfig.getParameter<bool>("centralBxOnly")),
0068 ignoreHtMiss_(iConfig.getParameter<bool>("ignoreHtMiss")) {
0069 using namespace l1extra;
0070
0071
0072 produces<L1EmParticleCollection>("Isolated");
0073 produces<L1EmParticleCollection>("NonIsolated");
0074 produces<L1JetParticleCollection>("Central");
0075 produces<L1JetParticleCollection>("Forward");
0076 produces<L1JetParticleCollection>("Tau");
0077 produces<L1JetParticleCollection>("IsoTau");
0078 produces<L1MuonParticleCollection>();
0079 produces<L1EtMissParticleCollection>("MET");
0080 produces<L1EtMissParticleCollection>("MHT");
0081 produces<L1HFRingsCollection>();
0082
0083
0084 consumes<L1MuGMTReadoutCollection>(muonSource_);
0085 consumes<L1GctEmCandCollection>(isoEmSource_);
0086 consumes<L1GctEmCandCollection>(nonIsoEmSource_);
0087 consumes<L1GctJetCandCollection>(cenJetSource_);
0088 consumes<L1GctJetCandCollection>(forJetSource_);
0089 consumes<L1GctJetCandCollection>(tauJetSource_);
0090 consumes<L1GctJetCandCollection>(isoTauJetSource_);
0091 consumes<L1GctEtTotalCollection>(etTotSource_);
0092 consumes<L1GctEtMissCollection>(etMissSource_);
0093 consumes<L1GctEtHadCollection>(etHadSource_);
0094 consumes<L1GctHtMissCollection>(htMissSource_);
0095 consumes<L1GctHFRingEtSumsCollection>(hfRingEtSumsSource_);
0096 consumes<L1GctHFBitCountsCollection>(hfRingBitCountsSource_);
0097
0098 if (produceMuonParticles_) {
0099 muScalesToken_ = esConsumes<L1MuTriggerScales, L1MuTriggerScalesRcd>();
0100 muPtScaleToken_ = esConsumes<L1MuTriggerPtScale, L1MuTriggerPtScaleRcd>();
0101 }
0102 if (produceCaloParticles_) {
0103 caloGeomToken_ = esConsumes<L1CaloGeometry, L1CaloGeometryRecord>();
0104 emScaleToken_ = esConsumes<L1CaloEtScale, L1EmEtScaleRcd>();
0105 jetScaleToken_ = esConsumes<L1CaloEtScale, L1JetEtScaleRcd>();
0106 jetFinderParamsToken_ = esConsumes<L1GctJetFinderParams, L1GctJetFinderParamsRcd>();
0107 hfRingEtScaleToken_ = esConsumes<L1CaloEtScale, L1HfRingEtScaleRcd>();
0108 if (!ignoreHtMiss_) {
0109 htMissScaleToken_ = esConsumes<L1CaloEtScale, L1HtMissScaleRcd>();
0110 }
0111 }
0112 }
0113
0114 L1ExtraParticlesProd::~L1ExtraParticlesProd() {
0115
0116
0117 }
0118
0119
0120
0121
0122
0123
0124 void L1ExtraParticlesProd::produce(edm::Event &iEvent, const edm::EventSetup &iSetup) {
0125 using namespace edm;
0126 using namespace l1extra;
0127 using namespace std;
0128
0129
0130
0131
0132
0133 unique_ptr<L1MuonParticleCollection> muColl(new L1MuonParticleCollection);
0134
0135 if (produceMuonParticles_) {
0136 ESHandle<L1MuTriggerScales> muScales = iSetup.getHandle(muScalesToken_);
0137
0138 ESHandle<L1MuTriggerPtScale> muPtScale = iSetup.getHandle(muPtScaleToken_);
0139
0140 Handle<L1MuGMTReadoutCollection> hwMuCollection;
0141 iEvent.getByLabel(muonSource_, hwMuCollection);
0142
0143 vector<L1MuGMTExtendedCand> hwMuCands;
0144
0145 if (!hwMuCollection.isValid()) {
0146 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1MuGMTReadoutCollection with " << muonSource_
0147 << "\nrequested in configuration, but not found in the event." << std::endl;
0148 } else {
0149 if (centralBxOnly_) {
0150
0151 hwMuCands = hwMuCollection->getRecord().getGMTCands();
0152 } else {
0153
0154 vector<L1MuGMTReadoutRecord> records = hwMuCollection->getRecords();
0155 vector<L1MuGMTReadoutRecord>::const_iterator rItr = records.begin();
0156 vector<L1MuGMTReadoutRecord>::const_iterator rEnd = records.end();
0157
0158 for (; rItr != rEnd; ++rItr) {
0159 vector<L1MuGMTExtendedCand> tmpCands = rItr->getGMTCands();
0160
0161 hwMuCands.insert(hwMuCands.end(), tmpCands.begin(), tmpCands.end());
0162 }
0163 }
0164
0165
0166 vector<L1MuGMTExtendedCand>::const_iterator muItr = hwMuCands.begin();
0167 vector<L1MuGMTExtendedCand>::const_iterator muEnd = hwMuCands.end();
0168 for (int i = 0; muItr != muEnd; ++muItr, ++i) {
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 if (!muItr->empty()) {
0181
0182 double pt = muPtScale->getPtScale()->getLowEdge(muItr->ptIndex()) + 1.e-6;
0183
0184
0185
0186 double eta = muScales->getGMTEtaScale()->getCenter(muItr->etaIndex());
0187
0188 double phi = muScales->getPhiScale()->getLowEdge(muItr->phiIndex());
0189
0190 math::PtEtaPhiMLorentzVector p4(pt, eta, phi, muonMassGeV_);
0191
0192 muColl->push_back(L1MuonParticle(muItr->charge(), p4, *muItr, muItr->bx()));
0193 }
0194 }
0195 }
0196 }
0197
0198 OrphanHandle<L1MuonParticleCollection> muHandle = iEvent.put(std::move(muColl));
0199
0200
0201
0202
0203
0204 unique_ptr<L1EmParticleCollection> isoEmColl(new L1EmParticleCollection);
0205
0206 unique_ptr<L1EmParticleCollection> nonIsoEmColl(new L1EmParticleCollection);
0207
0208 unique_ptr<L1JetParticleCollection> cenJetColl(new L1JetParticleCollection);
0209
0210 unique_ptr<L1JetParticleCollection> forJetColl(new L1JetParticleCollection);
0211
0212 unique_ptr<L1JetParticleCollection> tauJetColl(new L1JetParticleCollection);
0213
0214 unique_ptr<L1JetParticleCollection> isoTauJetColl(new L1JetParticleCollection);
0215
0216 unique_ptr<L1EtMissParticleCollection> etMissColl(new L1EtMissParticleCollection);
0217
0218 unique_ptr<L1EtMissParticleCollection> htMissColl(new L1EtMissParticleCollection);
0219
0220 unique_ptr<L1HFRingsCollection> hfRingsColl(new L1HFRingsCollection);
0221
0222 if (produceCaloParticles_) {
0223
0224
0225 ESHandle<L1CaloGeometry> caloGeomESH = iSetup.getHandle(caloGeomToken_);
0226 const L1CaloGeometry *caloGeom = &(*caloGeomESH);
0227
0228
0229
0230 ESHandle<L1CaloEtScale> emScale = iSetup.getHandle(emScaleToken_);
0231
0232
0233 Handle<L1GctEmCandCollection> hwIsoEmCands;
0234 iEvent.getByLabel(isoEmSource_, hwIsoEmCands);
0235
0236 if (!hwIsoEmCands.isValid()) {
0237 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctEmCandCollection with " << isoEmSource_
0238 << "\nrequested in configuration, but not found in the event." << std::endl;
0239 } else {
0240
0241
0242 L1GctEmCandCollection::const_iterator emItr = hwIsoEmCands->begin();
0243 L1GctEmCandCollection::const_iterator emEnd = hwIsoEmCands->end();
0244 for (int i = 0; emItr != emEnd; ++emItr, ++i) {
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256 if (!emItr->empty() && (!centralBxOnly_ || emItr->bx() == 0)) {
0257 double et = emScale->et(emItr->rank());
0258
0259
0260
0261 isoEmColl->push_back(L1EmParticle(
0262 gctLorentzVector(et, *emItr, caloGeom, true), Ref<L1GctEmCandCollection>(hwIsoEmCands, i), emItr->bx()));
0263 }
0264 }
0265 }
0266
0267
0268 Handle<L1GctEmCandCollection> hwNonIsoEmCands;
0269 iEvent.getByLabel(nonIsoEmSource_, hwNonIsoEmCands);
0270
0271 if (!hwNonIsoEmCands.isValid()) {
0272 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctEmCandCollection with " << nonIsoEmSource_
0273 << "\nrequested in configuration, but not found in the event." << std::endl;
0274 } else {
0275
0276 L1GctEmCandCollection::const_iterator emItr = hwNonIsoEmCands->begin();
0277 L1GctEmCandCollection::const_iterator emEnd = hwNonIsoEmCands->end();
0278 for (int i = 0; emItr != emEnd; ++emItr, ++i) {
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290 if (!emItr->empty() && (!centralBxOnly_ || emItr->bx() == 0)) {
0291 double et = emScale->et(emItr->rank());
0292
0293
0294
0295 nonIsoEmColl->push_back(L1EmParticle(gctLorentzVector(et, *emItr, caloGeom, true),
0296 Ref<L1GctEmCandCollection>(hwNonIsoEmCands, i),
0297 emItr->bx()));
0298 }
0299 }
0300 }
0301
0302
0303
0304 ESHandle<L1CaloEtScale> jetScale = iSetup.getHandle(jetScaleToken_);
0305
0306
0307 Handle<L1GctJetCandCollection> hwCenJetCands;
0308 iEvent.getByLabel(cenJetSource_, hwCenJetCands);
0309
0310 if (!hwCenJetCands.isValid()) {
0311 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctJetCandCollection with " << cenJetSource_
0312 << "\nrequested in configuration, but not found in the event." << std::endl;
0313 } else {
0314
0315 L1GctJetCandCollection::const_iterator jetItr = hwCenJetCands->begin();
0316 L1GctJetCandCollection::const_iterator jetEnd = hwCenJetCands->end();
0317 for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331 if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
0332 double et = jetScale->et(jetItr->rank());
0333
0334
0335
0336 cenJetColl->push_back(L1JetParticle(gctLorentzVector(et, *jetItr, caloGeom, true),
0337 Ref<L1GctJetCandCollection>(hwCenJetCands, i),
0338 jetItr->bx()));
0339 }
0340 }
0341 }
0342
0343
0344 Handle<L1GctJetCandCollection> hwForJetCands;
0345 iEvent.getByLabel(forJetSource_, hwForJetCands);
0346
0347 if (!hwForJetCands.isValid()) {
0348 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctEmCandCollection with " << forJetSource_
0349 << "\nrequested in configuration, but not found in the event." << std::endl;
0350 } else {
0351
0352 L1GctJetCandCollection::const_iterator jetItr = hwForJetCands->begin();
0353 L1GctJetCandCollection::const_iterator jetEnd = hwForJetCands->end();
0354 for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
0355
0356
0357
0358
0359
0360
0361
0362
0363
0364
0365
0366
0367
0368 if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
0369 double et = jetScale->et(jetItr->rank());
0370
0371
0372
0373 forJetColl->push_back(L1JetParticle(gctLorentzVector(et, *jetItr, caloGeom, false),
0374 Ref<L1GctJetCandCollection>(hwForJetCands, i),
0375 jetItr->bx()));
0376 }
0377 }
0378 }
0379
0380
0381
0382 Handle<L1GctJetCandCollection> hwTauJetCands;
0383 iEvent.getByLabel(tauJetSource_, hwTauJetCands);
0384
0385 if (!hwTauJetCands.isValid()) {
0386 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctJetCandCollection with " << tauJetSource_
0387 << "\nrequested in configuration, but not found in the event." << std::endl;
0388 } else {
0389 L1GctJetCandCollection::const_iterator jetItr = hwTauJetCands->begin();
0390 L1GctJetCandCollection::const_iterator jetEnd = hwTauJetCands->end();
0391 for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
0392
0393
0394
0395
0396
0397
0398
0399
0400
0401
0402
0403
0404
0405 if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
0406 double et = jetScale->et(jetItr->rank());
0407
0408
0409
0410 tauJetColl->push_back(L1JetParticle(gctLorentzVector(et, *jetItr, caloGeom, true),
0411 Ref<L1GctJetCandCollection>(hwTauJetCands, i),
0412 jetItr->bx()));
0413 }
0414 }
0415 }
0416
0417
0418
0419 Handle<L1GctJetCandCollection> hwIsoTauJetCands;
0420 iEvent.getByLabel(isoTauJetSource_, hwIsoTauJetCands);
0421
0422 if (!hwIsoTauJetCands.isValid()) {
0423 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctJetCandCollection with " << isoTauJetSource_
0424 << "\nrequested in configuration, but not found in the event." << std::endl;
0425 } else {
0426 L1GctJetCandCollection::const_iterator jetItr = hwIsoTauJetCands->begin();
0427 L1GctJetCandCollection::const_iterator jetEnd = hwIsoTauJetCands->end();
0428 for (int i = 0; jetItr != jetEnd; ++jetItr, ++i) {
0429
0430
0431
0432
0433
0434
0435
0436
0437
0438
0439
0440
0441
0442 if (!jetItr->empty() && (!centralBxOnly_ || jetItr->bx() == 0)) {
0443 double et = jetScale->et(jetItr->rank());
0444
0445
0446
0447 isoTauJetColl->push_back(L1JetParticle(gctLorentzVector(et, *jetItr, caloGeom, true),
0448 Ref<L1GctJetCandCollection>(hwIsoTauJetCands, i),
0449 jetItr->bx()));
0450 }
0451 }
0452 }
0453
0454
0455
0456 double etSumLSB = jetScale->linearLsb();
0457
0458 Handle<L1GctEtTotalCollection> hwEtTotColl;
0459 iEvent.getByLabel(etTotSource_, hwEtTotColl);
0460
0461 Handle<L1GctEtMissCollection> hwEtMissColl;
0462 iEvent.getByLabel(etMissSource_, hwEtMissColl);
0463
0464 if (!hwEtTotColl.isValid()) {
0465 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctEtTotalCollection with " << etTotSource_
0466 << "\nrequested in configuration, but not found in the event." << std::endl;
0467 } else if (!hwEtMissColl.isValid()) {
0468 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctEtMissCollection with " << etMissSource_
0469 << "\nrequested in configuration, but not found in the event." << std::endl;
0470 } else {
0471
0472
0473
0474 std::vector<bool> etMissMatched;
0475
0476 L1GctEtMissCollection::const_iterator hwEtMissItr = hwEtMissColl->begin();
0477 L1GctEtMissCollection::const_iterator hwEtMissEnd = hwEtMissColl->end();
0478 for (; hwEtMissItr != hwEtMissEnd; ++hwEtMissItr) {
0479 etMissMatched.push_back(false);
0480 }
0481
0482
0483 L1GctEtTotalCollection::const_iterator hwEtTotItr = hwEtTotColl->begin();
0484 L1GctEtTotalCollection::const_iterator hwEtTotEnd = hwEtTotColl->end();
0485
0486 int iTot = 0;
0487 for (; hwEtTotItr != hwEtTotEnd; ++hwEtTotItr, ++iTot) {
0488 int bx = hwEtTotItr->bx();
0489
0490 if (!centralBxOnly_ || bx == 0) {
0491
0492 double etTot =
0493 (hwEtTotItr->overFlow() ? (double)L1GctEtTotal::kEtTotalMaxValue : (double)hwEtTotItr->et()) * etSumLSB +
0494 1.e-6;
0495
0496 int iMiss = 0;
0497 hwEtMissItr = hwEtMissColl->begin();
0498 hwEtMissEnd = hwEtMissColl->end();
0499 for (; hwEtMissItr != hwEtMissEnd; ++hwEtMissItr, ++iMiss) {
0500 if (hwEtMissItr->bx() == bx) {
0501 etMissMatched[iMiss] = true;
0502 break;
0503 }
0504 }
0505
0506 double etMiss = 0.;
0507 double phi = 0.;
0508 math::PtEtaPhiMLorentzVector p4;
0509 Ref<L1GctEtMissCollection> metRef;
0510
0511
0512 if (hwEtMissItr != hwEtMissEnd) {
0513
0514 etMiss = (hwEtMissItr->overFlow() ? (double)L1GctEtMiss::kEtMissMaxValue : (double)hwEtMissItr->et()) *
0515 etSumLSB +
0516 1.e-6;
0517
0518
0519
0520 phi = caloGeom->etSumPhiBinCenter(hwEtMissItr->phi());
0521
0522 p4 = math::PtEtaPhiMLorentzVector(etMiss, 0., phi, 0.);
0523
0524 metRef = Ref<L1GctEtMissCollection>(hwEtMissColl, iMiss);
0525
0526
0527
0528
0529
0530
0531
0532 }
0533
0534
0535
0536
0537
0538
0539
0540
0541
0542
0543 etMissColl->push_back(L1EtMissParticle(p4,
0544 L1EtMissParticle::kMET,
0545 etTot,
0546 metRef,
0547 Ref<L1GctEtTotalCollection>(hwEtTotColl, iTot),
0548 Ref<L1GctHtMissCollection>(),
0549 Ref<L1GctEtHadCollection>(),
0550 bx));
0551 }
0552 }
0553
0554 if (!centralBxOnly_) {
0555
0556
0557
0558 double etTot = 0.;
0559
0560 hwEtMissItr = hwEtMissColl->begin();
0561 hwEtMissEnd = hwEtMissColl->end();
0562 int iMiss = 0;
0563 for (; hwEtMissItr != hwEtMissEnd; ++hwEtMissItr, ++iMiss) {
0564 if (!etMissMatched[iMiss]) {
0565 int bx = hwEtMissItr->bx();
0566
0567
0568 double etMiss =
0569 (hwEtMissItr->overFlow() ? (double)L1GctEtMiss::kEtMissMaxValue : (double)hwEtMissItr->et()) *
0570 etSumLSB +
0571 1.e-6;
0572
0573
0574
0575 double phi = caloGeom->etSumPhiBinCenter(hwEtMissItr->phi());
0576
0577 math::PtEtaPhiMLorentzVector p4(etMiss, 0., phi, 0.);
0578
0579
0580
0581
0582
0583
0584
0585
0586
0587 etMissColl->push_back(L1EtMissParticle(p4,
0588 L1EtMissParticle::kMET,
0589 etTot,
0590 Ref<L1GctEtMissCollection>(hwEtMissColl, iMiss),
0591 Ref<L1GctEtTotalCollection>(),
0592 Ref<L1GctHtMissCollection>(),
0593 Ref<L1GctEtHadCollection>(),
0594 bx));
0595 }
0596 }
0597 }
0598 }
0599
0600
0601
0602 Handle<L1GctEtHadCollection> hwEtHadColl;
0603 iEvent.getByLabel(etHadSource_, hwEtHadColl);
0604
0605 Handle<L1GctHtMissCollection> hwHtMissColl;
0606 if (!ignoreHtMiss_) {
0607 iEvent.getByLabel(htMissSource_, hwHtMissColl);
0608 }
0609
0610 ESHandle<L1GctJetFinderParams> jetFinderParams = iSetup.getHandle(jetFinderParamsToken_);
0611 double htSumLSB = jetFinderParams->getHtLsbGeV();
0612
0613 ESHandle<L1CaloEtScale> htMissScale;
0614 std::vector<bool> htMissMatched;
0615 if (!ignoreHtMiss_) {
0616 htMissScale = iSetup.getHandle(htMissScaleToken_);
0617
0618 if (!hwEtHadColl.isValid()) {
0619 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctEtHadCollection with " << etHadSource_
0620 << "\nrequested in configuration, but not found in the event." << std::endl;
0621 } else if (!hwHtMissColl.isValid()) {
0622 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctHtMissCollection with " << htMissSource_
0623 << "\nrequested in configuration, but not found in the event." << std::endl;
0624 } else {
0625
0626
0627
0628 L1GctHtMissCollection::const_iterator hwHtMissItr = hwHtMissColl->begin();
0629 L1GctHtMissCollection::const_iterator hwHtMissEnd = hwHtMissColl->end();
0630 for (; hwHtMissItr != hwHtMissEnd; ++hwHtMissItr) {
0631 htMissMatched.push_back(false);
0632 }
0633 }
0634 }
0635
0636 if (!hwEtHadColl.isValid()) {
0637 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctEtHadCollection with " << etHadSource_
0638 << "\nrequested in configuration, but not found in the event." << std::endl;
0639 } else if (!hwHtMissColl.isValid()) {
0640 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctHtMissCollection with " << htMissSource_
0641 << "\nrequested in configuration, but not found in the event." << std::endl;
0642 } else {
0643 L1GctEtHadCollection::const_iterator hwEtHadItr = hwEtHadColl->begin();
0644 L1GctEtHadCollection::const_iterator hwEtHadEnd = hwEtHadColl->end();
0645
0646 int iHad = 0;
0647 for (; hwEtHadItr != hwEtHadEnd; ++hwEtHadItr, ++iHad) {
0648 int bx = hwEtHadItr->bx();
0649
0650 if (!centralBxOnly_ || bx == 0) {
0651
0652 double htTot =
0653 (hwEtHadItr->overFlow() ? (double)L1GctEtHad::kEtHadMaxValue : (double)hwEtHadItr->et()) * htSumLSB +
0654 1.e-6;
0655
0656 double htMiss = 0.;
0657 double phi = 0.;
0658 math::PtEtaPhiMLorentzVector p4;
0659 Ref<L1GctHtMissCollection> mhtRef;
0660
0661 if (!ignoreHtMiss_) {
0662 L1GctHtMissCollection::const_iterator hwHtMissItr = hwHtMissColl->begin();
0663 L1GctHtMissCollection::const_iterator hwHtMissEnd = hwHtMissColl->end();
0664
0665 int iMiss = 0;
0666 for (; hwHtMissItr != hwHtMissEnd; ++hwHtMissItr, ++iMiss) {
0667 if (hwHtMissItr->bx() == bx) {
0668 htMissMatched[iMiss] = true;
0669 break;
0670 }
0671 }
0672
0673
0674 if (hwHtMissItr != hwHtMissEnd) {
0675
0676 htMiss =
0677 htMissScale->et(hwHtMissItr->overFlow() ? htMissScale->rankScaleMax() : hwHtMissItr->et()) + 1.e-6;
0678
0679
0680
0681 phi = caloGeom->htSumPhiBinCenter(hwHtMissItr->phi());
0682
0683 p4 = math::PtEtaPhiMLorentzVector(htMiss, 0., phi, 0.);
0684
0685 mhtRef = Ref<L1GctHtMissCollection>(hwHtMissColl, iMiss);
0686
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697 }
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708 }
0709
0710 htMissColl->push_back(L1EtMissParticle(p4,
0711 L1EtMissParticle::kMHT,
0712 htTot,
0713 Ref<L1GctEtMissCollection>(),
0714 Ref<L1GctEtTotalCollection>(),
0715 mhtRef,
0716 Ref<L1GctEtHadCollection>(hwEtHadColl, iHad),
0717 bx));
0718 }
0719 }
0720
0721 if (!centralBxOnly_ && !ignoreHtMiss_) {
0722
0723
0724 double htTot = 0.;
0725
0726 L1GctHtMissCollection::const_iterator hwHtMissItr = hwHtMissColl->begin();
0727 L1GctHtMissCollection::const_iterator hwHtMissEnd = hwHtMissColl->end();
0728
0729 int iMiss = 0;
0730 for (; hwHtMissItr != hwHtMissEnd; ++hwHtMissItr, ++iMiss) {
0731 if (!htMissMatched[iMiss]) {
0732 int bx = hwHtMissItr->bx();
0733
0734
0735 double htMiss =
0736 htMissScale->et(hwHtMissItr->overFlow() ? htMissScale->rankScaleMax() : hwHtMissItr->et()) + 1.e-6;
0737
0738
0739
0740 double phi = caloGeom->htSumPhiBinCenter(hwHtMissItr->phi());
0741
0742 math::PtEtaPhiMLorentzVector p4(htMiss, 0., phi, 0.);
0743
0744
0745
0746
0747
0748
0749
0750
0751
0752 htMissColl->push_back(L1EtMissParticle(p4,
0753 L1EtMissParticle::kMHT,
0754 htTot,
0755 Ref<L1GctEtMissCollection>(),
0756 Ref<L1GctEtTotalCollection>(),
0757 Ref<L1GctHtMissCollection>(hwHtMissColl, iMiss),
0758 Ref<L1GctEtHadCollection>(),
0759 bx));
0760 }
0761 }
0762 }
0763 }
0764
0765
0766
0767 Handle<L1GctHFRingEtSumsCollection> hwHFEtSumsColl;
0768 iEvent.getByLabel(hfRingEtSumsSource_, hwHFEtSumsColl);
0769
0770 Handle<L1GctHFBitCountsCollection> hwHFBitCountsColl;
0771 iEvent.getByLabel(hfRingBitCountsSource_, hwHFBitCountsColl);
0772
0773 ESHandle<L1CaloEtScale> hfRingEtScale = iSetup.getHandle(hfRingEtScaleToken_);
0774
0775 if (!hwHFEtSumsColl.isValid()) {
0776 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctHFRingEtSumsCollection with " << hfRingEtSumsSource_
0777 << "\nrequested in configuration, but not found in the event." << std::endl;
0778 } else if (!hwHFBitCountsColl.isValid()) {
0779 LogDebug("L1ExtraParticlesProd") << "\nWarning: L1GctHFBitCountsCollection with " << hfRingBitCountsSource_
0780 << "\nrequested in configuration, but not found in the event." << std::endl;
0781 } else {
0782 L1GctHFRingEtSumsCollection::const_iterator hwHFEtSumsItr = hwHFEtSumsColl->begin();
0783 L1GctHFRingEtSumsCollection::const_iterator hwHFEtSumsEnd = hwHFEtSumsColl->end();
0784
0785 int iEtSums = 0;
0786 for (; hwHFEtSumsItr != hwHFEtSumsEnd; ++hwHFEtSumsItr, ++iEtSums) {
0787 int bx = hwHFEtSumsItr->bx();
0788
0789 if (!centralBxOnly_ || bx == 0) {
0790 L1GctHFBitCountsCollection::const_iterator hwHFBitCountsItr = hwHFBitCountsColl->begin();
0791 L1GctHFBitCountsCollection::const_iterator hwHFBitCountsEnd = hwHFBitCountsColl->end();
0792
0793 int iBitCounts = 0;
0794 for (; hwHFBitCountsItr != hwHFBitCountsEnd; ++hwHFBitCountsItr, ++iBitCounts) {
0795 if (hwHFBitCountsItr->bx() == bx) {
0796 break;
0797 }
0798 }
0799
0800
0801 if (hwHFBitCountsItr != hwHFBitCountsEnd) {
0802
0803
0804
0805
0806
0807 double etSums[L1HFRings::kNumRings];
0808 etSums[L1HFRings::kRing1PosEta] = hfRingEtScale->et(hwHFEtSumsItr->etSum(0)) + 1.e-6;
0809 etSums[L1HFRings::kRing1NegEta] = hfRingEtScale->et(hwHFEtSumsItr->etSum(1)) + 1.e-6;
0810 etSums[L1HFRings::kRing2PosEta] = hfRingEtScale->et(hwHFEtSumsItr->etSum(2)) + 1.e-6;
0811 etSums[L1HFRings::kRing2NegEta] = hfRingEtScale->et(hwHFEtSumsItr->etSum(3)) + 1.e-6;
0812
0813
0814
0815
0816
0817
0818
0819
0820
0821
0822
0823
0824
0825
0826 int bitCounts[L1HFRings::kNumRings];
0827 bitCounts[L1HFRings::kRing1PosEta] = hwHFBitCountsItr->bitCount(0);
0828 bitCounts[L1HFRings::kRing1NegEta] = hwHFBitCountsItr->bitCount(1);
0829 bitCounts[L1HFRings::kRing2PosEta] = hwHFBitCountsItr->bitCount(2);
0830 bitCounts[L1HFRings::kRing2NegEta] = hwHFBitCountsItr->bitCount(3);
0831
0832
0833
0834
0835
0836
0837
0838
0839 hfRingsColl->push_back(L1HFRings(etSums,
0840 bitCounts,
0841 Ref<L1GctHFRingEtSumsCollection>(hwHFEtSumsColl, iEtSums),
0842 Ref<L1GctHFBitCountsCollection>(hwHFBitCountsColl, iBitCounts),
0843 bx));
0844 }
0845 }
0846 }
0847 }
0848 }
0849
0850 OrphanHandle<L1EmParticleCollection> isoEmHandle = iEvent.put(std::move(isoEmColl), "Isolated");
0851
0852 OrphanHandle<L1EmParticleCollection> nonIsoEmHandle = iEvent.put(std::move(nonIsoEmColl), "NonIsolated");
0853
0854 OrphanHandle<L1JetParticleCollection> cenJetHandle = iEvent.put(std::move(cenJetColl), "Central");
0855
0856 OrphanHandle<L1JetParticleCollection> forJetHandle = iEvent.put(std::move(forJetColl), "Forward");
0857
0858 OrphanHandle<L1JetParticleCollection> tauJetHandle = iEvent.put(std::move(tauJetColl), "Tau");
0859
0860 OrphanHandle<L1JetParticleCollection> IsoTauJetHandle = iEvent.put(std::move(isoTauJetColl), "IsoTau");
0861
0862 OrphanHandle<L1EtMissParticleCollection> etMissCollHandle = iEvent.put(std::move(etMissColl), "MET");
0863
0864 OrphanHandle<L1EtMissParticleCollection> htMissCollHandle = iEvent.put(std::move(htMissColl), "MHT");
0865
0866 OrphanHandle<L1HFRingsCollection> hfRingsCollHandle = iEvent.put(std::move(hfRingsColl));
0867 }
0868
0869
0870 math::PtEtaPhiMLorentzVector L1ExtraParticlesProd::gctLorentzVector(const double &et,
0871 const L1GctCand &cand,
0872 const L1CaloGeometry *geom,
0873 bool central) {
0874
0875 double etCorr = et + 1.e-6;
0876
0877 double eta = geom->etaBinCenter(cand.etaIndex(), central);
0878
0879
0880
0881
0882
0883
0884 double phi = geom->emJetPhiBinCenter(cand.phiIndex());
0885
0886
0887
0888
0889
0890 return math::PtEtaPhiMLorentzVector(etCorr, eta, phi, 0.);
0891 }
0892
0893
0894 DEFINE_FWK_MODULE(L1ExtraParticlesProd);