ATLAS Offline Software
SCT_DCSConditionsTempCondAlg.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 
9 #include <memory>
10 
11 SCT_DCSConditionsTempCondAlg::SCT_DCSConditionsTempCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
12  : ::AthReentrantAlgorithm(name, pSvcLocator)
13 {
14 }
15 
17  ATH_MSG_DEBUG("initialize " << name());
18 
19  // Read Cond Handle
21  // Write Cond Handles
23 
24  return StatusCode::SUCCESS;
25 }
26 
27 StatusCode SCT_DCSConditionsTempCondAlg::execute(const EventContext& ctx) const {
28  ATH_MSG_DEBUG("execute " << name());
29 
30  if (not m_returnHVTemp) {
31  return StatusCode::SUCCESS;
32  }
33 
34  // Write Cond Handle
36  // Do we have a valid Write Cond Handle for current time?
37  if (writeHandle.isValid()) {
38  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
39  << ". In theory this should not be called, but may happen"
40  << " if multiple concurrent events are being processed out of order.");
41  return StatusCode::SUCCESS;
42  }
43 
44  writeHandle.addDependency(IOVInfiniteRange::infiniteMixed());
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  // Add dependency
54  writeHandle.addDependency(readHandle);
55  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
56  ATH_MSG_INFO("Range of input is " << readHandle.getRange());
57 
58  // Construct the output Cond Object and fill it in
59  std::unique_ptr<SCT_DCSFloatCondData> writeCdo{std::make_unique<SCT_DCSFloatCondData>()};
60 
61  // Read temperature info
62  std::string param{"MOCH_TM0_RECV"};
63  CondAttrListCollection::const_iterator attrList{readCdo->begin()};
65  // CondAttrListCollection doesn't support C++11 type loops, no generic 'begin'
66  for (; attrList!=end; ++attrList) {
67  // A CondAttrListCollection is a map of ChanNum and AttributeList
68  CondAttrListCollection::ChanNum channelNumber{attrList->first};
69  const CondAttrListCollection::AttributeList &payload{attrList->second};
70  if (payload.exists(param) and not payload[param].isNull()) {
71  float val{payload[param].data<float>()};
72  writeCdo->setValue(channelNumber, val);
73  } else {
74  ATH_MSG_WARNING(param << " does not exist for ChanNum " << channelNumber);
75  }
76  }
77 
78  // Record the output cond object
79  if (writeHandle.record(std::move(writeCdo)).isFailure()) {
80  ATH_MSG_FATAL("Could not record SCT_DCSFloatCondData " << writeHandle.key()
81  << " with EventRange " << writeHandle.getRange()
82  << " into Conditions Store");
83  return StatusCode::FAILURE;
84  }
85  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
86 
87  return StatusCode::SUCCESS;
88 }
89 
91 {
92  ATH_MSG_DEBUG("finalize " << name());
93  return StatusCode::SUCCESS;
94 }
SCT_DCSConditionsTempCondAlg::SCT_DCSConditionsTempCondAlg
SCT_DCSConditionsTempCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_DCSConditionsTempCondAlg.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_DCSConditionsTempCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: SCT_DCSConditionsTempCondAlg.h:30
SCT_DCSConditionsTempCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_DCSConditionsTempCondAlg.cxx:90
IOVInfiniteRange::infiniteMixed
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Definition: IOVInfiniteRange.h:55
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
SCT_DCSConditionsTempCondAlg::m_returnHVTemp
BooleanProperty m_returnHVTemp
Definition: SCT_DCSConditionsTempCondAlg.h:33
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
IOVInfiniteRange.h
SCT_DCSConditionsTempCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_DCSFloatCondData > m_writeKey
Definition: SCT_DCSConditionsTempCondAlg.h:31
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SCT_DCSConditionsTempCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_DCSConditionsTempCondAlg.cxx:16
IdentifierHash.h
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
SCT_DCSConditionsTempCondAlg.h
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition: CondAttrListCollection.h:56
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_DCSConditionsTempCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_DCSConditionsTempCondAlg.cxx:27