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/DTDeadFlag.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 DTDeadFlag::DTDeadFlag() : dataVersion(" "), dBuf(new DTBufferTree<int, int>) { dataList.reserve(1000); }
0028
0029 DTDeadFlag::DTDeadFlag(const std::string& version) : dataVersion(version), dBuf(new DTBufferTree<int, int>) {
0030 dataList.reserve(1000);
0031 }
0032
0033 DTDeadFlagId::DTDeadFlagId() : wheelId(0), stationId(0), sectorId(0), slId(0), layerId(0), cellId(0) {}
0034
0035 DTDeadFlagData::DTDeadFlagData() : dead_HV(false), dead_TP(false), dead_RO(false), discCat(false) {}
0036
0037
0038
0039
0040 DTDeadFlag::~DTDeadFlag() {}
0041
0042 DTDeadFlagId::~DTDeadFlagId() {}
0043
0044 DTDeadFlagData::~DTDeadFlagData() {}
0045
0046
0047
0048
0049 int DTDeadFlag::get(int wheelId,
0050 int stationId,
0051 int sectorId,
0052 int slId,
0053 int layerId,
0054 int cellId,
0055 bool& dead_HV,
0056 bool& dead_TP,
0057 bool& dead_RO,
0058 bool& discCat) const {
0059 dead_HV = dead_TP = dead_RO = discCat = false;
0060
0061 std::vector<int> chanKey;
0062 chanKey.reserve(6);
0063 chanKey.push_back(wheelId);
0064 chanKey.push_back(stationId);
0065 chanKey.push_back(sectorId);
0066 chanKey.push_back(slId);
0067 chanKey.push_back(layerId);
0068 chanKey.push_back(cellId);
0069 int ientry;
0070 int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
0071 if (!searchStatus) {
0072 const DTDeadFlagData& data(dataList[ientry].second);
0073 dead_HV = data.dead_HV;
0074 dead_TP = data.dead_TP;
0075 dead_RO = data.dead_RO;
0076 discCat = data.discCat;
0077 }
0078
0079 return searchStatus;
0080 }
0081
0082 int DTDeadFlag::get(const DTWireId& id, bool& dead_HV, bool& dead_TP, bool& dead_RO, bool& discCat) const {
0083 return get(
0084 id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), dead_HV, dead_TP, dead_RO, discCat);
0085 }
0086
0087 bool DTDeadFlag::getCellDead_HV(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const {
0088 bool dead_HV;
0089 bool dead_TP;
0090 bool dead_RO;
0091 bool discCat;
0092 get(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0093 return dead_HV;
0094 }
0095
0096 bool DTDeadFlag::getCellDead_HV(const DTWireId& id) const {
0097 return getCellDead_HV(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire());
0098 }
0099
0100 bool DTDeadFlag::getCellDead_TP(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const {
0101 bool dead_HV;
0102 bool dead_TP;
0103 bool dead_RO;
0104 bool discCat;
0105 get(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0106 return dead_TP;
0107 }
0108
0109 bool DTDeadFlag::getCellDead_TP(const DTWireId& id) const {
0110 return getCellDead_TP(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire());
0111 }
0112
0113 bool DTDeadFlag::getCellDead_RO(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const {
0114 bool dead_HV;
0115 bool dead_TP;
0116 bool dead_RO;
0117 bool discCat;
0118 get(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0119 return dead_RO;
0120 }
0121
0122 bool DTDeadFlag::getCellDead_RO(const DTWireId& id) const {
0123 return getCellDead_RO(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire());
0124 }
0125
0126 bool DTDeadFlag::getCellDiscCat(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId) const {
0127 bool dead_HV;
0128 bool dead_TP;
0129 bool dead_RO;
0130 bool discCat;
0131 get(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0132 return discCat;
0133 }
0134
0135 bool DTDeadFlag::getCellDiscCat(const DTWireId& id) const {
0136 return getCellDiscCat(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire());
0137 }
0138
0139 const std::string& DTDeadFlag::version() const { return dataVersion; }
0140
0141 std::string& DTDeadFlag::version() { return dataVersion; }
0142
0143 void DTDeadFlag::clear() {
0144 dataList.clear();
0145 initialize();
0146 return;
0147 }
0148
0149 int DTDeadFlag::set(int wheelId,
0150 int stationId,
0151 int sectorId,
0152 int slId,
0153 int layerId,
0154 int cellId,
0155 bool dead_HV,
0156 bool dead_TP,
0157 bool dead_RO,
0158 bool discCat) {
0159 std::vector<int> chanKey;
0160 chanKey.reserve(6);
0161 chanKey.push_back(wheelId);
0162 chanKey.push_back(stationId);
0163 chanKey.push_back(sectorId);
0164 chanKey.push_back(slId);
0165 chanKey.push_back(layerId);
0166 chanKey.push_back(cellId);
0167 int ientry;
0168 int searchStatus = dBuf->find(chanKey.begin(), chanKey.end(), ientry);
0169
0170 if (!searchStatus) {
0171 DTDeadFlagData& data(dataList[ientry].second);
0172 data.dead_HV = dead_HV;
0173 data.dead_TP = dead_TP;
0174 data.dead_RO = dead_RO;
0175 data.discCat = discCat;
0176 return -1;
0177 } else {
0178 DTDeadFlagId key;
0179 key.wheelId = wheelId;
0180 key.stationId = stationId;
0181 key.sectorId = sectorId;
0182 key.slId = slId;
0183 key.layerId = layerId;
0184 key.cellId = cellId;
0185 DTDeadFlagData data;
0186 data.dead_HV = dead_HV;
0187 data.dead_TP = dead_TP;
0188 data.dead_RO = dead_RO;
0189 data.discCat = discCat;
0190 ientry = dataList.size();
0191 dataList.push_back(std::pair<const DTDeadFlagId, DTDeadFlagData>(key, data));
0192 dBuf->insert(chanKey.begin(), chanKey.end(), ientry);
0193 return 0;
0194 }
0195
0196 return 99;
0197 }
0198
0199 int DTDeadFlag::set(const DTWireId& id, bool dead_HV, bool dead_TP, bool dead_RO, bool discCat) {
0200 return set(
0201 id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), dead_HV, dead_TP, dead_RO, discCat);
0202 }
0203
0204 int DTDeadFlag::setCellDead_HV(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag) {
0205 bool dead_HV;
0206 bool dead_TP;
0207 bool dead_RO;
0208 bool discCat;
0209 int status = cellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0210 setCellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, flag, dead_TP, dead_RO, discCat);
0211 return status;
0212 }
0213
0214 int DTDeadFlag::setCellDead_HV(const DTWireId& id, bool flag) {
0215 return setCellDead_HV(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), flag);
0216 }
0217
0218 int DTDeadFlag::setCellDead_TP(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag) {
0219 bool dead_HV;
0220 bool dead_TP;
0221 bool dead_RO;
0222 bool discCat;
0223 int status = cellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0224 setCellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, flag, dead_RO, discCat);
0225 return status;
0226 }
0227
0228 int DTDeadFlag::setCellDead_TP(const DTWireId& id, bool flag) {
0229 return setCellDead_TP(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), flag);
0230 }
0231
0232 int DTDeadFlag::setCellDead_RO(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag) {
0233 bool dead_HV;
0234 bool dead_TP;
0235 bool dead_RO;
0236 bool discCat;
0237 int status = cellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0238 setCellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, flag, discCat);
0239 return status;
0240 }
0241
0242 int DTDeadFlag::setCellDead_RO(const DTWireId& id, bool flag) {
0243 return setCellDead_RO(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), flag);
0244 }
0245
0246 int DTDeadFlag::setCellDiscCat(int wheelId, int stationId, int sectorId, int slId, int layerId, int cellId, bool flag) {
0247 bool dead_HV;
0248 bool dead_TP;
0249 bool dead_RO;
0250 bool discCat;
0251 int status = cellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, discCat);
0252 setCellStatus(wheelId, stationId, sectorId, slId, layerId, cellId, dead_HV, dead_TP, dead_RO, flag);
0253 return status;
0254 }
0255
0256 int DTDeadFlag::setCellDiscCat(const DTWireId& id, bool flag) {
0257 return setCellDiscCat(id.wheel(), id.station(), id.sector(), id.superLayer(), id.layer(), id.wire(), flag);
0258 }
0259
0260 DTDeadFlag::const_iterator DTDeadFlag::begin() const { return dataList.begin(); }
0261
0262 DTDeadFlag::const_iterator DTDeadFlag::end() const { return dataList.end(); }
0263
0264 std::string DTDeadFlag::mapName() const {
0265 std::stringstream name;
0266 name << dataVersion << "_map_DeadFlag" << this;
0267 return name.str();
0268 }
0269
0270 void DTDeadFlag::initialize() {
0271 dBuf->clear();
0272
0273 int entryNum = 0;
0274 int entryMax = dataList.size();
0275 std::vector<int> chanKey;
0276 chanKey.reserve(6);
0277 while (entryNum < entryMax) {
0278 const DTDeadFlagId& chan = dataList[entryNum].first;
0279
0280 chanKey.clear();
0281 chanKey.push_back(chan.wheelId);
0282 chanKey.push_back(chan.stationId);
0283 chanKey.push_back(chan.sectorId);
0284 chanKey.push_back(chan.slId);
0285 chanKey.push_back(chan.layerId);
0286 chanKey.push_back(chan.cellId);
0287 dBuf->insert(chanKey.begin(), chanKey.end(), entryNum++);
0288 }
0289
0290 return;
0291 }