1 //Dear emacs, this is -*- c++ -*-
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
8 #include "TileConditions/TileCondProxyCool.h"
9 #include "TileCalibBlobObjs/TileCalibDrawerFlt.h"
10 #include "TileCalibBlobObjs/TileCalibDrawerBch.h"
11 #include "TileCalibBlobObjs/TileCalibDrawerOfc.h"
12 #include "TileCalibBlobObjs/TileCalibUtils.h"
15 #include "AthenaKernel/errorcheck.h"
16 #include "StoreGate/ReadCondHandle.h"
20 //____________________________________________________________________
22 TileCondProxyCool<T>::TileCondProxyCool(const std::string& type, const std::string& name,
23 const IInterface* parent)
24 : AthAlgTool(type, name, parent)
26 declareInterface<ITileCondProxy<T> >(this);
30 //____________________________________________________________________
32 StatusCode TileCondProxyCool<T>::initialize() {
34 ATH_MSG_DEBUG( "In initialize() for " << name() );
36 ATH_MSG_INFO( "Creating TileCondProxyCool(" << name()
37 << ") for folder: \"" << m_sourceKey.key() << "\"" );
39 ATH_CHECK( m_sourceKey.initialize() );
41 return StatusCode::SUCCESS;
45 //____________________________________________________________________
47 StatusCode TileCondProxyCool<T>::finalize() {
49 ATH_MSG_DEBUG( "finalize called for " << name() );
50 return StatusCode::SUCCESS;
55 StatusCode TileCondProxyCool<T>::fillCalibData(TileCalibData<T>& calibData,
56 EventIDRange& eventRange) const {
58 ATH_MSG_DEBUG( "createCalibData called for " << name() );
60 SG::ReadCondHandle<CondAttrListCollection> source{m_sourceKey};
61 const CondAttrListCollection* attrListCollection{*source};
63 if (!attrListCollection) {
64 ATH_MSG_ERROR("Failed to retrieve CondAttributeListCollection with key " << m_sourceKey.key());
65 return StatusCode::FAILURE;
68 //=== Loop over collection by increasing channel number (defaults first!)
69 for (unsigned int drawerIdx = 0; drawerIdx < TileCalibUtils::MAX_DRAWERIDX; ++drawerIdx) {
72 CondAttrListCollection::const_iterator attrListPair = attrListCollection->chanAttrListPair(drawerIdx);
73 if (attrListPair == attrListCollection->end()) {
74 ATH_MSG_ERROR("Cannot find drawer index " << drawerIdx << " in collection with key " << m_sourceKey.key());
75 return StatusCode::FAILURE;
77 const coral::Blob& blob = (attrListPair->second)[0].data<coral::Blob>();
81 //=== Get new TileCalibDrawer instance, interpreting current blob
82 std::unique_ptr<const T> calibDrawer(T::getInstance(blob));
83 calibData.setCalibDrawer(drawerIdx, calibDrawer.release());
89 ATH_MSG_ERROR( "No default available!?" );
90 return StatusCode::FAILURE;
92 //=== Determine default index
93 unsigned int defaultDrawerIdx = TileCalibUtils::getDefaultDrawerIdx(drawerIdx);
94 calibData.setCalibDrawer(drawerIdx, calibData.getCalibDrawer(defaultDrawerIdx));
96 ATH_MSG_VERBOSE( "Using default drawer " << defaultDrawerIdx
97 << " for drawerIdx=" << drawerIdx << endmsg
98 << "... i.e. TileCalibDrawer @ " << calibData.getCalibDrawer(drawerIdx));
105 // Define validity of the output cond object
106 if(!source.range(eventRange)) {
107 ATH_MSG_ERROR("Failed to retrieve validity range for " << source.key());
108 return StatusCode::FAILURE;
112 return StatusCode::SUCCESS;