Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:00

0001 /**
0002  * \class L1GlobalTriggerPSB
0003  *
0004  *
0005  * Description: Pipelined Synchronising Buffer, see header file for details.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: M. Fierro            - HEPHY Vienna - ORCA version
0011  * \author: Vasile Mihai Ghete   - HEPHY Vienna - CMSSW version
0012  *
0013  *
0014  */
0015 
0016 // this class header
0017 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerPSB.h"
0018 
0019 // system include files
0020 #include <bitset>
0021 #include <iomanip>
0022 #include <iostream>
0023 
0024 // user include files
0025 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
0026 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetup.h"
0027 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
0028 
0029 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCand.h"
0030 
0031 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEmCand.h"
0032 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctEtSums.h"
0033 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
0034 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFRingEtSums.h"
0035 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCand.h"
0036 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctJetCounts.h"
0037 
0038 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctCollections.h"
0039 
0040 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0041 #include "FWCore/Utilities/interface/Exception.h"
0042 
0043 #include "FWCore/Framework/interface/Event.h"
0044 #include "FWCore/Utilities/interface/InputTag.h"
0045 
0046 // forward declarations
0047 
0048 // constructor
0049 L1GlobalTriggerPSB::L1GlobalTriggerPSB(const edm::InputTag &m_caloGctInputTag,
0050                                        const std::vector<edm::InputTag> &m_technicalTriggersInputTags,
0051                                        edm::ConsumesCollector &&iC)
0052     : m_candL1NoIsoEG(new std::vector<const L1GctCand *>),
0053       m_candL1IsoEG(new std::vector<const L1GctCand *>),
0054       m_candL1CenJet(new std::vector<const L1GctCand *>),
0055       m_candL1ForJet(new std::vector<const L1GctCand *>),
0056       m_candL1TauJet(new std::vector<const L1GctCand *>),
0057       m_candETM(nullptr),
0058       m_candETT(nullptr),
0059       m_candHTT(nullptr),
0060       m_candHTM(nullptr),
0061       m_candJetCounts(nullptr),
0062       m_candHfBitCounts(nullptr),
0063       m_candHfRingEtSums(nullptr),
0064       m_isDebugEnabled(edm::isDebugEnabled())
0065 
0066 {
0067   iC.consumes<L1GctEmCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "nonIsoEm", ""));
0068   iC.consumes<L1GctEmCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "isoEm", ""));
0069   iC.consumes<L1GctJetCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "cenJets", ""));
0070   iC.consumes<L1GctJetCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "forJets", ""));
0071   iC.consumes<L1GctJetCandCollection>(edm::InputTag(m_caloGctInputTag.label(), "tauJets", ""));
0072   iC.consumes<L1GctEtMissCollection>(m_caloGctInputTag);
0073   iC.consumes<L1GctEtTotalCollection>(m_caloGctInputTag);
0074   iC.consumes<L1GctEtHadCollection>(m_caloGctInputTag);
0075   iC.consumes<L1GctHtMissCollection>(m_caloGctInputTag);
0076   iC.consumes<L1GctJetCountsCollection>(m_caloGctInputTag);
0077   iC.consumes<L1GctHFBitCountsCollection>(m_caloGctInputTag);
0078   iC.consumes<L1GctHFRingEtSumsCollection>(m_caloGctInputTag);
0079 
0080   for (std::vector<edm::InputTag>::const_iterator it = m_technicalTriggersInputTags.begin();
0081        it != m_technicalTriggersInputTags.end();
0082        it++) {
0083     iC.consumes<L1GtTechnicalTriggerRecord>((*it));
0084   }
0085   // empty
0086 }
0087 
0088 // destructor
0089 L1GlobalTriggerPSB::~L1GlobalTriggerPSB() {
0090   reset();
0091 
0092   delete m_candL1NoIsoEG;
0093   delete m_candL1IsoEG;
0094   delete m_candL1CenJet;
0095   delete m_candL1ForJet;
0096   delete m_candL1TauJet;
0097 }
0098 
0099 // operations
0100 void L1GlobalTriggerPSB::init(const int nrL1NoIsoEG,
0101                               const int nrL1IsoEG,
0102                               const int nrL1CenJet,
0103                               const int nrL1ForJet,
0104                               const int nrL1TauJet,
0105                               const int numberTechnicalTriggers) {
0106   m_candL1NoIsoEG->reserve(nrL1NoIsoEG);
0107   m_candL1IsoEG->reserve(nrL1IsoEG);
0108   m_candL1CenJet->reserve(nrL1CenJet);
0109   m_candL1ForJet->reserve(nrL1ForJet);
0110   m_candL1TauJet->reserve(nrL1TauJet);
0111 
0112   m_gtTechnicalTriggers.reserve(numberTechnicalTriggers);
0113   m_gtTechnicalTriggers.assign(numberTechnicalTriggers, false);
0114 }
0115 
0116 // receive input data
0117 
0118 void L1GlobalTriggerPSB::receiveGctObjectData(edm::Event &iEvent,
0119                                               const edm::InputTag &caloGctInputTag,
0120                                               const int iBxInEvent,
0121                                               const bool receiveNoIsoEG,
0122                                               const int nrL1NoIsoEG,
0123                                               const bool receiveIsoEG,
0124                                               const int nrL1IsoEG,
0125                                               const bool receiveCenJet,
0126                                               const int nrL1CenJet,
0127                                               const bool receiveForJet,
0128                                               const int nrL1ForJet,
0129                                               const bool receiveTauJet,
0130                                               const int nrL1TauJet,
0131                                               const bool receiveETM,
0132                                               const bool receiveETT,
0133                                               const bool receiveHTT,
0134                                               const bool receiveHTM,
0135                                               const bool receiveJetCounts,
0136                                               const bool receiveHfBitCounts,
0137                                               const bool receiveHfRingEtSums) {
0138   // LogDebug("L1GlobalTrigger")
0139   //        << "\n**** L1GlobalTriggerPSB receiving calorimeter data for
0140   //        BxInEvent = "
0141   //        << iBxInEvent << "\n     from " << caloGctInputTag << "\n"
0142   //        << std::endl;
0143 
0144   reset();
0145 
0146   std::ostringstream warningsStream;
0147   bool warningEnabled = edm::isWarningEnabled();
0148 
0149   if (receiveNoIsoEG) {
0150     // get GCT NoIsoEG
0151     edm::Handle<L1GctEmCandCollection> emCands;
0152     iEvent.getByLabel(caloGctInputTag.label(), "nonIsoEm", emCands);
0153 
0154     if (!emCands.isValid()) {
0155       if (warningEnabled) {
0156         warningsStream << "\nWarning: L1GctEmCandCollection with input label " << caloGctInputTag.label()
0157                        << " and instance \"nonIsoEm\" \n"
0158                        << "requested in configuration, but not found in the event.\n"
0159                        << std::endl;
0160       }
0161     } else {
0162       for (L1GctEmCandCollection::const_iterator it = emCands->begin(); it != emCands->end(); it++) {
0163         if ((*it).bx() == iBxInEvent) {
0164           (*m_candL1NoIsoEG).push_back(&(*it));
0165           // LogTrace("L1GlobalTrigger") << "NoIsoEG:  " << (*it) << std::endl;
0166         }
0167       }
0168     }
0169   }
0170 
0171   if (receiveIsoEG) {
0172     // get GCT IsoEG
0173     edm::Handle<L1GctEmCandCollection> isoEmCands;
0174     iEvent.getByLabel(caloGctInputTag.label(), "isoEm", isoEmCands);
0175 
0176     if (!isoEmCands.isValid()) {
0177       if (warningEnabled) {
0178         warningsStream << "\nWarning: L1GctEmCandCollection with input label " << caloGctInputTag.label()
0179                        << " and instance \"isoEm\" \n"
0180                        << "requested in configuration, but not found in the event.\n"
0181                        << std::endl;
0182       }
0183     } else {
0184       for (L1GctEmCandCollection::const_iterator it = isoEmCands->begin(); it != isoEmCands->end(); it++) {
0185         if ((*it).bx() == iBxInEvent) {
0186           (*m_candL1IsoEG).push_back(&(*it));
0187           // LogTrace("L1GlobalTrigger") << "IsoEG:    " <<  (*it) << std::endl;
0188         }
0189       }
0190     }
0191   }
0192 
0193   if (receiveCenJet) {
0194     // get GCT CenJet
0195     edm::Handle<L1GctJetCandCollection> cenJets;
0196     iEvent.getByLabel(caloGctInputTag.label(), "cenJets", cenJets);
0197 
0198     if (!cenJets.isValid()) {
0199       if (warningEnabled) {
0200         warningsStream << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
0201                        << " and instance \"cenJets\" \n"
0202                        << "requested in configuration, but not found in the event.\n"
0203                        << std::endl;
0204       }
0205     } else {
0206       for (L1GctJetCandCollection::const_iterator it = cenJets->begin(); it != cenJets->end(); it++) {
0207         if ((*it).bx() == iBxInEvent) {
0208           (*m_candL1CenJet).push_back(&(*it));
0209           // LogTrace("L1GlobalTrigger") << "CenJet    " <<  (*it) << std::endl;
0210         }
0211       }
0212     }
0213   }
0214 
0215   if (receiveForJet) {
0216     // get GCT ForJet
0217     edm::Handle<L1GctJetCandCollection> forJets;
0218     iEvent.getByLabel(caloGctInputTag.label(), "forJets", forJets);
0219 
0220     if (!forJets.isValid()) {
0221       if (warningEnabled) {
0222         warningsStream << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
0223                        << " and instance \"forJets\" \n"
0224                        << "requested in configuration, but not found in the event.\n"
0225                        << std::endl;
0226       }
0227     } else {
0228       for (L1GctJetCandCollection::const_iterator it = forJets->begin(); it != forJets->end(); it++) {
0229         if ((*it).bx() == iBxInEvent) {
0230           (*m_candL1ForJet).push_back(&(*it));
0231           // LogTrace("L1GlobalTrigger") << "ForJet    " <<  (*it) << std::endl;
0232         }
0233       }
0234     }
0235   }
0236 
0237   if (receiveTauJet) {
0238     // get GCT TauJet
0239     edm::Handle<L1GctJetCandCollection> tauJets;
0240     iEvent.getByLabel(caloGctInputTag.label(), "tauJets", tauJets);
0241 
0242     if (!tauJets.isValid()) {
0243       if (warningEnabled) {
0244         warningsStream << "\nWarning: L1GctJetCandCollection with input label " << caloGctInputTag.label()
0245                        << " and instance \"tauJets\" \n"
0246                        << "requested in configuration, but not found in the event.\n"
0247                        << std::endl;
0248       }
0249     } else {
0250       for (L1GctJetCandCollection::const_iterator it = tauJets->begin(); it != tauJets->end(); it++) {
0251         if ((*it).bx() == iBxInEvent) {
0252           (*m_candL1TauJet).push_back(&(*it));
0253           // LogTrace("L1GlobalTrigger") << "TauJet    " <<  (*it) << std::endl;
0254         }
0255       }
0256     }
0257   }
0258 
0259   // get GCT ETM
0260   if (receiveETM) {
0261     edm::Handle<L1GctEtMissCollection> missEtColl;
0262     iEvent.getByLabel(caloGctInputTag, missEtColl);
0263 
0264     if (!missEtColl.isValid()) {
0265       if (warningEnabled) {
0266         warningsStream << "\nWarning: L1GctEtMissCollection with input tag " << caloGctInputTag
0267                        << "\nrequested in configuration, but not found in the event.\n"
0268                        << std::endl;
0269       }
0270     } else {
0271       for (L1GctEtMissCollection::const_iterator it = missEtColl->begin(); it != missEtColl->end(); it++) {
0272         if ((*it).bx() == iBxInEvent) {
0273           m_candETM = &(*it);
0274           // LogTrace("L1GlobalTrigger") << "ETM      " << (*it) << std::endl;
0275         }
0276       }
0277     }
0278   }
0279 
0280   // get GCT ETT
0281   if (receiveETT) {
0282     edm::Handle<L1GctEtTotalCollection> sumEtColl;
0283     iEvent.getByLabel(caloGctInputTag, sumEtColl);
0284 
0285     if (!sumEtColl.isValid()) {
0286       if (warningEnabled) {
0287         warningsStream << "\nWarning: L1GctEtTotalCollection with input tag " << caloGctInputTag
0288                        << "\nrequested in configuration, but not found in the event.\n"
0289                        << std::endl;
0290       }
0291     } else {
0292       for (L1GctEtTotalCollection::const_iterator it = sumEtColl->begin(); it != sumEtColl->end(); it++) {
0293         if ((*it).bx() == iBxInEvent) {
0294           m_candETT = &(*it);
0295           // LogTrace("L1GlobalTrigger") << "ETT      " << (*it) << std::endl;
0296         }
0297       }
0298     }
0299   }
0300 
0301   // get GCT HTT
0302   if (receiveHTT) {
0303     edm::Handle<L1GctEtHadCollection> sumHtColl;
0304     iEvent.getByLabel(caloGctInputTag, sumHtColl);
0305 
0306     if (!sumHtColl.isValid()) {
0307       if (warningEnabled) {
0308         warningsStream << "\nWarning: L1GctEtHadCollection with input tag " << caloGctInputTag
0309                        << "\nrequested in configuration, but not found in the event.\n"
0310                        << std::endl;
0311       }
0312     } else {
0313       for (L1GctEtHadCollection::const_iterator it = sumHtColl->begin(); it != sumHtColl->end(); it++) {
0314         if ((*it).bx() == iBxInEvent) {
0315           m_candHTT = &(*it);
0316           // LogTrace("L1GlobalTrigger") << "HTT      "  << (*it) << std::endl;
0317         }
0318       }
0319     }
0320   }
0321 
0322   // get GCT HTM
0323   if (receiveHTM) {
0324     edm::Handle<L1GctHtMissCollection> missHtColl;
0325     iEvent.getByLabel(caloGctInputTag, missHtColl);
0326 
0327     if (!missHtColl.isValid()) {
0328       if (warningEnabled) {
0329         warningsStream << "\nWarning: L1GctHtMissCollection with input tag " << caloGctInputTag
0330                        << "\nrequested in configuration, but not found in the event.\n"
0331                        << std::endl;
0332       }
0333     } else {
0334       for (L1GctHtMissCollection::const_iterator it = missHtColl->begin(); it != missHtColl->end(); it++) {
0335         if ((*it).bx() == iBxInEvent) {
0336           m_candHTM = &(*it);
0337           // LogTrace("L1GlobalTrigger") << "HTM      " << (*it) << std::endl;
0338         }
0339       }
0340     }
0341   }
0342 
0343   // get GCT JetCounts
0344   if (receiveJetCounts) {
0345     edm::Handle<L1GctJetCountsCollection> jetCountColl;
0346     iEvent.getByLabel(caloGctInputTag, jetCountColl);
0347 
0348     if (!jetCountColl.isValid()) {
0349       if (warningEnabled) {
0350         warningsStream << "\nWarning: L1GctJetCountsCollection with input tag " << caloGctInputTag
0351                        << "\nrequested in configuration, but not found in the event.\n"
0352                        << std::endl;
0353       }
0354     } else {
0355       for (L1GctJetCountsCollection::const_iterator it = jetCountColl->begin(); it != jetCountColl->end(); it++) {
0356         if ((*it).bx() == iBxInEvent) {
0357           m_candJetCounts = &(*it);
0358           // LogTrace("L1GlobalTrigger") << (*it) << std::endl;
0359         }
0360       }
0361     }
0362   }
0363 
0364   // get GCT HfBitCounts
0365   if (receiveHfBitCounts) {
0366     edm::Handle<L1GctHFBitCountsCollection> hfBitCountsColl;
0367     iEvent.getByLabel(caloGctInputTag, hfBitCountsColl);
0368 
0369     if (!hfBitCountsColl.isValid()) {
0370       if (warningEnabled) {
0371         warningsStream << "\nWarning: L1GctHFBitCountsCollection with input tag " << caloGctInputTag
0372                        << "\nrequested in configuration, but not found in the event.\n"
0373                        << std::endl;
0374       }
0375     } else {
0376       for (L1GctHFBitCountsCollection::const_iterator it = hfBitCountsColl->begin(); it != hfBitCountsColl->end();
0377            it++) {
0378         if ((*it).bx() == iBxInEvent) {
0379           m_candHfBitCounts = &(*it);
0380           // LogTrace("L1GlobalTrigger") << "L1GctHFBitCountsCollection: "
0381           //<< (*it) << std::endl;
0382         }
0383       }
0384     }
0385   }
0386 
0387   // get GCT HfRingEtSums
0388   if (receiveHfRingEtSums) {
0389     edm::Handle<L1GctHFRingEtSumsCollection> hfRingEtSums;
0390     iEvent.getByLabel(caloGctInputTag, hfRingEtSums);
0391 
0392     if (!hfRingEtSums.isValid()) {
0393       if (warningEnabled) {
0394         warningsStream << "\nWarning: L1GctHFRingEtSumsCollection with input tag " << caloGctInputTag
0395                        << "\nrequested in configuration, but not found in the event.\n"
0396                        << std::endl;
0397       }
0398     } else {
0399       for (L1GctHFRingEtSumsCollection::const_iterator it = hfRingEtSums->begin(); it != hfRingEtSums->end(); it++) {
0400         if ((*it).bx() == iBxInEvent) {
0401           m_candHfRingEtSums = &(*it);
0402           // LogTrace("L1GlobalTrigger") << "L1GctHFRingEtSumsCollection: "
0403           //<< (*it) << std::endl;
0404         }
0405       }
0406     }
0407   }
0408 
0409   if (m_verbosity && warningEnabled) {
0410     if (warningsStream.tellp() > 0) {
0411       edm::LogWarning("L1GlobalTrigger") << warningsStream.str();
0412     }
0413   }
0414 
0415   if (m_verbosity && m_isDebugEnabled) {
0416     LogDebug("L1GlobalTrigger") << "\n**** L1GlobalTriggerPSB receiving calorimeter data for BxInEvent "
0417                                    "= "
0418                                 << iBxInEvent << "\n     from " << caloGctInputTag << "\n"
0419                                 << std::endl;
0420 
0421     printGctObjectData(iBxInEvent);
0422   }
0423 }
0424 
0425 // receive CASTOR objects
0426 void L1GlobalTriggerPSB::receiveCastorData(edm::Event &iEvent,
0427                                            const edm::InputTag &castorInputTag,
0428                                            const int iBxInEvent,
0429                                            const bool receiveCastor,
0430                                            const bool readFromPsb) {
0431   // get the CASTOR record
0432 
0433   // bool castorConditionFlag = true;
0434   // FIXME remove the following line and uncomment the line above
0435   //       when the L1CastorRecord is available
0436   //       until then, all CASTOR conditions are set to false
0437   // bool castorConditionFlag = false;
0438 
0439   // edm::Handle<L1CastorRecord > castorData;
0440   // iEvent.getByLabel(castorInputTag, castorData);
0441 
0442   // if (receiveCastor) {
0443   //
0444   //    if (!castorData.isValid()) {
0445   //        edm::LogWarning("L1GlobalTrigger")
0446   //        << "\nWarning: CASTOR record with input tag " << castorInputTag
0447   //        << "\nrequested in configuration, but not found in the event.\n"
0448   //        << std::endl;
0449   //
0450   //        castorConditionFlag = false;
0451   //    } else {
0452   //            LogTrace("L1GlobalTrigger") << *(castorData.product()) <<
0453   //            std::endl;
0454   //
0455   //    }
0456   //
0457   //} else {
0458   //
0459   //    // channel for CASTOR blocked - set all CASTOR to false
0460   //    // MUST NEVER BLOCK CASTOR CHANNEL AND USE OPERATOR "NOT" WITH CASTOR
0461   //    CONDITION
0462   //    //     ==> FALSE RESULTS!
0463   //    castorConditionResult = false;
0464   //
0465   //}
0466 }
0467 
0468 // receive BPTX objects
0469 //   from a GT record with bptxInputTag - if readFromPsb is true
0470 //   otherwise, generate them from randomly
0471 void L1GlobalTriggerPSB::receiveBptxData(edm::Event &iEvent,
0472                                          const edm::InputTag &bptxInputTag,
0473                                          const int iBxInEvent,
0474                                          const bool receiveBptx,
0475                                          const bool readFromPsb) {}
0476 
0477 // receive External objects
0478 //   from a GT record with ExternalInputTag - if readFromPsb is true
0479 //   otherwise, generate them from randomly
0480 void L1GlobalTriggerPSB::receiveExternalData(edm::Event &iEvent,
0481                                              const std::vector<edm::InputTag> &externalInputTags,
0482                                              const int iBxInEvent,
0483                                              const bool receiveExternal,
0484                                              const bool readFromPsb) {}
0485 
0486 // receive technical triggers
0487 // each L1GtTechnicalTriggerRecord can have more than one technical trigger bit,
0488 // such that a single producer per system can be used (if desired)
0489 void L1GlobalTriggerPSB::receiveTechnicalTriggers(edm::Event &iEvent,
0490                                                   const std::vector<edm::InputTag> &technicalTriggersInputTags,
0491                                                   const int iBxInEvent,
0492                                                   const bool receiveTechTr,
0493                                                   const int nrL1TechTr) {
0494   std::ostringstream warningsStream;
0495   bool warningEnabled = edm::isWarningEnabled();
0496 
0497   // reset the technical trigger bits
0498   m_gtTechnicalTriggers = std::vector<bool>(nrL1TechTr, false);
0499 
0500   if (receiveTechTr) {
0501     // get the technical trigger bits from the records and write them in
0502     // the decision word for technical triggers
0503 
0504     // loop over all producers of technical trigger records
0505     for (std::vector<edm::InputTag>::const_iterator it = technicalTriggersInputTags.begin();
0506          it != technicalTriggersInputTags.end();
0507          it++) {
0508       edm::Handle<L1GtTechnicalTriggerRecord> techTrigRecord;
0509       iEvent.getByLabel((*it), techTrigRecord);
0510 
0511       if (!techTrigRecord.isValid()) {
0512         if (warningEnabled) {
0513           warningsStream << "\nWarning: L1GtTechnicalTriggerRecord with input tag " << (*it)
0514                          << "\nrequested in configuration, but not found in the event.\n"
0515                          << std::endl;
0516         }
0517       } else {
0518         const std::vector<L1GtTechnicalTrigger> &ttVec = techTrigRecord->gtTechnicalTrigger();
0519         size_t ttVecSize = ttVec.size();
0520 
0521         for (size_t iTT = 0; iTT < ttVecSize; ++iTT) {
0522           const L1GtTechnicalTrigger &ttBxRecord = ttVec[iTT];
0523           int ttBxInEvent = ttBxRecord.bxInEvent();
0524 
0525           if (ttBxInEvent == iBxInEvent) {
0526             int ttBitNumber = ttBxRecord.gtTechnicalTriggerBitNumber();
0527             bool ttResult = ttBxRecord.gtTechnicalTriggerResult();
0528 
0529             m_gtTechnicalTriggers.at(ttBitNumber) = ttResult;
0530 
0531             if (m_verbosity) {
0532               LogTrace("L1GlobalTrigger") << "Add for BxInEvent " << iBxInEvent << " the technical trigger produced by "
0533                                           << (*it) << " : name " << (ttBxRecord.gtTechnicalTriggerName())
0534                                           << " , bit number " << ttBitNumber << " and result " << ttResult << std::endl;
0535             }
0536           }
0537         }
0538       }
0539     }
0540   }
0541 
0542   if (m_verbosity && warningEnabled) {
0543     if (warningsStream.tellp() > 0) {
0544       edm::LogWarning("L1GlobalTrigger") << warningsStream.str();
0545     }
0546   }
0547 
0548   if (m_verbosity && m_isDebugEnabled) {
0549     LogDebug("L1GlobalTrigger") << "\n**** L1GlobalTriggerPSB receiving technical triggers: " << std::endl;
0550 
0551     int sizeW64 = 64;  // 64 bits words
0552     int iBit = 0;
0553 
0554     std::ostringstream myCout;
0555 
0556     for (std::vector<bool>::reverse_iterator ritBit = m_gtTechnicalTriggers.rbegin();
0557          ritBit != m_gtTechnicalTriggers.rend();
0558          ++ritBit) {
0559       myCout << (*ritBit ? '1' : '0');
0560 
0561       if ((((iBit + 1) % 16) == (sizeW64 % 16)) && (iBit != 63)) {
0562         myCout << " ";
0563       }
0564 
0565       iBit++;
0566     }
0567 
0568     LogTrace("L1GlobalTrigger") << myCout.str() << "\n" << std::endl;
0569   }
0570 }
0571 
0572 // fill the content of active PSB boards
0573 void L1GlobalTriggerPSB::fillPsbBlock(edm::Event &iEvent,
0574                                       const uint16_t &activeBoardsGtDaq,
0575                                       const int recordLength0,
0576                                       const int recordLength1,
0577                                       const unsigned int altNrBxBoardDaq,
0578                                       const std::vector<L1GtBoard> &boardMaps,
0579                                       const int iBxInEvent,
0580                                       L1GlobalTriggerReadoutRecord *gtDaqReadoutRecord) {
0581   // fill in emulator the same bunch crossing (12 bits - hardwired number of
0582   // bits...) and the same local bunch crossing for all boards
0583   int bxCross = iEvent.bunchCrossing();
0584   uint16_t bxCrossHw = 0;
0585   if ((bxCross & 0xFFF) == bxCross) {
0586     bxCrossHw = static_cast<uint16_t>(bxCross);
0587   } else {
0588     bxCrossHw = 0;  // Bx number too large, set to 0!
0589     if (m_verbosity) {
0590       LogDebug("L1GlobalTrigger") << "\nBunch cross number [hex] = " << std::hex << bxCross
0591                                   << "\n  larger than 12 bits. Set to 0! \n"
0592                                   << std::dec << std::endl;
0593     }
0594   }
0595 
0596   typedef std::vector<L1GtBoard>::const_iterator CItBoardMaps;
0597 
0598   // loop over PSB blocks in the GT DAQ record and fill them
0599   // with the content of the object list
0600 
0601   for (CItBoardMaps itBoard = boardMaps.begin(); itBoard != boardMaps.end(); ++itBoard) {
0602     int iPosition = itBoard->gtPositionDaqRecord();
0603     if (iPosition > 0) {
0604       int iActiveBit = itBoard->gtBitDaqActiveBoards();
0605       bool activeBoard = false;
0606       bool writeBoard = false;
0607 
0608       int recLength = -1;
0609 
0610       if (iActiveBit >= 0) {
0611         activeBoard = activeBoardsGtDaq & (1 << iActiveBit);
0612 
0613         int altNrBxBoard = (altNrBxBoardDaq & (1 << iActiveBit)) >> iActiveBit;
0614 
0615         if (altNrBxBoard == 1) {
0616           recLength = recordLength1;
0617         } else {
0618           recLength = recordLength0;
0619         }
0620 
0621         int lowBxInEvent = (recLength + 1) / 2 - recLength;
0622         int uppBxInEvent = (recLength + 1) / 2 - 1;
0623 
0624         if ((iBxInEvent >= lowBxInEvent) && (iBxInEvent <= uppBxInEvent)) {
0625           writeBoard = true;
0626         }
0627 
0628         // LogTrace("L1GlobalTrigger")
0629         //    << "\nBoard " << std::hex << (itBoard->gtBoardId()) << std::dec
0630         //    << "\naltNrBxBoard = " << altNrBxBoard << " recLength " <<
0631         //    recLength
0632         //    << " lowBxInEvent " << lowBxInEvent
0633         //    << " uppBxInEvent " << uppBxInEvent
0634         //    << std::endl;
0635       }
0636 
0637       // LogTrace("L1GlobalTrigger")
0638       //    << "\nBoard " << std::hex << (itBoard->gtBoardId()) << std::dec
0639       //    << "\niBxInEvent = " << iBxInEvent << " iActiveBit " << iActiveBit
0640       //    << " activeBoard " << activeBoard
0641       //    << " writeBoard " << writeBoard
0642       //    << std::endl;
0643 
0644       if (activeBoard && writeBoard && (itBoard->gtBoardType() == PSB)) {
0645         L1GtPsbWord psbWordValue;
0646 
0647         // set board ID
0648         psbWordValue.setBoardId(itBoard->gtBoardId());
0649 
0650         // set bunch cross in the GT event record
0651         psbWordValue.setBxInEvent(iBxInEvent);
0652 
0653         // set bunch cross number of the actual bx
0654         uint16_t bxNrValue = bxCrossHw;
0655         psbWordValue.setBxNr(bxNrValue);
0656 
0657         // set event number since last L1 reset generated in PSB
0658         psbWordValue.setEventNr(static_cast<uint32_t>(iEvent.id().event()));
0659 
0660         // set local bunch cross number of the actual bx
0661         // set identical to bxCrossHw - other solution?
0662         uint16_t localBxNrValue = bxCrossHw;
0663         psbWordValue.setLocalBxNr(localBxNrValue);
0664 
0665         // get the objects coming to this PSB and the quadruplet index
0666 
0667         // two objects writen one after another from the same quadruplet
0668         int nrObjRow = 2;
0669 
0670         std::vector<L1GtPsbQuad> quadInPsb = itBoard->gtQuadInPsb();
0671         int nrCables = quadInPsb.size();
0672 
0673         uint16_t aDataVal = 0;
0674         uint16_t bDataVal = 0;
0675 
0676         int iCable = -1;
0677         for (std::vector<L1GtPsbQuad>::const_iterator itQuad = quadInPsb.begin(); itQuad != quadInPsb.end(); ++itQuad) {
0678           iCable++;
0679 
0680           int iAB = (nrCables - iCable - 1) * nrObjRow;
0681 
0682           switch (*itQuad) {
0683             case TechTr: {
0684               // LogTrace("L1GlobalTrigger")
0685               //<< "\nL1GlobalTriggerPSB: write TechTr for BxInEvent = "
0686               //<< iBxInEvent
0687               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0688               //<< " Cable " << iCable << " Quad " << (*itQuad)
0689               //<< std::endl;
0690 
0691               // order: 16-bit words
0692               int bitsPerWord = 16;
0693 
0694               //
0695               int iPair = 0;
0696               aDataVal = 0;
0697 
0698               int iBit = 0;
0699               uint16_t bitVal = 0;
0700 
0701               for (int i = 0; i < bitsPerWord; ++i) {
0702                 if (m_gtTechnicalTriggers[iBit]) {
0703                   bitVal = 1;
0704                 } else {
0705                   bitVal = 0;
0706                 }
0707 
0708                 aDataVal = aDataVal | (bitVal << i);
0709                 iBit++;
0710               }
0711               psbWordValue.setAData(aDataVal, iAB + iPair);
0712 
0713               //
0714               bDataVal = 0;
0715 
0716               for (int i = 0; i < bitsPerWord; ++i) {
0717                 if (m_gtTechnicalTriggers[iBit]) {
0718                   bitVal = 1;
0719                 } else {
0720                   bitVal = 0;
0721                 }
0722 
0723                 bDataVal = bDataVal | (bitVal << i);
0724                 iBit++;
0725               }
0726               psbWordValue.setBData(bDataVal, iAB + iPair);
0727 
0728               //
0729               iPair = 1;
0730               aDataVal = 0;
0731 
0732               for (int i = 0; i < bitsPerWord; ++i) {
0733                 if (m_gtTechnicalTriggers[iBit]) {
0734                   bitVal = 1;
0735                 } else {
0736                   bitVal = 0;
0737                 }
0738 
0739                 aDataVal = aDataVal | (bitVal << i);
0740                 iBit++;
0741               }
0742               psbWordValue.setAData(aDataVal, iAB + iPair);
0743 
0744               bDataVal = 0;
0745 
0746               for (int i = 0; i < bitsPerWord; ++i) {
0747                 if (m_gtTechnicalTriggers[iBit]) {
0748                   bitVal = 1;
0749                 } else {
0750                   bitVal = 0;
0751                 }
0752 
0753                 bDataVal = bDataVal | (bitVal << i);
0754                 iBit++;
0755               }
0756               psbWordValue.setBData(bDataVal, iAB + iPair);
0757             }
0758 
0759             break;
0760             case NoIsoEGQ: {
0761               // LogTrace("L1GlobalTrigger")
0762               //<< "\nL1GlobalTriggerPSB: write NoIsoEGQ for BxInEvent = "
0763               //<< iBxInEvent
0764               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0765               //<< " Cable " << iCable << " Quad " << (*itQuad)
0766               //<< std::endl;
0767 
0768               int recL1NoIsoEG = m_candL1NoIsoEG->size();
0769               for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0770                 if (iPair < recL1NoIsoEG) {
0771                   aDataVal = (static_cast<const L1GctEmCand *>((*m_candL1NoIsoEG)[iPair]))->raw();
0772                 } else {
0773                   aDataVal = 0;
0774                 }
0775                 psbWordValue.setAData(aDataVal, iAB + iPair);
0776 
0777                 if ((iPair + nrObjRow) < recL1NoIsoEG) {
0778                   bDataVal = (static_cast<const L1GctEmCand *>((*m_candL1NoIsoEG)[iPair + nrObjRow]))->raw();
0779                 } else {
0780                   bDataVal = 0;
0781                 }
0782                 psbWordValue.setBData(bDataVal, iAB + iPair);
0783               }
0784             }
0785 
0786             break;
0787             case IsoEGQ: {
0788               // LogTrace("L1GlobalTrigger")
0789               //<< "\nL1GlobalTriggerPSB: write IsoEGQ for BxInEvent = "
0790               //<< iBxInEvent
0791               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0792               //<< " Cable " << iCable << " Quad " << (*itQuad)
0793               //<< std::endl;
0794 
0795               int recL1IsoEG = m_candL1IsoEG->size();
0796               for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0797                 if (iPair < recL1IsoEG) {
0798                   aDataVal = (static_cast<const L1GctEmCand *>((*m_candL1IsoEG)[iPair]))->raw();
0799                 } else {
0800                   aDataVal = 0;
0801                 }
0802                 psbWordValue.setAData(aDataVal, iAB + iPair);
0803 
0804                 if ((iPair + nrObjRow) < recL1IsoEG) {
0805                   bDataVal = (static_cast<const L1GctEmCand *>((*m_candL1IsoEG)[iPair + nrObjRow]))->raw();
0806                 } else {
0807                   bDataVal = 0;
0808                 }
0809                 psbWordValue.setBData(bDataVal, iAB + iPair);
0810               }
0811 
0812             }
0813 
0814             break;
0815             case CenJetQ: {
0816               // LogTrace("L1GlobalTrigger")
0817               //<< "\nL1GlobalTriggerPSB: write CenJetQ for BxInEvent = "
0818               //<< iBxInEvent
0819               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0820               //<< " Cable " << iCable << " Quad " << (*itQuad)
0821               //<< std::endl;
0822 
0823               int recL1CenJet = m_candL1CenJet->size();
0824               for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0825                 if (iPair < recL1CenJet) {
0826                   aDataVal = (static_cast<const L1GctJetCand *>((*m_candL1CenJet)[iPair]))->raw();
0827                 } else {
0828                   aDataVal = 0;
0829                 }
0830                 psbWordValue.setAData(aDataVal, iAB + iPair);
0831 
0832                 if ((iPair + nrObjRow) < recL1CenJet) {
0833                   bDataVal = (static_cast<const L1GctJetCand *>((*m_candL1CenJet)[iPair + nrObjRow]))->raw();
0834                 } else {
0835                   bDataVal = 0;
0836                 }
0837                 psbWordValue.setBData(bDataVal, iAB + iPair);
0838               }
0839             }
0840 
0841             break;
0842             case ForJetQ: {
0843               // LogTrace("L1GlobalTrigger")
0844               //<< "\nL1GlobalTriggerPSB: write ForJetQ for BxInEvent = "
0845               //<< iBxInEvent
0846               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0847               //<< " Cable " << iCable << " Quad " << (*itQuad)
0848               //<< std::endl;
0849 
0850               int recL1ForJet = m_candL1ForJet->size();
0851               for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0852                 if (iPair < recL1ForJet) {
0853                   aDataVal = (static_cast<const L1GctJetCand *>((*m_candL1ForJet)[iPair]))->raw();
0854                 } else {
0855                   aDataVal = 0;
0856                 }
0857                 psbWordValue.setAData(aDataVal, iAB + iPair);
0858 
0859                 if ((iPair + nrObjRow) < recL1ForJet) {
0860                   bDataVal = (static_cast<const L1GctJetCand *>((*m_candL1ForJet)[iPair + nrObjRow]))->raw();
0861                 } else {
0862                   bDataVal = 0;
0863                 }
0864                 psbWordValue.setBData(bDataVal, iAB + iPair);
0865               }
0866 
0867             }
0868 
0869             break;
0870             case TauJetQ: {
0871               // LogTrace("L1GlobalTrigger")
0872               //<< "\nL1GlobalTriggerPSB: write TauJetQ for BxInEvent = "
0873               //<< iBxInEvent
0874               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0875               //<< " Cable " << iCable << " Quad " << (*itQuad)
0876               //<< std::endl;
0877 
0878               int recL1TauJet = m_candL1TauJet->size();
0879               for (int iPair = 0; iPair < nrObjRow; ++iPair) {
0880                 if (iPair < recL1TauJet) {
0881                   aDataVal = (static_cast<const L1GctJetCand *>((*m_candL1TauJet)[iPair]))->raw();
0882                 } else {
0883                   aDataVal = 0;
0884                 }
0885                 psbWordValue.setAData(aDataVal, iAB + iPair);
0886 
0887                 if ((iPair + nrObjRow) < recL1TauJet) {
0888                   bDataVal = (static_cast<const L1GctJetCand *>((*m_candL1TauJet)[iPair + nrObjRow]))->raw();
0889                 } else {
0890                   bDataVal = 0;
0891                 }
0892                 psbWordValue.setBData(bDataVal, iAB + iPair);
0893 
0894                 // LogTrace("L1GlobalTrigger")
0895                 //        << "\n aDataVal[" << (iAB + iPair)
0896                 //        << "] = 0x" << std::hex << aDataVal << std::dec
0897                 //        << " (object " << iPair << ")"
0898                 //        << "\n bDataVal[" << (iAB + iPair)
0899                 //        << "] = 0x" << std::hex << bDataVal << std::dec
0900                 //        << " (object " << (iPair + nrObjRow) << ")"
0901                 //        << std::endl;
0902               }
0903 
0904             }
0905 
0906             break;
0907             case ESumsQ: {
0908               // LogTrace("L1GlobalTrigger")
0909               //<< "\nL1GlobalTriggerPSB: write ESumsQ for BxInEvent = "
0910               //<< iBxInEvent
0911               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0912               //<< " Cable " << iCable << " Quad " << (*itQuad)
0913               //<< std::endl;
0914 
0915               // order: ETT, ETM et, HTT, ETM phi... hardcoded here
0916               int iPair = 0;
0917 
0918               if (m_candETT) {
0919                 aDataVal = m_candETT->raw();
0920               } else {
0921                 aDataVal = 0;
0922               }
0923               psbWordValue.setAData(aDataVal, iAB + iPair);
0924 
0925               if (m_candHTT) {
0926                 bDataVal = m_candHTT->raw();
0927               } else {
0928                 bDataVal = 0;
0929               }
0930               psbWordValue.setBData(bDataVal, iAB + iPair);
0931 
0932               // LogTrace("L1GlobalTrigger")
0933               //        << "\n aDataVal[" << (iAB + iPair)
0934               //        << "] = 0x" << std::hex << aDataVal << std::dec
0935               //        << "\n bDataVal[" << (iAB + iPair)
0936               //        << "] = 0x" << std::hex << bDataVal << std::dec
0937               //        << std::endl;
0938               //
0939               iPair = 1;
0940               if (m_candETM) {
0941                 // bits 0:15
0942                 aDataVal = m_candETM->raw() & 0x0000FFFF;
0943 
0944                 // LogTrace("L1GlobalTrigger") << std::hex
0945                 //        << "\n ETM et        = "
0946                 //        << m_candETM->et()
0947                 //        << "\n ETM overFlow  = "
0948                 //       << m_candETM->overFlow() << std::dec
0949                 //       << std::endl;
0950               } else {
0951                 aDataVal = 0;
0952               }
0953               psbWordValue.setAData(aDataVal, iAB + iPair);
0954 
0955               if (m_candETM) {
0956                 // bits 16:31
0957                 bDataVal = (m_candETM->raw() & 0xFFFF0000) >> 16;
0958 
0959                 // LogTrace("L1GlobalTrigger") << std::hex
0960                 //        << "\n ETM phi  = " << m_candETM->phi()
0961                 //        << std::dec << std::endl;
0962 
0963               } else {
0964                 bDataVal = 0;
0965               }
0966               psbWordValue.setBData(bDataVal, iAB + iPair);
0967 
0968               // FIXME add HTM
0969 
0970               // LogTrace("L1GlobalTrigger")
0971               //        << "\n aDataVal[" << (iAB + iPair)
0972               //        << "] = 0x" << std::hex << aDataVal << std::dec
0973               //       << "\n bDataVal[" << (iAB + iPair)
0974               //        << "] = 0x" << std::hex << bDataVal << std::dec
0975               //       << std::endl;
0976 
0977             }
0978 
0979             break;
0980             case JetCountsQ: {
0981               // LogTrace("L1GlobalTrigger")
0982               //<< "\nL1GlobalTriggerPSB: write JetCountsQ for BxInEvent = "
0983               //<< iBxInEvent
0984               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
0985               //<< " Cable " << iCable << " Quad " << (*itQuad)
0986               //<< std::endl;
0987 
0988               // order: 3 JetCounts per 16-bits word ... hardcoded here
0989               int jetCountsBits = 5;  // FIXME get it from event setup
0990               int countsPerWord = 3;
0991 
0992               //
0993               int iPair = 0;
0994               aDataVal = 0;
0995               bDataVal = 0;
0996 
0997               int iCount = 0;
0998 
0999               if (m_candJetCounts) {
1000                 for (int i = 0; i < countsPerWord; ++i) {
1001                   aDataVal = aDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1002                   iCount++;
1003                 }
1004 
1005                 //
1006 
1007                 for (int i = 0; i < countsPerWord; ++i) {
1008                   bDataVal = bDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1009                   iCount++;
1010                 }
1011               }
1012 
1013               psbWordValue.setAData(aDataVal, iAB + iPair);
1014               psbWordValue.setBData(bDataVal, iAB + iPair);
1015 
1016               //
1017               iPair = 1;
1018               aDataVal = 0;
1019               bDataVal = 0;
1020 
1021               if (m_candJetCounts) {
1022                 for (int i = 0; i < countsPerWord; ++i) {
1023                   aDataVal = aDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1024                   iCount++;
1025                 }
1026 
1027                 //
1028 
1029                 for (int i = 0; i < countsPerWord; ++i) {
1030                   bDataVal = bDataVal | ((m_candJetCounts->count(iCount)) << (jetCountsBits * i));
1031                   iCount++;
1032                 }
1033               }
1034 
1035               psbWordValue.setAData(aDataVal, iAB + iPair);
1036               psbWordValue.setBData(bDataVal, iAB + iPair);
1037             }
1038 
1039             break;
1040               // FIXME add MIP/Iso bits
1041             case HfQ: {
1042               // LogTrace("L1GlobalTrigger")
1043               //<< "\nL1GlobalTriggerPSB: write HfQ for BxInEvent = "
1044               //<< iBxInEvent
1045               //<< "\n PSB " << std::hex << itBoard->gtBoardId() << std::dec
1046               //<< " Cable " << iCable << " Quad " << (*itQuad)
1047               //<< std::endl;
1048 
1049               // FIXME get it from event setup?
1050               // 3 bits per Hf index
1051               // order hardcoded here
1052               // HfBitCounts first, followed by HfRingEtSum
1053               int hfBits = 3;
1054 
1055               L1GctHFBitCounts hfBitCounts;
1056               int nHfBitCounts = hfBitCounts.nCounts();
1057 
1058               L1GctHFRingEtSums hfRingEtSums;
1059               int nHfRingEtSums = hfRingEtSums.nSums();
1060 
1061               //
1062               int iPair = 0;
1063               aDataVal = 0;
1064               bDataVal = 0;
1065 
1066               // sizeof return in multiple of 8 bits
1067               int hfPerWord = sizeof(aDataVal) * 8 / hfBits;
1068               // LogTrace("L1GlobalTrigger")
1069               //<< "\n nHfBitCounts  = " << nHfBitCounts
1070               //<< "\n nHfRingEtSums = " << nHfRingEtSums
1071               //<< "\n hfPerWord     = " << hfPerWord
1072               //<< std::endl;
1073 
1074               int iHf = 0;
1075               bool aDataFlag = true;
1076               bool bDataFlag = false;
1077 
1078               if (m_candHfBitCounts) {
1079                 for (int i = 0; i < nHfBitCounts; ++i) {
1080                   if (aDataFlag) {
1081                     if (iHf < hfPerWord) {
1082                       // aData (cycle 0) for iPair 0 (object 0)
1083                       aDataVal = aDataVal | ((m_candHfBitCounts->bitCount(i)) << (hfBits * iHf));
1084                       iHf++;
1085                       // LogTrace("L1GlobalTrigger")
1086                       //        << "\n Added HfBitCounts index " << i << " to "
1087                       //        << " aDataVal[" << (iAB + iPair) << "]"
1088                       //        << std::endl;
1089                     } else {
1090                       aDataFlag = false;
1091                       bDataFlag = true;
1092                       iHf = 0;
1093                     }
1094                   }
1095 
1096                   if (bDataFlag) {
1097                     if (iHf < hfPerWord) {
1098                       // bData (cycle 1) for iPair 0 (object 2)
1099                       bDataVal = bDataVal | ((m_candHfBitCounts->bitCount(i)) << (hfBits * iHf));
1100                       iHf++;
1101                       // LogTrace("L1GlobalTrigger")
1102                       //        << "\n Added HfBitCounts index " << i << " to "
1103                       //        << " bDataVal[" << (iAB + iPair) << "]"
1104                       //       << std::endl;
1105                     } else {
1106                       aDataFlag = false;
1107                       bDataFlag = false;
1108                       iHf = 0;
1109                     }
1110                   }
1111                 }
1112               } else {
1113                 iHf = nHfBitCounts % hfPerWord;
1114                 // LogTrace("L1GlobalTrigger")
1115                 //        << "\n No HfBitCounts collection - skip "
1116                 //        << iHf*hfBits << " bits "
1117                 //        << std::endl;
1118               }
1119 
1120               if (aDataFlag && bDataFlag) {
1121                 LogTrace("L1GlobalTrigger")
1122                     << "\n HfBitCounts collection filled aData and bData [" << (iAB + iPair) << "]"
1123                     << "\n HfRingEtSums collection has no space to be written" << std::endl;
1124               }
1125 
1126               if (m_candHfRingEtSums) {
1127                 for (int i = 0; i < nHfRingEtSums; ++i) {
1128                   if (aDataFlag) {
1129                     if (iHf < hfPerWord) {
1130                       // aData (cycle 0) for iPair 0 (object 0)
1131                       aDataVal = aDataVal | ((m_candHfRingEtSums->etSum(i)) << (hfBits * iHf));
1132                       iHf++;
1133                       // LogTrace("L1GlobalTrigger")
1134                       //        << "\n Added HfRingEtSums index " << i << " to "
1135                       //        << " aDataVal[" << (iAB + iPair) << "]"
1136                       //       << std::endl;
1137                     } else {
1138                       aDataFlag = false;
1139                       bDataFlag = true;
1140                       iHf = 0;
1141                     }
1142                   }
1143 
1144                   if (bDataFlag) {
1145                     if (iHf < hfPerWord) {
1146                       // bData (cycle 1) for iPair 0 (object 2)
1147                       bDataVal = bDataVal | ((m_candHfRingEtSums->etSum(i)) << (hfBits * iHf));
1148                       iHf++;
1149                       // LogTrace("L1GlobalTrigger")
1150                       //        << "\n Added HfRingEtSums index " << i << " to "
1151                       //        << " bDataVal[" << (iAB + iPair) << "]"
1152                       //        << std::endl;
1153                     } else {
1154                       aDataFlag = false;
1155                       bDataFlag = false;
1156                       iHf = 0;
1157                     }
1158                   }
1159                 }
1160               } else {
1161                 iHf = nHfRingEtSums % hfPerWord;
1162                 // LogTrace("L1GlobalTrigger")
1163                 //        << "\n No HfRingEtSums collection - skip "
1164                 //        << iHf*hfBits << " bits "
1165                 //        << std::endl;
1166               }
1167 
1168               psbWordValue.setAData(aDataVal, iAB + iPair);
1169               psbWordValue.setBData(bDataVal, iAB + iPair);
1170 
1171               // LogTrace("L1GlobalTrigger")
1172               //        << "\n aDataVal[" << iAB + iPair
1173               //        << "] = 0x" << std::hex << aDataVal << std::dec
1174               //        << "\n bDataVal[" << (iAB + iPair)
1175               //        << "] = 0x" << std::hex << bDataVal << std::dec
1176               //       << std::endl;
1177 
1178               if (aDataFlag && bDataFlag) {
1179                 LogTrace("L1GlobalTrigger") << "\n aData and bData [" << (iAB + iPair) << "] full"
1180                                             << "\n HfRingEtSums collection has not enough space to be "
1181                                                "written"
1182                                             << std::endl;
1183               }
1184 
1185             }
1186 
1187             break;
1188             default: {
1189               // do nothing
1190             }
1191 
1192             break;
1193           }  // end switch (*itQuad)
1194 
1195         }  // end for: (itQuad)
1196 
1197         // ** fill L1PsbWord in GT DAQ record
1198 
1199         // LogTrace("L1GlobalTrigger")
1200         //<< "\nL1GlobalTriggerPSB: write psbWordValue"
1201         //<< std::endl;
1202 
1203         gtDaqReadoutRecord->setGtPsbWord(psbWordValue);
1204 
1205       }  // end if (active && PSB)
1206 
1207     }  // end if (iPosition)
1208 
1209   }  // end for (itBoard
1210 }
1211 
1212 // clear PSB
1213 
1214 void L1GlobalTriggerPSB::reset() {
1215   m_candL1NoIsoEG->clear();
1216   m_candL1IsoEG->clear();
1217   m_candL1CenJet->clear();
1218   m_candL1ForJet->clear();
1219   m_candL1TauJet->clear();
1220 
1221   // no reset() available...
1222   m_candETM = nullptr;
1223   m_candETT = nullptr;
1224   m_candHTT = nullptr;
1225   m_candHTM = nullptr;
1226 
1227   m_candJetCounts = nullptr;
1228 
1229   m_candHfBitCounts = nullptr;
1230   m_candHfRingEtSums = nullptr;
1231 }
1232 
1233 // print Global Calorimeter Trigger data
1234 // use int to bitset conversion to print
1235 void L1GlobalTriggerPSB::printGctObjectData(const int iBxInEvent) const {
1236   LogTrace("L1GlobalTrigger") << "\nL1GlobalTrigger: GCT data [hex] received by PSBs for BxInEvent = " << iBxInEvent
1237                               << "\n"
1238                               << std::endl;
1239 
1240   std::vector<const L1GctCand *>::const_iterator iterConst;
1241 
1242   LogTrace("L1GlobalTrigger") << "   GCT NoIsoEG " << std::endl;
1243   for (iterConst = m_candL1NoIsoEG->begin(); iterConst != m_candL1NoIsoEG->end(); iterConst++) {
1244     LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1245                                 << " Eta index = " << (*iterConst)->etaIndex()
1246                                 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1247   }
1248 
1249   LogTrace("L1GlobalTrigger") << "   GCT IsoEG " << std::endl;
1250   for (iterConst = m_candL1IsoEG->begin(); iterConst != m_candL1IsoEG->end(); iterConst++) {
1251     LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1252                                 << " Eta index = " << (*iterConst)->etaIndex()
1253                                 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1254   }
1255 
1256   LogTrace("L1GlobalTrigger") << "   GCT CenJet " << std::endl;
1257   for (iterConst = m_candL1CenJet->begin(); iterConst != m_candL1CenJet->end(); iterConst++) {
1258     LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1259                                 << " Eta index = " << (*iterConst)->etaIndex()
1260                                 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1261   }
1262 
1263   LogTrace("L1GlobalTrigger") << "   GCT ForJet " << std::endl;
1264   for (iterConst = m_candL1ForJet->begin(); iterConst != m_candL1ForJet->end(); iterConst++) {
1265     LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1266                                 << " Eta index = " << (*iterConst)->etaIndex()
1267                                 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1268   }
1269 
1270   LogTrace("L1GlobalTrigger") << "   GCT TauJet " << std::endl;
1271   for (iterConst = m_candL1TauJet->begin(); iterConst != m_candL1TauJet->end(); iterConst++) {
1272     LogTrace("L1GlobalTrigger") << std::hex << "Rank = " << (*iterConst)->rank()
1273                                 << " Eta index = " << (*iterConst)->etaIndex()
1274                                 << " Phi index = " << (*iterConst)->phiIndex() << std::dec << std::endl;
1275   }
1276 
1277   LogTrace("L1GlobalTrigger") << "   GCT ETM " << std::endl;
1278   if (m_candETM) {
1279     LogTrace("L1GlobalTrigger") << std::hex << "ET  = " << m_candETM->et() << std::dec << std::endl;
1280 
1281     LogTrace("L1GlobalTrigger") << std::hex << "phi = " << m_candETM->phi() << std::dec << std::endl;
1282   }
1283 
1284   LogTrace("L1GlobalTrigger") << "   GCT ETT " << std::endl;
1285   if (m_candETT) {
1286     LogTrace("L1GlobalTrigger") << std::hex << "ET  = " << m_candETT->et() << std::dec << std::endl;
1287   }
1288 
1289   LogTrace("L1GlobalTrigger") << "   GCT HTT " << std::endl;
1290   if (m_candHTT) {
1291     LogTrace("L1GlobalTrigger") << std::hex << "ET  = " << m_candHTT->et() << std::dec << std::endl;
1292   }
1293 
1294   LogTrace("L1GlobalTrigger") << "   GCT HTM " << std::endl;
1295   if (m_candHTM) {
1296     LogTrace("L1GlobalTrigger") << std::hex << "ET  = " << m_candHTM->et() << std::dec << std::endl;
1297 
1298     LogTrace("L1GlobalTrigger") << std::hex << "phi = " << m_candHTM->phi() << std::dec << std::endl;
1299   }
1300 
1301   LogTrace("L1GlobalTrigger") << "   GCT JetCounts " << std::endl;
1302   if (m_candJetCounts) {
1303     LogTrace("L1GlobalTrigger") << (*m_candJetCounts) << std::endl;
1304   }
1305 
1306   LogTrace("L1GlobalTrigger") << "   GCT HfBitCounts " << std::endl;
1307   if (m_candHfBitCounts) {
1308     LogTrace("L1GlobalTrigger") << (*m_candHfBitCounts) << std::endl;
1309   }
1310 
1311   LogTrace("L1GlobalTrigger") << "   GCT HfRingEtSums " << std::endl;
1312   if (m_candHfRingEtSums) {
1313     LogTrace("L1GlobalTrigger") << (*m_candHfRingEtSums) << std::endl;
1314   }
1315 }
1316 
1317 // static data members