File indexing completed on 2024-04-06 12:02:06
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "CondFormats/DTObjects/interface/DTLVStatus.h"
0012
0013
0014
0015
0016 #include "CondFormats/DTObjects/interface/DTBufferTree.h"
0017 #include "DataFormats/MuonDetId/interface/DTChamberId.h"
0018
0019
0020
0021
0022 #include <iostream>
0023 #include <sstream>
0024
0025
0026
0027
0028
0029
0030
0031
0032 DTLVStatus::DTLVStatus() : dataVersion(" "), dBuf(new DTBufferTree<int, int>) { dataList.reserve(10); }
0033
0034 DTLVStatus::DTLVStatus(const std::string& version) : dataVersion(version), dBuf(new DTBufferTree<int, int>) {
0035 dataList.reserve(10);
0036 }
0037
0038 DTLVStatusId::DTLVStatusId() : wheelId(0), stationId(0), sectorId(0) {}
0039
0040 DTLVStatusData::DTLVStatusData() : flagCFE(0), flagDFE(0), flagCMC(0), flagDMC(0) {}
0041
0042
0043
0044
0045 DTLVStatus::~DTLVStatus() {}
0046
0047 DTLVStatusId::~DTLVStatusId() {}
0048
0049 DTLVStatusData::~DTLVStatusData() {}
0050
0051
0052
0053
0054 int DTLVStatus::get(
0055 int wheelId, int stationId, int sectorId, int& flagCFE, int& flagDFE, int& flagCMC, int& flagDMC) const {
0056 flagCFE = 0;
0057 flagDFE = 0;
0058 flagCMC = 0;
0059 flagDMC = 0;
0060
0061 std::vector<int> chanKey;
0062 chanKey.reserve(3);
0063 chanKey.push_back(wheelId);
0064 chanKey.push_back(stationId);
0065 chanKey.push_back(sectorId);
0066 int ientry;
0067 int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
0068 if (!searchStatus) {
0069 const DTLVStatusData& data(dataList[ientry].second);
0070 flagCFE = data.flagCFE;
0071 flagDFE = data.flagDFE;
0072 flagCMC = data.flagCMC;
0073 flagDMC = data.flagDMC;
0074 }
0075
0076 return searchStatus;
0077 }
0078
0079 int DTLVStatus::get(const DTChamberId& id, int& flagCFE, int& flagDFE, int& flagCMC, int& flagDMC) const {
0080 return get(id.wheel(), id.station(), id.sector(), flagCFE, flagDFE, flagCMC, flagDMC);
0081 }
0082
0083 const std::string& DTLVStatus::version() const { return dataVersion; }
0084
0085 std::string& DTLVStatus::version() { return dataVersion; }
0086
0087 void DTLVStatus::clear() {
0088 dataList.clear();
0089 initialize();
0090 return;
0091 }
0092
0093 int DTLVStatus::set(int wheelId, int stationId, int sectorId, int flagCFE, int flagDFE, int flagCMC, int flagDMC) {
0094 std::vector<int> chanKey;
0095 chanKey.reserve(3);
0096 chanKey.push_back(wheelId);
0097 chanKey.push_back(stationId);
0098 chanKey.push_back(sectorId);
0099 int ientry;
0100 int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
0101
0102 if (!searchStatus) {
0103 DTLVStatusData& data(dataList[ientry].second);
0104 data.flagCFE = flagCFE;
0105 data.flagDFE = flagDFE;
0106 data.flagCMC = flagCMC;
0107 data.flagDMC = flagDMC;
0108 return -1;
0109 } else {
0110 DTLVStatusId key;
0111 key.wheelId = wheelId;
0112 key.stationId = stationId;
0113 key.sectorId = sectorId;
0114 DTLVStatusData data;
0115 data.flagCFE = flagCFE;
0116 data.flagDFE = flagDFE;
0117 data.flagCMC = flagCMC;
0118 data.flagDMC = flagDMC;
0119 ientry = dataList.size();
0120 dataList.push_back(std::pair<DTLVStatusId, DTLVStatusData>(key, data));
0121 dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
0122 return 0;
0123 }
0124
0125 return 99;
0126 }
0127
0128 int DTLVStatus::set(const DTChamberId& id, int flagCFE, int flagDFE, int flagCMC, int flagDMC) {
0129 return set(id.wheel(), id.station(), id.sector(), flagCFE, flagDFE, flagCMC, flagDMC);
0130 }
0131
0132 int DTLVStatus::setFlagCFE(int wheelId, int stationId, int sectorId, int flag) {
0133 int flagCFE;
0134 int flagDFE;
0135 int flagCMC;
0136 int flagDMC;
0137 get(wheelId, stationId, sectorId, flagCFE, flagDFE, flagCMC, flagDMC);
0138 return set(wheelId, stationId, sectorId, flag, flagDFE, flagCMC, flagDMC);
0139 }
0140
0141 int DTLVStatus::setFlagCFE(const DTChamberId& id, int flag) {
0142 return setFlagCFE(id.wheel(), id.station(), id.sector(), flag);
0143 }
0144
0145 int DTLVStatus::setFlagDFE(int wheelId, int stationId, int sectorId, int flag) {
0146 int flagCFE;
0147 int flagDFE;
0148 int flagCMC;
0149 int flagDMC;
0150 get(wheelId, stationId, sectorId, flagCFE, flagDFE, flagCMC, flagDMC);
0151 return set(wheelId, stationId, sectorId, flagCFE, flag, flagCMC, flagDMC);
0152 }
0153
0154 int DTLVStatus::setFlagDFE(const DTChamberId& id, int flag) {
0155 return setFlagDFE(id.wheel(), id.station(), id.sector(), flag);
0156 }
0157
0158 int DTLVStatus::setFlagCMC(int wheelId, int stationId, int sectorId, int flag) {
0159 int flagCFE;
0160 int flagDFE;
0161 int flagCMC;
0162 int flagDMC;
0163 get(wheelId, stationId, sectorId, flagCFE, flagDFE, flagCMC, flagDMC);
0164 return set(wheelId, stationId, sectorId, flagCFE, flagDFE, flag, flagDMC);
0165 }
0166
0167 int DTLVStatus::setFlagCMC(const DTChamberId& id, int flag) {
0168 return setFlagCMC(id.wheel(), id.station(), id.sector(), flag);
0169 }
0170
0171 int DTLVStatus::setFlagDMC(int wheelId, int stationId, int sectorId, int flag) {
0172 int flagCFE;
0173 int flagDFE;
0174 int flagCMC;
0175 int flagDMC;
0176 get(wheelId, stationId, sectorId, flagCFE, flagDFE, flagCMC, flagDMC);
0177 return set(wheelId, stationId, sectorId, flagCFE, flagDFE, flagCMC, flag);
0178 }
0179
0180 int DTLVStatus::setFlagDMC(const DTChamberId& id, int flag) {
0181 return setFlagDMC(id.wheel(), id.station(), id.sector(), flag);
0182 }
0183
0184 DTLVStatus::const_iterator DTLVStatus::begin() const { return dataList.begin(); }
0185
0186 DTLVStatus::const_iterator DTLVStatus::end() const { return dataList.end(); }
0187
0188 std::string DTLVStatus::mapName() const {
0189 std::stringstream name;
0190 name << dataVersion << "_map_Mtime" << this;
0191 return name.str();
0192 }
0193
0194 void DTLVStatus::initialize() {
0195 dBuf->clear();
0196
0197 int entryNum = 0;
0198 int entryMax = dataList.size();
0199 std::vector<int> chanKey;
0200 chanKey.reserve(3);
0201 while (entryNum < entryMax) {
0202 const DTLVStatusId& chan = dataList[entryNum].first;
0203
0204 chanKey.clear();
0205 chanKey.push_back(chan.wheelId);
0206 chanKey.push_back(chan.stationId);
0207 chanKey.push_back(chan.sectorId);
0208 dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
0209 }
0210
0211 return;
0212 }