Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:15:08

0001 /**
0002  * \class L1GtTriggerMenuLiteProducer
0003  * 
0004  * 
0005  * Description: L1GtTriggerMenuLite producer.
0006  *
0007  * Implementation:
0008  *    Read the L1 trigger menu, the trigger masks and the prescale factor sets
0009  *    from event setup and save a lite version (top level menu, trigger masks
0010  *    for physics partition and prescale factor set) in Run Data.
0011  *   
0012  * \author: Vasile Mihai Ghete - HEPHY Vienna 
0013  * 
0014  *
0015  */
0016 
0017 // this class header
0018 #include "EventFilter/L1GlobalTriggerRawToDigi/interface/L1GtTriggerMenuLiteProducer.h"
0019 
0020 // system include files
0021 #include <iostream>
0022 
0023 // user include files
0024 #include "DataFormats/L1GlobalTrigger/interface/L1GtTriggerMenuLite.h"
0025 
0026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0027 #include "FWCore/Utilities/interface/InputTag.h"
0028 
0029 #include "FWCore/Framework/interface/EventSetup.h"
0030 #include "FWCore/Framework/interface/ESHandle.h"
0031 #include "FWCore/Framework/interface/Run.h"
0032 
0033 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0034 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0035 
0036 // constructor(s)
0037 L1GtTriggerMenuLiteProducer::L1GtTriggerMenuLiteProducer(const edm::ParameterSet& parSet)
0038     : m_l1GtStableParCacheID(0ULL),
0039       m_numberPhysTriggers(0),
0040 
0041       m_numberTechnicalTriggers(0),
0042 
0043       m_l1GtMenuCacheID(0ULL),
0044 
0045       m_l1GtTmAlgoCacheID(0ULL),
0046       m_l1GtTmTechCacheID(0ULL),
0047 
0048       m_l1GtPfAlgoCacheID(0ULL),
0049       m_l1GtPfTechCacheID(0ULL),
0050 
0051       m_l1GtStableParamToken(esConsumes<L1GtStableParameters, L1GtStableParametersRcd, edm::Transition::BeginRun>()),
0052       m_l1GtPfAlgoToken(esConsumes<L1GtPrescaleFactors, L1GtPrescaleFactorsAlgoTrigRcd, edm::Transition::BeginRun>()),
0053       m_l1GtPfTechToken(esConsumes<L1GtPrescaleFactors, L1GtPrescaleFactorsTechTrigRcd, edm::Transition::BeginRun>()),
0054       m_l1GtTmAlgoToken(esConsumes<L1GtTriggerMask, L1GtTriggerMaskAlgoTrigRcd, edm::Transition::BeginRun>()),
0055       m_l1GtTmTechToken(esConsumes<L1GtTriggerMask, L1GtTriggerMaskTechTrigRcd, edm::Transition::BeginRun>()),
0056       m_l1GtMenuToken(esConsumes<L1GtTriggerMenu, L1GtTriggerMenuRcd, edm::Transition::BeginRun>()),
0057       m_physicsDaqPartition(0) {
0058   // EDM product in Run Data
0059   produces<L1GtTriggerMenuLite, edm::Transition::BeginRun>();
0060 }
0061 
0062 // destructor
0063 L1GtTriggerMenuLiteProducer::~L1GtTriggerMenuLiteProducer() {
0064   // empty
0065 }
0066 
0067 void L1GtTriggerMenuLiteProducer::retrieveL1EventSetup(const edm::EventSetup& evSetup) {
0068   // get / update the stable parameters from the EventSetup
0069   // local cache & check on cacheIdentifier
0070 
0071   unsigned long long l1GtStableParCacheID = evSetup.get<L1GtStableParametersRcd>().cacheIdentifier();
0072 
0073   if (m_l1GtStableParCacheID != l1GtStableParCacheID) {
0074     edm::ESHandle<L1GtStableParameters> l1GtStablePar = evSetup.getHandle(m_l1GtStableParamToken);
0075     m_l1GtStablePar = l1GtStablePar.product();
0076 
0077     // number of physics triggers
0078     m_numberPhysTriggers = m_l1GtStablePar->gtNumberPhysTriggers();
0079 
0080     // number of technical triggers
0081     m_numberTechnicalTriggers = m_l1GtStablePar->gtNumberTechnicalTriggers();
0082 
0083     //
0084     m_l1GtStableParCacheID = l1GtStableParCacheID;
0085   }
0086 
0087   // get / update the prescale factors from the EventSetup
0088   // local cache & check on cacheIdentifier
0089 
0090   unsigned long long l1GtPfAlgoCacheID = evSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().cacheIdentifier();
0091 
0092   if (m_l1GtPfAlgoCacheID != l1GtPfAlgoCacheID) {
0093     edm::ESHandle<L1GtPrescaleFactors> l1GtPfAlgo = evSetup.getHandle(m_l1GtPfAlgoToken);
0094     m_l1GtPfAlgo = l1GtPfAlgo.product();
0095 
0096     m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
0097 
0098     m_l1GtPfAlgoCacheID = l1GtPfAlgoCacheID;
0099   }
0100 
0101   unsigned long long l1GtPfTechCacheID = evSetup.get<L1GtPrescaleFactorsTechTrigRcd>().cacheIdentifier();
0102 
0103   if (m_l1GtPfTechCacheID != l1GtPfTechCacheID) {
0104     edm::ESHandle<L1GtPrescaleFactors> l1GtPfTech = evSetup.getHandle(m_l1GtPfTechToken);
0105     m_l1GtPfTech = l1GtPfTech.product();
0106 
0107     m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
0108 
0109     m_l1GtPfTechCacheID = l1GtPfTechCacheID;
0110   }
0111 
0112   // get / update the trigger mask from the EventSetup
0113   // local cache & check on cacheIdentifier
0114 
0115   unsigned long long l1GtTmAlgoCacheID = evSetup.get<L1GtTriggerMaskAlgoTrigRcd>().cacheIdentifier();
0116 
0117   if (m_l1GtTmAlgoCacheID != l1GtTmAlgoCacheID) {
0118     edm::ESHandle<L1GtTriggerMask> l1GtTmAlgo = evSetup.getHandle(m_l1GtTmAlgoToken);
0119     m_l1GtTmAlgo = l1GtTmAlgo.product();
0120 
0121     m_triggerMaskAlgoTrig = &(m_l1GtTmAlgo->gtTriggerMask());
0122 
0123     m_l1GtTmAlgoCacheID = l1GtTmAlgoCacheID;
0124   }
0125 
0126   unsigned long long l1GtTmTechCacheID = evSetup.get<L1GtTriggerMaskTechTrigRcd>().cacheIdentifier();
0127 
0128   if (m_l1GtTmTechCacheID != l1GtTmTechCacheID) {
0129     edm::ESHandle<L1GtTriggerMask> l1GtTmTech = evSetup.getHandle(m_l1GtTmTechToken);
0130     m_l1GtTmTech = l1GtTmTech.product();
0131 
0132     m_triggerMaskTechTrig = &(m_l1GtTmTech->gtTriggerMask());
0133 
0134     m_l1GtTmTechCacheID = l1GtTmTechCacheID;
0135   }
0136 
0137   // get / update the trigger menu from the EventSetup
0138   // local cache & check on cacheIdentifier
0139 
0140   unsigned long long l1GtMenuCacheID = evSetup.get<L1GtTriggerMenuRcd>().cacheIdentifier();
0141 
0142   if (m_l1GtMenuCacheID != l1GtMenuCacheID) {
0143     edm::ESHandle<L1GtTriggerMenu> l1GtMenu = evSetup.getHandle(m_l1GtMenuToken);
0144     m_l1GtMenu = l1GtMenu.product();
0145 
0146     m_algorithmMap = &(m_l1GtMenu->gtAlgorithmMap());
0147     m_algorithmAliasMap = &(m_l1GtMenu->gtAlgorithmAliasMap());
0148 
0149     m_technicalTriggerMap = &(m_l1GtMenu->gtTechnicalTriggerMap());
0150 
0151     m_l1GtMenuCacheID = l1GtMenuCacheID;
0152   }
0153 }
0154 
0155 // member functions
0156 
0157 void L1GtTriggerMenuLiteProducer::beginJob() {
0158   // empty
0159 }
0160 
0161 void L1GtTriggerMenuLiteProducer::beginRunProduce(edm::Run& iRun, const edm::EventSetup& evSetup) {
0162   //
0163 
0164   retrieveL1EventSetup(evSetup);
0165 
0166   // produce the L1GtTriggerMenuLite
0167   std::unique_ptr<L1GtTriggerMenuLite> gtTriggerMenuLite(new L1GtTriggerMenuLite());
0168 
0169   // lite L1 trigger menu
0170 
0171   gtTriggerMenuLite->setGtTriggerMenuInterface(m_l1GtMenu->gtTriggerMenuInterface());
0172   gtTriggerMenuLite->setGtTriggerMenuName(m_l1GtMenu->gtTriggerMenuName());
0173   gtTriggerMenuLite->setGtTriggerMenuImplementation(m_l1GtMenu->gtTriggerMenuImplementation());
0174 
0175   gtTriggerMenuLite->setGtScaleDbKey(m_l1GtMenu->gtScaleDbKey());
0176 
0177   //
0178   L1GtTriggerMenuLite::L1TriggerMap algMap;
0179   for (CItAlgo itAlgo = m_algorithmMap->begin(); itAlgo != m_algorithmMap->end(); itAlgo++) {
0180     unsigned int bitNumber = (itAlgo->second).algoBitNumber();
0181     algMap[bitNumber] = itAlgo->first;
0182   }
0183 
0184   gtTriggerMenuLite->setGtAlgorithmMap(algMap);
0185 
0186   //
0187   L1GtTriggerMenuLite::L1TriggerMap algAliasMap;
0188   for (CItAlgo itAlgo = m_algorithmAliasMap->begin(); itAlgo != m_algorithmAliasMap->end(); itAlgo++) {
0189     unsigned int bitNumber = (itAlgo->second).algoBitNumber();
0190     algAliasMap[bitNumber] = itAlgo->first;
0191   }
0192 
0193   gtTriggerMenuLite->setGtAlgorithmAliasMap(algAliasMap);
0194 
0195   //
0196   L1GtTriggerMenuLite::L1TriggerMap techMap;
0197   for (CItAlgo itAlgo = m_technicalTriggerMap->begin(); itAlgo != m_technicalTriggerMap->end(); itAlgo++) {
0198     unsigned int bitNumber = (itAlgo->second).algoBitNumber();
0199     techMap[bitNumber] = itAlgo->first;
0200   }
0201 
0202   gtTriggerMenuLite->setGtTechnicalTriggerMap(techMap);
0203 
0204   // trigger masks
0205   std::vector<unsigned int> triggerMaskAlgoTrig(m_numberPhysTriggers, 0);
0206   int iBit = -1;
0207 
0208   for (std::vector<unsigned int>::const_iterator itBit = m_triggerMaskAlgoTrig->begin();
0209        itBit != m_triggerMaskAlgoTrig->end();
0210        itBit++) {
0211     iBit++;
0212     triggerMaskAlgoTrig[iBit] = (*itBit) & (1 << m_physicsDaqPartition);
0213   }
0214   gtTriggerMenuLite->setGtTriggerMaskAlgoTrig(triggerMaskAlgoTrig);
0215 
0216   //
0217   std::vector<unsigned int> triggerMaskTechTrig(m_numberTechnicalTriggers, 0);
0218   iBit = -1;
0219 
0220   for (std::vector<unsigned int>::const_iterator itBit = m_triggerMaskTechTrig->begin();
0221        itBit != m_triggerMaskTechTrig->end();
0222        itBit++) {
0223     iBit++;
0224     triggerMaskTechTrig[iBit] = (*itBit) & (1 << m_physicsDaqPartition);
0225   }
0226   gtTriggerMenuLite->setGtTriggerMaskTechTrig(triggerMaskTechTrig);
0227 
0228   //
0229   gtTriggerMenuLite->setGtPrescaleFactorsAlgoTrig(*m_prescaleFactorsAlgoTrig);
0230   gtTriggerMenuLite->setGtPrescaleFactorsTechTrig(*m_prescaleFactorsTechTrig);
0231 
0232   // print menu, trigger masks and prescale factors
0233   if (edm::isDebugEnabled()) {
0234     LogDebug("L1GtTriggerMenuLiteProducer") << *gtTriggerMenuLite;
0235   }
0236 
0237   // put records into event
0238   iRun.put(std::move(gtTriggerMenuLite));
0239 }
0240 
0241 void L1GtTriggerMenuLiteProducer::produce(edm::Event& iEvent, const edm::EventSetup& evSetup) {}
0242 
0243 //
0244 void L1GtTriggerMenuLiteProducer::endJob() {
0245   // empty now
0246 }
0247 
0248 // static class members
0249 
0250 //define this as a plug-in
0251 DEFINE_FWK_MODULE(L1GtTriggerMenuLiteProducer);