ATLAS Offline Software
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"
20 #include "InDetIdentifier/SCT_ID.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 
32 const std::string SCTCalibWriteTool::s_separator{"-"};
33 const std::string SCTCalibWriteTool::s_defectFolderName{"/SCT/Derived/Monitoring"};
34 const std::string SCTCalibWriteTool::s_deadStripFolderName{"/SCT/Derived/DeadStrips"};
35 const std::string SCTCalibWriteTool::s_deadChipFolderName{"/SCT/Derived/DeadChips"};
36 const std::string SCTCalibWriteTool::s_effFolderName{"/SCT/Derived/Efficiency"};
37 const std::string SCTCalibWriteTool::s_noFolderName{"/SCT/Derived/NoiseOccupancy"};
38 const std::string SCTCalibWriteTool::s_RawOccuFolderName{"/SCT/Derived/RawOccupancy"};
39 const std::string SCTCalibWriteTool::s_BSErrFolderName{"/SCT/Derived/BSErrorsRun2"};
40 const std::string SCTCalibWriteTool::s_LAFolderName{"/SCT/Derived/LorentzAngleRun2_v2"};
41 
42 const bool becCapsFormat{true};
43 const bool becUnderscoreFormat{false};
44 
45 SCTCalibWriteTool::SCTCalibWriteTool(const std::string& type, const std::string& name, const IInterface* parent) :
47  m_regSvc("IOVRegistrationSvc", name),
48  m_streamer(((m_version == 0) ? "AthenaOutputStreamTool" : "AthenaPoolOutputStreamTool"), this),
49  m_IOVDbSvc("IOVDbSvc", name)
50 {
51 }
52 
54 
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 
89 unsigned 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 
102 std::string
103 SCTCalibWriteTool::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 
121 std::string
122 SCTCalibWriteTool::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 
135 std::string
136 SCTCalibWriteTool::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 
150 SCTCalibWriteTool::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 
179 SCTCalibWriteTool::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 
215 SCTCalibWriteTool::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 
245 SCTCalibWriteTool::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 
272 SCTCalibWriteTool::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 
299 SCTCalibWriteTool::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 
325 SCTCalibWriteTool::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 
354 SCTCalibWriteTool::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 
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 
432 int
433 SCTCalibWriteTool::stringToInt(const std::string& s) const {
434  return atoi(s.c_str());
435 }
436 
438 
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 
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 
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 
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 
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 
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 
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 
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 
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] = 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 
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 
551 SCTCalibWriteTool::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 
605 SCTCalibWriteTool::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 
618 SCTCalibWriteTool::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 
633 coral::AttributeListSpecification*
634 SCTCalibWriteTool::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 
647 void
648 SCTCalibWriteTool::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  attrList[becName].setValue(static_cast<int>(barrel_ec));
657  attrList["Layer"].setValue(static_cast<int>(layer));
658  attrList["Eta"].setValue(static_cast<int>(eta));
659  attrList["Phi"].setValue(static_cast<int>(phi));
660 
661  return;
662 }
663 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCTCalibWriteTool::m_BSErrRecorded
bool m_BSErrRecorded
Definition: SCTCalibWriteTool.h:212
SCTCalibWriteTool::m_mutex
std::mutex m_mutex
Definition: SCTCalibWriteTool.h:174
SCTCalibWriteTool::m_effRecorded
bool m_effRecorded
Definition: SCTCalibWriteTool.h:209
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
IAthenaOutputStreamTool::TypeKeyPairs
std::vector< TypeKeyPair > TypeKeyPairs
Definition: IAthenaOutputStreamTool.h:100
SCTCalibWriteTool::m_RawOccuRecorded
bool m_RawOccuRecorded
Definition: SCTCalibWriteTool.h:211
SCTCalibWriteTool::m_regSvc
ServiceHandle< IIOVRegistrationSvc > m_regSvc
Definition: SCTCalibWriteTool.h:202
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SCTCalibWriteTool::wrapUpLorentzAngle
StatusCode wrapUpLorentzAngle()
Definition: SCTCalibWriteTool.cxx:503
SCTCalibWriteTool::wrapUpBSErrors
StatusCode wrapUpBSErrors()
Definition: SCTCalibWriteTool.cxx:494
SCTCalibWriteTool::s_deadChipFolderName
static const std::string s_deadChipFolderName
Definition: SCTCalibWriteTool.h:166
SCTCalibWriteTool::m_IOVDbSvc
ServiceHandle< IIOVDbSvc > m_IOVDbSvc
Definition: SCTCalibWriteTool.h:204
SCTCalibWriteTool::createBasicDbSpec
coral::AttributeListSpecification * createBasicDbSpec(const bool capsFormat) const
Definition: SCTCalibWriteTool.cxx:634
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SCTCalibWriteTool::m_attrListColl_RawOccu
std::unique_ptr< CondAttrListCollection > m_attrListColl_RawOccu
Definition: SCTCalibWriteTool.h:181
SCTCalibWriteTool::stringToInt
int stringToInt(const std::string &s) const
Definition: SCTCalibWriteTool.cxx:433
SCTCalibWriteTool::m_deadChipRecorded
bool m_deadChipRecorded
Definition: SCTCalibWriteTool.h:208
SCTCalibWriteTool::s_noFolderName
static const std::string s_noFolderName
Definition: SCTCalibWriteTool.h:168
SCTCalibWriteTool::m_tagID4Efficiency
StringProperty m_tagID4Efficiency
Definition: SCTCalibWriteTool.h:196
SCTCalibWriteTool::createDefectString
std::string createDefectString(const int defectBeginChannel, const int defectEndChannel) const
Definition: SCTCalibWriteTool.cxx:122
python.checkUPD1.foldername
foldername
Definition: checkUPD1.py:77
SCTCalibWriteTool::m_attrListColl_eff
std::unique_ptr< CondAttrListCollection > m_attrListColl_eff
Definition: SCTCalibWriteTool.h:179
SCTCalibWriteTool::m_beginRun
IntegerProperty m_beginRun
Definition: SCTCalibWriteTool.h:190
SCTCalibWriteTool::setBasicValues
void setBasicValues(coral::AttributeList &attrList, const Identifier &wafer_id, const int samplesize, const SCT_ID *m_sctId, const bool capsFormat) const
Definition: SCTCalibWriteTool.cxx:648
SCTCalibWriteTool::m_pHelper
const SCT_ID * m_pHelper
Definition: SCTCalibWriteTool.h:214
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
python.RatesEmulationExample.lock
lock
Definition: RatesEmulationExample.py:148
SCT_ID::phi_module
int phi_module(const Identifier &id) const
Definition: SCT_ID.h:740
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
SCTCalibWriteTool::m_attrListColl_no
std::unique_ptr< CondAttrListCollection > m_attrListColl_no
Definition: SCTCalibWriteTool.h:180
SCTCalibWriteTool::wrapUpNoiseOccupancy
StatusCode wrapUpNoiseOccupancy()
Definition: SCTCalibWriteTool.cxx:476
SCTCalibWriteTool::m_tagID4DeadStrips
StringProperty m_tagID4DeadStrips
Definition: SCTCalibWriteTool.h:194
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
SCTCalibWriteTool::wrapUpEfficiency
StatusCode wrapUpEfficiency()
Definition: SCTCalibWriteTool.cxx:467
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SCTCalibWriteTool::m_attrListColl
std::unique_ptr< CondAttrListCollection > m_attrListColl
Definition: SCTCalibWriteTool.h:176
AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
SCTCalibWriteTool::s_BSErrFolderName
static const std::string s_BSErrFolderName
Definition: SCTCalibWriteTool.h:170
becUnderscoreFormat
const bool becUnderscoreFormat
Definition: SCTCalibWriteTool.cxx:43
TRT::Hit::side
@ side
Definition: HitInfo.h:83
SCTCalibWriteTool::m_tagID4LorentzAngle
StringProperty m_tagID4LorentzAngle
Definition: SCTCalibWriteTool.h:200
IAthenaOutputStreamTool.h
Interface to an output stream tool.
SCTCalibWriteTool::m_tagID4NoisyStrips
StringProperty m_tagID4NoisyStrips
Definition: SCTCalibWriteTool.h:193
python.PyAthena.module
module
Definition: PyAthena.py:131
SCTCalibWriteTool::m_endRun
IntegerProperty m_endRun
Definition: SCTCalibWriteTool.h:191
SCTCalibWriteTool::m_streamer
ToolHandle< IAthenaOutputStreamTool > m_streamer
Definition: SCTCalibWriteTool.h:203
SCTCalibWriteTool::m_twoStepWriteReg
BooleanProperty m_twoStepWriteReg
Definition: SCTCalibWriteTool.h:187
SCTCalibWriteTool::m_tagID4DeadChips
StringProperty m_tagID4DeadChips
Definition: SCTCalibWriteTool.h:195
SCTCalibWriteTool::computeIstrip4moncond
unsigned int computeIstrip4moncond(const Identifier &elementId) const
Definition: SCTCalibWriteTool.cxx:90
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SCTCalibWriteTool::m_defectRecorded
bool m_defectRecorded
Definition: SCTCalibWriteTool.h:206
SCTCalibWriteTool::addDefect
std::string addDefect(const std::string &defectlist, const int defectBeginChannel, const int defectEndChannel) const
Definition: SCTCalibWriteTool.cxx:103
SCTCalibWriteTool::m_regIOV
BooleanProperty m_regIOV
Definition: SCTCalibWriteTool.h:185
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
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
master.flag
bool flag
Definition: master.py:29
SCTCalibWriteTool::wrapUpDeadStrips
StatusCode wrapUpDeadStrips()
Definition: SCTCalibWriteTool.cxx:449
IAthenaOutputStreamTool::TypeKeyPair
std::pair< std::string, std::string > TypeKeyPair
Stream out objects.
Definition: IAthenaOutputStreamTool.h:99
test_pyathena.parent
parent
Definition: test_pyathena.py:15
SCTCalibWriteTool::m_attrListColl_deadStrip
std::unique_ptr< CondAttrListCollection > m_attrListColl_deadStrip
Definition: SCTCalibWriteTool.h:177
SCTCalibWriteTool::s_separator
static const std::string s_separator
Definition: SCTCalibWriteTool.h:163
SCTCalibWriteTool::getAttrListCollectionByFolder
const CondAttrListCollection * getAttrListCollectionByFolder(const std::string &) const
Definition: SCTCalibWriteTool.cxx:413
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCTCalibWriteTool::s_effFolderName
static const std::string s_effFolderName
Definition: SCTCalibWriteTool.h:167
ATLAS_NOT_THREAD_SAFE
StatusCode SCTCalibWriteTool::createCondObjects ATLAS_NOT_THREAD_SAFE(const Identifier &wafer_id, const SCT_ID *sctId, const int samplesize, const std::string &defectType, const float threshold, const std::string &defectList) const
Definition: SCTCalibWriteTool.cxx:151
SCTCalibWriteTool::wrapUpRawOccupancy
StatusCode wrapUpRawOccupancy()
Definition: SCTCalibWriteTool.cxx:485
SCTCalibWriteTool::streamOutCondObjectsWithErrMsg
StatusCode streamOutCondObjectsWithErrMsg(const std::string &foldername)
Definition: SCTCalibWriteTool.cxx:539
SCTCalibWriteTool::addNumber
std::string addNumber(const std::string &numStr, const unsigned long long number) const
Definition: SCTCalibWriteTool.cxx:136
becCapsFormat
const bool becCapsFormat
Definition: SCTCalibWriteTool.cxx:42
SCTCalibWriteTool::m_tagID4RawOccupancy
StringProperty m_tagID4RawOccupancy
Definition: SCTCalibWriteTool.h:198
SCTCalibWriteTool::m_attrListColl_BSErr
std::unique_ptr< CondAttrListCollection > m_attrListColl_BSErr
Definition: SCTCalibWriteTool.h:182
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition: IOVTime.h:51
PathResolver.h
SCTCalibWriteTool::initialize
virtual StatusCode initialize() override
Definition: SCTCalibWriteTool.cxx:56
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
IdentifierHash.h
threshold
Definition: chainparser.cxx:74
SCT_ID::layer_disk
int layer_disk(const Identifier &id) const
Definition: SCT_ID.h:734
SCTCalibWriteTool::m_LARecorded
bool m_LARecorded
Definition: SCTCalibWriteTool.h:213
IOVTime::MINEVENT
static constexpr uint32_t MINEVENT
Definition: IOVTime.h:50
dq_defect_bulk_create_defects.defect
defect
Definition: dq_defect_bulk_create_defects.py:35
SCTCalibWriteTool::recordAndStream
StatusCode recordAndStream(std::unique_ptr< CondAttrListCollection > pCollection, const std::string &foldername, bool &flag)
Definition: SCTCalibWriteTool.cxx:618
SCT_ID
Definition: SCT_ID.h:68
SCT_ID::strip
int strip(const Identifier &id) const
Definition: SCT_ID.h:764
SCTCalibWriteTool::wrapUpNoisyChannel
StatusCode wrapUpNoisyChannel()
Definition: SCTCalibWriteTool.cxx:440
SCTCalibWriteTool::m_writeCondObjs
BooleanProperty m_writeCondObjs
Definition: SCTCalibWriteTool.h:184
SCTCalibWriteTool::registerCondObjects
StatusCode registerCondObjects(const std::string &foldername, const std::string &tagname) const
Definition: SCTCalibWriteTool.cxx:551
SCTCalibWriteTool::m_attrListColl_deadChip
std::unique_ptr< CondAttrListCollection > m_attrListColl_deadChip
Definition: SCTCalibWriteTool.h:178
SCTCalibWriteTool.h
SCT_ID::eta_module
int eta_module(const Identifier &id) const
Definition: SCT_ID.h:746
SCTCalibWriteTool::m_tagID4NoiseOccupancy
StringProperty m_tagID4NoiseOccupancy
Definition: SCTCalibWriteTool.h:197
python.SystemOfUnits.s
float s
Definition: SystemOfUnits.py:147
tagname
Definition: tagname.h:29
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
SCT_ID::side
int side(const Identifier &id) const
Definition: SCT_ID.h:752
SCTCalibWriteTool::s_LAFolderName
static const std::string s_LAFolderName
Definition: SCTCalibWriteTool.h:171
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
SCTCalibWriteTool::m_noRecorded
bool m_noRecorded
Definition: SCTCalibWriteTool.h:210
SCTCalibWriteTool::SCTCalibWriteTool
SCTCalibWriteTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCTCalibWriteTool.cxx:45
SCTCalibWriteTool::registerCondObjectsWithErrMsg
StatusCode registerCondObjectsWithErrMsg(const std::string &foldername, const std::string &tagname) const
Definition: SCTCalibWriteTool.cxx:605
SCTCalibWriteTool::s_deadStripFolderName
static const std::string s_deadStripFolderName
Definition: SCTCalibWriteTool.h:165
AthAlgTool
Definition: AthAlgTool.h:26
SCTCalibWriteTool::wrapUpDeadChips
StatusCode wrapUpDeadChips()
Definition: SCTCalibWriteTool.cxx:458
SCTCalibWriteTool::m_streamName
StringProperty m_streamName
Definition: SCTCalibWriteTool.h:192
SCTCalibWriteTool::s_RawOccuFolderName
static const std::string s_RawOccuFolderName
Definition: SCTCalibWriteTool.h:169
SCTCalibWriteTool::m_tagID4BSErrors
StringProperty m_tagID4BSErrors
Definition: SCTCalibWriteTool.h:199
SCTCalibWriteTool::s_defectFolderName
static const std::string s_defectFolderName
Definition: SCTCalibWriteTool.h:164
SCTCalibWriteTool::m_readWriteCool
BooleanProperty m_readWriteCool
Definition: SCTCalibWriteTool.h:186
SCTCalibWriteTool::m_manualiov
BooleanProperty m_manualiov
Definition: SCTCalibWriteTool.h:188
SCTCalibWriteTool::streamOutCondObjects
StatusCode streamOutCondObjects(const std::string &foldername)
Definition: SCTCalibWriteTool.cxx:512
dumpTgcDigiThreshold.threshold
list threshold
Definition: dumpTgcDigiThreshold.py:34
SCTCalibWriteTool::m_deadStripRecorded
bool m_deadStripRecorded
Definition: SCTCalibWriteTool.h:207
SCTCalibWriteTool::m_attrListColl_LA
std::unique_ptr< CondAttrListCollection > m_attrListColl_LA
Definition: SCTCalibWriteTool.h:183
Identifier
Definition: IdentifierFieldParser.cxx:14