ATLAS Offline Software
ToolConstantsCondAlg.cxx
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration.
3  */
12 #include "ToolConstantsCondAlg.h"
14 
19 {
20  if (!m_coolFolderKey.empty()) {
21  if (!m_detStoreKey.empty()) {
22  ATH_MSG_ERROR( "Configuration error: both COOL folder and det store key specified." );
23  return StatusCode::FAILURE;
24  }
25  ATH_CHECK( m_blobTool.retrieve() );
27  }
28  else if (m_detStoreKey.empty()) {
29  ATH_MSG_ERROR( "Configuration error: neither COOL folder nor det store key specified." );
30  return StatusCode::FAILURE;
31  }
32 
34 
35  return StatusCode::SUCCESS;
36 }
37 
38 
43 StatusCode ToolConstantsCondAlg::execute (const EventContext& ctx) const
44 {
46  (m_toolConstantsKey, ctx);
47 
48  auto tc = std::make_unique<CaloRec::ToolConstants>();
49 
50  if (!m_coolFolderKey.empty()) {
52 
53  const std::string key = m_toolConstantsKey.key();
54 
55  const unsigned chNbr = m_blobTool->nameToChannelNumber (key);
56  // Check that this channel actually exits
57  const std::string& chanName = coolFolder->chanName (chNbr);
58  if (!chanName.empty() && key!=chanName) {
59  ATH_MSG_ERROR( "Channel name does not match! Expected " << key << " found " << chanName );
60  return StatusCode::FAILURE;
61  }
62  else {
63  ATH_MSG_DEBUG( "Found channel number " << chNbr << " named " << key );
64  }
65 
66  const coral::AttributeList& attrList = coolFolder->attributeList (chNbr);
67  ATH_CHECK( m_blobTool->AttrListToToolConstants (attrList, *tc) );
68 
69  toolConstants.addDependency (coolFolder);
70  }
71  else if (!m_detStoreKey.empty()) {
72  const CaloRec::ToolConstants* tc_in = nullptr;
74  *tc = *tc_in;
75 
76  const EventIDRange fullRange=IOVInfiniteRange::infiniteRunLB();
77  toolConstants.addDependency (fullRange);
78  }
79  else {
80  ATH_MSG_ERROR( "Bad configuration." );
81  return StatusCode::FAILURE;
82  }
83 
84  ATH_CHECK( toolConstants.record (std::move (tc)) );
85  return StatusCode::SUCCESS;
86 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ToolConstantsCondAlg::initialize
virtual StatusCode initialize() override
Gaudi initialize method.
Definition: ToolConstantsCondAlg.cxx:18
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ToolConstantsCondAlg.h
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
ToolConstantsCondAlg::m_coolFolderKey
SG::ReadCondHandleKey< CondAttrListCollection > m_coolFolderKey
Definition: ToolConstantsCondAlg.h:61
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
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
IOVInfiniteRange::infiniteRunLB
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
Definition: IOVInfiniteRange.h:39
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondAttrListCollection::attributeList
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
Definition: CondAttrListCollection.h:401
CondAttrListCollection::chanName
const std::string & chanName(ChanNum chanNum) const
find name for particular channel
Definition: CondAttrListCollection.h:426
IOVInfiniteRange.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
ToolConstantsCondAlg::m_detStoreKey
StringProperty m_detStoreKey
Definition: ToolConstantsCondAlg.h:64
CaloRec::ToolConstants
Container for the tool constants managed by ToolWithConstants.
Definition: ToolConstants.h:32
ToolConstantsCondAlg::execute
StatusCode execute(const EventContext &ctx) const override
Gaudi execute method.
Definition: ToolConstantsCondAlg.cxx:43
ToolConstantsCondAlg::m_toolConstantsKey
SG::WriteCondHandleKey< CaloRec::ToolConstants > m_toolConstantsKey
Definition: ToolConstantsCondAlg.h:67
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
ToolConstantsCondAlg::m_blobTool
ToolHandle< Blob2ToolConstants > m_blobTool
Definition: ToolConstantsCondAlg.h:58
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition: WriteCondHandle.h:275
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37