ATLAS Offline Software
CscCondDbAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include <utility>
6 
7 
8 
10 
12 
13 // constructor
14 CscCondDbAlg::CscCondDbAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15  AthReentrantAlgorithm(name, pSvcLocator) {}
16 
17 // Initialize
19  ATH_MSG_DEBUG("initializing " << name());
20  ATH_CHECK(m_idHelperSvc.retrieve());
22 
23  if (m_pslopeFromDB) {
24  ATH_MSG_WARNING("You have activated the retrieval of the pslope per CSC channel from the COOL database. "
25  << "Please make sure that a correct PSLOPE database is in place which uses geometrical CSC hashes in hex format "
26  << "as keys and different values of the pslopes for the different CSC channels as values, otherwise please run "
27  << "with the ReadPSlopeFromDatabase property set to false");
28  } else {
29  float pslope = m_pslope; // Work around cppcheck false positive
30  if (!(pslope > 0 && pslope < 1)) {
31  ATH_MSG_FATAL("The Pslope cannot be set to a value <=0 or >=1");
32  return StatusCode::FAILURE;
33  } else if (m_pslope != m_DEFAULT_PSLOPE) {
34  ATH_MSG_WARNING("You have manually set the Pslope property (to " << m_pslope
35  << "). Please check whether this is really intended.");
36  }
37  }
38 
48 
49  return StatusCode::SUCCESS;
50 }
51 
52 // execute
53 StatusCode CscCondDbAlg::execute(const EventContext& ctx) const {
54  ATH_MSG_DEBUG("execute " << name());
55 
56  // launching Write Cond Handle
58  if (writeHandle.isValid()) {
59  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
60  << " In theory this should not be called, but may happen"
61  << " if multiple concurrent events are being processed out of order.");
62  return StatusCode::SUCCESS;
63  }
64  std::unique_ptr<CscCondDbData> writeCdo{std::make_unique<CscCondDbData>()};
65 
66  writeCdo->loadParameters(&m_idHelperSvc->cscIdHelper());
67  writeCdo->setParameters(m_onlineOfflinePhiFlip);
68 
69  // data only
70  if (m_isData) {
71  // ATH_CHECK(loadDataHv(writeHandle, writeCdo.get(), ctx)); // keep for future development
72  }
73 
74  // both data and MC
75  ATH_CHECK(loadDataF001(writeHandle, writeCdo.get(), ctx));
76  ATH_CHECK(loadDataNoise(writeHandle, writeCdo.get(), ctx));
77  ATH_CHECK(loadDataPed(writeHandle, writeCdo.get(), ctx));
78  if (m_pslopeFromDB) ATH_CHECK(loadDataPSlope(writeHandle, writeCdo.get(), ctx));
79  ATH_CHECK(loadDataRMS(writeHandle, writeCdo.get(), ctx));
80  ATH_CHECK(loadDataStatus(writeHandle, writeCdo.get(), ctx));
81 
82  if (!m_isOnline) {
83  ATH_CHECK(loadDataT0Base(writeHandle, writeCdo.get(), ctx));
84  ATH_CHECK(loadDataT0Phase(writeHandle, writeCdo.get(), ctx));
85  }
86 
87  if (writeHandle.record(std::move(writeCdo)).isFailure()) {
88  ATH_MSG_FATAL("Could not record CscCondDbData " << writeHandle.key() << " with EventRange " << writeHandle.getRange()
89  << " into Conditions Store");
90  return StatusCode::FAILURE;
91  }
92  ATH_MSG_DEBUG("Recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
93 
94  return StatusCode::SUCCESS;
95 }
96 
97 // loadDataHv
98 StatusCode CscCondDbAlg::loadDataHv(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
100  const CondAttrListCollection* readCdo{*readHandle};
101  if (readCdo == nullptr) {
102  ATH_MSG_ERROR("Null pointer to the read conditions object");
103  return StatusCode::FAILURE;
104  }
105  writeHandle.addDependency(readHandle);
106 
107  ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
108  ATH_MSG_DEBUG("Range of input is " << readHandle.getRange() << ", range of output is " << writeHandle.getRange());
109 
111  std::map<Identifier, int> layerMap;
112  int hv_state, lv_state, hv_setpoint0, hv_setpoint1;
113  unsigned int chan_index = 0;
114  for (itr = readCdo->begin(); itr != readCdo->end(); ++itr) {
115  unsigned int chanNum = readCdo->chanNum(chan_index);
116  const std::string& csc_chan_name = readCdo->chanName(chanNum);
117 
118  const coral::AttributeList& atr = itr->second;
119 
120  if (atr.size()) {
121  hv_state = *(static_cast<const int*>((atr["HVState"]).addressOfData()));
122  lv_state = *(static_cast<const int*>((atr["LVState"]).addressOfData()));
123  hv_setpoint0 = *(static_cast<const int*>((atr["HVSetpoint0"]).addressOfData()));
124  hv_setpoint1 = *(static_cast<const int*>((atr["HVSetpoint1"]).addressOfData()));
125 
126  std::string_view delimiter{"_"};
127  auto tokens = CxxUtils::tokenize(csc_chan_name, delimiter);
128 
129  if ((hv_state != 1 or lv_state != 1 or hv_setpoint0 < 1000 or hv_setpoint1 < 1000) && !tokens.empty()) {
130  std::string_view layer = tokens[1];
131  std::string number_layer = tokens[1].substr(1, 2);
132  int wirelayer = CxxUtils::atoi(number_layer);
133 
134  int eta = 0;
135  char eta_side = tokens[0][0];
136  if (eta_side == 'A') eta = +1;
137  if (eta_side == 'C') eta = -1;
138 
139  std::string chamber_name;
140  char size_side = tokens[0][1];
141  if (size_side == 'L') chamber_name = "CSL";
142  else if (size_side == 'S') chamber_name = "CSS";
143 
144  int phi = 0;
145  std::string sector_side = tokens[0].substr(2, 4);
146  if (sector_side == "01" || sector_side == "02") phi = 1;
147  else if (sector_side == "03" || sector_side == "04") phi = 2;
148  else if (sector_side == "05" || sector_side == "06") phi = 3;
149  else if (sector_side == "07" || sector_side == "08") phi = 4;
150  else if (sector_side == "09" || sector_side == "10") phi = 5;
151  else if (sector_side == "11" || sector_side == "12") phi = 6;
152  else if (sector_side == "13" || sector_side == "14") phi = 7;
153  else if (sector_side == "15" || sector_side == "16") phi = 8;
154 
155  Identifier ChamberId = m_idHelperSvc->cscIdHelper().elementID(chamber_name, eta, phi);
156  Identifier WireLayerId = m_idHelperSvc->cscIdHelper().channelID(ChamberId, 1, wirelayer, 1, 1);
157  std::string WireLayerstring = std::string(chamber_name);
158  WireLayerstring += '_';
159  WireLayerstring += eta_side;
160  WireLayerstring += '_';
161  WireLayerstring += sector_side;
162  WireLayerstring += '_';
163  WireLayerstring += layer;
164 
165  writeCdo->setDeadLayer(WireLayerstring, WireLayerId);
166  int& mapval = layerMap[ChamberId];
167  ++mapval;
168  if (mapval == 3) writeCdo->setDeadStation(chamber_name, ChamberId);
169  }
170  }
171  chan_index++;
172  }
173 
174  return StatusCode::SUCCESS;
175 }
176 
177 // loadDataF001
178 StatusCode CscCondDbAlg::loadDataF001(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
180  writeHandle.addDependency(readHandle);
181  return loadData(writeCdo, *readHandle, "f001");
182 }
183 
184 // loadDataNoise
185 StatusCode CscCondDbAlg::loadDataNoise(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
187  writeHandle.addDependency(readHandle);
188  return loadData(writeCdo, *readHandle, "noise");
189 }
190 
191 // loadDataPed
192 StatusCode CscCondDbAlg::loadDataPed(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
194  writeHandle.addDependency(readHandle);
195  return loadData(writeCdo, *readHandle, "ped");
196 }
197 
198 // loadDataPSlope
199 StatusCode CscCondDbAlg::loadDataPSlope(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
201  writeHandle.addDependency(readHandle);
202  return loadData(writeCdo, *readHandle, "pslope");
203 }
204 
205 // loadDataRMS
206 StatusCode CscCondDbAlg::loadDataRMS(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
208  writeHandle.addDependency(readHandle);
209  return loadData(writeCdo, *readHandle, "rms");
210 }
211 
212 // loadDataStatus
213 StatusCode CscCondDbAlg::loadDataStatus(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
215  writeHandle.addDependency(readHandle);
216  return loadData(writeCdo, *readHandle, "status");
217 }
218 
219 // loadDataT0Base
220 StatusCode CscCondDbAlg::loadDataT0Base(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
222  writeHandle.addDependency(readHandle);
223  return loadData(writeCdo, *readHandle, "t0base");
224 }
225 
226 // loadDataT0Phase
227 StatusCode CscCondDbAlg::loadDataT0Phase(writeHandle_t& writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
229  writeHandle.addDependency(readHandle);
230  return loadData(writeCdo, *readHandle, "t0phase", true);
231 }
232 
233 // loadData
234 StatusCode CscCondDbAlg::loadData(CscCondDbData* writeCdo, const CondAttrListCollection* readCdo, const std::string& parName,
235  bool parAsm) const {
237 
238  for (itr = readCdo->begin(); itr != readCdo->end(); ++itr) {
239  const coral::AttributeList& atr = itr->second;
240  std::string data = atr["Data"].data<std::string>();
241  ATH_MSG_DEBUG("Data is: " << data);
242 
243  std::istringstream ss(data);
244 
245  if (!ss.good()) {
246  ATH_MSG_WARNING("Failed forming stringstream during caching");
247  continue;
248  }
249 
250  std::string version;
251  ss >> version;
252 
253  if (version == "02-00" && parAsm) {
254  if (!cacheASM(data, writeCdo, parName).isSuccess()) {
255  ATH_MSG_ERROR("Failed caching from COOL string version 02-00 in ASM format");
256  return StatusCode::FAILURE;
257  }
258  } else if (version == "02-00") {
259  if (!cache(data, writeCdo, parName).isSuccess()) {
260  ATH_MSG_ERROR("Failed caching from COOL string version 02-00");
261  return StatusCode::FAILURE;
262  }
263  } else {
264  // Old version was treated as an actual number rather than string. It was always
265  // set to 1 or sometimes 1.00000, so we convert to integer here and check
266  ATH_MSG_WARNING("Don't recognize CSC COOL string version " << version << ". Will treat as default version "
268  if (m_defaultDatabaseReadVersion == "02-00" && parAsm) {
269  if (!cacheASM(data, writeCdo, parName).isSuccess()) {
270  ATH_MSG_ERROR("Failed caching from COOL string version 02-00 in ASM format");
271  return StatusCode::FAILURE;
272  }
273  } else if (m_defaultDatabaseReadVersion == "02-00") {
274  if (!cache(data, writeCdo, parName).isSuccess()) {
275  ATH_MSG_ERROR("Failed caching from COOL string version 02-00");
276  return StatusCode::FAILURE;
277  }
278  } else {
279  ATH_MSG_FATAL("Did not recognize CSC COOL string version "
280  << version
281  << ". Currently, only version 02-00 is supported. The keys of the database have to be geometrical CSC hashes "
282  "in hex format.");
283  return StatusCode::FAILURE;
284  }
285  }
286  }
287 
288  return StatusCode::SUCCESS;
289 }
290 
291 StatusCode CscCondDbAlg::cache(const std::string& data, CscCondDbData* writeCdo, const std::string& parName) const {
292  std::istringstream ss(data);
293  std::string valueStr;
294  unsigned int chanAddress = 0;
295 
296  bool started = false;
297  while (ss.good()) {
298  ss >> valueStr;
299 
300  if (valueStr == "<END_DATA>") break;
301 
302  if (valueStr == "<BEGIN_DATA>") {
303  started = true;
304  continue;
305  }
306  if (!started) continue;
307  ATH_MSG_VERBOSE("cache() - current element " << valueStr);
308  std::istringstream iss(valueStr);
309 
310  // use new iss to translate the hex
311  if (chanAddress == 0) {
312  iss >> std::hex >> chanAddress;
313  continue;
314  }
315 
316  // record parameter
317  if (recordParameter(chanAddress, valueStr, writeCdo, parName).isFailure()) return StatusCode::FAILURE;
318 
319  // reset the address
320  chanAddress = 0;
321  }
322 
323  return StatusCode::SUCCESS;
324 }
325 
326 StatusCode CscCondDbAlg::cacheASM(const std::string& data, CscCondDbData* writeCdo, const std::string& parName) const {
327  std::istringstream ss(data);
328  std::string valueStr;
329  std::string chanAddress;
330  bool setAddress = false;
331 
332  bool started = false;
333  while (ss.good()) {
334  ss >> valueStr;
335 
336  if (valueStr == "<END_DATA>") break;
337 
338  if (valueStr == "<BEGIN_DATA>") {
339  started = true;
340  continue;
341  }
342  if (!started) continue;
343  ATH_MSG_VERBOSE("cacheASM() - current element " << valueStr);
344  std::istringstream iss(valueStr);
345 
346  // use new iss to translate the hex
347  if (!setAddress) {
348  iss >> chanAddress;
349  setAddress = true;
350  continue;
351  }
352 
353  // chanAddress is the ASM tag, need to do something with it
354  // format: ASM[#:1-5]_[StationEtaString:AorC][stationPhi:1-8]_[stationName:50-51]
355  // xxx 3 x 5 6 x x9
356  int asmNum = atoi(chanAddress.substr(3, 1).c_str());
357 
358  int stationEta = 0;
359  if (chanAddress[5] == 'A')
360  stationEta = 1;
361  else if (chanAddress[5] == 'C')
362  stationEta = -1;
363  else {
364  ATH_MSG_FATAL("Bad ASMID String in CSC COOL database \"" << chanAddress << "\" (wheel " << chanAddress[5] << " doesn't exist!");
365  return StatusCode::FAILURE;
366  }
367 
368  int stationPhi = atoi(chanAddress.substr(6, 1).c_str());
369  int stationName = atoi(chanAddress.substr(8, 2).c_str());
370 
371  if (stationPhi < 1 || stationPhi > 8 || stationName < 50 || stationName > 51) {
372  ATH_MSG_FATAL("Bad ASMID String in CSC COOL database: \"" << chanAddress << "\"");
373  ATH_MSG_FATAL("Read station phi: " << stationPhi << ", stationName " << stationName);
374  return StatusCode::FAILURE;
375  }
376 
377  int chamberLayer = 2; // chamberLayer1 was never built.
378 
379  int measuresPhi = 0;
380  int layerSince = 0;
381  int layerUntil = 0;
382  int stripSince = 0;
383  int stripUntil = 0;
384  if (!getAsmScope(asmNum, measuresPhi, layerSince, layerUntil, stripSince, stripUntil).isSuccess()) {
385  ATH_MSG_FATAL("Failure of getAsmScope in cacheASM.");
386  return StatusCode::FAILURE;
387  }
388 
389  // Now for given asmID, loop over strip and layer
390  unsigned int index = 0;
391  Identifier chanId;
392  IdentifierHash hashIdentifier;
393  for (int iStrip = stripSince; iStrip < stripUntil; iStrip++) {
394  for (int iLayer = layerSince; iLayer < layerUntil; iLayer++) {
395  // The following call of channelID with check=true ensures that the identifier is checked to be physically valid.
396  // This is currently required to be checked when running with layouts which do not contain all CSCs anymore, since the
397  // CSCCool database contains still all CSCs. A clean fix would be to have a dedicated database for every layout.
398  bool isValid = true;
399  chanId = m_idHelperSvc->cscIdHelper().channelID(stationName, stationEta, stationPhi, chamberLayer, iLayer, measuresPhi,
400  iStrip, isValid);
401 
402  static std::atomic<bool> conversionFailPrinted = false;
403  if (!isValid) {
404  if (!conversionFailPrinted.load()) {
406  "Failed to retrieve offline identifier from ASM cool "
407  "string "
408  << chanAddress
409  << ". This is likely due to the fact that the CSCCool "
410  "database contains "
411  << "more entries than the detector layout.");
412  conversionFailPrinted.store(true);
413  }
414  continue;
415  }
416  if (m_idHelperSvc->cscIdHelper().get_channel_hash(chanId, hashIdentifier)) {
417  ATH_MSG_WARNING("Failed to retrieve channel hash for Identifier " << chanId.get_compact());
418  }
419  index = (int)hashIdentifier;
420  if (index == UINT_MAX) continue;
421 
422  ATH_MSG_VERBOSE("[cache version 2 (ASM)] Recording " << valueStr << " at index " << index << "\nstationName " << stationName
423  << "\nstationEta " << stationEta << "\nstationPhi " << stationPhi
424  << "\nchamberLayer " << chamberLayer << "\niLayer " << iLayer
425  << "\nmeasuresPhi " << measuresPhi << "\niStrip " << iStrip);
426 
427  // record parameter
428  if (recordParameter(hashIdentifier, valueStr, writeCdo, parName).isFailure()) return StatusCode::FAILURE;
429  }
430  }
431 
432  // reset the address
433  setAddress = false;
434  chanAddress = "";
435  }
436 
437  return StatusCode::SUCCESS;
438 }
439 
440 // getAsmScope
441 StatusCode CscCondDbAlg::getAsmScope(int asmNum, int& measuresPhi, int& layerSince, int& layerUntil, int& stripSince,
442  int& stripUntil) const {
443  // copy-paste from CscCoolStrSvc
444 
445  if (asmNum == 1) {
446  stripSince = 1; // inclusive
447  stripUntil = 97; // exclusive
448  layerSince = 1; // inclusive
449  layerUntil = 3; // exclusive
450  measuresPhi = 0;
451  } else if (asmNum == 2) {
452  stripSince = 1; // inclusive
453  stripUntil = 97; // exclusive
454  layerSince = 3; // inclusive
455  layerUntil = 5; // exclusive
456  measuresPhi = 0;
457  } else if (asmNum == 3) {
458  stripSince = 97;
459  stripUntil = 193;
460  layerSince = 1;
461  layerUntil = 3;
462  measuresPhi = 0;
463  } else if (asmNum == 4) {
464  stripSince = 97;
465  stripUntil = 193;
466  layerSince = 3;
467  layerUntil = 5;
468  measuresPhi = 0;
469  } else if (asmNum == 5) {
470  stripSince = 1;
471  stripUntil = 49;
472  layerSince = 1;
473  layerUntil = 5;
474  measuresPhi = 1;
475  } else {
476  ATH_MSG_FATAL("ASM number \"" << asmNum << "\" is invalid. It needs to end in a number from 1-5.");
477  return StatusCode::FAILURE;
478  }
479  return StatusCode::SUCCESS;
480 }
481 
482 // recordParameter
483 StatusCode CscCondDbAlg::recordParameter(unsigned int chanAddress, const std::string& data, CscCondDbData* writeCdo,
484  const std::string& parName) const {
485  // retrieve channel hash
486  Identifier chamberId;
488  if (!writeCdo->onlineToOfflineIds(&m_idHelperSvc->cscIdHelper(), chanAddress, chamberId, channelId).isSuccess()) {
489  // if onlineToOfflineIds does not return SUCCESS, the underlying reason was alrady printed there, so no need to also print a WARNING
490  // here
491  return StatusCode::SUCCESS;
492  }
493 
494  IdentifierHash chanHash;
495  if (m_idHelperSvc->cscIdHelper().get_channel_hash(channelId, chanHash)) {
496  ATH_MSG_WARNING("recordParameter(): Failed to retrieve channel Identifier hash for Identifier " << channelId.get_compact()
497  << ". Not recording parameter...");
498  return StatusCode::SUCCESS;
499  }
500 
501  // record parameter
502  return recordParameter(chanHash, data, writeCdo, parName);
503 }
504 
505 // recordParameter
507  const std::string& parName) const {
508  // record parameter
509  StatusCode sc = StatusCode::FAILURE;
510  if (parName == "f001")
511  sc = recordParameterF001(chanHash, data, writeCdo);
512  else if (parName == "noise")
513  sc = recordParameterNoise(chanHash, data, writeCdo);
514  else if (parName == "ped")
515  sc = recordParameterPed(chanHash, data, writeCdo);
516  else if (parName == "pslope")
517  sc = recordParameterPSlope(chanHash, data, writeCdo);
518  else if (parName == "rms")
519  sc = recordParameterRMS(chanHash, data, writeCdo);
520  else if (parName == "status")
521  sc = recordParameterStatus(chanHash, data, writeCdo);
522  else if (parName == "t0base")
523  sc = recordParameterT0Base(chanHash, data, writeCdo);
524  else if (parName == "t0phase")
525  sc = recordParameterT0Phase(chanHash, data, writeCdo);
526 
527  if (!sc.isSuccess())
528  ATH_MSG_ERROR("Cannot extract parameter " << parName << " for channel hash " << chanHash << " from data string '" << data << "'");
529  return sc;
530 }
531 
532 // recordParameterF001
534  float token;
535  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
536  writeCdo->setChannelF001(chanHash, token);
537  return StatusCode::SUCCESS;
538 }
539 
540 // recordParameterNoise
542  float token;
543  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
544  writeCdo->setChannelNoise(chanHash, token);
545  return StatusCode::SUCCESS;
546 }
547 
548 // recordParameterPed
550  float token;
551  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
552  writeCdo->setChannelPed(chanHash, token);
553  return StatusCode::SUCCESS;
554 }
555 
556 // recordParameterPSlope
558  if (m_pslopeFromDB) {
559  float token;
560  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
561  writeCdo->setChannelPSlope(chanHash, token);
562  } else {
563  // just set plsope to m_pslope for every channel
564  writeCdo->setChannelPSlope(chanHash, m_pslope);
565  }
566  return StatusCode::SUCCESS;
567 }
568 
569 // recordParameterRMS
571  float token;
572  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
573  writeCdo->setChannelRMS(chanHash, token);
574  return StatusCode::SUCCESS;
575 }
576 
577 // recordParameterStatus
579  unsigned int token;
580  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
581  writeCdo->setChannelStatus(chanHash, token);
582  return StatusCode::SUCCESS;
583 }
584 
585 // recordParameterT0Base
587  float token;
588  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
589  writeCdo->setChannelT0Base(chanHash, token);
590  return StatusCode::SUCCESS;
591 }
592 
593 // recordParameterT0Phase
595  bool token;
596  if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
597  writeCdo->setChannelT0Phase(chanHash, token);
598  return StatusCode::SUCCESS;
599 }
600 
601 /*
602 keep for future development:
603 
604 // loadDataDeadChambers
605 StatusCode
606 CscCondDbAlg::loadDataDeadChambers(writeHandle_t & writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
607 
608  ATH_CHECK(m_readKey_folder_da_chambers.initialize());
609  SG::ReadCondHandle<CondAttrListCollection> readHandle{m_readKey_folder_da_chambers, ctx};
610  const CondAttrListCollection* readCdo{*readHandle};
611  if(readCdo==0){
612  ATH_MSG_ERROR("Null pointer to the read conditions object");
613  return StatusCode::FAILURE;
614  }
615 
616  EventIDRange range;
617  if ( !readHandle.range(range) ) {
618  ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandle.key());
619  return StatusCode::FAILURE;
620  }
621 
622  //intersect validity range of this obj with the validity of already-loaded objs
623  rangeW = EventIDRange::intersect(range, rangeW);
624 
625  ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
626  ATH_MSG_DEBUG("Range of input is " << range << ", range of output is " << rangeW);
627 
628  std::vector<std::string> goodChambers;
629  std::vector<std::string> deadChambers;
630 
631  CondAttrListCollection::const_iterator itr;
632  for(itr = readCdo->begin(); itr != readCdo->end(); ++itr) {
633 
634  const coral::AttributeList& atr = itr->second;
635  std::string chamber_enabled = *(static_cast<const std::string*>((atr["enabledChambers"]).addressOfData()));
636 
637  std::string_view delimiter = " ";
638  std::vector<std::string> tokens = CxxUtils::tokenize(chamber_enabled, delimiter);
639 
640  for (unsigned int i=0; i<tokens.size(); i++) goodChambers.push_back(tokens[i]);
641  }
642 
643  std::string chamber_all[] = {"A01","A02","A03","A04","A05","A06","A07","A08","A09","A10","A11","A12","A13","A14","A15","A16",
644  "C01","C02","C03","C04","C05","C06","C07","C08","C09","C10","C11","C12","C13","C14","C15","C16"};
645  std::vector<std::string> chamber_v(chamber_all,chamber_all+32);
646  sort(chamber_v.begin(), chamber_v.end());
647 
648  for(unsigned int i=0; i<chamber_v.size(); ++i){
649  if(!binary_search(goodChambers.begin(), goodChambers.end(), chamber_v[i]))
650  deadChambers.push_back(chamber_v[i]);
651  }
652 
653  for(unsigned int i=0; i<deadChambers.size(); ++i){
654  int eta = 0;
655  std::string eta_side = deadChambers[i].substr(0,1);
656  if(eta_side == "A") eta = +1;
657  if(eta_side == "C") eta = -1;
658 
659  int phi = 0;
660  std::string sector_side = deadChambers[i].substr(2,4);
661  if(sector_side == "01" || sector_side == "02") phi=1;
662  if(sector_side == "03" || sector_side == "04") phi=2;
663  if(sector_side == "05" || sector_side == "06") phi=3;
664  if(sector_side == "07" || sector_side == "08") phi=4;
665  if(sector_side == "09" || sector_side == "10") phi=5;
666  if(sector_side == "11" || sector_side == "12") phi=6;
667  if(sector_side == "13" || sector_side == "14") phi=7;
668  if(sector_side == "15" || sector_side == "16") phi=8;
669 
670  std::string chamber_name = "";
671  if(sector_side == "01" || sector_side == "03" ||sector_side == "05" ||sector_side == "07" || sector_side == "09" || sector_side ==
672 "11" || sector_side == "13" || sector_side == "15" ) chamber_name = "CSL"; if(sector_side == "02" || sector_side == "04" || sector_side ==
673 "06"|| sector_side == "08" || sector_side == "10"|| sector_side == "12"|| sector_side == "14"|| sector_side == "16") chamber_name = "CSS";
674 
675  Identifier ChamberId = m_idHelperSvc->cscIdHelper().elementID(chamber_name, eta, phi);
676  writeCdo->setDeadStation(deadChambers[i], ChamberId);
677  }
678 
679  return StatusCode::SUCCESS;
680 }
681 */
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Muon::nsw::STGTPSegments::moduleIDBits::stationPhi
constexpr uint8_t stationPhi
station Phi 1 to 8
Definition: NSWSTGTPDecodeBitmaps.h:129
CondAttrListCollection::end
const_iterator end() const
Definition: CondAttrListCollection.h:315
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
CscCondDbAlg::recordParameterT0Phase
StatusCode recordParameterT0Phase(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:594
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
CscCondDbAlg::recordParameter
StatusCode recordParameter(unsigned int, const std::string &, CscCondDbData *, const std::string &) const
Definition: CscCondDbAlg.cxx:483
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
CscCondDbAlg::loadDataF001
StatusCode loadDataF001(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:178
CscCondDbAlg::m_readKey_folder_da_t0base
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_t0base
Definition: CscCondDbAlg.h:91
dumpTgcDigiDeadChambers.stationName
dictionary stationName
Definition: dumpTgcDigiDeadChambers.py:30
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
index
Definition: index.py:1
CscCondDbData::setChannelNoise
void setChannelNoise(IdentifierHash, float)
Definition: CscCondDbData.cxx:68
CxxUtils::tokenize
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
Definition: Control/CxxUtils/Root/StringUtils.cxx:15
CscCondDbAlg.h
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition: WriteCondHandle.h:89
CscCondDbAlg::m_isOnline
Gaudi::Property< bool > m_isOnline
Definition: CscCondDbAlg.h:67
CscCondDbData::setChannelPSlope
void setChannelPSlope(IdentifierHash, float)
Definition: CscCondDbData.cxx:80
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition: CondAttrListCollection.h:309
CscCondDbAlg::recordParameterT0Base
StatusCode recordParameterT0Base(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:586
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CscCondDbAlg::recordParameterPed
StatusCode recordParameterPed(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:549
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
CscCondDbAlg::m_readKey_folder_da_ped
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_ped
Definition: CscCondDbAlg.h:83
CscCondDbAlg::m_readKey_folder_da_hv
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_hv
Definition: CscCondDbAlg.h:77
CscCondDbAlg::loadDataPSlope
StatusCode loadDataPSlope(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:199
CscCondDbAlg::m_onlineOfflinePhiFlip
Gaudi::Property< bool > m_onlineOfflinePhiFlip
Definition: CscCondDbAlg.h:70
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
CscCondDbAlg::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: CscCondDbAlg.h:73
CscCondDbAlg::m_pslope
Gaudi::Property< float > m_pslope
Definition: CscCondDbAlg.h:111
createDCubeDigitHistograms_withSel.chamber_name
chamber_name
Definition: createDCubeDigitHistograms_withSel.py:109
CscCondDbAlg::CscCondDbAlg
CscCondDbAlg(const std::string &name, ISvcLocator *svc)
Definition: CscCondDbAlg.cxx:14
CscCondDbAlg::m_readKey_folder_da_noise
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_noise
Definition: CscCondDbAlg.h:81
CscCondDbAlg::recordParameterRMS
StatusCode recordParameterRMS(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:570
CscCondDbAlg::m_isData
Gaudi::Property< bool > m_isData
Definition: CscCondDbAlg.h:68
CscCondDbData::setChannelRMS
void setChannelRMS(IdentifierHash, float)
Definition: CscCondDbData.cxx:86
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
checkCoolLatestUpdate.chanNum
chanNum
Definition: checkCoolLatestUpdate.py:27
CscCondDbData::setChannelPed
void setChannelPed(IdentifierHash, float)
Definition: CscCondDbData.cxx:74
CscCondDbAlg::m_pslopeFromDB
Gaudi::Property< bool > m_pslopeFromDB
The pslope is the gain of each CSC channel.
Definition: CscCondDbAlg.h:103
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
CscCondDbAlg::m_writeKey
SG::WriteCondHandleKey< CscCondDbData > m_writeKey
Definition: CscCondDbAlg.h:75
CscCondDbAlg::loadDataRMS
StatusCode loadDataRMS(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:206
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
CscCondDbAlg::loadDataNoise
StatusCode loadDataNoise(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:185
CscCondDbAlg::cache
StatusCode cache(const std::string &, CscCondDbData *, const std::string &) const
Definition: CscCondDbAlg.cxx:291
CscCondDbData::setChannelT0Phase
void setChannelT0Phase(IdentifierHash, bool)
Definition: CscCondDbData.cxx:105
beamspotnt.parName
list parName
Definition: bin/beamspotnt.py:1287
CscCondDbData::setChannelStatus
void setChannelStatus(IdentifierHash, int)
Definition: CscCondDbData.cxx:92
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CscCondDbAlg::m_readKey_folder_da_pslope
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_pslope
Definition: CscCondDbAlg.h:85
CscCondDbData::setDeadStation
void setDeadStation(std::string_view, Identifier)
Definition: CscCondDbData.cxx:130
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
CscCondDbAlg::cacheASM
StatusCode cacheASM(const std::string &, CscCondDbData *, const std::string &) const
Definition: CscCondDbAlg.cxx:326
CscCondDbData::setDeadLayer
void setDeadLayer(std::string_view, Identifier)
Definition: CscCondDbData.cxx:122
CscCondDbAlg::loadDataStatus
StatusCode loadDataStatus(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:213
CscCondDbAlg::loadDataPed
StatusCode loadDataPed(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:192
CscCondDbAlg::getParameter
StatusCode getParameter(IdentifierHash chanHash, std::string data, T &token) const
Definition: CscCondDbAlg.h:115
IOVInfiniteRange.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CscCondDbAlg::m_readKey_folder_da_f001
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_f001
Definition: CscCondDbAlg.h:79
CscCondDbAlg::loadData
StatusCode loadData(CscCondDbData *, const CondAttrListCollection *, const std::string &, bool=false) const
Definition: CscCondDbAlg.cxx:234
CscCondDbData::setChannelF001
void setChannelF001(IdentifierHash, float)
Definition: CscCondDbData.cxx:62
CscCondDbAlg::loadDataHv
StatusCode loadDataHv(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:98
get_generator_info.version
version
Definition: get_generator_info.py:33
CscCondDbAlg::recordParameterF001
StatusCode recordParameterF001(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:533
CscCondDbAlg::m_readKey_folder_da_t0phase
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_t0phase
Definition: CscCondDbAlg.h:93
CscCondDbAlg::getAsmScope
StatusCode getAsmScope(int, int &, int &, int &, int &, int &) const
Definition: CscCondDbAlg.cxx:441
CscCondDbData::onlineToOfflineIds
StatusCode onlineToOfflineIds(const CscIdHelper *, const unsigned int &, Identifier &, Identifier &) const
Definition: CscCondDbData.cxx:483
CscCondDbAlg::execute
virtual StatusCode execute(const EventContext &) const override
Definition: CscCondDbAlg.cxx:53
Identifier::get_compact
value_type get_compact(void) const
Get the compact id.
CscCondDbAlg::m_readKey_folder_da_status
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_status
Definition: CscCondDbAlg.h:89
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
CscCondDbAlg::initialize
virtual StatusCode initialize() override
Definition: CscCondDbAlg.cxx:18
CscCondDbAlg::recordParameterNoise
StatusCode recordParameterNoise(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:541
CscCondDbAlg::m_readKey_folder_da_rms
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_rms
Definition: CscCondDbAlg.h:87
CscCondDbAlg::recordParameterStatus
StatusCode recordParameterStatus(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:578
CscCondDbAlg::m_DEFAULT_PSLOPE
const float m_DEFAULT_PSLOPE
The CSC gain was originally 5.304 ADC counts per fC, but later increased to 5.7 ADC counts per fC,...
Definition: CscCondDbAlg.h:110
CscCondDbAlg::loadDataT0Phase
StatusCode loadDataT0Phase(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:227
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
CscCondDbAlg::m_defaultDatabaseReadVersion
Gaudi::Property< std::string > m_defaultDatabaseReadVersion
Definition: CscCondDbAlg.h:71
Muon::nsw::STGTPSegments::moduleIDBits::stationEta
constexpr uint8_t stationEta
1 to 3
Definition: NSWSTGTPDecodeBitmaps.h:127
IdentifierHash
Definition: IdentifierHash.h:38
CscCondDbAlg::recordParameterPSlope
StatusCode recordParameterPSlope(IdentifierHash, std::string, CscCondDbData *) const
Definition: CscCondDbAlg.cxx:557
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
CscCondDbAlg::loadDataT0Base
StatusCode loadDataT0Base(writeHandle_t &, CscCondDbData *, const EventContext &) const
Definition: CscCondDbAlg.cxx:220
CscCondDbData::setChannelT0Base
void setChannelT0Base(IdentifierHash, float)
Definition: CscCondDbData.cxx:99
CscCondDbData
Definition: CscCondDbData.h:24
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275