ATLAS Offline Software
Loading...
Searching...
No Matches
CscCondDbAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include <utility>
6
7
8
10
12
13// constructor
14CscCondDbAlg::CscCondDbAlg(const std::string& name, ISvcLocator* pSvcLocator) :
15 AthCondAlgorithm(name, pSvcLocator) {}
16
17// Initialize
19 ATH_MSG_DEBUG("initializing " << name());
20 ATH_CHECK(m_idHelperSvc.retrieve());
21 ATH_CHECK(m_writeKey.initialize());
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
53StatusCode 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
98StatusCode 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
178StatusCode 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
185StatusCode 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
192StatusCode 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
199StatusCode 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
206StatusCode 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
213StatusCode 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
220StatusCode 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
227StatusCode 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
234StatusCode 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
291StatusCode 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
326StatusCode 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
441StatusCode 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
483StatusCode CscCondDbAlg::recordParameter(unsigned int chanAddress, const std::string& data, CscCondDbData* writeCdo,
484 const std::string& parName) const {
485 // retrieve channel hash
486 Identifier chamberId;
487 Identifier channelId;
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
506StatusCode CscCondDbAlg::recordParameter(IdentifierHash chanHash, const std::string& data, CscCondDbData* writeCdo,
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
533StatusCode CscCondDbAlg::recordParameterF001(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
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
541StatusCode CscCondDbAlg::recordParameterNoise(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
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
549StatusCode CscCondDbAlg::recordParameterPed(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
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
557StatusCode CscCondDbAlg::recordParameterPSlope(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
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
570StatusCode CscCondDbAlg::recordParameterRMS(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
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
578StatusCode CscCondDbAlg::recordParameterStatus(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
579 int token{};
580 if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
581 //setChannelStatus takes signed int token argument
582 writeCdo->setChannelStatus(chanHash, token);
583 return StatusCode::SUCCESS;
584}
585
586// recordParameterT0Base
587StatusCode CscCondDbAlg::recordParameterT0Base(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
588 float token;
589 if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
590 writeCdo->setChannelT0Base(chanHash, token);
591 return StatusCode::SUCCESS;
592}
593
594// recordParameterT0Phase
595StatusCode CscCondDbAlg::recordParameterT0Phase(IdentifierHash chanHash, std::string data, CscCondDbData* writeCdo) const {
596 bool token;
597 if (getParameter(chanHash, std::move(data), token).isFailure()) return StatusCode::FAILURE;
598 writeCdo->setChannelT0Phase(chanHash, token);
599 return StatusCode::SUCCESS;
600}
601
602/*
603keep for future development:
604
605// loadDataDeadChambers
606StatusCode
607CscCondDbAlg::loadDataDeadChambers(writeHandle_t & writeHandle, CscCondDbData* writeCdo, const EventContext& ctx) const {
608
609 ATH_CHECK(m_readKey_folder_da_chambers.initialize());
610 SG::ReadCondHandle<CondAttrListCollection> readHandle{m_readKey_folder_da_chambers, ctx};
611 const CondAttrListCollection* readCdo{*readHandle};
612 if(readCdo==0){
613 ATH_MSG_ERROR("Null pointer to the read conditions object");
614 return StatusCode::FAILURE;
615 }
616
617 EventIDRange range;
618 if ( !readHandle.range(range) ) {
619 ATH_MSG_ERROR("Failed to retrieve validity range for " << readHandle.key());
620 return StatusCode::FAILURE;
621 }
622
623 //intersect validity range of this obj with the validity of already-loaded objs
624 rangeW = EventIDRange::intersect(range, rangeW);
625
626 ATH_MSG_DEBUG("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
627 ATH_MSG_DEBUG("Range of input is " << range << ", range of output is " << rangeW);
628
629 std::vector<std::string> goodChambers;
630 std::vector<std::string> deadChambers;
631
632 CondAttrListCollection::const_iterator itr;
633 for(itr = readCdo->begin(); itr != readCdo->end(); ++itr) {
634
635 const coral::AttributeList& atr = itr->second;
636 std::string chamber_enabled = *(static_cast<const std::string*>((atr["enabledChambers"]).addressOfData()));
637
638 std::string_view delimiter = " ";
639 std::vector<std::string> tokens = CxxUtils::tokenize(chamber_enabled, delimiter);
640
641 for (unsigned int i=0; i<tokens.size(); i++) goodChambers.push_back(tokens[i]);
642 }
643
644 std::string chamber_all[] = {"A01","A02","A03","A04","A05","A06","A07","A08","A09","A10","A11","A12","A13","A14","A15","A16",
645 "C01","C02","C03","C04","C05","C06","C07","C08","C09","C10","C11","C12","C13","C14","C15","C16"};
646 std::vector<std::string> chamber_v(chamber_all,chamber_all+32);
647 sort(chamber_v.begin(), chamber_v.end());
648
649 for(unsigned int i=0; i<chamber_v.size(); ++i){
650 if(!binary_search(goodChambers.begin(), goodChambers.end(), chamber_v[i]))
651 deadChambers.push_back(chamber_v[i]);
652 }
653
654 for(unsigned int i=0; i<deadChambers.size(); ++i){
655 int eta = 0;
656 std::string eta_side = deadChambers[i].substr(0,1);
657 if(eta_side == "A") eta = +1;
658 if(eta_side == "C") eta = -1;
659
660 int phi = 0;
661 std::string sector_side = deadChambers[i].substr(2,4);
662 if(sector_side == "01" || sector_side == "02") phi=1;
663 if(sector_side == "03" || sector_side == "04") phi=2;
664 if(sector_side == "05" || sector_side == "06") phi=3;
665 if(sector_side == "07" || sector_side == "08") phi=4;
666 if(sector_side == "09" || sector_side == "10") phi=5;
667 if(sector_side == "11" || sector_side == "12") phi=6;
668 if(sector_side == "13" || sector_side == "14") phi=7;
669 if(sector_side == "15" || sector_side == "16") phi=8;
670
671 std::string chamber_name = "";
672 if(sector_side == "01" || sector_side == "03" ||sector_side == "05" ||sector_side == "07" || sector_side == "09" || sector_side ==
673"11" || sector_side == "13" || sector_side == "15" ) chamber_name = "CSL"; if(sector_side == "02" || sector_side == "04" || sector_side ==
674"06"|| sector_side == "08" || sector_side == "10"|| sector_side == "12"|| sector_side == "14"|| sector_side == "16") chamber_name = "CSS";
675
676 Identifier ChamberId = m_idHelperSvc->cscIdHelper().elementID(chamber_name, eta, phi);
677 writeCdo->setDeadStation(deadChambers[i], ChamberId);
678 }
679
680 return StatusCode::SUCCESS;
681}
682*/
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition AtlasPID.h:878
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t ss
static Double_t sc
Base class for conditions algorithms.
This class is a collection of AttributeLists where each one is associated with a channel number.
ChanNum chanNum(unsigned int index) const
channel number for index: (index = 0 to size-1)
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
const std::string & chanName(ChanNum chanNum) const
find name for particular channel
size_type size() const
number of Chan/AttributeList pairs
ChanAttrListMap::const_iterator const_iterator
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_rms
StatusCode recordParameterT0Phase(IdentifierHash, std::string, CscCondDbData *) const
StatusCode recordParameterRMS(IdentifierHash, std::string, CscCondDbData *) const
StatusCode loadDataPSlope(writeHandle_t &, CscCondDbData *, const EventContext &) const
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
StatusCode loadDataHv(writeHandle_t &, CscCondDbData *, const EventContext &) const
CscCondDbAlg(const std::string &name, ISvcLocator *svc)
StatusCode recordParameter(unsigned int, const std::string &, CscCondDbData *, const std::string &) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_status
StatusCode recordParameterPed(IdentifierHash, std::string, CscCondDbData *) const
StatusCode cacheASM(const std::string &, CscCondDbData *, const std::string &) const
Gaudi::Property< float > m_pslope
StatusCode loadDataT0Base(writeHandle_t &, CscCondDbData *, const EventContext &) const
virtual StatusCode execute(const EventContext &) const override
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_t0base
StatusCode loadDataStatus(writeHandle_t &, CscCondDbData *, const EventContext &) const
virtual StatusCode initialize() override
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_noise
SG::WriteCondHandle< CscCondDbData > writeHandle_t
StatusCode cache(const std::string &, CscCondDbData *, const std::string &) const
StatusCode recordParameterF001(IdentifierHash, std::string, CscCondDbData *) const
Gaudi::Property< bool > m_pslopeFromDB
The pslope is the gain of each CSC channel.
SG::WriteCondHandleKey< CscCondDbData > m_writeKey
Gaudi::Property< bool > m_onlineOfflinePhiFlip
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_t0phase
StatusCode getAsmScope(int, int &, int &, int &, int &, int &) const
StatusCode recordParameterT0Base(IdentifierHash, std::string, CscCondDbData *) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_ped
StatusCode recordParameterStatus(IdentifierHash, std::string, CscCondDbData *) const
Gaudi::Property< bool > m_isData
StatusCode loadDataF001(writeHandle_t &, CscCondDbData *, const EventContext &) const
StatusCode loadDataNoise(writeHandle_t &, CscCondDbData *, const EventContext &) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_pslope
StatusCode getParameter(IdentifierHash chanHash, std::string data, T &token) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_hv
StatusCode loadDataT0Phase(writeHandle_t &, CscCondDbData *, const EventContext &) const
StatusCode loadDataPed(writeHandle_t &, CscCondDbData *, const EventContext &) const
Gaudi::Property< std::string > m_defaultDatabaseReadVersion
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,...
StatusCode loadDataRMS(writeHandle_t &, CscCondDbData *, const EventContext &) const
StatusCode loadData(CscCondDbData *, const CondAttrListCollection *, const std::string &, bool=false) const
StatusCode recordParameterNoise(IdentifierHash, std::string, CscCondDbData *) const
Gaudi::Property< bool > m_isOnline
StatusCode recordParameterPSlope(IdentifierHash, std::string, CscCondDbData *) const
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_folder_da_f001
StatusCode onlineToOfflineIds(const CscIdHelper *, const unsigned int &, Identifier &, Identifier &) const
void setChannelStatus(IdentifierHash, int)
void setDeadLayer(std::string_view, Identifier)
void setChannelT0Phase(IdentifierHash, bool)
void setChannelRMS(IdentifierHash, float)
void setDeadStation(std::string_view, Identifier)
void setChannelNoise(IdentifierHash, float)
void setChannelPSlope(IdentifierHash, float)
void setChannelF001(IdentifierHash, float)
void setChannelT0Base(IdentifierHash, float)
void setChannelPed(IdentifierHash, float)
This is a "hash" representation of an Identifier.
value_type get_compact() const
Get the compact id.
const DataObjID & fullKey() const
const EventIDRange & getRange()
const std::string & key() const
void addDependency(const EventIDRange &range)
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...
Definition index.py:1