ATLAS Offline Software
Loading...
Searching...
No Matches
TileCondProxyCool.icc
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
7// Tile includes
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"
13
14// Athena includes
15#include "AthenaKernel/errorcheck.h"
16#include "StoreGate/ReadCondHandle.h"
17
18
19//
20//____________________________________________________________________
21template<typename T>
22TileCondProxyCool<T>::TileCondProxyCool(const std::string& type, const std::string& name,
23 const IInterface* parent)
24 : AthAlgTool(type, name, parent)
25{
26 declareInterface<ITileCondProxy<T> >(this);
27}
28
29//
30//____________________________________________________________________
31template<typename T>
32StatusCode TileCondProxyCool<T>::initialize() {
33
34 ATH_MSG_DEBUG( "In initialize() for " << name() );
35
36 ATH_MSG_INFO( "Creating TileCondProxyCool(" << name()
37 << ") for folder: \"" << m_sourceKey.key() << "\"" );
38
39 ATH_CHECK( m_sourceKey.initialize() );
40
41 return StatusCode::SUCCESS;
42}
43
44//
45//____________________________________________________________________
46template<typename T>
47StatusCode TileCondProxyCool<T>::finalize() {
48
49 ATH_MSG_DEBUG( "finalize called for " << name() );
50 return StatusCode::SUCCESS;
51
52}
53
54template<typename T>
55StatusCode TileCondProxyCool<T>::fillCalibData(TileCalibData<T>& calibData,
56 EventIDRange& eventRange) const {
57
58 ATH_MSG_DEBUG( "createCalibData called for " << name() );
59
60 SG::ReadCondHandle<CondAttrListCollection> source{m_sourceKey};
61 const CondAttrListCollection* attrListCollection{*source};
62
63 if (!attrListCollection) {
64 ATH_MSG_ERROR("Failed to retrieve CondAttributeListCollection with key " << m_sourceKey.key());
65 return StatusCode::FAILURE;
66 }
67
68 //=== Loop over collection by increasing channel number (defaults first!)
69 for (unsigned int drawerIdx = 0; drawerIdx < TileCalibUtils::MAX_DRAWERIDX; ++drawerIdx) {
70
71 //=== get the BLOB
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;
76 }
77 const coral::Blob& blob = (attrListPair->second)[0].data<coral::Blob>();
78
79 if (blob.size()) {
80
81 //=== Get new TileCalibDrawer instance, interpreting current blob
82 std::unique_ptr<const T> calibDrawer(T::getInstance(blob));
83 calibData.setCalibDrawer(drawerIdx, calibDrawer.release());
84
85 } else {
86
87 //=== Default policy
88 if (drawerIdx == 0) {
89 ATH_MSG_ERROR( "No default available!?" );
90 return StatusCode::FAILURE;
91 }
92 //=== Determine default index
93 unsigned int defaultDrawerIdx = TileCalibUtils::getDefaultDrawerIdx(drawerIdx);
94 calibData.setCalibDrawer(drawerIdx, calibData.getCalibDrawer(defaultDrawerIdx));
95
96 ATH_MSG_VERBOSE( "Using default drawer " << defaultDrawerIdx
97 << " for drawerIdx=" << drawerIdx << endmsg
98 << "... i.e. TileCalibDrawer @ " << calibData.getCalibDrawer(drawerIdx));
99
100 }
101
102 } // End drawerIdx
103
104
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;
109 }
110
111
112 return StatusCode::SUCCESS;
113}