File indexing completed on 2024-09-07 04:35:40
0001 #ifndef CondFormats_RPCObjects_L1RPCHwConfig_h
0002 #define CondFormats_RPCObjects_L1RPCHwConfig_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 #include "CondFormats/Serialization/interface/Serializable.h"
0028
0029 #include <set>
0030 #include <vector>
0031 #include <sstream>
0032
0033 #include <iostream>
0034
0035 struct L1RPCDevCoords {
0036 public:
0037 L1RPCDevCoords() : m_tower(-255), m_PAC(-255) {}
0038 L1RPCDevCoords(int tower, int sector, int segment) : m_tower(tower), m_PAC(sector * 12 + segment) {}
0039 int getTower() { return m_tower; };
0040 int getPAC() { return m_PAC; };
0041 int getSector() { return m_PAC / 12; };
0042 int getSegment() { return m_PAC % 12; };
0043
0044 std::string toString() const {
0045 std::stringstream ss;
0046 ss << m_tower << " " << m_PAC;
0047 return ss.str();
0048 };
0049
0050 bool operator<(const L1RPCDevCoords& l2) const {
0051 if (this->m_tower != l2.m_tower)
0052 return this->m_tower < l2.m_tower;
0053 return this->m_PAC < l2.m_PAC;
0054 }
0055
0056 bool operator==(const L1RPCDevCoords& l2) const { return (this->m_tower == l2.m_tower) && (this->m_PAC == l2.m_PAC); }
0057
0058
0059 signed short m_tower;
0060 signed short m_PAC;
0061
0062 COND_SERIALIZABLE;
0063 };
0064
0065 class L1RPCHwConfig {
0066 public:
0067 L1RPCHwConfig();
0068 virtual ~L1RPCHwConfig();
0069
0070 bool isActive(int tower, int sector, int segment) const {
0071 return m_disabledDevices.find(L1RPCDevCoords(tower, sector, segment)) == m_disabledDevices.end();
0072 };
0073
0074 bool isActive(int tower, int PAC) const {
0075 return m_disabledDevices.end() == m_disabledDevices.find(L1RPCDevCoords(tower, PAC / 12, PAC % 12));
0076 };
0077
0078 void enablePAC(int tower, int sector, int segment, bool enable);
0079
0080 void enableTower(int tower, bool enable);
0081
0082 void enableTowerInCrate(int tower, int crate, bool enable);
0083
0084 void enableCrate(int logSector, bool enable);
0085
0086 void enableAll(bool enable);
0087
0088 int size() const { return m_disabledDevices.size(); };
0089 void dump() const {
0090 for (std::set<L1RPCDevCoords>::const_iterator it = m_disabledDevices.begin(); it != m_disabledDevices.end(); ++it) {
0091 std::cout << it->toString() << std::endl;
0092 }
0093 };
0094
0095
0096
0097
0098
0099
0100
0101 private:
0102 std::set<L1RPCDevCoords> m_disabledDevices;
0103
0104
0105
0106 COND_SERIALIZABLE;
0107 };
0108
0109 #endif