File indexing completed on 2024-04-06 12:22:25
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021
0022
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
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
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
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 RPCTriggerHwConfig::RPCTriggerHwConfig(const edm::ParameterSet& iConfig) {
0069
0070
0071 setWhatProduced(this);
0072
0073
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
0089 }
0090 }
0091
0092 RPCTriggerHwConfig::~RPCTriggerHwConfig() {
0093
0094
0095 }
0096
0097
0098
0099
0100
0101
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
0138 DEFINE_FWK_EVENTSETUP_MODULE(RPCTriggerHwConfig);