42 std::string AtlasVersion = geoModel->atlasVersion();
43 std::string MuonVersion = geoModel->muonVersionOverride();
44 std::string detectorKey = MuonVersion.empty() ? AtlasVersion : MuonVersion;
45 std::string detectorNode = MuonVersion.empty() ?
"ATLAS" :
"MuonSpectrometer";
50 IRDBRecordset_ptr switchSet = accessSvc->getRecordsetPtr(
"HwSwIdMapping", detectorKey, detectorNode);
52 if ((*switchSet).size() == 0) {
53 ATH_MSG_WARNING(
"Old Atlas Version : " << AtlasVersion <<
" Only Online Identifier. Falling back to HwSwIdMapping-00 tag");
54 switchSet = accessSvc->getRecordsetPtr(
"HwSwIdMapping",
"HwSwIdMapping-00");
57 for (
unsigned int irow = 0; irow < (*switchSet).size(); ++irow) {
58 const IRDBRecord* switches = (*switchSet)[irow];
59 std::string hardwareName = switches->
getString(
"HARDNAME");
61 int stPhi = switches->
getInt(
"SOFTOCTANT");
62 int stEta = switches->
getInt(
"SOFTIZ");
70 return StatusCode::SUCCESS;
75 return StatusCode::SUCCESS;
79 ATH_MSG_FATAL(
"Failed to load conditions from "<<key.fullKey());
80 return StatusCode::FAILURE;
82 wh.addDependency(readHandle);
83 return StatusCode::SUCCESS;
97 return StatusCode::SUCCESS;
106 return StatusCode::SUCCESS;
113 <<
" In theory this should not be called, but may happen"
114 <<
" if multiple concurrent events are being processed out of order.");
115 return StatusCode::SUCCESS;
117 auto writeCdo{std::make_unique<MdtCondDbData>(
m_idHelperSvc->mdtIdHelper())};
135 ATH_MSG_DEBUG(
"Recorded new " << writeHandle.
key() <<
" with range " << writeHandle.
getRange() <<
" into Conditions Store");
137 return StatusCode::SUCCESS;
146 return StatusCode::FAILURE;
149 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
151 std::vector<Identifier> cachedDeadMultiLayersId_standby;
153 const unsigned int chanNum = itr.first;
154 const coral::AttributeList& atr = itr.second;
155 const std::string& hv_payload = readCdo->
chanName(chanNum);
158 if (atr.size() == 1) {
159 hv_name = *(
static_cast<const std::string*
>((atr[
"fsm_currentState"]).addressOfData()));
161 auto tokens =
tokenize(hv_name,
" ");
162 auto tokens2 =
tokenize(hv_payload,
"_");
164 if (tokens[0] !=
"ON" && tokens[0] !=
"STANDBY" && tokens[0] !=
"UNKNOWN") {
165 int multilayer =
atoi(tokens2[3]);
166 const auto &chamber_name = tokens2[2];
172 cachedDeadMultiLayersId_standby.push_back(MultiLayerId);
175 if (tokens[0] ==
"STANDBY") {
176 int multilayer =
atoi(tokens2[3]);
177 const auto &chamber_name = tokens2[2];
183 cachedDeadMultiLayersId_standby.push_back(MultiLayerId);
192 std::map<Identifier, float> chamberML_V1;
193 std::map<Identifier, float> chamberML_V0;
200 return StatusCode::FAILURE;
203 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle_v0.
fullKey() <<
" readCdo->size()= " << readCdo_v0->
size());
210 return StatusCode::FAILURE;
213 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle_v1.
fullKey() <<
" readCdo->size()= " << readCdo_v1->
size());
217 const unsigned int chanNum = itr_v0.first;
218 const coral::AttributeList& atr_v0 = itr_v0.second;
219 const std::string& setPointsV0_payload = readCdo_v0->
chanName(chanNum);
220 float setPointsV0_name{0.};
222 if (atr_v0.size() == 1) {
223 setPointsV0_name = *(
static_cast<const float*
>((atr_v0[
"readBackSettings_v0"]).addressOfData()));
225 auto tokens2 =
tokenize(setPointsV0_payload,
"_");
227 int multilayer =
atoi(tokens2[3]);
228 const auto &chamber_name = tokens2[2];
231 chamberML_V0[MultiLayerId] = setPointsV0_name;
238 const unsigned int chanNum = itr_v1.first;
239 const coral::AttributeList& atr_v1 = itr_v1.second;
240 const std::string& setPointsV1_payload = readCdo_v1->
chanName(chanNum);
241 float setPointsV1_name{0.};
243 if (atr_v1.size() == 1) {
244 setPointsV1_name = *(
static_cast<const float*
>((atr_v1[
"readBackSettings_v1"]).addressOfData()));
247 auto tokens2=
tokenize(setPointsV1_payload,
"_");
249 int multilayer =
atoi(tokens2[3]);
250 const auto &chamber_name = tokens2[2];
253 chamberML_V1[MultiLayerId] = setPointsV1_name;
259 for (
const Identifier& MultilayerId_ch : cachedDeadMultiLayersId_standby) {
260 if (chamberML_V1.find(MultilayerId_ch)->second == chamberML_V0.find(MultilayerId_ch)->second) {
261 ATH_MSG_DEBUG(
"Chamber has correct Voltage V1 = " << chamberML_V1.find(MultilayerId_ch)->second
262 <<
" V0= " << chamberML_V0.find(MultilayerId_ch)->second);
264 ATH_MSG_DEBUG(
"Chamber has wrong correct Voltage V1 = " << chamberML_V1.find(MultilayerId_ch)->second
265 <<
" V0= " << chamberML_V0.find(MultilayerId_ch)->second);
271 return StatusCode::SUCCESS;
280 return StatusCode::FAILURE;
282 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
283 for (
const auto& [chanNum, atr] : *readCdo) {
284 const std::string& hv_payload = readCdo->
chanName(chanNum);
287 if (!atr.size()) {
continue; }
288 hv_name = *(
static_cast<const std::string*
>((atr[
"fsm_currentState"]).addressOfData()));
290 auto tokens =
tokenize(hv_name,
" ");
291 auto tokens2 =
tokenize(hv_payload,
"_");
292 if (tokens[0] !=
"ON") {
293 const auto &chamber_name = tokens2[2];
299 return StatusCode::SUCCESS;
305 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readCdo.
fullKey() <<
" readCdo->size()= " << readCdo->size());
306 for (
const auto& [chanNum, atr] : **readCdo) {
307 if (!atr.size()) {
continue; }
309 const std::string& hv_payload = readCdo->chanName(chanNum);
310 const std::string& hv_name_ml1{*(
static_cast<const std::string*
>((atr[
"fsmCurrentState_ML1"]).addressOfData()))};
311 const std::string& hv_name_ml2{*(
static_cast<const std::string*
>((atr[
"fsmCurrentState_ML2"]).addressOfData()))};
312 const float hv_v0_ml1{*(
static_cast<const float*
>((atr[
"v0set_ML1"]).addressOfData()))};
313 const float hv_v1_ml1{*(
static_cast<const float*
>((atr[
"v1set_ML1"]).addressOfData()))};
314 const float hv_v0_ml2{*(
static_cast<const float*
>((atr[
"v0set_ML2"]).addressOfData()))};
315 const float hv_v1_ml2{*(
static_cast<const float*
>((atr[
"v1set_ML2"]).addressOfData()))};
318 if (!chamberId.
is_valid())
continue;
320 const float standbyVolt,
321 const float readyVolt,
322 const int multiLayer) {
327 if ( (std::find(goodStates.begin(), goodStates.end(), dcsState) == goodStates.end()) ||
331 writeCdo.
setHvState(mlId, dcsState, standbyVolt, readyVolt);
336 return StatusCode::SUCCESS;
345 return StatusCode::FAILURE;
347 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
349 for (
const auto& [chanNum, atr] : *readCdo) {
350 if (!atr.size()) {
continue; }
351 const std::string& lv_payload = readCdo->
chanName(chanNum);
352 const std::string& lv_name{*
static_cast<const std::string*
>((atr[
"fsmCurrentState_LV"]).addressOfData())};
353 if (lv_payload.empty() || lv_name.empty()){
354 ATH_MSG_WARNING(
"The read data with chanNum "<<chanNum<<
", lv_payload: "<<lv_payload<<
", hv_name: "<<lv_name
355 <<
". Does not have any fsmCurrentState_LV attribute. "
356 <<
"May be this is related to ATLASRECTS-6920 / ATLASRECTS-6879. Skip it");
360 auto tokens =
tokenize(lv_name,
" ");
362 if (tokens[0] !=
"ON") {
368 return StatusCode::SUCCESS;
378 return StatusCode::FAILURE;
380 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
383 const coral::AttributeList& atr = itr.second;
384 const std::string& chamber_dropped{*(
static_cast<const std::string*
>((atr[
"Chambers_disabled"]).addressOfData()))};
386 auto tokens =
tokenize(chamber_dropped,
" ");
387 for (
auto & token : tokens) {
389 const auto &chamber_name = token;
395 return StatusCode::SUCCESS;
404 return StatusCode::FAILURE;
407 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
410 const coral::AttributeList& atr = itr.second;
411 const std::string& chamber_name{*(
static_cast<const std::string*
>((atr[
"Chambers_Name"]).addressOfData()))};
412 const std::string& list_mlayer{*(
static_cast<const std::string*
>((atr[
"Dead_multilayer"]).addressOfData()))};
413 const std::string& list_layer{*(
static_cast<const std::string*
>((atr[
"Dead_layer"]).addressOfData()))};
414 const std::string& list_tube{*(
static_cast<const std::string*
>((atr[
"Dead_tube"]).addressOfData()))};
417 auto tokens =
tokenize(list_tube,
" ");
418 auto tokens_mlayer =
tokenize(list_mlayer,
" ");
419 auto tokens_layer =
tokenize(list_layer,
" ");
421 for (
auto & token : tokens) {
424 int ml =
atoi(token.substr(0, 1));
425 int layer =
atoi(token.substr(1, 2));
426 int tube =
atoi(token.substr(2));
433 for (
unsigned int i = 0; i < tokens_mlayer.size(); i++) {
434 if (tokens_mlayer[i] !=
"0") {
435 int ml =
atoi(tokens_mlayer[i].substr(0));
442 for (
unsigned int i = 0; i < tokens_layer.size(); i++) {
443 if (tokens_layer[i] !=
"0") {
444 int ml =
atoi(tokens_layer[i].substr(0, 1));
445 int layer =
atoi(tokens_layer[i].substr(1));
453 return StatusCode::SUCCESS;
462 return StatusCode::FAILURE;
465 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
468 const coral::AttributeList& atr = itr.second;
470 std::string dead_tube = *(
static_cast<const std::string*
>((atr[
"DeadTube_List"]).addressOfData()));
471 std::string chamber_name = *(
static_cast<const std::string*
>((atr[
"Chamber_Name"]).addressOfData()));
473 auto tokens =
tokenize(dead_tube,
" ");
476 for (
auto & token : tokens) {
477 int ml =
atoi(token.substr(0, 1));
478 int layer =
atoi(token.substr(1, 2));
479 int tube =
atoi(token.substr(2));
486 return StatusCode::SUCCESS;
495 return StatusCode::FAILURE;
498 ATH_MSG_DEBUG(
"Size of CondAttrListCollection " << readHandle.
fullKey() <<
" readCdo->size()= " << readCdo->
size());
499 for (
const auto &[chanNum, atr] : *readCdo) {
503 const std::string& hv_payload = readCdo->
chanName(chanNum);
504 const std::string& hv_name{*(
static_cast<const std::string*
>((atr[
"fsm_currentState"]).addressOfData()))};
506 auto tokens =
tokenize(hv_name,
" ");
508 auto tokens2 =
tokenize(hv_payload,
"_");
510 if (tokens[0] !=
"ON") {
516 return StatusCode::SUCCESS;
519 if (chamber[2] ==
'Y' || chamber[2] ==
'X') chamber[2] =
'S';
520 auto itr =
m_chamberNames.find(chamber.substr(0, chamber.find(
'_')));
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition of the abstract IRDBAccessSvc interface.
std::shared_ptr< IRDBRecordset > IRDBRecordset_ptr
Definition of the abstract IRDBRecord interface.
Definition of the abstract IRDBRecordset interface.
CondAttrListCollection::ChanAttrListPair readOutPair
This class is a collection of AttributeLists where each one is associated with a channel number.
const std::string & chanName(ChanNum chanNum) const
find name for particular channel
size_type size() const
number of Chan/AttributeList pairs
ChanAttrListMap::value_type ChanAttrListPair
ChanAttrListMap::const_iterator const_iterator
IRDBRecord is one record in the IRDBRecordset object.
virtual const std::string & getString(const std::string &fieldName) const =0
Get string field value.
virtual int getInt(const std::string &fieldName) const =0
Get int field value.
bool is_valid() const
Check if id is in a valid state.
void setDeadTube(const Identifier &ident)
The indiviudal tube is dead.
void setDeadMultilayer(const Identifier &ident)
All tubes in a multi layer are dead.
void setDeadLayer(const Identifier &ident)
All tubes in a drift layer are dead.
void setHvState(const Identifier &multiLayerID, const DcsFsmState state, const float standByVolt, const float readyVolt)
Adds a DCS state to the conditions object multiLayerID -> Identifier of a tube in the multilayer stat...
void setDeadChamber(const Identifier &ident)
All tubes in a chamber are dead.
Identifier multilayerID(const Identifier &channeldID) const
int numberOfMultilayers(const Identifier &id) const
Gaudi::Property< bool > m_isOnline
dataBaseKey_t m_readKey_folder_mc_droppedChambers
StatusCode loadDependencies(const EventContext &ctx, writeHandle_t &wh) const
StatusCode addDHDependency(const EventContext &ctx, const dataBaseKey_t &key, writeHandle_t &wh) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
dataBaseKey_t m_readKey_folder_da_hv
dataBaseKey_t m_readKey_folder_mc_deadTubes
dataBaseKey_t m_readKey_folder_da_pslv
virtual StatusCode initialize() override
std::map< std::string, Identifier > m_chamberNames
StatusCode loadDataLv(const EventContext &ctx, MdtCondDbData &dataOut) const
dataBaseKey_t m_readKey_folder_da_psv1
dataBaseKey_t m_readKey_folder_mc_deadElements
Gaudi::Property< bool > m_isData
Gaudi::Property< bool > m_isRun1
dataBaseKey_t m_readKey_folder_da_psv0
SG::WriteCondHandle< MdtCondDbData > writeHandle_t
Identifier identifyChamber(std::string chamber) const
dataBaseKey_t m_readKey_folder_da_lv
SG::WriteCondHandleKey< MdtCondDbData > m_writeKey
StatusCode loadDataHv(const EventContext &ctx, MdtCondDbData &dataOut) const
SG::ReadCondHandleKey< CondAttrListCollection > dataBaseKey_t
dataBaseKey_t m_readKey_folder_mc_noisyChannels
StatusCode loadDataPsHv(const EventContext &ctx, MdtCondDbData &dataOut) const
StatusCode loadDataPsLv(const EventContext &ctx, MdtCondDbData &dataOut) const
dataBaseKey_t m_readKey_folder_da_droppedChambers
StatusCode loadDroppedChambers(const EventContext &ctx, MdtCondDbData &dataOut, bool isMC) const
Gaudi::Property< bool > m_checkOnSetPoint
StatusCode loadMcDeadElements(const EventContext &ctx, MdtCondDbData &dataOut) const
virtual StatusCode execute(const EventContext &) const override
StatusCode loadMcDeadTubes(const EventContext &ctx, MdtCondDbData &dataOut) const
dataBaseKey_t m_readKey_folder_da_pshv
StatusCode loadMcNoisyChannels(const EventContext &ctx, MdtCondDbData &dataOut) const
const DataObjID & fullKey() const
const std::string & key() const
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
DcsFsmState getFsmStateEnum(const std::string &fsmState)
const std::string & stName(StIndex index)
convert StIndex into a string
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.