ATLAS Offline Software
Loading...
Searching...
No Matches
SCTCalibWriteTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
13
14// Athena includes
16#include "CoralBase/Attribute.h"
17
19#include "Identifier/Identifier.h"
21
22//path resolver to find the file
24
25// Gaudi includes
26#include "GaudiKernel/StatusCode.h"
27#include "GaudiKernel/IToolSvc.h"
28
29#include <sstream>
30
32const std::string SCTCalibWriteTool::s_separator{"-"};
33const std::string SCTCalibWriteTool::s_defectFolderName{"/SCT/Derived/Monitoring"};
34const std::string SCTCalibWriteTool::s_deadStripFolderName{"/SCT/Derived/DeadStrips"};
35const std::string SCTCalibWriteTool::s_deadChipFolderName{"/SCT/Derived/DeadChips"};
36const std::string SCTCalibWriteTool::s_effFolderName{"/SCT/Derived/Efficiency"};
37const std::string SCTCalibWriteTool::s_noFolderName{"/SCT/Derived/NoiseOccupancy"};
38const std::string SCTCalibWriteTool::s_RawOccuFolderName{"/SCT/Derived/RawOccupancy"};
39const std::string SCTCalibWriteTool::s_BSErrFolderName{"/SCT/Derived/BSErrorsRun2"};
40const std::string SCTCalibWriteTool::s_LAFolderName{"/SCT/Derived/LorentzAngleRun2_v2"};
41
42const bool becCapsFormat{true};
43const bool becUnderscoreFormat{false};
44
45SCTCalibWriteTool::SCTCalibWriteTool(const std::string& type, const std::string& name, const IInterface* parent) :
46 AthAlgTool(type, name, parent),
47 m_regSvc("IOVRegistrationSvc", name),
48 m_streamer(((m_version == 0) ? "AthenaOutputStreamTool" : "AthenaPoolOutputStreamTool"), this),
49 m_IOVDbSvc("IOVDbSvc", name)
50{
51}
52
54
55StatusCode
57{
58
59 ATH_MSG_DEBUG("in SCTCalibWriteTool::initialize start");
60
61 ATH_CHECK( detStore()->retrieve(m_pHelper,"SCT_ID") );
62
63 // ------------------------------------------------------------
64 // The following is required for writing out something to COOL
65
66 // CondAttrListCollection to store table temporarily
67 m_attrListColl = std::make_unique<CondAttrListCollection>(true);
68 m_attrListColl_deadStrip = std::make_unique<CondAttrListCollection>(true);
69 m_attrListColl_deadChip = std::make_unique<CondAttrListCollection>(true);
70 m_attrListColl_eff = std::make_unique<CondAttrListCollection>(true);
71 m_attrListColl_no = std::make_unique<CondAttrListCollection>(true);
72 m_attrListColl_RawOccu = std::make_unique<CondAttrListCollection>(true);
73 m_attrListColl_BSErr = std::make_unique<CondAttrListCollection>(true);
74 m_attrListColl_LA = std::make_unique<CondAttrListCollection>(true);
75
76 // Get the IOVRegistrationSvc when needed
77 if (m_regIOV) {
78 ATH_CHECK( m_regSvc.retrieve() );
79 }
80
81 // Retrieve IOVDb service
82 ATH_CHECK( m_IOVDbSvc.retrieve() );
83
84 return StatusCode::SUCCESS;
85}
86
88
89unsigned int
91 unsigned int iiside{static_cast<unsigned int>(m_pHelper->side(elementId))};
92 unsigned int iistrip{static_cast<unsigned int>(m_pHelper->strip(elementId))};
93 return 768*iiside + iistrip;
94}
95
97
99// Local stuff
101
102std::string
103SCTCalibWriteTool::addDefect(const std::string& defectlist, const int defectBeginChannel, const int defectEndChannel) const {
104 // check size of defect list,
105 // if it is empty then use createDefectString to make first entry.
106 if (defectlist.empty()) return createDefectString(defectBeginChannel, defectEndChannel);
107
108 // adding another Defect in DefectList
109 std::ostringstream defect;
110 defect << defectlist << " " << defectBeginChannel;
111 if (defectBeginChannel==defectEndChannel) {
112 defect << " ";
113 } else {
114 defect << "-" << defectEndChannel << " ";
115 }
116 return defect.str();
117}
118
120
121std::string
122SCTCalibWriteTool::createDefectString(const int defectBeginChannel, const int defectEndChannel) const {
123 std::ostringstream defect;
124 defect << " " << defectBeginChannel;
125 if (defectBeginChannel!=defectEndChannel) {
126 defect << "-" << defectEndChannel;
127 }
128 defect << " ";
129 return defect.str();
130}
131
132
134
135std::string
136SCTCalibWriteTool::addNumber(const std::string& numStr, const unsigned long long number) const {
137 std::ostringstream num_string;
138 // if it is empty then use createDefectString to make first entry.
139 if (numStr.empty()) {
140 num_string << number;
141 } else { // adding another number to numStr
142 num_string << numStr << " " << number;
143 }
144 return num_string.str();
145}
146
148
149StatusCode
150SCTCalibWriteTool::createCondObjects ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
151(const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const std::string& defectType, const float threshold, const std::string& defectList) const {
152 if (!m_writeCondObjs) {
153 return StatusCode::SUCCESS;
154 }
155 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becCapsFormat)};
156 attrSpec->extend("DefectType", "string");
157 attrSpec->extend("Threshold", "float");
158 attrSpec->extend("DefectList", "string");
159
160 if (!attrSpec->size()) {
161 ATH_MSG_ERROR(" Attribute list specification is empty");
162 return StatusCode::FAILURE;
163 }
164
165 coral::AttributeList attrList0{*attrSpec};
166 setBasicValues(attrList0, wafer_id, samplesize,sctId,becCapsFormat);
167 attrList0["DefectType"].setValue(static_cast<std::string>(defectType));
168 attrList0["Threshold"].setValue(static_cast<float>(threshold));
169 attrList0["DefectList"].setValue(static_cast<std::string>(defectList));
170 std::ostringstream attrStr2;
171 attrList0.toOutputStream(attrStr2);
172 m_attrListColl->add(wafer_id.get_identifier32().get_compact(), attrList0);
173 return StatusCode::SUCCESS;
174}
175
177
178StatusCode
179SCTCalibWriteTool::createListStrip ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
180(const Identifier& wafer_id,
181 const SCT_ID* sctId,
182 const int samplesize,
183 const std::string& defectType,
184 const float threshold,
185 const std::string& defectList) const
186{
187 if (!m_writeCondObjs) {
188 return StatusCode::SUCCESS;
189 }
190 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becCapsFormat)};
191 attrSpec->extend("DefectType", "string");
192 attrSpec->extend("Threshold", "float");
193 attrSpec->extend("DefectList", "string");
194
195 if (!attrSpec->size()) {
196 ATH_MSG_ERROR(" Attribute list specification is empty");
197 return StatusCode::FAILURE;
198 }
199
200 coral::AttributeList attrList0{*attrSpec};
201 setBasicValues(attrList0, wafer_id, samplesize, sctId, becCapsFormat);
202 attrList0["DefectType"].setValue(static_cast<std::string>(defectType));
203 attrList0["Threshold"].setValue(static_cast<float>(threshold));
204 attrList0["DefectList"].setValue(static_cast<std::string>(defectList));
205
206 std::ostringstream attrStr2;
207 attrList0.toOutputStream(attrStr2);
208 m_attrListColl_deadStrip->add(wafer_id.get_identifier32().get_compact(), attrList0);
209 return StatusCode::SUCCESS;
210}
211
213
214StatusCode
215SCTCalibWriteTool::createListChip ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
216(const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const std::string& defectType, const float threshold, const std::string& defectList) const {
217 if (!m_writeCondObjs) {
218 return StatusCode::SUCCESS;
219 }
220 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becCapsFormat)};
221 attrSpec->extend("DefectType", "string");
222 attrSpec->extend("Threshold", "float");
223 attrSpec->extend("DefectList", "string");
224 if (!attrSpec->size()) {
225 ATH_MSG_ERROR(" Attribute list specification is empty");
226 return StatusCode::FAILURE;
227 }
228
229 coral::AttributeList attrList0{*attrSpec};
230 setBasicValues(attrList0, wafer_id, samplesize, sctId, becCapsFormat);
231 attrList0["DefectType"].setValue(static_cast<std::string>(defectType));
232 attrList0["Threshold"].setValue(static_cast<float>(threshold));
233 attrList0["DefectList"].setValue(static_cast<std::string>(defectList));
234
235 std::ostringstream attrStr2;
236 attrList0.toOutputStream(attrStr2);
237 m_attrListColl_deadChip->add(wafer_id.get_identifier32().get_compact(), attrList0);
238
239 return StatusCode::SUCCESS;
240}
241
243
244StatusCode
245SCTCalibWriteTool::createListEff ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
246(const Identifier& wafer_id,const SCT_ID* sctId, const int samplesize, const float eff) const {
247 if (!m_writeCondObjs) {
248 return StatusCode::SUCCESS;
249 }
250
251 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
252 attrSpec->extend("Efficiency", "float");
253 if (!attrSpec->size()) {
254 ATH_MSG_ERROR(" Attribute list specification is empty");
255 return StatusCode::FAILURE;
256 }
257
258 coral::AttributeList attrList0{*attrSpec};
259 setBasicValues(attrList0, wafer_id, samplesize,sctId,becUnderscoreFormat);
260 attrList0["Efficiency"].setValue(static_cast<float>(eff));
261
262 std::ostringstream attrStr2;
263 attrList0.toOutputStream(attrStr2);
264 m_attrListColl_eff->add(wafer_id.get_identifier32().get_compact(), attrList0);
265
266 return StatusCode::SUCCESS;
267}
268
270
271StatusCode
272SCTCalibWriteTool::createListNO ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
273(const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const float noise_occ) const {
274 if (!m_writeCondObjs) {
275 return StatusCode::SUCCESS;
276 }
277
278 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
279 attrSpec->extend("NoiseOccupancy", "float");
280 if (!attrSpec->size()) {
281 ATH_MSG_ERROR(" Attribute list specification is empty");
282 return StatusCode::FAILURE;
283 }
284
285 coral::AttributeList attrList0{*attrSpec};
286 setBasicValues(attrList0, wafer_id, samplesize, sctId, becUnderscoreFormat);
287 attrList0["NoiseOccupancy"].setValue(static_cast<float>(noise_occ));
288
289 std::ostringstream attrStr2;
290 attrList0.toOutputStream(attrStr2);
291 m_attrListColl_no->add(wafer_id.get_identifier32().get_compact(), attrList0);
292
293 return StatusCode::SUCCESS;
294}
295
297
298StatusCode
299SCTCalibWriteTool::createListRawOccu ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
300(const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const float raw_occu) const {
301 if (!m_writeCondObjs) {
302 return StatusCode::SUCCESS;
303 }
304
305 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
306 attrSpec->extend("RawOccupancy", "float");
307 if (!attrSpec->size()) {
308 ATH_MSG_ERROR(" Attribute list specification is empty");
309 return StatusCode::FAILURE;
310 }
311
312 coral::AttributeList attrList0{*attrSpec};
313 setBasicValues(attrList0, wafer_id, samplesize, sctId, becUnderscoreFormat);
314 attrList0["RawOccupancy"].setValue(static_cast<float>(raw_occu));
315
316 std::ostringstream attrStr2;
317 attrList0.toOutputStream(attrStr2);
318 m_attrListColl_RawOccu->add(wafer_id.get_identifier32().get_compact(), attrList0);
319 return StatusCode::SUCCESS;
320}
321
323
324StatusCode
325SCTCalibWriteTool::createListBSErr ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
326(const Identifier& wafer_id,const SCT_ID* sctId,const int samplesize, const std::string& errorList, const std::string& probList) const {
327 if (!m_writeCondObjs) {
328 return StatusCode::SUCCESS;
329 }
330
331 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
332 attrSpec->extend("BSErrors", "string");
333 attrSpec->extend("BadFraction", "string");
334
335 if (!attrSpec->size()) {
336 ATH_MSG_ERROR(" Attribute list specification is empty");
337 return StatusCode::FAILURE;
338 }
339
340 coral::AttributeList attrList0{*attrSpec};
341 setBasicValues(attrList0, wafer_id, samplesize, sctId, becUnderscoreFormat);
342 attrList0["BSErrors"].setValue(static_cast<std::string>(errorList));
343 attrList0["BadFraction"].setValue(static_cast<std::string>(probList));
344
345 std::ostringstream attrStr2;
346 attrList0.toOutputStream(attrStr2);
347 m_attrListColl_BSErr->add(wafer_id.get_identifier32().get_compact(), attrList0);
348 return StatusCode::SUCCESS;
349}
350
352
353StatusCode
354SCTCalibWriteTool::createListLA ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
355(const Identifier& wafer_id,const SCT_ID* sctId,const int samplesize,int module, const float lorentz, const float err_lorentz, const float chisq, const float fitParam_a, const float err_a, const float fitParam_b, const float err_b, const float fitParam_sigma, const float err_sigma, const float MCW, const float err_MCW) const {
356 if (!m_writeCondObjs) return StatusCode::SUCCESS;
357 int barrel_ec{sctId->barrel_ec(wafer_id)};
358 int layer{sctId->layer_disk(wafer_id)};
359 int side{sctId->side(wafer_id)};
360
361 coral::AttributeListSpecification* attrSpec{new coral::AttributeListSpecification{}};
362 attrSpec->extend("SampleSize", "int");
363 attrSpec->extend("barrel_endcap", "int");
364 attrSpec->extend("Layer", "int");
365 attrSpec->extend("Side", "int");
366 attrSpec->extend("moduleType", "int");
367 attrSpec->extend("lorentzAngle", "float");
368 attrSpec->extend("err_lorentzAngle", "float");
369 attrSpec->extend("chisq", "float");
370 attrSpec->extend("fitParam_a", "float");
371 attrSpec->extend("err_a", "float");
372 attrSpec->extend("fitParam_b", "float");
373 attrSpec->extend("err_b", "float");
374 attrSpec->extend("fitParam_sigma", "float");
375 attrSpec->extend("err_sigma", "float");
376 attrSpec->extend("minClusterWidth", "float");
377 attrSpec->extend("err_minClusterWidth", "float");
378
379 if (!attrSpec->size()) {
380 ATH_MSG_ERROR(" Attribute list specification is empty");
381 return StatusCode::FAILURE;
382 }
383
384 // Add three attr lists
385 coral::AttributeList attrList0{*attrSpec};
386 attrList0["SampleSize"].setValue(static_cast<int>(samplesize));
387 attrList0["barrel_endcap"].setValue(static_cast<int>(barrel_ec));
388 attrList0["Layer"].setValue(static_cast<int>(layer));
389 attrList0["Side"].setValue(static_cast<int>(side));
390 attrList0["moduleType"].setValue(static_cast<int>(module));
391 attrList0["lorentzAngle"].setValue(static_cast<float>(lorentz));
392 attrList0["err_lorentzAngle"].setValue(static_cast<float>(err_lorentz));
393 attrList0["chisq"].setValue(static_cast<float>(chisq));
394 attrList0["fitParam_a"].setValue(static_cast<float>(fitParam_a));
395 attrList0["err_a"].setValue(static_cast<float>(err_a));
396 attrList0["fitParam_b"].setValue(static_cast<float>(fitParam_b));
397 attrList0["err_b"].setValue(static_cast<float>(err_b));
398 attrList0["fitParam_sigma"].setValue(static_cast<float>(fitParam_sigma));
399 attrList0["err_sigma"].setValue(static_cast<float>(err_sigma));
400 attrList0["minClusterWidth"].setValue(static_cast<float>(MCW));
401 attrList0["err_minClusterWidth"].setValue(static_cast<float>(err_MCW));
402
403 std::ostringstream attrStr2;
404 attrList0.toOutputStream(attrStr2);
405 m_attrListColl_LA->add(wafer_id.get_identifier32().get_compact(), attrList0);
406
407 return StatusCode::SUCCESS;
408}
409
411
413SCTCalibWriteTool::getAttrListCollectionByFolder(const std::string& foldername) const {
414 std::lock_guard<std::mutex> lock{m_mutex};
415 // trying to find the pointer in the hashmap
416 // if it exists, return it, otherwise put it in.
417 const CondAttrListCollection* attrListCollection{nullptr};
418 if (m_attrListCollectionMap.count(foldername) == 0) {
419 if (detStore()->retrieve(attrListCollection, foldername).isFailure()) {
420 ATH_MSG_ERROR("Could not retrieve " << foldername);
421 return nullptr;
422 }
423 m_attrListCollectionMap.insert(make_pair(foldername, attrListCollection));
424 } else {
425 attrListCollection = m_attrListCollectionMap[foldername];
426 }
427 return attrListCollection;
428}
429
431
432int
433SCTCalibWriteTool::stringToInt(const std::string& s) const {
434 return atoi(s.c_str());
435}
436
438
439StatusCode
441 if (recordAndStream(std::move(m_attrListColl), s_defectFolderName, m_defectRecorded).isFailure()) return StatusCode::FAILURE;
442 if (registerCondObjectsWithErrMsg(s_defectFolderName, m_tagID4NoisyStrips).isFailure()) return StatusCode::FAILURE;
443 return StatusCode::SUCCESS;
444}
445
447
448StatusCode
450 if (recordAndStream(std::move(m_attrListColl_deadStrip), s_deadStripFolderName, m_deadStripRecorded).isFailure()) return StatusCode::FAILURE;
451 if (registerCondObjectsWithErrMsg(s_deadStripFolderName, m_tagID4DeadStrips).isFailure()) return StatusCode::FAILURE;
452 return StatusCode::SUCCESS;
453}
454
456StatusCode
457
459 if (recordAndStream(std::move(m_attrListColl_deadChip), s_deadChipFolderName, m_deadChipRecorded).isFailure()) return StatusCode::FAILURE;
460 if (registerCondObjectsWithErrMsg(s_deadChipFolderName, m_tagID4DeadChips).isFailure()) return StatusCode::FAILURE;
461 return StatusCode::SUCCESS;
462}
463
465
466StatusCode
468 if (recordAndStream(std::move(m_attrListColl_eff), s_effFolderName, m_effRecorded).isFailure()) return StatusCode::FAILURE;
469 if (registerCondObjectsWithErrMsg(s_effFolderName, m_tagID4Efficiency).isFailure()) return StatusCode::FAILURE;
470 return StatusCode::SUCCESS;
471}
472
474
475StatusCode
477 if (recordAndStream(std::move(m_attrListColl_no), s_noFolderName, m_noRecorded).isFailure()) return StatusCode::FAILURE;
478 if (registerCondObjectsWithErrMsg(s_noFolderName, m_tagID4NoiseOccupancy).isFailure()) return StatusCode::FAILURE;
479 return StatusCode::SUCCESS;
480}
481
483
484StatusCode
486 if (recordAndStream(std::move(m_attrListColl_RawOccu), s_RawOccuFolderName, m_RawOccuRecorded).isFailure()) return StatusCode::FAILURE;
487 if (registerCondObjectsWithErrMsg(s_RawOccuFolderName, m_tagID4RawOccupancy).isFailure()) return StatusCode::FAILURE;
488 return StatusCode::SUCCESS;
489}
490
492
493StatusCode
495 if (recordAndStream(std::move(m_attrListColl_BSErr), s_BSErrFolderName, m_BSErrRecorded).isFailure()) return StatusCode::FAILURE;
496 if (registerCondObjectsWithErrMsg(s_BSErrFolderName, m_tagID4BSErrors).isFailure()) return StatusCode::FAILURE;
497 return StatusCode::SUCCESS;
498}
499
501
502StatusCode
504 if (recordAndStream(std::move(m_attrListColl_LA), s_LAFolderName, m_LARecorded).isFailure()) return StatusCode::FAILURE;
505 if (registerCondObjectsWithErrMsg(s_LAFolderName, m_tagID4LorentzAngle).isFailure()) return StatusCode::FAILURE;
506 return StatusCode::SUCCESS;
507}
508
510
511StatusCode
512SCTCalibWriteTool::streamOutCondObjects(const std::string& foldername) {
513 ATH_MSG_DEBUG("streamOutCondObjects start");
514 if (m_streamer->connectOutput(m_streamName).isFailure()) {
515 ATH_MSG_ERROR("Could not connect stream to output");
516 return( StatusCode::FAILURE);
517 }
519 if (m_readWriteCool) {
520 IAthenaOutputStreamTool::TypeKeyPair attrCollPair{"CondAttrListCollection", foldername};
521 typeKeys[0] = std::move(attrCollPair);
522 }
523
524 if (m_streamer->streamObjects(typeKeys).isFailure()) {
525 ATH_MSG_ERROR("Could not stream out AttributeLists");
526 return StatusCode::FAILURE;
527 }
528
529 if (m_streamer->commitOutput().isFailure()) {
530 ATH_MSG_ERROR("Could not commit output stream");
531 return StatusCode::FAILURE;
532 }
533 return StatusCode::SUCCESS;
534}
535
537
538StatusCode
540 ATH_MSG_DEBUG("streamOutCondObjectsWithErrMsg: foldername " << foldername);
541 if (streamOutCondObjects(foldername).isFailure()) {
542 ATH_MSG_ERROR("Could not create conditions object " << foldername);
543 return StatusCode::FAILURE;
544 }
545 return StatusCode::SUCCESS;
546}
547
549
550StatusCode
551SCTCalibWriteTool::registerCondObjects(const std::string& foldername,const std::string& tagname) const {
552 // Register the IOV DB with the conditions data written out
553 ATH_MSG_DEBUG("registerCondObjects start");
554 if (m_readWriteCool) {
555 // Can only write out AttrList's if this is NOT write and reg in two steps
556 if (!m_twoStepWriteReg) {
557 // Using COOL, write out attrlist and collection of attrlists
558 // attrlist collection
559 StatusCode sc;
560 unsigned int beginRun;
561 unsigned int endRun;
562 if (!m_manualiov) {
563
564 const EventContext& ctx = Gaudi::Hive::currentContext();
565 beginRun = ctx.eventID().run_number();
566 endRun = beginRun;
567
568 } else {
569 beginRun = m_beginRun;
570 if ( m_endRun != -1 ) endRun = m_endRun;
571 else endRun = IOVTime::MAXRUN;
572 }
573
574 unsigned int beginLB{IOVTime::MINEVENT};
575 unsigned int endLB{IOVTime::MAXEVENT};
576
577 ATH_MSG_DEBUG("registerCondObjects: registerCondObjects middle");
578
579 if (not tagname.empty()) {
580 ATH_MSG_DEBUG("registerCondObjects: registerCondObjects before registerIOV 1");
581 ATH_MSG_DEBUG("registerCondObjects: foldername, tagname, beginRun, endRun, beginLB, endLB: " << foldername << ", " << tagname << ", " << beginRun << ", " << endRun << ", " << beginLB << ", " << endLB);
582 sc = m_regSvc->registerIOV("CondAttrListCollection", foldername, tagname, beginRun, endRun, beginLB, endLB);
583 ATH_MSG_DEBUG("registerCondObjects after registerIOV 1");
584 } else {
585 ATH_MSG_DEBUG("registerCondObjects before registerIOV 2");
586 ATH_MSG_DEBUG("registerCondObjects: foldername, beginRun, endRun, beginLB, endLB: " << foldername << ", " << beginRun << ", " << endRun << ", " << beginLB << ", " << endLB);
587 sc = m_regSvc->registerIOV("CondAttrListCollection", foldername, "", beginRun, endRun, beginLB, endLB);
588 ATH_MSG_DEBUG("registerCondObjects after registerIOV 2");
589 }
590 if (sc.isFailure()) {
591 ATH_MSG_ERROR("registerCondObjects: Could not register in IOV DB for CondAttrListCollection");
592 return StatusCode::FAILURE;
593 }
594 }
595 }
596
597 ATH_MSG_DEBUG("registerCondObjects end");
598
599 return StatusCode::SUCCESS;
600}
601
603
604StatusCode
605SCTCalibWriteTool::registerCondObjectsWithErrMsg(const std::string& foldername,const std::string& tagname) const {
606 if (m_regIOV) {
607 if (registerCondObjects(foldername,tagname).isFailure()) {
608 ATH_MSG_ERROR("registerCondObjectsWithErrMsg: Could not register " << foldername);
609 return StatusCode::FAILURE;
610 }
611 }
612 return StatusCode::SUCCESS;
613}
614
616
617StatusCode
618SCTCalibWriteTool::recordAndStream(std::unique_ptr<CondAttrListCollection> pCollection,const std::string& foldername, bool& flag) {
619 ATH_MSG_DEBUG("recordAndStream start " << foldername);
620 if (m_writeCondObjs) {
621 if (detStore()->record(std::move(pCollection), foldername).isFailure()) {
622 ATH_MSG_ERROR("Could not record "<<foldername);
623 return StatusCode::FAILURE;
624 }
625 flag=true;
626 if (streamOutCondObjectsWithErrMsg(s_defectFolderName).isFailure()) return StatusCode::FAILURE;
627 }
628 return StatusCode::SUCCESS;
629}
630
632
633coral::AttributeListSpecification*
634SCTCalibWriteTool::createBasicDbSpec(const bool capsFormat) const {
635 coral::AttributeListSpecification* attrSpec{new coral::AttributeListSpecification{}};
636 const std::string becName{capsFormat?"BarrelEndcap":"barrel_endcap"};
637 attrSpec->extend("SampleSize", "int");
638 attrSpec->extend(becName, "int");
639 attrSpec->extend("Layer", "int");
640 attrSpec->extend("Eta", "int");
641 attrSpec->extend("Phi", "int");
642 return attrSpec;
643}
644
646
647void
648SCTCalibWriteTool::setBasicValues(coral::AttributeList& attrList, const Identifier& wafer_id, const int samplesize, const SCT_ID* sctId, const bool capsFormat) const {
649 int eta{sctId->eta_module(wafer_id)};
650 int phi{sctId->phi_module(wafer_id)};
651 int barrel_ec{sctId->barrel_ec(wafer_id)};
652 int layer{sctId->layer_disk(wafer_id)};
653 //
654 const std::string becName{capsFormat?"BarrelEndcap":"barrel_endcap"};
655 attrList["SampleSize"].setValue(static_cast<int>(samplesize));
656 //coverity[copy_constructor_call]
657 attrList[becName].setValue(static_cast<int>(barrel_ec));
658 attrList["Layer"].setValue(static_cast<int>(layer));
659 attrList["Eta"].setValue(static_cast<int>(eta));
660 attrList["Phi"].setValue(static_cast<int>(phi));
661
662 return;
663}
664
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_DEBUG(x)
Interface to an output stream tool.
static Double_t sc
const bool becCapsFormat
const bool becUnderscoreFormat
This is an Identifier helper class for the SCT subdetector.
#define ATLAS_NOT_THREAD_SAFE
getNoisyStrip() Find noisy strips from hitmaps and write out into xml/db formats
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
This class is a collection of AttributeLists where each one is associated with a channel number.
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
std::vector< TypeKeyPair > TypeKeyPairs
static constexpr uint32_t MAXRUN
Definition IOVTime.h:48
static constexpr uint32_t MINEVENT
Definition IOVTime.h:50
static constexpr uint32_t MAXEVENT
Definition IOVTime.h:51
IntegerProperty m_version
BooleanProperty m_twoStepWriteReg
StatusCode registerCondObjectsWithErrMsg(const std::string &foldername, const std::string &tagname) const
static const std::string s_defectFolderName
static const std::string s_deadChipFolderName
std::unique_ptr< CondAttrListCollection > m_attrListColl
static const std::string s_separator
StatusCode wrapUpNoiseOccupancy()
std::unique_ptr< CondAttrListCollection > m_attrListColl_deadStrip
int stringToInt(const std::string &s) const
static const std::string s_LAFolderName
BooleanProperty m_readWriteCool
StatusCode wrapUpDeadStrips()
const SCT_ID * m_pHelper
StringProperty m_tagID4NoiseOccupancy
std::unique_ptr< CondAttrListCollection > m_attrListColl_LA
std::unique_ptr< CondAttrListCollection > m_attrListColl_no
StatusCode wrapUpEfficiency()
std::unique_ptr< CondAttrListCollection > m_attrListColl_RawOccu
BooleanProperty m_regIOV
static const std::string s_effFolderName
static const std::string s_BSErrFolderName
ServiceHandle< IIOVRegistrationSvc > m_regSvc
StringProperty m_tagID4DeadChips
StatusCode wrapUpNoisyChannel()
StringProperty m_tagID4DeadStrips
static const std::string s_deadStripFolderName
SCTCalibWriteTool(const std::string &type, const std::string &name, const IInterface *parent)
static const std::string s_RawOccuFolderName
ToolHandle< IAthenaOutputStreamTool > m_streamer
IntegerProperty m_endRun
StatusCode wrapUpLorentzAngle()
std::unique_ptr< CondAttrListCollection > m_attrListColl_BSErr
StringProperty m_tagID4Efficiency
IntegerProperty m_beginRun
std::string addNumber(const std::string &numStr, const unsigned long long number) const
StringProperty m_tagID4LorentzAngle
StringProperty m_streamName
StatusCode streamOutCondObjectsWithErrMsg(const std::string &foldername)
StatusCode recordAndStream(std::unique_ptr< CondAttrListCollection > pCollection, const std::string &foldername, bool &flag)
coral::AttributeListSpecification * createBasicDbSpec(const bool capsFormat) const
std::string addDefect(const std::string &defectlist, const int defectBeginChannel, const int defectEndChannel) const
BooleanProperty m_manualiov
StatusCode wrapUpRawOccupancy()
void setBasicValues(coral::AttributeList &attrList, const Identifier &wafer_id, const int samplesize, const SCT_ID *m_sctId, const bool capsFormat) const
std::unique_ptr< CondAttrListCollection > m_attrListColl_deadChip
const CondAttrListCollection * getAttrListCollectionByFolder(const std::string &) const
std::unique_ptr< CondAttrListCollection > m_attrListColl_eff
StringProperty m_tagID4BSErrors
StringProperty m_tagID4NoisyStrips
StringProperty m_tagID4RawOccupancy
virtual StatusCode initialize() override
std::string createDefectString(const int defectBeginChannel, const int defectEndChannel) const
StatusCode streamOutCondObjects(const std::string &foldername)
static const std::string s_noFolderName
unsigned int computeIstrip4moncond(const Identifier &elementId) const
StatusCode registerCondObjects(const std::string &foldername, const std::string &tagname) const
ServiceHandle< IIOVDbSvc > m_IOVDbSvc
BooleanProperty m_writeCondObjs
This is an Identifier helper class for the SCT subdetector.
Definition SCT_ID.h:68
int layer_disk(const Identifier &id) const
Definition SCT_ID.h:687
int phi_module(const Identifier &id) const
Definition SCT_ID.h:693
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition SCT_ID.h:681
int eta_module(const Identifier &id) const
Definition SCT_ID.h:699
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186