ATLAS Offline Software
CaloClusterCorrDBWriter.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //-----------------------------------------------------------------------
6 //
7 // Description: see CaloClusterCorrDBWriter.h
8 //-----------------------------------------------------------------------
9 
10 
12 #include "GaudiKernel/ThreadLocalContext.h"
13 
17 
18 
19 using namespace CaloRec;
20 
21 //#############################################################################
22 
24 {
25  ATH_CHECK( m_blobTool.retrieve());
26  ATH_CHECK( m_tools.retrieve());
27  REPORT_MESSAGE(MSG::INFO) << m_key << ": "
28  << "Found " << m_tools.size() <<
29  " tools.";
30  return StatusCode::SUCCESS;
31 }
32 
33 //#############################################################################
34 
36 {
37  const EventContext& ctx = Gaudi::Hive::currentContext();
38  if (!m_inlineFolder.empty()) {
40  std::string toolnames;
41  unsigned coolChannelNbr=m_blobTool->nameToChannelNumber(m_key);
42  CondAttrListCollection* attrColl=nullptr;
43  if (detStore()->contains<CondAttrListCollection>(m_inlineFolder)) {
44  CHECK(detStore()->retrieve(attrColl,m_inlineFolder));
45  }
46  else {
47  attrColl=new CondAttrListCollection(true);
48  CHECK(detStore()->record(attrColl,m_inlineFolder));
49  }
50 
51  for (size_t i = 0; i < m_tools.size(); i++) {
52  CHECK( m_tools[i]->mergeConstants (tc, ctx) );
53  toolnames += m_tools[i]->name() + " ";
54  }
55  coral::AttributeList* attrList=m_blobTool->ToolConstantsToAttrList(&tc);
56  if (!attrList)
57  return StatusCode::FAILURE;
58 
59  const std::string& tName=m_key;
60  attrColl->add(coolChannelNbr,tName);
61  attrColl->add(coolChannelNbr,*attrList);
62 
63  delete attrList;
64 
65 
66  REPORT_MESSAGE(MSG::INFO) << "Recorded CondAttributeListCollection with key " << m_inlineFolder << " channel name " << m_key
67  << " to DetStore.\n Tools: " << toolnames;
68  }
69  else {
70  auto tc = std::make_unique<CaloRec::ToolConstants>();
71  std::string toolnames;
72  for (size_t i = 0; i < m_tools.size(); i++) {
73  CHECK( m_tools[i]->mergeConstants (*tc, ctx) );
74  toolnames += m_tools[i]->name() + " ";
75  }
76 
77  CHECK( detStore()->record (std::move(tc), m_key) );
78  REPORT_MESSAGE(MSG::INFO) << "Recorded constants for key " << m_key
79  << " to DetStore.\n Tools: " << toolnames;
80  }//end else m_inline
81 
82 
83 
84 
85  //std::cout << detStore()->dump() << std::endl;
86 
87 
88  return StatusCode::SUCCESS;
89 }
90 
91 //#############################################################################
92 
93 StatusCode CaloClusterCorrDBWriter::execute (const EventContext& /*ctx*/) const
94 {
95  // Make sure the detector store gets created.
96  (void)detStore()->name();
97  return StatusCode::SUCCESS;
98 }
99 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
ToolConstants.h
Container for the tool constants managed by ToolWithConstants.
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
CaloClusterCorrDBWriter::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: CaloClusterCorrDBWriter.cxx:93
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
CaloClusterCorrDBWriter::initialize
virtual StatusCode initialize() override
Definition: CaloClusterCorrDBWriter.cxx:23
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
CaloRec
Namespace for helper functions.
Definition: CaloCellFactor.h:22
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
CaloRec::ToolConstants
Container for the tool constants managed by ToolWithConstants.
Definition: ToolConstants.h:32
CaloClusterCorrDBWriter::finalize
virtual StatusCode finalize() override
Definition: CaloClusterCorrDBWriter.cxx:35
CaloClusterCorrDBWriter.h
CondAttrListCollection::add
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
Definition: CondAttrListCollection.h:452