00001
00017
00018 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTrigger.h"
00019
00020
00021 #include <memory>
00022 #include <iostream>
00023 #include <iomanip>
00024 #include <algorithm>
00025
00026 #include <boost/cstdint.hpp>
00027
00028
00029
00030 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
00031 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerEvmReadoutRecord.h"
00032 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMapRecord.h"
00033
00034 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMap.h"
00035
00036 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTReadoutCollection.h"
00037 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
00038 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTExtendedCand.h"
00039
00040 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h"
00041 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
00042 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
00043 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
00044 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
00045 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFRingEtSums.h"
00046
00047 #include "FWCore/Framework/interface/Event.h"
00048 #include "FWCore/Framework/interface/EventSetup.h"
00049 #include "FWCore/Framework/interface/ESHandle.h"
00050
00051 #include "CondFormats/L1TObjects/interface/L1GtStableParameters.h"
00052 #include "CondFormats/DataRecord/interface/L1GtStableParametersRcd.h"
00053
00054 #include "CondFormats/L1TObjects/interface/L1GtParameters.h"
00055 #include "CondFormats/DataRecord/interface/L1GtParametersRcd.h"
00056
00057 #include "CondFormats/L1TObjects/interface/L1GtFwd.h"
00058 #include "CondFormats/L1TObjects/interface/L1GtBoard.h"
00059 #include "CondFormats/L1TObjects/interface/L1GtBoardMaps.h"
00060 #include "CondFormats/DataRecord/interface/L1GtBoardMapsRcd.h"
00061
00062 #include "CondFormats/L1TObjects/interface/L1GtPrescaleFactors.h"
00063 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsAlgoTrigRcd.h"
00064 #include "CondFormats/DataRecord/interface/L1GtPrescaleFactorsTechTrigRcd.h"
00065
00066 #include "CondFormats/L1TObjects/interface/L1GtTriggerMask.h"
00067 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskAlgoTrigRcd.h"
00068 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskTechTrigRcd.h"
00069
00070 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoAlgoTrigRcd.h"
00071 #include "CondFormats/DataRecord/interface/L1GtTriggerMaskVetoTechTrigRcd.h"
00072
00073 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
00074 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerGTL.h"
00075 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFDL.h"
00076
00077 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeWord.h"
00078 #include "DataFormats/L1GlobalTrigger/interface/L1GtfeExtWord.h"
00079 #include "DataFormats/L1GlobalTrigger/interface/L1TcsWord.h"
00080
00081 #include "DataFormats/Common/interface/RefProd.h"
00082 #include "FWCore/Utilities/interface/InputTag.h"
00083
00084 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00085 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00086
00087
00088
00089
00090
00091 L1GlobalTrigger::L1GlobalTrigger(const edm::ParameterSet& parSet) :
00092 m_muGmtInputTag(parSet.getParameter<edm::InputTag> ("GmtInputTag")),
00093 m_caloGctInputTag(parSet.getParameter<edm::InputTag> ("GctInputTag")),
00094 m_castorInputTag(parSet.getParameter<edm::InputTag> ("CastorInputTag")),
00095 m_technicalTriggersInputTags(parSet.getParameter<std::vector<edm::InputTag> > (
00096 "TechnicalTriggersInputTags")),
00097 m_produceL1GtDaqRecord(parSet.getParameter<bool> ("ProduceL1GtDaqRecord")),
00098 m_produceL1GtEvmRecord(parSet.getParameter<bool> ("ProduceL1GtEvmRecord")),
00099 m_produceL1GtObjectMapRecord(parSet.getParameter<bool> ("ProduceL1GtObjectMapRecord")),
00100 m_writePsbL1GtDaqRecord(parSet.getParameter<bool> ("WritePsbL1GtDaqRecord")),
00101 m_readTechnicalTriggerRecords(parSet.getParameter<bool> ("ReadTechnicalTriggerRecords")),
00102 m_emulateBxInEvent(parSet.getParameter<int> ("EmulateBxInEvent")),
00103 m_recordLength(parSet.getParameter<std::vector<int> > ("RecordLength")),
00104 m_alternativeNrBxBoardDaq(parSet.getParameter<unsigned int> ("AlternativeNrBxBoardDaq")),
00105 m_alternativeNrBxBoardEvm(parSet.getParameter<unsigned int> ("AlternativeNrBxBoardEvm")),
00106 m_psBstLengthBytes(parSet.getParameter<int> ("BstLengthBytes")),
00107 m_algorithmTriggersUnprescaled(parSet.getParameter<bool> ("AlgorithmTriggersUnprescaled")),
00108 m_algorithmTriggersUnmasked(parSet.getParameter<bool> ("AlgorithmTriggersUnmasked")),
00109 m_technicalTriggersUnprescaled(parSet.getParameter<bool> ("TechnicalTriggersUnprescaled")),
00110 m_technicalTriggersUnmasked(parSet.getParameter<bool> ("TechnicalTriggersUnmasked")),
00111 m_technicalTriggersVetoUnmasked(parSet.getParameter<bool> ("TechnicalTriggersVetoUnmasked")),
00112 m_verbosity(parSet.getUntrackedParameter<int>("Verbosity", 0)),
00113 m_isDebugEnabled(edm::isDebugEnabled())
00114
00115
00116 {
00117
00118 if (m_verbosity) {
00119
00120 LogDebug("L1GlobalTrigger") << std::endl;
00121
00122 LogTrace("L1GlobalTrigger")
00123 << "\nInput tag for muon collection from GMT: " << m_muGmtInputTag
00124 << "\nInput tag for calorimeter collections from GCT: " << m_caloGctInputTag
00125 << "\nInput tag for CASTOR record: " << m_castorInputTag
00126 << "\nInput tag for technical triggers: "
00127 << std::endl;
00128
00129
00130 for (std::vector<edm::InputTag>::const_iterator it = m_technicalTriggersInputTags.begin(); it
00131 != m_technicalTriggersInputTags.end(); it++) {
00132 LogTrace("L1GlobalTrigger") << "\n " << ( *it ) << std::endl;
00133 }
00134
00135 LogTrace("L1GlobalTrigger")
00136 << "\nProduce the L1 GT DAQ readout record: " << m_produceL1GtDaqRecord
00137 << "\nProduce the L1 GT EVM readout record: " << m_produceL1GtEvmRecord
00138 << "\nProduce the L1 GT Object Map record: " << m_produceL1GtObjectMapRecord
00139 << " \n"
00140 << "\nWrite Psb content to L1 GT DAQ Record: " << m_writePsbL1GtDaqRecord
00141 << " \n"
00142 << "\nRead technical trigger records: " << m_readTechnicalTriggerRecords
00143 << " \n"
00144 << "\nNumber of BxInEvent to be emulated: " << m_emulateBxInEvent
00145 << "\nNumber of BXs corresponding to alternative 0: " << m_recordLength.at(0)
00146 << "\nNumber of BXs corresponding to alternative 1: " << m_recordLength.at(1)
00147 << " \n"
00148 << "\nAlternative for number of BX in GT DAQ record: 0x" << std::hex
00149 << m_alternativeNrBxBoardDaq
00150 << "\nAlternative for number of BX in GT EVM record: 0x" << std::hex
00151 << m_alternativeNrBxBoardEvm << std::dec
00152 << " \n"
00153 << "\nLength of BST message [bytes]: " << m_psBstLengthBytes
00154 << "\n"
00155 << "\nRun algorithm triggers unprescaled: " << m_algorithmTriggersUnprescaled
00156 << "\nRun algorithm triggers unmasked (all enabled): " << m_algorithmTriggersUnmasked
00157 << "\n"
00158 << "\nRun technical triggers unprescaled: " << m_technicalTriggersUnprescaled
00159 << "\nRun technical triggers unmasked (all enabled): " << m_technicalTriggersUnmasked
00160 << "\nRun technical triggers veto unmasked (no veto): " << m_technicalTriggersUnmasked
00161 << "\n"
00162 << std::endl;
00163 }
00164
00165
00166 if ( ( m_emulateBxInEvent > 0 ) && ( ( m_emulateBxInEvent % 2 ) == 0 )) {
00167 m_emulateBxInEvent = m_emulateBxInEvent - 1;
00168
00169 if (m_verbosity) {
00170 edm::LogWarning("L1GlobalTrigger")
00171 << "\nWARNING: Number of bunch crossing to be emulated rounded to: "
00172 << m_emulateBxInEvent << "\n The number must be an odd number!\n"
00173 << std::endl;
00174 }
00175 }
00176
00177 int requiredRecordLength = std::max(m_recordLength.at(0), m_recordLength.at(1));
00178 if ((m_emulateBxInEvent >= 0) && (m_emulateBxInEvent < requiredRecordLength) ) {
00179
00180 m_emulateBxInEvent = requiredRecordLength;
00181
00182 if (m_verbosity) {
00183 edm::LogWarning("L1GlobalTrigger")
00184 << "\nWARNING: Number of bunch crossing required to be emulated ( "
00185 << m_emulateBxInEvent << " BX) smaller as required in RecordLength:"
00186 << "\n Number of BXs corresponding to alternative 0: " << m_recordLength.at(0)
00187 << "\n Number of BXs corresponding to alternative 1: " << m_recordLength.at(1)
00188 << "\nEmulating " << requiredRecordLength << " BX!"
00189 << "\n"
00190 << std::endl;
00191 }
00192
00193 }
00194
00195
00196 if (m_produceL1GtDaqRecord) {
00197 produces<L1GlobalTriggerReadoutRecord>();
00198 }
00199
00200 if (m_produceL1GtEvmRecord) {
00201 produces<L1GlobalTriggerEvmReadoutRecord>();
00202 }
00203
00204 if (m_produceL1GtObjectMapRecord) {
00205 produces<L1GlobalTriggerObjectMapRecord>();
00206 }
00207
00208
00209 m_gtPSB = new L1GlobalTriggerPSB();
00210 m_gtPSB->setVerbosity(m_verbosity);
00211
00212
00213 m_gtGTL = new L1GlobalTriggerGTL();
00214 m_gtGTL->setVerbosity(m_verbosity);
00215
00216
00217 m_gtFDL = new L1GlobalTriggerFDL();
00218 m_gtFDL->setVerbosity(m_verbosity);
00219
00220
00221
00222
00223 m_l1GtStableParCacheID = 0ULL;
00224
00225 m_numberPhysTriggers = 0;
00226 m_numberTechnicalTriggers = 0;
00227 m_numberDaqPartitions = 0;
00228
00229 m_nrL1Mu = 0;
00230
00231 m_nrL1NoIsoEG = 0;
00232 m_nrL1IsoEG = 0;
00233
00234 m_nrL1CenJet = 0;
00235 m_nrL1ForJet = 0;
00236 m_nrL1TauJet = 0;
00237
00238 m_nrL1JetCounts = 0;
00239
00240 m_ifMuEtaNumberBits = 0;
00241 m_ifCaloEtaNumberBits = 0;
00242
00243
00244 m_l1GtParCacheID = 0ULL;
00245
00246 m_totalBxInEvent = 0;
00247
00248 m_activeBoardsGtDaq = 0;
00249 m_activeBoardsGtEvm = 0;
00250 m_bstLengthBytes = 0;
00251
00252
00253 m_l1GtBMCacheID = 0ULL;
00254
00255
00256 m_l1GtPfAlgoCacheID = 0ULL;
00257 m_l1GtPfTechCacheID = 0ULL;
00258
00259 m_l1GtTmAlgoCacheID = 0ULL;
00260 m_l1GtTmTechCacheID = 0ULL;
00261
00262 m_l1GtTmVetoAlgoCacheID = 0ULL;
00263 m_l1GtTmVetoTechCacheID = 0ULL;
00264
00265 }
00266
00267
00268 L1GlobalTrigger::~L1GlobalTrigger()
00269 {
00270
00271 delete m_gtPSB;
00272 delete m_gtGTL;
00273 delete m_gtFDL;
00274 }
00275
00276
00277
00278
00279 void L1GlobalTrigger::produce(edm::Event& iEvent, const edm::EventSetup& evSetup)
00280 {
00281
00282
00283
00284
00285
00286
00287 unsigned long long l1GtStableParCacheID =
00288 evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
00289
00290 if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
00291
00292 edm::ESHandle< L1GtStableParameters > l1GtStablePar;
00293 evSetup.get< L1GtStableParametersRcd >().get( l1GtStablePar );
00294 m_l1GtStablePar = l1GtStablePar.product();
00295
00296
00297 m_numberPhysTriggers = m_l1GtStablePar->gtNumberPhysTriggers();
00298
00299
00300 m_numberTechnicalTriggers = m_l1GtStablePar->gtNumberTechnicalTriggers();
00301
00302
00303 m_numberDaqPartitions = 8;
00304
00305
00306 m_nrL1Mu = static_cast<int> (m_l1GtStablePar->gtNumberL1Mu());
00307
00308 m_nrL1NoIsoEG = static_cast<int> (m_l1GtStablePar->gtNumberL1NoIsoEG());
00309 m_nrL1IsoEG = static_cast<int> (m_l1GtStablePar->gtNumberL1IsoEG());
00310
00311 m_nrL1CenJet = static_cast<int> (m_l1GtStablePar->gtNumberL1CenJet());
00312 m_nrL1ForJet = static_cast<int> (m_l1GtStablePar->gtNumberL1ForJet());
00313 m_nrL1TauJet = static_cast<int> (m_l1GtStablePar->gtNumberL1TauJet());
00314
00315 m_nrL1JetCounts = static_cast<int> (m_l1GtStablePar->gtNumberL1JetCounts());
00316
00317
00318
00319 m_ifMuEtaNumberBits = static_cast<int> (m_l1GtStablePar->gtIfMuEtaNumberBits());
00320 m_ifCaloEtaNumberBits = static_cast<int> (m_l1GtStablePar->gtIfCaloEtaNumberBits());
00321
00322
00323 m_gtGTL->init(m_nrL1Mu, m_numberPhysTriggers);
00324
00325
00326 m_gtPSB->init(m_nrL1NoIsoEG, m_nrL1IsoEG,
00327 m_nrL1CenJet, m_nrL1ForJet, m_nrL1TauJet,
00328 m_numberTechnicalTriggers);
00329
00330
00331 m_l1GtStableParCacheID = l1GtStableParCacheID;
00332
00333 }
00334
00335
00336
00337
00338 unsigned long long l1GtParCacheID = evSetup.get<L1GtParametersRcd>().cacheIdentifier();
00339
00340 if (m_l1GtParCacheID != l1GtParCacheID) {
00341
00342 edm::ESHandle< L1GtParameters > l1GtPar;
00343 evSetup.get< L1GtParametersRcd >().get( l1GtPar );
00344 m_l1GtPar = l1GtPar.product();
00345
00346
00347 m_totalBxInEvent = m_l1GtPar->gtTotalBxInEvent();
00348
00349
00350 m_activeBoardsGtDaq = m_l1GtPar->gtDaqActiveBoards();
00351 m_activeBoardsGtEvm = m_l1GtPar->gtEvmActiveBoards();
00352
00354 m_bstLengthBytes = m_l1GtPar->gtBstLengthBytes();
00355
00356
00357 m_l1GtParCacheID = l1GtParCacheID;
00358
00359 }
00360
00361
00362 if (m_emulateBxInEvent < 0) {
00363 m_emulateBxInEvent = m_totalBxInEvent;
00364 }
00365
00366 int minBxInEvent = (m_emulateBxInEvent + 1)/2 - m_emulateBxInEvent;
00367 int maxBxInEvent = (m_emulateBxInEvent + 1)/2 - 1;
00368
00369 int recordLength0 = m_recordLength.at(0);
00370 int recordLength1 = m_recordLength.at(1);
00371
00372 if ((recordLength0 < 0) || (recordLength1 < 0) ) {
00373
00374
00375
00376
00377 recordLength0 = m_emulateBxInEvent;
00378 recordLength1 = m_emulateBxInEvent;
00379
00380 }
00381
00382
00383
00384 if (m_verbosity) {
00385
00386 LogDebug("L1GlobalTrigger")
00387 << "\nTotal number of BX to emulate in the GT readout record: "
00388 << m_emulateBxInEvent << " = " << "[" << minBxInEvent << ", " << maxBxInEvent
00389 << "] BX\n"
00390 << "\nNumber of BX for alternative 0: " << recordLength0
00391 << "\nNumber of BX for alternative 1: " << recordLength1
00392 << "\nActive boards in L1 GT DAQ record (hex format) = " << std::hex
00393 << std::setw(sizeof(m_activeBoardsGtDaq) * 2) << std::setfill('0')
00394 << m_activeBoardsGtDaq << std::dec << std::setfill(' ')
00395 << "\nActive boards in L1 GT EVM record (hex format) = " << std::hex
00396 << std::setw(sizeof(m_activeBoardsGtEvm) * 2) << std::setfill('0')
00397 << m_activeBoardsGtEvm << std::dec << std::setfill(' ') << "\n"
00398 << std::endl;
00399 }
00400
00401
00402
00403
00404 typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
00405
00406 unsigned long long l1GtBMCacheID = evSetup.get<L1GtBoardMapsRcd>().cacheIdentifier();
00407
00408 if (m_l1GtBMCacheID != l1GtBMCacheID) {
00409
00410 edm::ESHandle< L1GtBoardMaps > l1GtBM;
00411 evSetup.get< L1GtBoardMapsRcd >().get( l1GtBM );
00412 m_l1GtBM = l1GtBM.product();
00413
00414 m_l1GtBMCacheID = l1GtBMCacheID;
00415
00416 }
00417
00418
00419 const std::vector<L1GtBoard>& boardMaps = m_l1GtBM->gtBoardMaps();
00420
00421
00422
00423
00424 unsigned long long l1GtPfAlgoCacheID =
00425 evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
00426
00427 if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
00428
00429 edm::ESHandle< L1GtPrescaleFactors > l1GtPfAlgo;
00430 evSetup.get< L1GtPrescaleFactorsAlgoTrigRcd >().get( l1GtPfAlgo );
00431 m_l1GtPfAlgo = l1GtPfAlgo.product();
00432
00433 m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
00434
00435 m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
00436
00437 }
00438
00439 unsigned long long l1GtPfTechCacheID =
00440 evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
00441
00442 if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
00443
00444 edm::ESHandle< L1GtPrescaleFactors > l1GtPfTech;
00445 evSetup.get< L1GtPrescaleFactorsTechTrigRcd >().get( l1GtPfTech );
00446 m_l1GtPfTech = l1GtPfTech.product();
00447
00448 m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
00449
00450 m_l1GtPfTechCacheID = l1GtPfTechCacheID;
00451
00452 }
00453
00454
00455
00456
00457
00458 unsigned long long l1GtTmAlgoCacheID =
00459 evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
00460
00461 if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
00462
00463 edm::ESHandle< L1GtTriggerMask > l1GtTmAlgo;
00464 evSetup.get< L1GtTriggerMaskAlgoTrigRcd >().get( l1GtTmAlgo );
00465 m_l1GtTmAlgo = l1GtTmAlgo.product();
00466
00467 m_triggerMaskAlgoTrig = m_l1GtTmAlgo->gtTriggerMask();
00468
00469 m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
00470
00471 }
00472
00473
00474 unsigned long long l1GtTmTechCacheID =
00475 evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
00476
00477 if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
00478
00479 edm::ESHandle< L1GtTriggerMask > l1GtTmTech;
00480 evSetup.get< L1GtTriggerMaskTechTrigRcd >().get( l1GtTmTech );
00481 m_l1GtTmTech = l1GtTmTech.product();
00482
00483 m_triggerMaskTechTrig = m_l1GtTmTech->gtTriggerMask();
00484
00485 m_l1GtTmTechCacheID = l1GtTmTechCacheID;
00486
00487 }
00488
00489 unsigned long long l1GtTmVetoAlgoCacheID =
00490 evSetup.get<L1GtTriggerMaskVetoAlgoTrigRcd>().cacheIdentifier();
00491
00492 if (m_l1GtTmVetoAlgoCacheID != l1GtTmVetoAlgoCacheID) {
00493
00494 edm::ESHandle< L1GtTriggerMask > l1GtTmVetoAlgo;
00495 evSetup.get< L1GtTriggerMaskVetoAlgoTrigRcd >().get( l1GtTmVetoAlgo );
00496 m_l1GtTmVetoAlgo = l1GtTmVetoAlgo.product();
00497
00498 m_triggerMaskVetoAlgoTrig = m_l1GtTmVetoAlgo->gtTriggerMask();
00499
00500 m_l1GtTmVetoAlgoCacheID = l1GtTmVetoAlgoCacheID;
00501
00502 }
00503
00504
00505 unsigned long long l1GtTmVetoTechCacheID =
00506 evSetup.get<L1GtTriggerMaskVetoTechTrigRcd>().cacheIdentifier();
00507
00508 if (m_l1GtTmVetoTechCacheID != l1GtTmVetoTechCacheID) {
00509
00510 edm::ESHandle< L1GtTriggerMask > l1GtTmVetoTech;
00511 evSetup.get< L1GtTriggerMaskVetoTechTrigRcd >().get( l1GtTmVetoTech );
00512 m_l1GtTmVetoTech = l1GtTmVetoTech.product();
00513
00514 m_triggerMaskVetoTechTrig = m_l1GtTmVetoTech->gtTriggerMask();
00515
00516 m_l1GtTmVetoTechCacheID = l1GtTmVetoTechCacheID;
00517
00518 }
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528 int daqNrGtfeBoards = 0;
00529
00530 int daqNrFdlBoards = 0;
00531 int daqNrPsbBoards = 0;
00532 int daqNrGmtBoards = 0;
00533 int daqNrTcsBoards = 0;
00534 int daqNrTimBoards = 0;
00535
00536
00537 bool receiveMu = false;
00538 bool receiveNoIsoEG = false;
00539 bool receiveIsoEG = false;
00540 bool receiveCenJet = false;
00541 bool receiveForJet = false;
00542 bool receiveTauJet = false;
00543 bool receiveETM = false;
00544 bool receiveETT = false;
00545 bool receiveHTT = false;
00546 bool receiveHTM = false;
00547 bool receiveJetCounts = false;
00548 bool receiveHfBitCounts = false;
00549 bool receiveHfRingEtSums = false;
00550
00551 bool receiveExternal = false;
00552
00553 bool receiveTechTr = false;
00554
00555 for (CItBoardMaps
00556 itBoard = boardMaps.begin();
00557 itBoard != boardMaps.end(); ++itBoard) {
00558
00559 int iPosition = itBoard->gtPositionDaqRecord();
00560 if (iPosition > 0) {
00561
00562 int iActiveBit = itBoard->gtBitDaqActiveBoards();
00563 bool activeBoard = false;
00564
00565 if (iActiveBit >= 0) {
00566 activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
00567 }
00568
00569
00570
00571 if ((iActiveBit < 0) || activeBoard) {
00572
00573 switch (itBoard->gtBoardType()) {
00574
00575 case GTFE: {
00576 daqNrGtfeBoards++;
00577 }
00578
00579 break;
00580 case FDL: {
00581 daqNrFdlBoards++;
00582 }
00583
00584 break;
00585 case PSB: {
00586 daqNrPsbBoards++;
00587
00588
00589 std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
00590 for (std::vector<L1GtPsbQuad>::const_iterator
00591 itQuad = quadInPsb.begin();
00592 itQuad != quadInPsb.end(); ++itQuad) {
00593
00594 switch (*itQuad) {
00595
00596 case TechTr: {
00597 receiveTechTr = true;
00598 }
00599
00600 break;
00601 case NoIsoEGQ: {
00602 receiveNoIsoEG = true;
00603 }
00604
00605 break;
00606 case IsoEGQ: {
00607 receiveIsoEG = true;
00608 }
00609
00610 break;
00611 case CenJetQ: {
00612 receiveCenJet = true;
00613 }
00614
00615 break;
00616 case ForJetQ: {
00617 receiveForJet = true;
00618 }
00619
00620 break;
00621 case TauJetQ: {
00622 receiveTauJet = true;
00623 }
00624
00625 break;
00626 case ESumsQ: {
00627 receiveETM = true;
00628 receiveETT = true;
00629 receiveHTT = true;
00630 receiveHTM = true;
00631 }
00632
00633 break;
00634 case JetCountsQ: {
00635 receiveJetCounts = true;
00636 }
00637
00638 break;
00639 case CastorQ: {
00640
00641 }
00642
00643 break;
00644 case BptxQ: {
00645
00646 }
00647
00648 break;
00649 case GtExternalQ: {
00650 receiveExternal = true;
00651 }
00652
00653 break;
00654 case HfQ: {
00655 receiveHfBitCounts = true;
00656 receiveHfRingEtSums = true;
00657 }
00658
00659 break;
00660
00661 default: {
00662
00663 }
00664
00665 break;
00666 }
00667
00668 }
00669
00670 }
00671
00672 break;
00673 case GMT: {
00674 daqNrGmtBoards++;
00675 receiveMu = true;
00676 }
00677
00678 break;
00679 case TCS: {
00680 daqNrTcsBoards++;
00681 }
00682
00683 break;
00684 case TIM: {
00685 daqNrTimBoards++;
00686 }
00687
00688 break;
00689 default: {
00690
00691 }
00692
00693 break;
00694 }
00695 }
00696 }
00697
00698 }
00699
00700
00701
00702 std::auto_ptr<L1GlobalTriggerReadoutRecord> gtDaqReadoutRecord(
00703 new L1GlobalTriggerReadoutRecord(
00704 m_emulateBxInEvent, daqNrFdlBoards, daqNrPsbBoards) );
00705
00706
00707
00708 std::auto_ptr<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord(
00709 new L1GlobalTriggerEvmReadoutRecord(m_emulateBxInEvent, daqNrFdlBoards) );
00710
00711
00712
00713 std::auto_ptr<L1GlobalTriggerObjectMapRecord> gtObjectMapRecord(
00714 new L1GlobalTriggerObjectMapRecord() );
00715
00716
00717
00718
00719
00720
00721
00722 int bxCross = iEvent.bunchCrossing();
00723 boost::uint16_t bxCrossHw = 0;
00724 if ((bxCross & 0xFFF) == bxCross) {
00725 bxCrossHw = static_cast<boost::uint16_t> (bxCross);
00726 }
00727 else {
00728 bxCrossHw = 0;
00729 if (m_verbosity) {
00730
00731 LogDebug("L1GlobalTrigger")
00732 << "\nBunch cross number [hex] = " << std::hex << bxCross
00733 << "\n larger than 12 bits. Set to 0! \n" << std::dec
00734 << std::endl;
00735 }
00736 }
00737
00738
00739 if (m_produceL1GtDaqRecord) {
00740
00741 for (CItBoardMaps
00742 itBoard = boardMaps.begin();
00743 itBoard != boardMaps.end(); ++itBoard) {
00744
00745 int iPosition = itBoard->gtPositionDaqRecord();
00746 if (iPosition > 0) {
00747
00748 int iActiveBit = itBoard->gtBitDaqActiveBoards();
00749 bool activeBoard = false;
00750
00751 if (iActiveBit >= 0) {
00752 activeBoard = m_activeBoardsGtDaq & (1 << iActiveBit);
00753 }
00754
00755
00756
00757 if ((iActiveBit < 0) || activeBoard) {
00758
00759 switch (itBoard->gtBoardType()) {
00760
00761 case GTFE: {
00762 L1GtfeWord gtfeWordValue;
00763
00764 gtfeWordValue.setBoardId( itBoard->gtBoardId() );
00765
00766
00767
00768 gtfeWordValue.setRecordLength(
00769 static_cast<boost::uint16_t>(recordLength0));
00770
00771 gtfeWordValue.setRecordLength1(
00772 static_cast<boost::uint16_t>(recordLength1));
00773
00774
00775 gtfeWordValue.setBxNr(bxCrossHw);
00776
00777
00778 gtfeWordValue.setActiveBoards(m_activeBoardsGtDaq);
00779
00780
00781 gtfeWordValue.setAltNrBxBoard(
00782 static_cast<boost::uint16_t> (m_alternativeNrBxBoardDaq));
00783
00784
00785
00786
00787 gtfeWordValue.setTotalTriggerNr(
00788 static_cast<boost::uint32_t>(iEvent.id().event()));
00789
00790
00791
00792 gtDaqReadoutRecord->setGtfeWord(gtfeWordValue);
00793 }
00794
00795 break;
00796 case TCS: {
00797
00798 }
00799
00800 break;
00801 case TIM: {
00802
00803 }
00804
00805 break;
00806 default: {
00807
00808 }
00809
00810 break;
00811 }
00812 }
00813 }
00814
00815 }
00816
00817 }
00818
00819
00820
00821 int evmNrFdlBoards = 0;
00822
00823 if (m_produceL1GtEvmRecord) {
00824
00825
00826
00827 int bstLengthBytes = 0;
00828
00829 if (m_psBstLengthBytes < 0) {
00830
00831 bstLengthBytes = static_cast<int> (m_bstLengthBytes);
00832
00833 } else {
00834
00835 bstLengthBytes = m_psBstLengthBytes;
00836 }
00837
00838 if (m_verbosity) {
00839
00840 LogTrace("L1GlobalTrigger")
00841 << "\n Length of BST message (in bytes): "
00842 << bstLengthBytes << "\n"
00843 << std::endl;
00844 }
00845
00846 for (CItBoardMaps
00847 itBoard = boardMaps.begin();
00848 itBoard != boardMaps.end(); ++itBoard) {
00849
00850 int iPosition = itBoard->gtPositionEvmRecord();
00851 if (iPosition > 0) {
00852
00853 int iActiveBit = itBoard->gtBitEvmActiveBoards();
00854 bool activeBoard = false;
00855
00856 if (iActiveBit >= 0) {
00857 activeBoard = m_activeBoardsGtEvm & (1 << iActiveBit);
00858 }
00859
00860
00861
00862 if ((iActiveBit < 0) || activeBoard) {
00863
00864 switch (itBoard->gtBoardType()) {
00865
00866 case GTFE: {
00867 L1GtfeExtWord gtfeWordValue(bstLengthBytes);
00868
00869 gtfeWordValue.setBoardId(itBoard->gtBoardId() );
00870
00871
00872
00873 gtfeWordValue.setRecordLength(
00874 static_cast<boost::uint16_t>(recordLength0));
00875
00876 gtfeWordValue.setRecordLength1(
00877 static_cast<boost::uint16_t>(recordLength1));
00878
00879
00880 gtfeWordValue.setBxNr(bxCrossHw);
00881
00882
00883 gtfeWordValue.setActiveBoards(m_activeBoardsGtEvm);
00884
00885
00886 gtfeWordValue.setAltNrBxBoard(
00887 static_cast<boost::uint16_t> (m_alternativeNrBxBoardEvm));
00888
00889
00890
00891
00892 gtfeWordValue.setTotalTriggerNr(
00893 static_cast<boost::uint32_t>(iEvent.id().event()));
00894
00895
00896 edm::TimeValue_t evTime = iEvent.time().value();
00897
00898 gtfeWordValue.setGpsTime(evTime);
00899
00900
00901
00902
00903
00904
00905
00906 boost::uint16_t bstSourceVal = 0xDDDD;
00907 gtfeWordValue.setBstSource(bstSourceVal);
00908
00909
00910
00911 gtEvmReadoutRecord->setGtfeWord(gtfeWordValue);
00912 }
00913
00914 break;
00915 case FDL: {
00916 evmNrFdlBoards++;
00917 }
00918
00919 break;
00920 case TCS: {
00921
00922 L1TcsWord tcsWordValue;
00923
00924 tcsWordValue.setBoardId( itBoard->gtBoardId() );
00925
00926
00927 tcsWordValue.setBxNr(bxCrossHw);
00928
00929 boost::uint16_t trigType = 0x5;
00930 tcsWordValue.setTriggerType(trigType);
00931
00932
00933 tcsWordValue.setLuminositySegmentNr(
00934 static_cast<boost::uint16_t>(iEvent.luminosityBlock()));
00935
00936
00937
00938 tcsWordValue.setEventNr(
00939 static_cast<boost::uint32_t>(iEvent.id().event()));
00940
00941
00942 tcsWordValue.setOrbitNr(
00943 static_cast<boost::uint64_t>(iEvent.orbitNumber()) );
00944
00945
00946
00947 gtEvmReadoutRecord->setTcsWord(tcsWordValue);
00948
00949 }
00950
00951 break;
00952 case TIM: {
00953
00954 }
00955
00956 break;
00957 default: {
00958
00959 }
00960
00961 break;
00962 }
00963 }
00964 }
00965
00966 }
00967
00968 }
00969
00970
00971 int pfAlgoSetIndex = 0;
00972 const std::vector<int>& prescaleFactorsAlgoTrig =
00973 (*m_prescaleFactorsAlgoTrig).at(pfAlgoSetIndex);
00974
00975 int pfTechSetIndex = 0;
00976 const std::vector<int>& prescaleFactorsTechTrig =
00977 (*m_prescaleFactorsTechTrig).at(pfTechSetIndex);
00978
00979
00980
00981
00982 for (int iBxInEvent = minBxInEvent; iBxInEvent <= maxBxInEvent;
00983 ++iBxInEvent) {
00984
00985
00986
00987
00988
00989
00990 m_gtPSB->receiveGctObjectData(
00991 iEvent,
00992 m_caloGctInputTag, iBxInEvent,
00993 receiveNoIsoEG, m_nrL1NoIsoEG,
00994 receiveIsoEG, m_nrL1IsoEG,
00995 receiveCenJet, m_nrL1CenJet,
00996 receiveForJet, m_nrL1ForJet,
00997 receiveTauJet, m_nrL1TauJet,
00998 receiveETM, receiveETT, receiveHTT, receiveHTM,
00999 receiveJetCounts,
01000 receiveHfBitCounts,
01001 receiveHfRingEtSums);
01002
01004 if (m_readTechnicalTriggerRecords) {
01005 m_gtPSB->receiveTechnicalTriggers(iEvent,
01006 m_technicalTriggersInputTags, iBxInEvent, receiveTechTr,
01007 m_numberTechnicalTriggers);
01008 }
01009
01010 if (receiveExternal) {
01011
01012 }
01013
01014
01015 if (m_produceL1GtDaqRecord && m_writePsbL1GtDaqRecord) {
01016 m_gtPSB->fillPsbBlock(
01017 iEvent, m_activeBoardsGtDaq, recordLength0, recordLength1,
01018 m_alternativeNrBxBoardDaq, boardMaps, iBxInEvent, gtDaqReadoutRecord);
01019 }
01020
01021
01022
01023
01024
01025
01026 m_gtGTL->receiveGmtObjectData(iEvent, m_muGmtInputTag, iBxInEvent,
01027 receiveMu, m_nrL1Mu);
01028
01029
01030
01031
01032
01033
01034 m_gtGTL->run(iEvent, evSetup, m_gtPSB,
01035 m_produceL1GtObjectMapRecord, iBxInEvent, gtObjectMapRecord,
01036 m_numberPhysTriggers,
01037 m_nrL1Mu,
01038 m_nrL1NoIsoEG,
01039 m_nrL1IsoEG,
01040 m_nrL1CenJet,
01041 m_nrL1ForJet,
01042 m_nrL1TauJet,
01043 m_nrL1JetCounts,
01044 m_ifMuEtaNumberBits,
01045 m_ifCaloEtaNumberBits);
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056 m_gtFDL->run(iEvent,
01057 prescaleFactorsAlgoTrig, prescaleFactorsTechTrig,
01058 m_triggerMaskAlgoTrig, m_triggerMaskTechTrig,
01059 m_triggerMaskVetoAlgoTrig, m_triggerMaskVetoTechTrig,
01060 boardMaps, m_emulateBxInEvent, iBxInEvent,
01061 m_numberPhysTriggers, m_numberTechnicalTriggers,
01062 m_numberDaqPartitions,
01063 m_gtGTL, m_gtPSB,
01064 pfAlgoSetIndex,
01065 pfTechSetIndex,
01066 m_algorithmTriggersUnprescaled,
01067 m_algorithmTriggersUnmasked,
01068 m_technicalTriggersUnprescaled,
01069 m_technicalTriggersUnmasked,
01070 m_technicalTriggersVetoUnmasked
01071 );
01072
01073 if (m_produceL1GtDaqRecord && ( daqNrFdlBoards > 0 )) {
01074 m_gtFDL->fillDaqFdlBlock(iBxInEvent,
01075 m_activeBoardsGtDaq, recordLength0, recordLength1, m_alternativeNrBxBoardDaq,
01076 boardMaps, gtDaqReadoutRecord);
01077 }
01078
01079
01080 if (m_produceL1GtEvmRecord && ( evmNrFdlBoards > 0 )) {
01081 m_gtFDL->fillEvmFdlBlock(iBxInEvent,
01082 m_activeBoardsGtEvm, recordLength0, recordLength1, m_alternativeNrBxBoardEvm,
01083 boardMaps, gtEvmReadoutRecord);
01084 }
01085
01086
01087 m_gtPSB->reset();
01088 m_gtGTL->reset();
01089 m_gtFDL->reset();
01090
01091
01092
01093 }
01094
01095
01096 if ( receiveMu ) {
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108 edm::Handle<L1MuGMTReadoutCollection> gmtRcHandle;
01109 iEvent.getByLabel(m_muGmtInputTag, gmtRcHandle);
01110
01111
01112
01113 if (!gmtRcHandle.isValid()) {
01114 if (m_verbosity) {
01115 edm::LogWarning("L1GlobalTrigger")
01116 << "\nWarning: L1MuGMTReadoutCollection with input tag " << m_muGmtInputTag
01117 << "\nrequested in configuration, but not found in the event.\n"
01118 << std::endl;
01119 }
01120 } else {
01121
01122 gtDaqReadoutRecord->setMuCollectionRefProd(gmtRcHandle);
01123
01124 }
01125
01126 }
01127
01128 if ( m_verbosity && m_isDebugEnabled ) {
01129
01130 std::ostringstream myCoutStream;
01131 gtDaqReadoutRecord->print(myCoutStream);
01132 LogTrace("L1GlobalTrigger")
01133 << "\n The following L1 GT DAQ readout record was produced:\n"
01134 << myCoutStream.str() << "\n"
01135 << std::endl;
01136
01137 myCoutStream.str("");
01138 myCoutStream.clear();
01139
01140 gtEvmReadoutRecord->print(myCoutStream);
01141 LogTrace("L1GlobalTrigger")
01142 << "\n The following L1 GT EVM readout record was produced:\n"
01143 << myCoutStream.str() << "\n"
01144 << std::endl;
01145
01146 myCoutStream.str("");
01147 myCoutStream.clear();
01148
01149 const std::vector<L1GlobalTriggerObjectMap> objMapVec =
01150 gtObjectMapRecord->gtObjectMap();
01151
01152 for (std::vector<L1GlobalTriggerObjectMap>::const_iterator
01153 it = objMapVec.begin(); it != objMapVec.end(); ++it) {
01154
01155 (*it).print(myCoutStream);
01156
01157 }
01158
01159
01160 LogDebug("L1GlobalTrigger")
01161 << "Test gtObjectMapRecord in L1GlobalTrigger \n\n" << myCoutStream.str() << "\n\n"
01162 << std::endl;
01163
01164 myCoutStream.str("");
01165 myCoutStream.clear();
01166
01167 }
01168
01169
01170
01171 if (m_produceL1GtDaqRecord) {
01172 iEvent.put( gtDaqReadoutRecord );
01173 }
01174
01175 if (m_produceL1GtEvmRecord) {
01176 iEvent.put( gtEvmReadoutRecord );
01177 }
01178
01179 if (m_produceL1GtObjectMapRecord) {
01180 iEvent.put( gtObjectMapRecord );
01181 }
01182
01183 }
01184
01185
01186