1 //Dear emacs, this is -*- c++ -*-
4 Copyright (C) 2002-2018 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 const coral::Blob& blob = (attrListPair->second)[0].data<coral::Blob>();
77 //=== Get new TileCalibDrawer instance, interpreting current blob
78 std::unique_ptr<const T> calibDrawer(T::getInstance(blob));
79 calibData.setCalibDrawer(drawerIdx, calibDrawer.release());
85 ATH_MSG_ERROR( "No default available!?" );
86 return StatusCode::FAILURE;
88 //=== Determine default index
89 unsigned int defaultDrawerIdx = TileCalibUtils::getDefaultDrawerIdx(drawerIdx);
90 calibData.setCalibDrawer(drawerIdx, calibData.getCalibDrawer(defaultDrawerIdx));
92 ATH_MSG_VERBOSE( "Using default drawer " << defaultDrawerIdx
93 << " for drawerIdx=" << drawerIdx << endmsg
94 << "... i.e. TileCalibDrawer @ " << calibData.getCalibDrawer(drawerIdx));
101 // Define validity of the output cond object
102 if(!source.range(eventRange)) {
103 ATH_MSG_ERROR("Failed to retrieve validity range for " << source.key());
104 return StatusCode::FAILURE;
108 return StatusCode::SUCCESS;