ATLAS Offline Software
Loading...
Searching...
No Matches
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
19using 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;
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
93StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t tc
Container for the tool constants managed by ToolWithConstants.
const ServiceHandle< StoreGateSvc > & detStore() const
virtual StatusCode initialize() override
ToolHandle< Blob2ToolConstants > m_blobTool
virtual StatusCode execute(const EventContext &ctx) const override
virtual StatusCode finalize() override
StringProperty m_key
Key for the DetectorStore (jobOptions) The ToolConstants will be recorded with this key.
ToolHandleArray< IToolWithConstants > m_tools
The list of tools.
Container for the tool constants managed by ToolWithConstants.
This class is a collection of AttributeLists where each one is associated with a channel number.
bool add(ChanNum chanNum, const AttributeList &attributeList)
Adding in chan/attrList pairs.
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
Namespace for helper functions.