ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_MonitorCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9#include <memory>
10
11SCT_MonitorCondAlg::SCT_MonitorCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
12 : ::AthCondAlgorithm(name, pSvcLocator)
13{
14}
15
17{
18 ATH_MSG_DEBUG("initialize " << name());
19
20 ATH_CHECK(detStore()->retrieve(m_helper, "SCT_ID"));
21
22 // Read Cond Handle
23 ATH_CHECK(m_readKey.initialize());
24
25 // Write Cond Handle
26 ATH_CHECK(m_writeKey.initialize());
27
28 return StatusCode::SUCCESS;
29}
30
31StatusCode SCT_MonitorCondAlg::execute(const EventContext& ctx) const
32{
33 ATH_MSG_DEBUG("execute " << name());
34
35 // Write Cond Handle
37
38 // Do we have a valid Write Cond Handle for current time?
39 if (writeHandle.isValid()) {
40 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
41 << ". In theory this should not be called, but may happen"
42 << " if multiple concurrent events are being processed out of order.");
43 return StatusCode::SUCCESS;
44 }
45
46 // Read Cond Handle
48 const CondAttrListCollection* readCdo{*readHandle};
49 if (readCdo==nullptr) {
50 ATH_MSG_FATAL("Null pointer to the read conditions object");
51 return StatusCode::FAILURE;
52 }
53 ATH_MSG_INFO("Size of CondAttrListCollection readCdo->size()= " << readCdo->size());
54
55 // Add dependency
56 writeHandle.addDependency(readHandle);
57
58 // Construct the output Cond Object and fill it in
59 std::unique_ptr<SCT_MonitorCondData> writeCdo{std::make_unique<SCT_MonitorCondData>()};
60
61 // Fill Write Cond Handle
62 static const unsigned int defectListIndex{7};
65 for (; iter!=last; ++iter) {
66 const coral::AttributeList& list{iter->second};
67 if (list.size()>defectListIndex) {
68 const Identifier moduleId{m_helper->module_id(Identifier{iter->first})};
69 const IdentifierHash moduleHash{m_helper->wafer_hash(moduleId)};
70 writeCdo->insert(moduleHash, list[defectListIndex].data<std::string>());
71 }
72 }
73
74 // Record validity of the output cond obbject
75 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
76 ATH_MSG_FATAL("Could not record SCT_MonitorCondData " << writeHandle.key()
77 << " with EventRange " << writeHandle.getRange()
78 << " into Conditions Store");
79 return StatusCode::FAILURE;
80 }
81 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
82
83 return StatusCode::SUCCESS;
84}
85
87{
88 ATH_MSG_DEBUG("finalize " << name());
89 return StatusCode::SUCCESS;
90}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
This is an Identifier helper class for the SCT subdetector.
const ServiceHandle< StoreGateSvc > & detStore() const
Base class for conditions algorithms.
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
size_type size() const
number of Chan/AttributeList pairs
ChanAttrListMap::const_iterator const_iterator
This is a "hash" representation of an Identifier.
virtual StatusCode initialize() override final
virtual StatusCode finalize() override final
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteCondHandleKey< SCT_MonitorCondData > m_writeKey
SCT_MonitorCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
const SCT_ID * m_helper
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const