ATLAS Offline Software
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 
5 #include "SCT_SensorsCondAlg.h"
6 
7 #include <memory>
8 
9 SCT_SensorsCondAlg::SCT_SensorsCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
10  : ::AthReentrantAlgorithm(name, pSvcLocator)
11 {
12 }
13 
15 {
16  ATH_MSG_DEBUG("initialize " << name());
17 
18  // Read Cond Handle
20 
21  // Write Cond Handle
23 
24  return StatusCode::SUCCESS;
25 }
26 
27 StatusCode 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
59  CondAttrListCollection::const_iterator attrList{readCdo->begin()};
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 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_SensorsCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_SensorsCondAlg.cxx:94
SCT_SensorCondData::SENSOR2
@ SENSOR2
Definition: SCT_SensorCondData.h:52
SCT_SensorsCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_SensorsCondData > m_writeKey
Definition: SCT_SensorsCondAlg.h:29
SCT_SensorCondData::SENSOR3
@ SENSOR3
Definition: SCT_SensorCondData.h:52
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
SCT_SensorsCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_SensorsCondAlg.cxx:14
SCT_SensorsCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: SCT_SensorsCondAlg.h:28
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
SCT_SensorCondData::SENSOR4
@ SENSOR4
Definition: SCT_SensorCondData.h:52
SCT_SensorsCondAlg.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
SCT_SensorsCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_SensorsCondAlg.cxx:27
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
SCT_SensorsCondAlg::SCT_SensorsCondAlg
SCT_SensorsCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_SensorsCondAlg.cxx:9
SCT_SensorCondData::SENSOR1
@ SENSOR1
Definition: SCT_SensorCondData.h:52
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_SensorCondData
Class for data object used in SCT_SensorsCondAlg and SCT_SensorsTool.
Definition: SCT_SensorCondData.h:25