ATLAS Offline Software
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 
5 #include "SCT_MonitorCondAlg.h"
6 
8 
9 #include <memory>
10 
11 SCT_MonitorCondAlg::SCT_MonitorCondAlg(const std::string& name, ISvcLocator* pSvcLocator)
12  : ::AthReentrantAlgorithm(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
24 
25  // Write Cond Handle
27 
28  return StatusCode::SUCCESS;
29 }
30 
31 StatusCode 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};
63  CondAttrListCollection::const_iterator iter{readCdo->begin()};
64  CondAttrListCollection::const_iterator last{readCdo->end()};
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_MonitorCondAlg::SCT_MonitorCondAlg
SCT_MonitorCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_MonitorCondAlg.cxx:11
SCT_MonitorCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: SCT_MonitorCondAlg.cxx:31
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
SCT_ID::module_id
Identifier module_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: SCT_ID.h:416
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
SCT_MonitorCondAlg::initialize
virtual StatusCode initialize() override final
Definition: SCT_MonitorCondAlg.cxx:16
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
SCT_MonitorCondAlg::finalize
virtual StatusCode finalize() override final
Definition: SCT_MonitorCondAlg.cxx:86
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
SCT_MonitorCondAlg::m_writeKey
SG::WriteCondHandleKey< SCT_MonitorCondData > m_writeKey
Definition: SCT_MonitorCondAlg.h:29
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
SCT_MonitorCondAlg.h
SCT_MonitorCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: SCT_MonitorCondAlg.h:28
IdentifierHash
Definition: IdentifierHash.h:38
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
SCT_MonitorCondAlg::m_helper
const SCT_ID * m_helper
Definition: SCT_MonitorCondAlg.h:30