ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_ModuleVetoCondAlg.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
7#include <memory>
8
9namespace {
10 template <class T>
11 std::vector<T>
12 string2Vector(const std::string& s) {
13 std::vector<T> v;
14 std::istringstream inputStream{s};
15 std::istream_iterator<T> vecRead{inputStream};
16 std::istream_iterator<T> endOfString; //relies on default constructor to produce eof
17 std::copy(vecRead,endOfString, std::back_inserter(v)); // DOESN'T ALLOW NON-WHITESPACE DELIMITER !
18 return v;
19 }
20}
21
22SCT_ModuleVetoCondAlg::SCT_ModuleVetoCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
23 : ::AthCondAlgorithm(name, pSvcLocator)
24{
25}
26
28 ATH_MSG_DEBUG("initialize " << name());
29
30 // Read Cond Handle
31 ATH_CHECK(m_readKey.initialize());
32 // Write Cond Handles
33 ATH_CHECK(m_writeKey.initialize());
34
35 return StatusCode::SUCCESS;
36}
37
38StatusCode SCT_ModuleVetoCondAlg::execute(const EventContext& ctx) const {
39 ATH_MSG_DEBUG("execute " << name());
40
41 // Write Cond Handle
43 // Do we have a valid Write Cond Handle for current time?
44 if (writeHandle.isValid()) {
45 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
46 << ". In theory this should not be called, but may happen"
47 << " if multiple concurrent events are being processed out of order.");
48 return StatusCode::SUCCESS;
49 }
50
51 // Read Cond Handle
53 const AthenaAttributeList* readCdo{*readHandle};
54 if (readCdo==nullptr) {
55 ATH_MSG_FATAL("Null pointer to the read conditions object");
56 return StatusCode::FAILURE;
57 }
58 // Add dependency
59 writeHandle.addDependency(readHandle);
60 ATH_MSG_INFO("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
61 ATH_MSG_INFO("Range of input is " << readHandle.getRange());
62
63 // Construct the output Cond Object and fill it in
64 std::unique_ptr<SCT_ModuleVetoCondData> writeCdo{std::make_unique<SCT_ModuleVetoCondData>()};
65
66 // Read bad wafer info
67 const std::string &badModuleString{(*readCdo)["ModuleList"].data<std::string>()};
68 std::vector<unsigned long long> v{string2Vector<unsigned long long>(badModuleString)};
69 unsigned long long numberInDb{static_cast<unsigned long long>(v.size())};
70 ATH_MSG_INFO(numberInDb << " elements were declared bad in the database.");
71 for (const unsigned long long badWaferId: v) {
72 writeCdo->setBadWaferId(Identifier{badWaferId});
73 }
74
75 // Record the output cond object
76 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
77 ATH_MSG_FATAL("Could not record SCT_ModuleVetoCondData " << writeHandle.key()
78 << " with EventRange " << writeHandle.getRange()
79 << " into Conditions Store");
80 return StatusCode::FAILURE;
81 }
82 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
83
84 return StatusCode::SUCCESS;
85}
86
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)
Base class for conditions algorithms.
An AttributeList represents a logical row of attributes in a metadata table.
SCT_ModuleVetoCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode initialize() override final
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteCondHandleKey< SCT_ModuleVetoCondData > m_writeKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
virtual StatusCode finalize() override final
const DataObjID & fullKey() const
const EventIDRange & getRange()
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