File indexing completed on 2023-03-17 10:46:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #include "CondFormats/DTObjects/interface/DTStatusFlag.h"
0012
0013
0014
0015
0016 #include "CondFormats/DTObjects/interface/DTBufferTree.h"
0017
0018
0019
0020
0021 #include <iostream>
0022 #include <sstream>
0023
0024
0025
0026
0027 DTStatusFlag::DTStatusFlag() : dataVersion(" "), dBuf(new DTBufferTree<int, int>) { dataList.reserve(1000); }
0028
0029 DTStatusFlag::DTStatusFlag(const std::string& version) : dataVersion(version), dBuf(new DTBufferTree<int, int>) {
0030 dataList.reserve(1000);
0031 }
0032
0033 DTStatusFlagId::DTStatusFlagId() : wheelId(0), stationId(0), sectorId(0), slId(0), layerId(0), cellId(0) {}
0034
0035 DTStatusFlagData::DTStatusFlagData()
0036 : noiseFlag(false), feMask(false), tdcMask(false), trigMask(false), deadFlag(false), nohvFlag(false) {}
0037
0038
0039
0040
0041 DTStatusFlag::~DTStatusFlag() {}
0042
0043 DTStatusFlagId::~DTStatusFlagId() {}
0044
0045 DTStatusFlagData::~DTStatusFlagData() {}
0046
0047
0048
0049
0050 int DTStatusFlag::get(int wheelId,
0051 int stationId,
0052 int sectorId,
0053 int slId,
0054 int layerId,
0055 int cellId,
0056 bool& noiseFlag,
0057 bool& feMask,
0058 bool& tdcMask,
0059 bool& trigMask,
0060 bool& deadFlag,
0061 bool& nohvFlag) const {
0062 noiseFlag = feMask = tdcMask = trigMask = deadFlag = nohvFlag = false;
0063
0064 std::vector<int> chanKey;
0065 chanKey.reserve(6);
0066 chanKey.push_back(wheelId);
0067 chanKey.push_back(stationId);
0068 chanKey.push_back(sectorId);
0069 chanKey.push_back(slId);
0070 chanKey.push_back(layerId);
0071 chanKey.push_back(cellId);
0072 int ientry;
0073 int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
0074 if (!searchStatus) {
0075 const DTStatusFlagData& data(dataList[ientry].second);
0076 noiseFlag = data.noiseFlag;
0077 feMask = data.feMask;
0078 tdcMask = data.tdcMask;
0079 trigMask = data.trigMask;
0080 deadFlag = data.deadFlag;
0081 nohvFlag = data.nohvFlag;
0082 }
0083
0084 return searchStatus;
0085 }
0086
0087 int DTStatusFlag::get(const DTWireId& id,
0088 bool& noiseFlag,
0089 bool& feMask,
0090 bool& tdcMask,
0091 bool& trigMask,
0092 bool& deadFlag,
0093 bool& nohvFlag) const {
0094 return get(id.wheel(),
0095 id.station(),
0096 id.sector(),
0097 id.superLayer(),
0098 id.layer(),
0099 id.wire(),
0100 noiseFlag,
0101 feMask,
0102 tdcMask,
0103 trigMask,
0104 deadFlag,
0105 nohvFlag);
0106 }
0107
0108 const std::string& DTStatusFlag::version() const { return dataVersion; }
0109
0110 std::string& DTStatusFlag::version() { return dataVersion; }
0111
0112 void DTStatusFlag::clear() {
0113 dataList.clear();
0114 initialize();
0115 return;
0116 }
0117
0118 int DTStatusFlag::set(int wheelId,
0119 int stationId,
0120 int sectorId,
0121 int slId,
0122 int layerId,
0123 int cellId,
0124 bool noiseFlag,
0125 bool feMask,
0126 bool tdcMask,
0127 bool trigMask,
0128 bool deadFlag,
0129 bool nohvFlag) {
0130 std::vector<int> chanKey;
0131 chanKey.reserve(6);
0132 chanKey.push_back(wheelId);
0133 chanKey.push_back(stationId);
0134 chanKey.push_back(sectorId);
0135 chanKey.push_back(slId);
0136 chanKey.push_back(layerId);
0137 chanKey.push_back(cellId);
0138 int ientry;
0139 int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
0140
0141 if (!searchStatus) {
0142 DTStatusFlagData& data(dataList[ientry].second);
0143 data.noiseFlag = noiseFlag;
0144 data.feMask = feMask;
0145 data.tdcMask = tdcMask;
0146 data.trigMask = trigMask;
0147 data.deadFlag = deadFlag;
0148 data.nohvFlag = nohvFlag;
0149 return -1;
0150 } else {
0151 DTStatusFlagId key;
0152 key.wheelId = wheelId;
0153 key.stationId = stationId;
0154 key.sectorId = sectorId;
0155 key.slId = slId;
0156 key.layerId = layerId;
0157 key.cellId = cellId;
0158 DTStatusFlagData data;
0159 data.noiseFlag = noiseFlag;
0160 data.feMask = feMask;
0161 data.tdcMask = tdcMask;
0162 data.trigMask = trigMask;
0163 data.deadFlag = deadFlag;
0164 data.nohvFlag = nohvFlag;
0165 ientry = dataList.size();
0166 dataList.push_back(std::pair<const DTStatusFlagId, DTStatusFlagData>(key, data));
0167 dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
0168 return 0;
0169 }
0170
0171 return 99;
0172 }
0173
0174 int DTStatusFlag::set(
0175 const DTWireId& id, bool noiseFlag, bool feMask, bool tdcMask, bool trigMask, bool deadFlag, bool nohvFlag) {
0176 return set(id.wheel(),
0177 id.station(),
0178 id.sector(),
0179 id.superLayer(),
0180 id.layer(),
0181 id.wire(),
0182 noiseFlag,
0183 feMask,
0184 tdcMask,
0185 trigMask,
0186 deadFlag,
0187 nohvFlag);
0188 }
0189
0190 int DTStatusFlag::setCellNoise(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag) {
0191 bool noiseFlag;
0192 bool feMask;
0193 bool tdcMask;
0194 bool trigMask;
0195 bool deadFlag;
0196 bool nohvFlag;
0197 int status = get(
0198 wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, deadFlag, nohvFlag);
0199 set(wheelId, stationId, sectorId, slId, layerId, cellId, flag, feMask, tdcMask, trigMask, deadFlag, nohvFlag);
0200 return status;
0201 }
0202
0203 int DTStatusFlag::setCellNoise(const DTWireId& id, bool flag) {
0204 return setCellNoise(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), flag);
0205 }
0206
0207 int DTStatusFlag::setCellFEMask(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool mask) {
0208 bool noiseFlag;
0209 bool feMask;
0210 bool tdcMask;
0211 bool trigMask;
0212 bool deadFlag;
0213 bool nohvFlag;
0214 int status = get(
0215 wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, deadFlag, nohvFlag);
0216 set(wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, mask, tdcMask, trigMask, deadFlag, nohvFlag);
0217 return status;
0218 }
0219
0220 int DTStatusFlag::setCellFEMask(const DTWireId& id, bool mask) {
0221 return setCellFEMask(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), mask);
0222 }
0223
0224 int DTStatusFlag::setCellTDCMask(
0225 int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool mask) {
0226 bool noiseFlag;
0227 bool feMask;
0228 bool tdcMask;
0229 bool trigMask;
0230 bool deadFlag;
0231 bool nohvFlag;
0232 int status = get(
0233 wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, deadFlag, nohvFlag);
0234 set(wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, mask, trigMask, deadFlag, nohvFlag);
0235 return status;
0236 }
0237
0238 int DTStatusFlag::setCellTDCMask(const DTWireId& id, bool mask) {
0239 return setCellTDCMask(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), mask);
0240 }
0241
0242 int DTStatusFlag::setCellTrigMask(
0243 int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool mask) {
0244 bool noiseFlag;
0245 bool feMask;
0246 bool tdcMask;
0247 bool trigMask;
0248 bool deadFlag;
0249 bool nohvFlag;
0250 int status = get(
0251 wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, deadFlag, nohvFlag);
0252 set(wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, mask, deadFlag, nohvFlag);
0253 return status;
0254 }
0255
0256 int DTStatusFlag::setCellTrigMask(const DTWireId& id, bool mask) {
0257 return setCellTrigMask(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), mask);
0258 }
0259
0260 int DTStatusFlag::setCellDead(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag) {
0261 bool noiseFlag;
0262 bool feMask;
0263 bool tdcMask;
0264 bool trigMask;
0265 bool deadFlag;
0266 bool nohvFlag;
0267 int status = get(
0268 wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, deadFlag, nohvFlag);
0269 set(wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, flag, nohvFlag);
0270 return status;
0271 }
0272
0273 int DTStatusFlag::setCellDead(const DTWireId& id, bool flag) {
0274 return setCellDead(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), flag);
0275 }
0276
0277 int DTStatusFlag::setCellNoHV(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag) {
0278 bool noiseFlag;
0279 bool feMask;
0280 bool tdcMask;
0281 bool trigMask;
0282 bool deadFlag;
0283 bool nohvFlag;
0284 int status = get(
0285 wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, deadFlag, nohvFlag);
0286 set(wheelId, stationId, sectorId, slId, layerId, cellId, noiseFlag, feMask, tdcMask, trigMask, deadFlag, flag);
0287 return status;
0288 }
0289
0290 int DTStatusFlag::setCellNoHV(const DTWireId& id, bool flag) {
0291 return setCellNoHV(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), flag);
0292 }
0293
0294 DTStatusFlag::const_iterator DTStatusFlag::begin() const { return dataList.begin(); }
0295
0296 DTStatusFlag::const_iterator DTStatusFlag::end() const { return dataList.end(); }
0297
0298 std::string DTStatusFlag::mapName() const {
0299 std::stringstream name;
0300 name << dataVersion << "_map_StatusFlag" << this;
0301 return name.str();
0302 }
0303
0304 void DTStatusFlag::initialize() {
0305 dBuf->clear();
0306
0307 int entryNum = 0;
0308 int entryMax = dataList.size();
0309 std::vector<int> chanKey;
0310 chanKey.reserve(6);
0311 while (entryNum < entryMax) {
0312 const DTStatusFlagId& chan = dataList[entryNum].first;
0313
0314 chanKey.clear();
0315 chanKey.push_back(chan.wheelId);
0316 chanKey.push_back(chan.stationId);
0317 chanKey.push_back(chan.sectorId);
0318 chanKey.push_back(chan.slId);
0319 chanKey.push_back(chan.layerId);
0320 chanKey.push_back(chan.cellId);
0321 dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
0322 }
0323
0324 return;
0325 }