ATLAS Offline Software
SCTCalibWriteTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 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 <fstream>
30 #include <iostream>
31 #include <istream>
32 #include <iterator>
33 #include <sstream>
34 
35 using std::string;
37 const string SCTCalibWriteTool::s_separator{"-"};
38 const string SCTCalibWriteTool::s_defectFolderName{"/SCT/Derived/Monitoring"};
39 const string SCTCalibWriteTool::s_deadStripFolderName{"/SCT/Derived/DeadStrips"};
40 const string SCTCalibWriteTool::s_deadChipFolderName{"/SCT/Derived/DeadChips"};
41 const string SCTCalibWriteTool::s_effFolderName{"/SCT/Derived/Efficiency"};
42 const string SCTCalibWriteTool::s_noFolderName{"/SCT/Derived/NoiseOccupancy"};
43 const string SCTCalibWriteTool::s_RawOccuFolderName{"/SCT/Derived/RawOccupancy"};
44 const string SCTCalibWriteTool::s_BSErrFolderName{"/SCT/Derived/BSErrorsRun2"};
45 const string SCTCalibWriteTool::s_LAFolderName{"/SCT/Derived/LorentzAngleRun2_v2"};
46 
47 const bool becCapsFormat{true};
48 const bool becUnderscoreFormat{false};
49 
50 SCTCalibWriteTool::SCTCalibWriteTool(const std::string& type, const std::string& name, const IInterface* parent) :
52  m_regSvc("IOVRegistrationSvc", name),
53  m_streamer(((m_version == 0) ? "AthenaOutputStreamTool" : "AthenaPoolOutputStreamTool"), this),
54  m_IOVDbSvc("IOVDbSvc", name)
55 {
56 }
57 
59 
61 {
62 }
63 
65 
67 SCTCalibWriteTool::queryInterface(const InterfaceID& riid, void** ppvIF)
68 {
69  if (SCTCalibWriteTool::interfaceID().versionMatch(riid) ) {
70  *ppvIF = static_cast<SCTCalibWriteTool*>(this);
71  } else {
72  return AthAlgTool::queryInterface(riid, ppvIF);
73  }
74  return StatusCode::SUCCESS;
75 }
76 
78 
81 {
82 
83  ATH_MSG_DEBUG("in SCTCalibWriteTool::initialize start");
84 
85  ATH_CHECK( detStore()->retrieve(m_pHelper,"SCT_ID") );
86 
87  // ------------------------------------------------------------
88  // The following is required for writing out something to COOL
89 
90  // CondAttrListCollection to store table temporarily
91  m_attrListColl = std::make_unique<CondAttrListCollection>(true);
92  m_attrListColl_deadStrip = std::make_unique<CondAttrListCollection>(true);
93  m_attrListColl_deadChip = std::make_unique<CondAttrListCollection>(true);
94  m_attrListColl_eff = std::make_unique<CondAttrListCollection>(true);
95  m_attrListColl_no = std::make_unique<CondAttrListCollection>(true);
96  m_attrListColl_RawOccu = std::make_unique<CondAttrListCollection>(true);
97  m_attrListColl_BSErr = std::make_unique<CondAttrListCollection>(true);
98  m_attrListColl_LA = std::make_unique<CondAttrListCollection>(true);
99 
100  // Get the IOVRegistrationSvc when needed
101  if (m_regIOV) {
102  ATH_CHECK( m_regSvc.retrieve() );
103  }
104 
105  // Retrieve IOVDb service
106  ATH_CHECK( m_IOVDbSvc.retrieve() );
107 
108  return StatusCode::SUCCESS;
109 }
110 
112 
115  ATH_MSG_DEBUG("SCTCalibWriteTool::finalize");
116  if (!m_streamer.release().isSuccess()) {
117  return StatusCode::FAILURE;
118  }
119  if (!m_IOVDbSvc.release().isSuccess()) {
120  return StatusCode::FAILURE;
121  }
122  ATH_MSG_DEBUG("Thank you for using the SCTCalibWriteTool");
123  return StatusCode::SUCCESS;
124 }
125 
127 
128 unsigned int
130  unsigned int iiside{static_cast<unsigned int>(m_pHelper->side(elementId))};
131  unsigned int iistrip{static_cast<unsigned int>(m_pHelper->strip(elementId))};
132  return 768*iiside + iistrip;
133 }
134 
136 
138 // Local stuff
140 
141 string
142 SCTCalibWriteTool::addDefect(const string& defectlist, const int defectBeginChannel, const int defectEndChannel) const {
143  // check size of defect list,
144  // if it is empty then use createDefectString to make first entry.
145  if (defectlist.empty()) return createDefectString(defectBeginChannel, defectEndChannel);
146 
147  // adding another Defect in DefectList
148  std::ostringstream defect;
149  defect << defectlist << " " << defectBeginChannel;
150  if (defectBeginChannel==defectEndChannel) {
151  defect << " ";
152  } else {
153  defect << "-" << defectEndChannel << " ";
154  }
155  return defect.str();
156 }
157 
159 
160 std::string
161 SCTCalibWriteTool::createDefectString(const int defectBeginChannel, const int defectEndChannel) const {
162  std::ostringstream defect;
163  defect << " " << defectBeginChannel;
164  if (defectBeginChannel!=defectEndChannel) {
165  defect << "-" << defectEndChannel;
166  }
167  defect << " ";
168  return defect.str();
169 }
170 
171 
173 
174 std::string
175 SCTCalibWriteTool::addNumber(const string& numStr, const unsigned long long number) const {
176  std::ostringstream num_string;
177  // if it is empty then use createDefectString to make first entry.
178  if (numStr.empty()) {
179  num_string << number;
180  } else { // adding another number to numStr
181  num_string << numStr << " " << number;
182  }
183  return num_string.str();
184 }
185 
187 
189 SCTCalibWriteTool::createCondObjects ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
190 (const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const std::string& defectType, const float threshold, const std::string& defectList) const {
191  if (!m_writeCondObjs) {
192  return StatusCode::SUCCESS;
193  }
194  coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becCapsFormat)};
195  attrSpec->extend("DefectType", "string");
196  attrSpec->extend("Threshold", "float");
197  attrSpec->extend("DefectList", "string");
198 
199  if (!attrSpec->size()) {
200  ATH_MSG_ERROR(" Attribute list specification is empty");
201  return StatusCode::FAILURE;
202  }
203 
204  coral::AttributeList attrList0{*attrSpec};
205  setBasicValues(attrList0, wafer_id, samplesize,sctId,becCapsFormat);
206  attrList0["DefectType"].setValue(static_cast<std::string>(defectType));
207  attrList0["Threshold"].setValue(static_cast<float>(threshold));
208  attrList0["DefectList"].setValue(static_cast<std::string>(defectList));
209  std::ostringstream attrStr2;
210  attrList0.toOutputStream(attrStr2);
211  m_attrListColl->add(wafer_id.get_identifier32().get_compact(), attrList0);
212  return StatusCode::SUCCESS;
213 }
214 
216 
218 SCTCalibWriteTool::createListStrip ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
219 (const Identifier& wafer_id,
220  const SCT_ID* sctId,
221  const int samplesize,
222  const std::string& defectType,
223  const float threshold,
224  const std::string& defectList) const
225 {
226  if (!m_writeCondObjs) {
227  return StatusCode::SUCCESS;
228  }
229  coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becCapsFormat)};
230  attrSpec->extend("DefectType", "string");
231  attrSpec->extend("Threshold", "float");
232  attrSpec->extend("DefectList", "string");
233 
234  if (!attrSpec->size()) {
235  ATH_MSG_ERROR(" Attribute list specification is empty");
236  return StatusCode::FAILURE;
237  }
238 
239  coral::AttributeList attrList0{*attrSpec};
240  setBasicValues(attrList0, wafer_id, samplesize, sctId, becCapsFormat);
241  attrList0["DefectType"].setValue(static_cast<std::string>(defectType));
242  attrList0["Threshold"].setValue(static_cast<float>(threshold));
243  attrList0["DefectList"].setValue(static_cast<std::string>(defectList));
244 
245  std::ostringstream attrStr2;
246  attrList0.toOutputStream(attrStr2);
247  m_attrListColl_deadStrip->add(wafer_id.get_identifier32().get_compact(), attrList0);
248  return StatusCode::SUCCESS;
249 }
250 
252 
254 SCTCalibWriteTool::createListChip ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
255 (const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const std::string& defectType, const float threshold, const std::string& defectList) const {
256  if (!m_writeCondObjs) {
257  return StatusCode::SUCCESS;
258  }
259  coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becCapsFormat)};
260  attrSpec->extend("DefectType", "string");
261  attrSpec->extend("Threshold", "float");
262  attrSpec->extend("DefectList", "string");
263  if (!attrSpec->size()) {
264  ATH_MSG_ERROR(" Attribute list specification is empty");
265  return StatusCode::FAILURE;
266  }
267 
268  coral::AttributeList attrList0{*attrSpec};
269  setBasicValues(attrList0, wafer_id, samplesize, sctId, becCapsFormat);
270  attrList0["DefectType"].setValue(static_cast<std::string>(defectType));
271  attrList0["Threshold"].setValue(static_cast<float>(threshold));
272  attrList0["DefectList"].setValue(static_cast<std::string>(defectList));
273 
274  std::ostringstream attrStr2;
275  attrList0.toOutputStream(attrStr2);
276  m_attrListColl_deadChip->add(wafer_id.get_identifier32().get_compact(), attrList0);
277 
278  return StatusCode::SUCCESS;
279 }
280 
282 
284 SCTCalibWriteTool::createListEff ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
285 (const Identifier& wafer_id,const SCT_ID* sctId, const int samplesize, const float eff) const {
286  if (!m_writeCondObjs) {
287  return StatusCode::SUCCESS;
288  }
289 
290  coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
291  attrSpec->extend("Efficiency", "float");
292  if (!attrSpec->size()) {
293  ATH_MSG_ERROR(" Attribute list specification is empty");
294  return StatusCode::FAILURE;
295  }
296 
297  coral::AttributeList attrList0{*attrSpec};
298  setBasicValues(attrList0, wafer_id, samplesize,sctId,becUnderscoreFormat);
299  attrList0["Efficiency"].setValue(static_cast<float>(eff));
300 
301  std::ostringstream attrStr2;
302  attrList0.toOutputStream(attrStr2);
303  m_attrListColl_eff->add(wafer_id.get_identifier32().get_compact(), attrList0);
304 
305  return StatusCode::SUCCESS;
306 }
307 
309 
311 SCTCalibWriteTool::createListNO ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
312 (const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const float noise_occ) const {
313  if (!m_writeCondObjs) {
314  return StatusCode::SUCCESS;
315  }
316 
317  coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
318  attrSpec->extend("NoiseOccupancy", "float");
319  if (!attrSpec->size()) {
320  ATH_MSG_ERROR(" Attribute list specification is empty");
321  return StatusCode::FAILURE;
322  }
323 
324  coral::AttributeList attrList0{*attrSpec};
325  setBasicValues(attrList0, wafer_id, samplesize, sctId, becUnderscoreFormat);
326  attrList0["NoiseOccupancy"].setValue(static_cast<float>(noise_occ));
327 
328  std::ostringstream attrStr2;
329  attrList0.toOutputStream(attrStr2);
330  m_attrListColl_no->add(wafer_id.get_identifier32().get_compact(), attrList0);
331 
332  return StatusCode::SUCCESS;
333 }
334 
336 
338 SCTCalibWriteTool::createListRawOccu ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
339 (const Identifier& wafer_id, const SCT_ID* sctId, const int samplesize, const float raw_occu) const {
340  if (!m_writeCondObjs) {
341  return StatusCode::SUCCESS;
342  }
343 
344  coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
345  attrSpec->extend("RawOccupancy", "float");
346  if (!attrSpec->size()) {
347  ATH_MSG_ERROR(" Attribute list specification is empty");
348  return StatusCode::FAILURE;
349  }
350 
351  coral::AttributeList attrList0{*attrSpec};
352  setBasicValues(attrList0, wafer_id, samplesize, sctId, becUnderscoreFormat);
353  attrList0["RawOccupancy"].setValue(static_cast<float>(raw_occu));
354 
355  std::ostringstream attrStr2;
356  attrList0.toOutputStream(attrStr2);
357  m_attrListColl_RawOccu->add(wafer_id.get_identifier32().get_compact(), attrList0);
358  return StatusCode::SUCCESS;
359 }
360 
362 
364 SCTCalibWriteTool::createListBSErr ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
365 (const Identifier& wafer_id,const SCT_ID* sctId,const int samplesize, const std::string& errorList, const std::string& probList) const {
366  if (!m_writeCondObjs) {
367  return StatusCode::SUCCESS;
368  }
369 
370  coral::AttributeListSpecification* attrSpec{createBasicDbSpec(becUnderscoreFormat)};
371  attrSpec->extend("BSErrors", "string");
372  attrSpec->extend("BadFraction", "string");
373 
374  if (!attrSpec->size()) {
375  ATH_MSG_ERROR(" Attribute list specification is empty");
376  return StatusCode::FAILURE;
377  }
378 
379  coral::AttributeList attrList0{*attrSpec};
380  setBasicValues(attrList0, wafer_id, samplesize, sctId, becUnderscoreFormat);
381  attrList0["BSErrors"].setValue(static_cast<std::string>(errorList));
382  attrList0["BadFraction"].setValue(static_cast<std::string>(probList));
383 
384  std::ostringstream attrStr2;
385  attrList0.toOutputStream(attrStr2);
386  m_attrListColl_BSErr->add(wafer_id.get_identifier32().get_compact(), attrList0);
387  return StatusCode::SUCCESS;
388 }
389 
391 
393 SCTCalibWriteTool::createListLA ATLAS_NOT_THREAD_SAFE // Thread unsafe CondAttrListCollection::add is used.
394 (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 {
395  if (!m_writeCondObjs) return StatusCode::SUCCESS;
396  int barrel_ec{sctId->barrel_ec(wafer_id)};
397  int layer{sctId->layer_disk(wafer_id)};
398  int side{sctId->side(wafer_id)};
399 
400  coral::AttributeListSpecification* attrSpec{new coral::AttributeListSpecification{}};
401  attrSpec->extend("SampleSize", "int");
402  attrSpec->extend("barrel_endcap", "int");
403  attrSpec->extend("Layer", "int");
404  attrSpec->extend("Side", "int");
405  attrSpec->extend("moduleType", "int");
406  attrSpec->extend("lorentzAngle", "float");
407  attrSpec->extend("err_lorentzAngle", "float");
408  attrSpec->extend("chisq", "float");
409  attrSpec->extend("fitParam_a", "float");
410  attrSpec->extend("err_a", "float");
411  attrSpec->extend("fitParam_b", "float");
412  attrSpec->extend("err_b", "float");
413  attrSpec->extend("fitParam_sigma", "float");
414  attrSpec->extend("err_sigma", "float");
415  attrSpec->extend("minClusterWidth", "float");
416  attrSpec->extend("err_minClusterWidth", "float");
417 
418  if (!attrSpec->size()) {
419  ATH_MSG_ERROR(" Attribute list specification is empty");
420  return StatusCode::FAILURE;
421  }
422 
423  // Add three attr lists
424  coral::AttributeList attrList0{*attrSpec};
425  attrList0["SampleSize"].setValue(static_cast<int>(samplesize));
426  attrList0["barrel_endcap"].setValue(static_cast<int>(barrel_ec));
427  attrList0["Layer"].setValue(static_cast<int>(layer));
428  attrList0["Side"].setValue(static_cast<int>(side));
429  attrList0["moduleType"].setValue(static_cast<int>(module));
430  attrList0["lorentzAngle"].setValue(static_cast<float>(lorentz));
431  attrList0["err_lorentzAngle"].setValue(static_cast<float>(err_lorentz));
432  attrList0["chisq"].setValue(static_cast<float>(chisq));
433  attrList0["fitParam_a"].setValue(static_cast<float>(fitParam_a));
434  attrList0["err_a"].setValue(static_cast<float>(err_a));
435  attrList0["fitParam_b"].setValue(static_cast<float>(fitParam_b));
436  attrList0["err_b"].setValue(static_cast<float>(err_b));
437  attrList0["fitParam_sigma"].setValue(static_cast<float>(fitParam_sigma));
438  attrList0["err_sigma"].setValue(static_cast<float>(err_sigma));
439  attrList0["minClusterWidth"].setValue(static_cast<float>(MCW));
440  attrList0["err_minClusterWidth"].setValue(static_cast<float>(err_MCW));
441 
442  std::ostringstream attrStr2;
443  attrList0.toOutputStream(attrStr2);
444  m_attrListColl_LA->add(wafer_id.get_identifier32().get_compact(), attrList0);
445 
446  return StatusCode::SUCCESS;
447 }
448 
450 
453  std::lock_guard<std::mutex> lock{m_mutex};
454  // trying to find the pointer in the hashmap
455  // if it exists, return it, otherwise put it in.
456  const CondAttrListCollection* attrListCollection{nullptr};
457  if (m_attrListCollectionMap.count(foldername) == 0) {
458  if (detStore()->retrieve(attrListCollection, foldername).isFailure()) {
459  ATH_MSG_ERROR("Could not retrieve " << foldername);
460  return nullptr;
461  }
462  m_attrListCollectionMap.insert(make_pair(foldername, attrListCollection));
463  } else {
464  attrListCollection = m_attrListCollectionMap[foldername];
465  }
466  return attrListCollection;
467 }
468 
470 
471 int
472 SCTCalibWriteTool::stringToInt(const std::string& s) const {
473  return atoi(s.c_str());
474 }
475 
477 
480  if (recordAndStream(std::move(m_attrListColl), s_defectFolderName, m_defectRecorded).isFailure()) return StatusCode::FAILURE;
481  if (registerCondObjectsWithErrMsg(s_defectFolderName, m_tagID4NoisyStrips).isFailure()) return StatusCode::FAILURE;
482  return StatusCode::SUCCESS;
483 }
484 
486 
489  if (recordAndStream(std::move(m_attrListColl_deadStrip), s_deadStripFolderName, m_deadStripRecorded).isFailure()) return StatusCode::FAILURE;
490  if (registerCondObjectsWithErrMsg(s_deadStripFolderName, m_tagID4DeadStrips).isFailure()) return StatusCode::FAILURE;
491  return StatusCode::SUCCESS;
492 }
493 
496 
498  if (recordAndStream(std::move(m_attrListColl_deadChip), s_deadChipFolderName, m_deadChipRecorded).isFailure()) return StatusCode::FAILURE;
499  if (registerCondObjectsWithErrMsg(s_deadChipFolderName, m_tagID4DeadChips).isFailure()) return StatusCode::FAILURE;
500  return StatusCode::SUCCESS;
501 }
502 
504 
507  if (recordAndStream(std::move(m_attrListColl_eff), s_effFolderName, m_effRecorded).isFailure()) return StatusCode::FAILURE;
508  if (registerCondObjectsWithErrMsg(s_effFolderName, m_tagID4Efficiency).isFailure()) return StatusCode::FAILURE;
509  return StatusCode::SUCCESS;
510 }
511 
513 
516  if (recordAndStream(std::move(m_attrListColl_no), s_noFolderName, m_noRecorded).isFailure()) return StatusCode::FAILURE;
517  if (registerCondObjectsWithErrMsg(s_noFolderName, m_tagID4NoiseOccupancy).isFailure()) return StatusCode::FAILURE;
518  return StatusCode::SUCCESS;
519 }
520 
522 
525  if (recordAndStream(std::move(m_attrListColl_RawOccu), s_RawOccuFolderName, m_RawOccuRecorded).isFailure()) return StatusCode::FAILURE;
526  if (registerCondObjectsWithErrMsg(s_RawOccuFolderName, m_tagID4RawOccupancy).isFailure()) return StatusCode::FAILURE;
527  return StatusCode::SUCCESS;
528 }
529 
531 
534  if (recordAndStream(std::move(m_attrListColl_BSErr), s_BSErrFolderName, m_BSErrRecorded).isFailure()) return StatusCode::FAILURE;
535  if (registerCondObjectsWithErrMsg(s_BSErrFolderName, m_tagID4BSErrors).isFailure()) return StatusCode::FAILURE;
536  return StatusCode::SUCCESS;
537 }
538 
540 
543  if (recordAndStream(std::move(m_attrListColl_LA), s_LAFolderName, m_LARecorded).isFailure()) return StatusCode::FAILURE;
544  if (registerCondObjectsWithErrMsg(s_LAFolderName, m_tagID4LorentzAngle).isFailure()) return StatusCode::FAILURE;
545  return StatusCode::SUCCESS;
546 }
547 
549 
552  ATH_MSG_DEBUG("streamOutCondObjects start");
553  if (m_streamer->connectOutput(m_streamName).isFailure()) {
554  ATH_MSG_ERROR("Could not connect stream to output");
555  return( StatusCode::FAILURE);
556  }
558  if (m_readWriteCool) {
559  IAthenaOutputStreamTool::TypeKeyPair attrCollPair{"CondAttrListCollection", foldername};
560  typeKeys[0] = attrCollPair;
561  }
562 
563  if (m_streamer->streamObjects(typeKeys).isFailure()) {
564  ATH_MSG_ERROR("Could not stream out AttributeLists");
565  return StatusCode::FAILURE;
566  }
567 
568  if (m_streamer->commitOutput().isFailure()) {
569  ATH_MSG_ERROR("Could not commit output stream");
570  return StatusCode::FAILURE;
571  }
572  return StatusCode::SUCCESS;
573 }
574 
576 
579  ATH_MSG_DEBUG("streamOutCondObjectsWithErrMsg: foldername " << foldername);
580  if (streamOutCondObjects(foldername).isFailure()) {
581  ATH_MSG_ERROR("Could not create conditions object " << foldername);
582  return StatusCode::FAILURE;
583  }
584  return StatusCode::SUCCESS;
585 }
586 
588 
590 SCTCalibWriteTool::registerCondObjects(const std::string& foldername,const std::string& tagname) const {
591  // Register the IOV DB with the conditions data written out
592  ATH_MSG_DEBUG("registerCondObjects start");
593  if (m_readWriteCool) {
594  // Can only write out AttrList's if this is NOT write and reg in two steps
595  if (!m_twoStepWriteReg) {
596  // Using COOL, write out attrlist and collection of attrlists
597  // attrlist collection
598  StatusCode sc;
599  unsigned int beginRun;
600  unsigned int endRun;
601  if (!m_manualiov) {
602 
603  const EventContext& ctx = Gaudi::Hive::currentContext();
604  beginRun = ctx.eventID().run_number();
605  endRun = beginRun;
606 
607  } else {
608  beginRun = m_beginRun;
609  if ( m_endRun != -1 ) endRun = m_endRun;
610  else endRun = IOVTime::MAXRUN;
611  }
612 
613  unsigned int beginLB{IOVTime::MINEVENT};
614  unsigned int endLB{IOVTime::MAXEVENT};
615 
616  ATH_MSG_DEBUG("registerCondObjects: registerCondObjects middle");
617 
618  if (not tagname.empty()) {
619  ATH_MSG_DEBUG("registerCondObjects: registerCondObjects before registerIOV 1");
620  ATH_MSG_DEBUG("registerCondObjects: foldername, tagname, beginRun, endRun, beginLB, endLB: " << foldername << ", " << tagname << ", " << beginRun << ", " << endRun << ", " << beginLB << ", " << endLB);
621  sc = m_regSvc->registerIOV("CondAttrListCollection", foldername, tagname, beginRun, endRun, beginLB, endLB);
622  ATH_MSG_DEBUG("registerCondObjects after registerIOV 1");
623  } else {
624  ATH_MSG_DEBUG("registerCondObjects before registerIOV 2");
625  ATH_MSG_DEBUG("registerCondObjects: foldername, beginRun, endRun, beginLB, endLB: " << foldername << ", " << beginRun << ", " << endRun << ", " << beginLB << ", " << endLB);
626  sc = m_regSvc->registerIOV("CondAttrListCollection", foldername, "", beginRun, endRun, beginLB, endLB);
627  ATH_MSG_DEBUG("registerCondObjects after registerIOV 2");
628  }
629  if (sc.isFailure()) {
630  ATH_MSG_ERROR("registerCondObjects: Could not register in IOV DB for CondAttrListCollection");
631  return StatusCode::FAILURE;
632  }
633  }
634  }
635 
636  ATH_MSG_DEBUG("registerCondObjects end");
637 
638  return StatusCode::SUCCESS;
639 }
640 
642 
644 SCTCalibWriteTool::registerCondObjectsWithErrMsg(const std::string& foldername,const std::string& tagname) const {
645  if (m_regIOV) {
646  if (registerCondObjects(foldername,tagname).isFailure()) {
647  ATH_MSG_ERROR("registerCondObjectsWithErrMsg: Could not register " << foldername);
648  return StatusCode::FAILURE;
649  }
650  }
651  return StatusCode::SUCCESS;
652 }
653 
655 
657 SCTCalibWriteTool::recordAndStream(std::unique_ptr<CondAttrListCollection> pCollection,const std::string& foldername, bool& flag) {
658  ATH_MSG_DEBUG("recordAndStream start " << foldername);
659  if (m_writeCondObjs) {
660  if (detStore()->record(std::move(pCollection), foldername).isFailure()) {
661  ATH_MSG_ERROR("Could not record "<<foldername);
662  return StatusCode::FAILURE;
663  }
664  flag=true;
665  if (streamOutCondObjectsWithErrMsg(s_defectFolderName).isFailure()) return StatusCode::FAILURE;
666  }
667  return StatusCode::SUCCESS;
668 }
669 
671 
672 coral::AttributeListSpecification*
673 SCTCalibWriteTool::createBasicDbSpec(const bool capsFormat) const {
674  coral::AttributeListSpecification* attrSpec{new coral::AttributeListSpecification{}};
675  const std::string becName{capsFormat?"BarrelEndcap":"barrel_endcap"};
676  attrSpec->extend("SampleSize", "int");
677  attrSpec->extend(becName, "int");
678  attrSpec->extend("Layer", "int");
679  attrSpec->extend("Eta", "int");
680  attrSpec->extend("Phi", "int");
681  return attrSpec;
682 }
683 
685 
686 void
687 SCTCalibWriteTool::setBasicValues(coral::AttributeList& attrList, const Identifier& wafer_id, const int samplesize, const SCT_ID* sctId, const bool capsFormat) const {
688  int eta{sctId->eta_module(wafer_id)};
689  int phi{sctId->phi_module(wafer_id)};
690  int barrel_ec{sctId->barrel_ec(wafer_id)};
691  int layer{sctId->layer_disk(wafer_id)};
692  //
693  const std::string becName{capsFormat?"BarrelEndcap":"barrel_endcap"};
694  attrList["SampleSize"].setValue(static_cast<int>(samplesize));
695  attrList[becName].setValue(static_cast<int>(barrel_ec));
696  attrList["Layer"].setValue(static_cast<int>(layer));
697  attrList["Eta"].setValue(static_cast<int>(eta));
698  attrList["Phi"].setValue(static_cast<int>(phi));
699 
700  return;
701 }
702 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCTCalibWriteTool::m_BSErrRecorded
bool m_BSErrRecorded
Definition: SCTCalibWriteTool.h:223
SCTCalibWriteTool::m_mutex
std::mutex m_mutex
Definition: SCTCalibWriteTool.h:185
SCTCalibWriteTool::m_effRecorded
bool m_effRecorded
Definition: SCTCalibWriteTool.h:220
SCTCalibWriteTool::s_LAFolderName
static const std::string s_LAFolderName
Definition: SCTCalibWriteTool.h:182
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
IAthenaOutputStreamTool::TypeKeyPairs
std::vector< TypeKeyPair > TypeKeyPairs
Definition: IAthenaOutputStreamTool.h:100
SCTCalibWriteTool::m_RawOccuRecorded
bool m_RawOccuRecorded
Definition: SCTCalibWriteTool.h:222
SCTCalibWriteTool::m_regSvc
ServiceHandle< IIOVRegistrationSvc > m_regSvc
Definition: SCTCalibWriteTool.h:213
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
SCTCalibWriteTool::finalize
virtual StatusCode finalize()
Definition: SCTCalibWriteTool.cxx:114
SCTCalibWriteTool::wrapUpLorentzAngle
StatusCode wrapUpLorentzAngle()
Definition: SCTCalibWriteTool.cxx:542
SCTCalibWriteTool::wrapUpBSErrors
StatusCode wrapUpBSErrors()
Definition: SCTCalibWriteTool.cxx:533
SCTCalibWriteTool::m_IOVDbSvc
ServiceHandle< IIOVDbSvc > m_IOVDbSvc
Definition: SCTCalibWriteTool.h:215
SCTCalibWriteTool::createBasicDbSpec
coral::AttributeListSpecification * createBasicDbSpec(const bool capsFormat) const
Definition: SCTCalibWriteTool.cxx:673
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
SCTCalibWriteTool::m_attrListColl_RawOccu
std::unique_ptr< CondAttrListCollection > m_attrListColl_RawOccu
Definition: SCTCalibWriteTool.h:192
SCTCalibWriteTool
Algorithm to test writing conditions data and reading them back.
Definition: SCTCalibWriteTool.h:57
SCTCalibWriteTool::stringToInt
int stringToInt(const std::string &s) const
Definition: SCTCalibWriteTool.cxx:472
SCTCalibWriteTool::m_deadChipRecorded
bool m_deadChipRecorded
Definition: SCTCalibWriteTool.h:219
SCTCalibWriteTool::s_RawOccuFolderName
static const std::string s_RawOccuFolderName
Definition: SCTCalibWriteTool.h:180
SCTCalibWriteTool::m_tagID4Efficiency
StringProperty m_tagID4Efficiency
Definition: SCTCalibWriteTool.h:207
SCTCalibWriteTool::createDefectString
std::string createDefectString(const int defectBeginChannel, const int defectEndChannel) const
Definition: SCTCalibWriteTool.cxx:161
python.checkUPD1.foldername
foldername
Definition: checkUPD1.py:77
SCTCalibWriteTool::m_attrListColl_eff
std::unique_ptr< CondAttrListCollection > m_attrListColl_eff
Definition: SCTCalibWriteTool.h:190
SCTCalibWriteTool::m_beginRun
IntegerProperty m_beginRun
Definition: SCTCalibWriteTool.h:201
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:687
SCTCalibWriteTool::m_pHelper
const SCT_ID * m_pHelper
Definition: SCTCalibWriteTool.h:225
SCT_ID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: SCT_ID.h:728
SCTCalibWriteTool::~SCTCalibWriteTool
virtual ~SCTCalibWriteTool()
Definition: SCTCalibWriteTool.cxx:60
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:191
SCTCalibWriteTool::wrapUpNoiseOccupancy
StatusCode wrapUpNoiseOccupancy()
Definition: SCTCalibWriteTool.cxx:515
SCTCalibWriteTool::m_tagID4DeadStrips
StringProperty m_tagID4DeadStrips
Definition: SCTCalibWriteTool.h:205
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:506
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SCTCalibWriteTool::m_attrListColl
std::unique_ptr< CondAttrListCollection > m_attrListColl
Definition: SCTCalibWriteTool.h:187
SCTCalibWriteTool::s_noFolderName
static const std::string s_noFolderName
Definition: SCTCalibWriteTool.h:179
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
becUnderscoreFormat
const bool becUnderscoreFormat
Definition: SCTCalibWriteTool.cxx:48
TRT::Hit::side
@ side
Definition: HitInfo.h:83
SCTCalibWriteTool::m_tagID4LorentzAngle
StringProperty m_tagID4LorentzAngle
Definition: SCTCalibWriteTool.h:211
IAthenaOutputStreamTool.h
Interface to an output stream tool.
SCTCalibWriteTool::m_tagID4NoisyStrips
StringProperty m_tagID4NoisyStrips
Definition: SCTCalibWriteTool.h:204
python.PyAthena.module
module
Definition: PyAthena.py:131
SCTCalibWriteTool::m_endRun
IntegerProperty m_endRun
Definition: SCTCalibWriteTool.h:202
SCTCalibWriteTool::m_streamer
ToolHandle< IAthenaOutputStreamTool > m_streamer
Definition: SCTCalibWriteTool.h:214
SCTCalibWriteTool::m_twoStepWriteReg
BooleanProperty m_twoStepWriteReg
Definition: SCTCalibWriteTool.h:198
SCTCalibWriteTool::m_tagID4DeadChips
StringProperty m_tagID4DeadChips
Definition: SCTCalibWriteTool.h:206
SCTCalibWriteTool::computeIstrip4moncond
unsigned int computeIstrip4moncond(const Identifier &elementId) const
Definition: SCTCalibWriteTool.cxx:129
SCTCalibWriteTool::s_deadChipFolderName
static const std::string s_deadChipFolderName
Definition: SCTCalibWriteTool.h:177
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SCTCalibWriteTool::m_defectRecorded
bool m_defectRecorded
Definition: SCTCalibWriteTool.h:217
SCTCalibWriteTool::m_regIOV
BooleanProperty m_regIOV
Definition: SCTCalibWriteTool.h:196
SCTCalibWriteTool::s_effFolderName
static const std::string s_effFolderName
Definition: SCTCalibWriteTool.h:178
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:488
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:188
SCTCalibWriteTool::getAttrListCollectionByFolder
const CondAttrListCollection * getAttrListCollectionByFolder(const std::string &) const
Definition: SCTCalibWriteTool.cxx:452
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCTCalibWriteTool::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvIF)
Definition: SCTCalibWriteTool.cxx:67
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:190
SCTCalibWriteTool::wrapUpRawOccupancy
StatusCode wrapUpRawOccupancy()
Definition: SCTCalibWriteTool.cxx:524
SCTCalibWriteTool::initialize
virtual StatusCode initialize()
Definition: SCTCalibWriteTool.cxx:80
SCTCalibWriteTool::streamOutCondObjectsWithErrMsg
StatusCode streamOutCondObjectsWithErrMsg(const std::string &foldername)
Definition: SCTCalibWriteTool.cxx:578
SCTCalibWriteTool::addNumber
std::string addNumber(const std::string &numStr, const unsigned long long number) const
Definition: SCTCalibWriteTool.cxx:175
becCapsFormat
const bool becCapsFormat
Definition: SCTCalibWriteTool.cxx:47
SCTCalibWriteTool::m_tagID4RawOccupancy
StringProperty m_tagID4RawOccupancy
Definition: SCTCalibWriteTool.h:209
SCTCalibWriteTool::m_attrListColl_BSErr
std::unique_ptr< CondAttrListCollection > m_attrListColl_BSErr
Definition: SCTCalibWriteTool.h:193
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition: IOVTime.h:51
PathResolver.h
python.selection.number
number
Definition: selection.py:20
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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:224
SCTCalibWriteTool::addDefect
std::string addDefect(const std::string &defectlist, const int defectBeginChannel, const int defectEndChannel) const
Definition: SCTCalibWriteTool.cxx:142
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::interfaceID
static const InterfaceID & interfaceID()
Definition: SCTCalibWriteTool.h:229
SCTCalibWriteTool::s_BSErrFolderName
static const std::string s_BSErrFolderName
Definition: SCTCalibWriteTool.h:181
SCTCalibWriteTool::s_defectFolderName
static const std::string s_defectFolderName
Definition: SCTCalibWriteTool.h:175
SCTCalibWriteTool::recordAndStream
StatusCode recordAndStream(std::unique_ptr< CondAttrListCollection > pCollection, const std::string &foldername, bool &flag)
Definition: SCTCalibWriteTool.cxx:657
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:479
SCTCalibWriteTool::m_writeCondObjs
BooleanProperty m_writeCondObjs
Definition: SCTCalibWriteTool.h:195
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCTCalibWriteTool::registerCondObjects
StatusCode registerCondObjects(const std::string &foldername, const std::string &tagname) const
Definition: SCTCalibWriteTool.cxx:590
SCTCalibWriteTool::m_attrListColl_deadChip
std::unique_ptr< CondAttrListCollection > m_attrListColl_deadChip
Definition: SCTCalibWriteTool.h:189
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:208
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
dqt_zlumi_alleff_HIST.eff
int eff
Definition: dqt_zlumi_alleff_HIST.py:113
SCTCalibWriteTool::m_noRecorded
bool m_noRecorded
Definition: SCTCalibWriteTool.h:221
SCTCalibWriteTool::SCTCalibWriteTool
SCTCalibWriteTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SCTCalibWriteTool.cxx:50
SCTCalibWriteTool::registerCondObjectsWithErrMsg
StatusCode registerCondObjectsWithErrMsg(const std::string &foldername, const std::string &tagname) const
Definition: SCTCalibWriteTool.cxx:644
AthAlgTool
Definition: AthAlgTool.h:26
SCTCalibWriteTool::wrapUpDeadChips
StatusCode wrapUpDeadChips()
Definition: SCTCalibWriteTool.cxx:497
SCTCalibWriteTool::m_streamName
StringProperty m_streamName
Definition: SCTCalibWriteTool.h:203
SCTCalibWriteTool::m_tagID4BSErrors
StringProperty m_tagID4BSErrors
Definition: SCTCalibWriteTool.h:210
SCTCalibWriteTool::m_readWriteCool
BooleanProperty m_readWriteCool
Definition: SCTCalibWriteTool.h:197
SCTCalibWriteTool::m_manualiov
BooleanProperty m_manualiov
Definition: SCTCalibWriteTool.h:199
SCTCalibWriteTool::streamOutCondObjects
StatusCode streamOutCondObjects(const std::string &foldername)
Definition: SCTCalibWriteTool.cxx:551
dumpTgcDigiThreshold.threshold
list threshold
Definition: dumpTgcDigiThreshold.py:34
SCTCalibWriteTool::s_separator
static const std::string s_separator
Definition: SCTCalibWriteTool.h:174
SCTCalibWriteTool::m_deadStripRecorded
bool m_deadStripRecorded
Definition: SCTCalibWriteTool.h:218
SCTCalibWriteTool::m_attrListColl_LA
std::unique_ptr< CondAttrListCollection > m_attrListColl_LA
Definition: SCTCalibWriteTool.h:194
SCTCalibWriteTool::s_deadStripFolderName
static const std::string s_deadStripFolderName
Definition: SCTCalibWriteTool.h:176
Identifier
Definition: IdentifierFieldParser.cxx:14