ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_SensorsCondAlg.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
9SCT_SensorsCondAlg::SCT_SensorsCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
10 : ::AthCondAlgorithm(name, pSvcLocator)
11{
12}
13
15{
16 ATH_MSG_DEBUG("initialize " << name());
17
18 // Read Cond Handle
19 ATH_CHECK(m_readKey.initialize());
20
21 // Write Cond Handle
22 ATH_CHECK(m_writeKey.initialize());
23
24 return StatusCode::SUCCESS;
25}
26
27StatusCode SCT_SensorsCondAlg::execute(const EventContext& ctx) const
28{
29 ATH_MSG_DEBUG("execute " << name());
30
31 // Write Cond Handle
33
34 // Do we have a valid Write Cond Handle for current time?
35 if (writeHandle.isValid()) {
36
37 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
38 << ". In theory this should not be called, but may happen"
39 << " if multiple concurrent events are being processed out of order.");
40 return StatusCode::SUCCESS;
41 }
42
43 // Read Cond Handle
45 const CondAttrListCollection* readCdo{*readHandle};
46 if (readCdo==nullptr) {
47 ATH_MSG_FATAL("Null pointer to the read conditions object");
48 return StatusCode::FAILURE;
49 }
50 ATH_MSG_INFO("Size of CondAttrListCollection readCdo->size()= " << readCdo->size());
51
52 // Add dependency
53 writeHandle.addDependency(readHandle);
54
55 // Construct the output Cond Object and fill it in
56 std::unique_ptr<SCT_SensorsCondData> writeCdo{std::make_unique<SCT_SensorsCondData>()};
57
58 // Fill write conditions data object
61 // CondAttrListCollection doesnt support C++11 type loops, no generic 'begin'
62 for (; attrList!=end; ++attrList) {
63 CondAttrListCollection::ChanNum truncatedSerialNumber{attrList->first};
65 bool isOK{false};
66 isOK |= data.setTruncatedSerialNumber(truncatedSerialNumber);
67 isOK |= data.setManufacturer(attrList->second[0].data<std::string>());
68 isOK |= data.setDepletionVoltage(SCT_SensorCondData::SENSOR1, attrList->second[1].data<float>());
69 isOK |= data.setDepletionVoltage(SCT_SensorCondData::SENSOR2, attrList->second[2].data<float>());
70 isOK |= data.setDepletionVoltage(SCT_SensorCondData::SENSOR3, attrList->second[3].data<float>());
71 isOK |= data.setDepletionVoltage(SCT_SensorCondData::SENSOR4, attrList->second[4].data<float>());
72 isOK |= data.setCrystalOrientation(SCT_SensorCondData::SENSOR1, static_cast<int>(attrList->second[5].data<long long>()));
73 isOK |= data.setCrystalOrientation(SCT_SensorCondData::SENSOR2, static_cast<int>(attrList->second[6].data<long long>()));
74 isOK |= data.setCrystalOrientation(SCT_SensorCondData::SENSOR3, static_cast<int>(attrList->second[7].data<long long>()));
75 isOK |= data.setCrystalOrientation(SCT_SensorCondData::SENSOR4, static_cast<int>(attrList->second[8].data<long long>()));
76 if (not isOK) {
77 ATH_MSG_WARNING("At least one element of SCT_SensorCondData for truncatedSerialNumber " << truncatedSerialNumber << " was not correctly stored.");
78 }
79 (*writeCdo)[truncatedSerialNumber] = data;
80 }
81
82 // Record write conditions data object
83 if (writeHandle.record(std::move(writeCdo)).isFailure()) {
84 ATH_MSG_FATAL("Could not record SCT_SensorsCondData " << writeHandle.key()
85 << " with EventRange " << writeHandle.getRange()
86 << " into Conditions Store");
87 return StatusCode::FAILURE;
88 }
89 ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
90
91 return StatusCode::SUCCESS;
92}
93
95{
96 ATH_MSG_DEBUG("finalize " << name());
97 return StatusCode::SUCCESS;
98}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
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
Class for data object used in SCT_SensorsCondAlg and SCT_SensorsTool.
SCT_SensorsCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
virtual StatusCode execute(const EventContext &ctx) const override final
virtual StatusCode finalize() override final
SG::WriteCondHandleKey< SCT_SensorsCondData > m_writeKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
virtual StatusCode initialize() override final
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