ATLAS Offline Software
PixelDCSCondStatusAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "GaudiKernel/EventIDRange.h"
8 #include <memory>
9 
10 PixelDCSCondStatusAlg::PixelDCSCondStatusAlg(const std::string& name, ISvcLocator* pSvcLocator):
11  ::AthReentrantAlgorithm(name, pSvcLocator)
12 {
13 }
14 
16  ATH_MSG_DEBUG("PixelDCSCondStatusAlg::initialize()");
17 
18  ATH_CHECK(detStore()->retrieve(m_pixelID,"PixelID"));
21 
22  return StatusCode::SUCCESS;
23 }
24 
25 StatusCode PixelDCSCondStatusAlg::execute(const EventContext& ctx) const {
26  ATH_MSG_DEBUG("PixelDCSCondStatusAlg::execute()");
27 
29  if (writeHandleStatus.isValid()) {
30  ATH_MSG_DEBUG("CondHandle " << writeHandleStatus.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
31  return StatusCode::SUCCESS;
32  }
33 
34  // Construct the output Cond Object and fill it in
35  std::unique_ptr<PixelDCSStatusData> writeCdoStatus(std::make_unique<PixelDCSStatusData>());
36 
37  const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0, 0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
38  const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
39 
40  EventIDRange rangeW{start, stop};
41 
42  if (!m_readKeyStatus.empty()) {
44  const CondAttrListCollection* readCdoStatus(*readHandle);
45  if (readCdoStatus==nullptr) {
46  ATH_MSG_FATAL("Null pointer to the read conditions object (state)");
47  return StatusCode::FAILURE;
48  }
49  // Get the validitiy range
50  if (not readHandle.range(rangeW)) {
51  ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
52  return StatusCode::FAILURE;
53  }
54  ATH_MSG_INFO("Size of CondAttrListCollection " << readHandle.fullKey() << " readCdo->size()= " << readCdoStatus->size());
55  ATH_MSG_INFO("Range of state input is " << rangeW);
56 
57  // Read state info
58  const std::string paramStatus = "FSM_status";
59  for (const auto & readCdoStatu : *readCdoStatus) {
60  const CondAttrListCollection::ChanNum &channelNumber = readCdoStatu.first;
61  const CondAttrListCollection::AttributeList &payload = readCdoStatu.second;
62  if (payload.exists(paramStatus.c_str()) and not payload[paramStatus.c_str()].isNull()) {
63  const std::string& val = payload[paramStatus.c_str()].data<std::string>();
64  if (val=="OK") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::OK); }
65  else if (val=="WARNING") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::WARNING); }
66  else if (val=="ERROR") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::ERROR); }
67  else if (val=="FATAL") { writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::FATAL); }
68  }
69  else {
70  ATH_MSG_WARNING(paramStatus << " does not exist for ChanNum " << channelNumber);
71  writeCdoStatus->setModuleStatus(channelNumber,PixelDCSStatusData::DCSModuleStatus::NOSTATUS);
72  }
73  }
74  }
75  else {
76  for (int i=0; i<(int)m_pixelID->wafer_hash_max(); i++) {
77  writeCdoStatus->setModuleStatus(i,PixelDCSStatusData::DCSModuleStatus::OK);
78  }
79  }
80 
81  if (writeHandleStatus.record(rangeW, std::move(writeCdoStatus)).isFailure()) {
82  ATH_MSG_FATAL("Could not record PixelDCSStatusData " << writeHandleStatus.key() << " with EventRange "
83  << writeHandleStatus.getRange() << " into Conditions Store");
84  return StatusCode::FAILURE;
85  }
86  ATH_MSG_INFO("recorded new CDO " << writeHandleStatus.key() << " with range "
87  << writeHandleStatus.getRange() << " into Conditions Store");
88 
89  return StatusCode::SUCCESS;
90 }
91 
PixelDCSCondStatusAlg::m_writeKeyStatus
SG::WriteCondHandleKey< PixelDCSStatusData > m_writeKeyStatus
Definition: PixelDCSCondStatusAlg.h:42
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition: ReadCondHandle.h:60
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition: WriteCondHandle.h:89
python.Constants.ERROR
int ERROR
Definition: Control/AthenaCommon/python/Constants.py:18
PixelDCSCondStatusAlg::m_readKeyStatus
SG::ReadCondHandleKey< CondAttrListCollection > m_readKeyStatus
Definition: PixelDCSCondStatusAlg.h:39
PixelDCSCondStatusAlg::m_pixelID
const PixelID * m_pixelID
Definition: PixelDCSCondStatusAlg.h:36
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition: ReadCondHandle.h:224
SG::VarHandleKey::empty
bool empty() const
Test if the key is blank.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:150
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
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
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
PixelDCSCondStatusAlg::initialize
virtual StatusCode initialize() override final
Definition: PixelDCSCondStatusAlg.cxx:15
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
lumiFormat.i
int i
Definition: lumiFormat.py:85
PixelDCSCondStatusAlg.h
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
python.Constants.WARNING
int WARNING
Definition: Control/AthenaCommon/python/Constants.py:17
CondAttrListCollection::ChanNum
unsigned int ChanNum
Definition: CondAttrListCollection.h:55
PixelDCSCondStatusAlg::PixelDCSCondStatusAlg
PixelDCSCondStatusAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelDCSCondStatusAlg.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
IdentifierHash.h
PixelDCSCondStatusAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: PixelDCSCondStatusAlg.cxx:25
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
PixelID::wafer_hash_max
size_type wafer_hash_max(void) const
Definition: PixelID.cxx:831
CondAttrListCollection::size
size_type size() const
number of Chan/AttributeList pairs
Definition: CondAttrListCollection.h:322
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
CondAttrListCollection::AttributeList
coral::AttributeList AttributeList
Definition: CondAttrListCollection.h:56
SG::ReadCondHandle::key
const std::string & key() const
Definition: ReadCondHandle.h:59
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
PixelDCSStatusData::setModuleStatus
void setModuleStatus(const int chanNum, const int value)
Definition: PixelDCSStatusData.cxx:7