19 #include "CoralBase/Attribute.h"
22 #include "Identifier/Identifier.h"
29 #include "GaudiKernel/StatusCode.h"
30 #include "GaudiKernel/IToolSvc.h"
55 m_streamer(((m_version == 0) ?
"AthenaOutputStreamTool" :
"AthenaPoolOutputStreamTool"), this),
56 m_IOVDbSvc(
"IOVDbSvc",
"SCTCalibWriteTool")
74 return AthAlgTool::queryInterface(riid, ppvIF);
76 return StatusCode::SUCCESS;
89 return StatusCode::FAILURE;
108 if (service(
"IOVRegistrationSvc",
m_regSvc).isFailure()) {
110 return StatusCode::FAILURE;
116 return msg(MSG:: ERROR)<<
"Failed to retrieve IOVDbSvc " <<
endmsg, StatusCode::FAILURE;
118 return StatusCode::SUCCESS;
127 return StatusCode::FAILURE;
130 return StatusCode::FAILURE;
133 return StatusCode::SUCCESS;
140 unsigned int iiside{
static_cast<unsigned int>(
m_pHelper->
side(elementId))};
141 unsigned int iistrip{
static_cast<unsigned int>(
m_pHelper->
strip(elementId))};
142 return 768*iiside + iistrip;
155 if (defectlist.empty())
return createDefectString(defectBeginChannel, defectEndChannel);
158 std::ostringstream
defect;
159 defect << defectlist <<
" " << defectBeginChannel;
160 if (defectBeginChannel==defectEndChannel) {
163 defect <<
"-" << defectEndChannel <<
" ";
172 std::ostringstream
defect;
173 defect <<
" " << defectBeginChannel;
174 if (defectBeginChannel!=defectEndChannel) {
175 defect <<
"-" << defectEndChannel;
186 std::ostringstream num_string;
188 if (numStr.empty()) {
191 num_string << numStr <<
" " <<
number;
193 return num_string.str();
200 (
const Identifier& wafer_id,
const SCT_ID* sctId,
const int samplesize,
const std::string& defectType,
const float threshold,
const std::string& defectList)
const {
201 if (!m_writeCondObjs) {
202 return StatusCode::SUCCESS;
204 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(
becCapsFormat)};
205 attrSpec->extend(
"DefectType",
"string");
206 attrSpec->extend(
"Threshold",
"float");
207 attrSpec->extend(
"DefectList",
"string");
209 if (!attrSpec->size()) {
211 return StatusCode::FAILURE;
215 setBasicValues(attrList0, wafer_id, samplesize,sctId,
becCapsFormat);
216 attrList0[
"DefectType"].setValue(
static_cast<std::string
>(defectType));
217 attrList0[
"Threshold"].setValue(
static_cast<float>(
threshold));
218 attrList0[
"DefectList"].setValue(
static_cast<std::string
>(defectList));
219 std::ostringstream attrStr2;
220 attrList0.toOutputStream(attrStr2);
221 m_attrListColl->add(wafer_id.get_identifier32().get_compact(), attrList0);
222 return StatusCode::SUCCESS;
231 const int samplesize,
232 const std::string& defectType,
234 const std::string& defectList)
const
236 if (!m_writeCondObjs) {
237 return StatusCode::SUCCESS;
239 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(
becCapsFormat)};
240 attrSpec->extend(
"DefectType",
"string");
241 attrSpec->extend(
"Threshold",
"float");
242 attrSpec->extend(
"DefectList",
"string");
244 if (!attrSpec->size()) {
246 return StatusCode::FAILURE;
250 setBasicValues(attrList0, wafer_id, samplesize, sctId,
becCapsFormat);
251 attrList0[
"DefectType"].setValue(
static_cast<std::string
>(defectType));
252 attrList0[
"Threshold"].setValue(
static_cast<float>(
threshold));
253 attrList0[
"DefectList"].setValue(
static_cast<std::string
>(defectList));
255 std::ostringstream attrStr2;
256 attrList0.toOutputStream(attrStr2);
257 m_attrListColl_deadStrip->add(wafer_id.get_identifier32().get_compact(), attrList0);
258 return StatusCode::SUCCESS;
265 (
const Identifier& wafer_id,
const SCT_ID* sctId,
const int samplesize,
const std::string& defectType,
const float threshold,
const std::string& defectList)
const {
266 if (!m_writeCondObjs) {
267 return StatusCode::SUCCESS;
269 coral::AttributeListSpecification* attrSpec{createBasicDbSpec(
becCapsFormat)};
270 attrSpec->extend(
"DefectType",
"string");
271 attrSpec->extend(
"Threshold",
"float");
272 attrSpec->extend(
"DefectList",
"string");
273 if (!attrSpec->size()) {
275 return StatusCode::FAILURE;
279 setBasicValues(attrList0, wafer_id, samplesize, sctId,
becCapsFormat);
280 attrList0[
"DefectType"].setValue(
static_cast<std::string
>(defectType));
281 attrList0[
"Threshold"].setValue(
static_cast<float>(
threshold));
282 attrList0[
"DefectList"].setValue(
static_cast<std::string
>(defectList));
284 std::ostringstream attrStr2;
285 attrList0.toOutputStream(attrStr2);
286 m_attrListColl_deadChip->add(wafer_id.get_identifier32().get_compact(), attrList0);
288 return StatusCode::SUCCESS;
295 (
const Identifier& wafer_id,
const SCT_ID* sctId,
const int samplesize,
const float eff)
const {
296 if (!m_writeCondObjs) {
297 return StatusCode::SUCCESS;
301 attrSpec->extend(
"Efficiency",
"float");
302 if (!attrSpec->size()) {
304 return StatusCode::FAILURE;
309 attrList0[
"Efficiency"].setValue(
static_cast<float>(
eff));
311 std::ostringstream attrStr2;
312 attrList0.toOutputStream(attrStr2);
313 m_attrListColl_eff->add(wafer_id.get_identifier32().get_compact(), attrList0);
315 return StatusCode::SUCCESS;
322 (
const Identifier& wafer_id,
const SCT_ID* sctId,
const int samplesize,
const float noise_occ)
const {
323 if (!m_writeCondObjs) {
324 return StatusCode::SUCCESS;
328 attrSpec->extend(
"NoiseOccupancy",
"float");
329 if (!attrSpec->size()) {
331 return StatusCode::FAILURE;
336 attrList0[
"NoiseOccupancy"].setValue(
static_cast<float>(noise_occ));
338 std::ostringstream attrStr2;
339 attrList0.toOutputStream(attrStr2);
340 m_attrListColl_no->add(wafer_id.get_identifier32().get_compact(), attrList0);
342 return StatusCode::SUCCESS;
349 (
const Identifier& wafer_id,
const SCT_ID* sctId,
const int samplesize,
const float raw_occu)
const {
350 if (!m_writeCondObjs) {
351 return StatusCode::SUCCESS;
355 attrSpec->extend(
"RawOccupancy",
"float");
356 if (!attrSpec->size()) {
358 return StatusCode::FAILURE;
363 attrList0[
"RawOccupancy"].setValue(
static_cast<float>(raw_occu));
365 std::ostringstream attrStr2;
366 attrList0.toOutputStream(attrStr2);
367 m_attrListColl_RawOccu->add(wafer_id.get_identifier32().get_compact(), attrList0);
368 return StatusCode::SUCCESS;
375 (
const Identifier& wafer_id,
const SCT_ID* sctId,
const int samplesize,
const std::string& errorList,
const std::string& probList)
const {
376 if (!m_writeCondObjs) {
377 return StatusCode::SUCCESS;
381 attrSpec->extend(
"BSErrors",
"string");
382 attrSpec->extend(
"BadFraction",
"string");
384 if (!attrSpec->size()) {
386 return StatusCode::FAILURE;
391 attrList0[
"BSErrors"].setValue(
static_cast<std::string
>(errorList));
392 attrList0[
"BadFraction"].setValue(
static_cast<std::string
>(probList));
394 std::ostringstream attrStr2;
395 attrList0.toOutputStream(attrStr2);
396 m_attrListColl_BSErr->add(wafer_id.get_identifier32().get_compact(), attrList0);
397 return StatusCode::SUCCESS;
404 (
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 {
405 if (!m_writeCondObjs)
return StatusCode::SUCCESS;
406 int barrel_ec{sctId->barrel_ec(wafer_id)};
407 int layer{sctId->layer_disk(wafer_id)};
408 int side{sctId->side(wafer_id)};
410 coral::AttributeListSpecification* attrSpec{
new coral::AttributeListSpecification{}};
411 attrSpec->extend(
"SampleSize",
"int");
412 attrSpec->extend(
"barrel_endcap",
"int");
413 attrSpec->extend(
"Layer",
"int");
414 attrSpec->extend(
"Side",
"int");
415 attrSpec->extend(
"moduleType",
"int");
416 attrSpec->extend(
"lorentzAngle",
"float");
417 attrSpec->extend(
"err_lorentzAngle",
"float");
418 attrSpec->extend(
"chisq",
"float");
419 attrSpec->extend(
"fitParam_a",
"float");
420 attrSpec->extend(
"err_a",
"float");
421 attrSpec->extend(
"fitParam_b",
"float");
422 attrSpec->extend(
"err_b",
"float");
423 attrSpec->extend(
"fitParam_sigma",
"float");
424 attrSpec->extend(
"err_sigma",
"float");
425 attrSpec->extend(
"minClusterWidth",
"float");
426 attrSpec->extend(
"err_minClusterWidth",
"float");
428 if (!attrSpec->size()) {
430 return StatusCode::FAILURE;
435 attrList0[
"SampleSize"].setValue(
static_cast<int>(samplesize));
436 attrList0[
"barrel_endcap"].setValue(
static_cast<int>(barrel_ec));
437 attrList0[
"Layer"].setValue(
static_cast<int>(
layer));
438 attrList0[
"Side"].setValue(
static_cast<int>(
side));
439 attrList0[
"moduleType"].setValue(
static_cast<int>(
module));
440 attrList0[
"lorentzAngle"].setValue(
static_cast<float>(lorentz));
441 attrList0[
"err_lorentzAngle"].setValue(
static_cast<float>(err_lorentz));
442 attrList0[
"chisq"].setValue(
static_cast<float>(chisq));
443 attrList0[
"fitParam_a"].setValue(
static_cast<float>(fitParam_a));
444 attrList0[
"err_a"].setValue(
static_cast<float>(err_a));
445 attrList0[
"fitParam_b"].setValue(
static_cast<float>(fitParam_b));
446 attrList0[
"err_b"].setValue(
static_cast<float>(err_b));
447 attrList0[
"fitParam_sigma"].setValue(
static_cast<float>(fitParam_sigma));
448 attrList0[
"err_sigma"].setValue(
static_cast<float>(err_sigma));
449 attrList0[
"minClusterWidth"].setValue(
static_cast<float>(MCW));
450 attrList0[
"err_minClusterWidth"].setValue(
static_cast<float>(err_MCW));
452 std::ostringstream attrStr2;
453 attrList0.toOutputStream(attrStr2);
454 m_attrListColl_LA->add(wafer_id.get_identifier32().get_compact(), attrList0);
456 return StatusCode::SUCCESS;
463 std::lock_guard<std::mutex> lock{
m_mutex};
467 if (m_attrListCollectionMap.count(
foldername) == 0) {
472 m_attrListCollectionMap.insert(make_pair(
foldername, attrListCollection));
474 attrListCollection = m_attrListCollectionMap[
foldername];
476 return attrListCollection;
483 return atoi(
s.c_str());
492 return StatusCode::SUCCESS;
501 return StatusCode::SUCCESS;
510 return StatusCode::SUCCESS;
519 return StatusCode::SUCCESS;
528 return StatusCode::SUCCESS;
537 return StatusCode::SUCCESS;
546 return StatusCode::SUCCESS;
555 return StatusCode::SUCCESS;
565 return( StatusCode::FAILURE);
570 typeKeys[0] = attrCollPair;
573 if (
m_streamer->streamObjects(typeKeys).isFailure()) {
575 return StatusCode::FAILURE;
580 return StatusCode::FAILURE;
582 return StatusCode::SUCCESS;
592 return StatusCode::FAILURE;
594 return StatusCode::SUCCESS;
609 unsigned int beginRun;
613 const EventContext& ctx = Gaudi::Hive::currentContext();
614 beginRun = ctx.eventID().run_number();
626 ATH_MSG_DEBUG(
"registerCondObjects: registerCondObjects middle");
629 ATH_MSG_DEBUG(
"registerCondObjects: registerCondObjects before registerIOV 1");
630 ATH_MSG_DEBUG(
"registerCondObjects: foldername, tagname, beginRun, endRun, beginLB, endLB: " <<
foldername <<
", " <<
tagname <<
", " << beginRun <<
", " << endRun <<
", " << beginLB <<
", " << endLB);
635 ATH_MSG_DEBUG(
"registerCondObjects: foldername, beginRun, endRun, beginLB, endLB: " <<
foldername <<
", " << beginRun <<
", " << endRun <<
", " << beginLB <<
", " << endLB);
639 if (
sc.isFailure()) {
640 ATH_MSG_ERROR(
"registerCondObjects: Could not register in IOV DB for CondAttrListCollection");
641 return StatusCode::FAILURE;
648 return StatusCode::SUCCESS;
658 return StatusCode::FAILURE;
661 return StatusCode::SUCCESS;
672 return StatusCode::FAILURE;
677 return StatusCode::SUCCESS;
682 coral::AttributeListSpecification*
684 coral::AttributeListSpecification* attrSpec{
new coral::AttributeListSpecification{}};
685 const std::string becName{capsFormat?
"BarrelEndcap":
"barrel_endcap"};
686 attrSpec->extend(
"SampleSize",
"int");
687 attrSpec->extend(becName,
"int");
688 attrSpec->extend(
"Layer",
"int");
689 attrSpec->extend(
"Eta",
"int");
690 attrSpec->extend(
"Phi",
"int");
700 int barrel_ec{sctId->
barrel_ec(wafer_id)};
703 const std::string becName{capsFormat?
"BarrelEndcap":
"barrel_endcap"};
704 attrList[
"SampleSize"].setValue(
static_cast<int>(samplesize));
705 attrList[becName].setValue(
static_cast<int>(barrel_ec));
706 attrList[
"Layer"].setValue(
static_cast<int>(
layer));
707 attrList[
"Eta"].setValue(
static_cast<int>(
eta));
708 attrList[
"Phi"].setValue(
static_cast<int>(
phi));