Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:25

0001 // -*- C++ -*-
0002 //
0003 // Package:    RPCTriggerHwConfig
0004 // Class:      RPCTriggerHwConfig
0005 //
0006 /**\class RPCTriggerHwConfig RPCTriggerHwConfig.h L1TriggerConfig/RPCTriggerHwConfig/src/RPCTriggerHwConfig.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Tomasz Maciej Frueboes
0015 //         Created:  Wed Apr  9 13:57:29 CEST 2008
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/ModuleFactory.h"
0024 #include "FWCore/Framework/interface/ESProducer.h"
0025 
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 
0028 #include "CondFormats/DataRecord/interface/L1RPCHwConfigRcd.h"
0029 #include "CondFormats/RPCObjects/interface/L1RPCHwConfig.h"
0030 
0031 //
0032 // class decleration
0033 //
0034 
0035 class RPCTriggerHwConfig : public edm::ESProducer {
0036 public:
0037   RPCTriggerHwConfig(const edm::ParameterSet&);
0038   ~RPCTriggerHwConfig() override;
0039 
0040   typedef std::unique_ptr<L1RPCHwConfig> ReturnType;
0041 
0042   ReturnType produce(const L1RPCHwConfigRcd&);
0043 
0044 private:
0045   // ----------member data ---------------------------
0046   std::vector<int> m_disableTowers;
0047   std::vector<int> m_disableCrates;
0048   std::vector<int> m_disableTowersInCrates;
0049 
0050   std::vector<int> m_enableTowers;
0051   std::vector<int> m_enableCrates;
0052   std::vector<int> m_enableTowersInCrates;
0053 
0054   bool m_disableAll;
0055 };
0056 
0057 //
0058 // constants, enums and typedefs
0059 //
0060 
0061 //
0062 // static data member definitions
0063 //
0064 
0065 //
0066 // constructors and destructor
0067 //
0068 RPCTriggerHwConfig::RPCTriggerHwConfig(const edm::ParameterSet& iConfig) {
0069   //the following line is needed to tell the framework what
0070   // data is being produced
0071   setWhatProduced(this);
0072 
0073   //now do what ever other initialization is needed
0074   m_disableTowers = iConfig.getParameter<std::vector<int> >("disableTowers");
0075   m_disableCrates = iConfig.getParameter<std::vector<int> >("disableCrates");
0076   m_disableTowersInCrates = iConfig.getParameter<std::vector<int> >("disableTowersInCrates");
0077 
0078   m_disableAll = iConfig.getParameter<bool>("disableAll");
0079 
0080   m_enableTowers = iConfig.getParameter<std::vector<int> >("enableTowers");
0081   m_enableCrates = iConfig.getParameter<std::vector<int> >("enableCrates");
0082   m_enableTowersInCrates = iConfig.getParameter<std::vector<int> >("enableTowersInCrates");
0083 
0084   if (m_disableAll) {
0085     m_disableTowers.clear();
0086     m_disableCrates.clear();
0087     m_disableTowersInCrates.clear();
0088     // check if m_enableTowers  & m_enableCrates are not empty?
0089   }
0090 }
0091 
0092 RPCTriggerHwConfig::~RPCTriggerHwConfig() {
0093   // do anything here that needs to be done at desctruction time
0094   // (e.g. close files, deallocate resources etc.)
0095 }
0096 
0097 //
0098 // member functions
0099 //
0100 
0101 // ------------ method called to produce the data  ------------
0102 RPCTriggerHwConfig::ReturnType RPCTriggerHwConfig::produce(const L1RPCHwConfigRcd& iRecord) {
0103   auto pL1RPCHwConfig = std::make_unique<L1RPCHwConfig>();
0104 
0105   if (m_disableAll) {
0106     pL1RPCHwConfig->enableAll(false);
0107     std::vector<int>::iterator crIt = m_enableCrates.begin();
0108     std::vector<int>::iterator twIt = m_enableTowers.begin();
0109     for (; crIt != m_enableCrates.end(); ++crIt) {
0110       pL1RPCHwConfig->enableCrate(*crIt, true);
0111     }
0112     for (; twIt != m_enableTowers.end(); ++twIt) {
0113       pL1RPCHwConfig->enableTower(*twIt, true);
0114     }
0115     for (unsigned int It = 0; It < m_enableTowersInCrates.size(); It++) {
0116       if (It % 2 == 0)
0117         pL1RPCHwConfig->enableTowerInCrate(m_enableTowersInCrates[It + 1], m_enableTowersInCrates[It], true);
0118     }
0119   } else {
0120     std::vector<int>::iterator crIt = m_disableCrates.begin();
0121     std::vector<int>::iterator twIt = m_disableTowers.begin();
0122     for (; crIt != m_disableCrates.end(); ++crIt) {
0123       pL1RPCHwConfig->enableCrate(*crIt, false);
0124     }
0125     for (; twIt != m_disableTowers.end(); ++twIt) {
0126       pL1RPCHwConfig->enableTower(*twIt, false);
0127     }
0128     for (unsigned int It = 0; It < m_disableTowersInCrates.size(); It++) {
0129       if (It % 2 == 0)
0130         pL1RPCHwConfig->enableTowerInCrate(m_disableTowersInCrates[It + 1], m_disableTowersInCrates[It], false);
0131     }
0132   }
0133 
0134   return pL1RPCHwConfig;
0135 }
0136 
0137 //define this as a plug-in
0138 DEFINE_FWK_EVENTSETUP_MODULE(RPCTriggerHwConfig);