ATLAS Offline Software
PixelDeadMapCondAlg.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 "PixelDeadMapCondAlg.h"
6 #include "GaudiKernel/EventIDRange.h"
7 #include "StringUtilities.h"
8 
9 
11 
12 PixelDeadMapCondAlg::PixelDeadMapCondAlg(const std::string& name, ISvcLocator* pSvcLocator):
13  ::AthReentrantAlgorithm(name, pSvcLocator)
14 {
15 }
16 
18  ATH_MSG_DEBUG("PixelDeadMapCondAlg::initialize()");
19 
22 
23  return StatusCode::SUCCESS;
24 }
25 
26 StatusCode PixelDeadMapCondAlg::execute(const EventContext& ctx) const {
27  ATH_MSG_DEBUG("PixelDeadMapCondAlg::execute()");
28 
30  if (writeHandle.isValid()) {
31  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid.. In theory this should not be called, but may happen if multiple concurrent events are being processed out of order.");
32  return StatusCode::SUCCESS;
33  }
34 
35  // Construct the output Cond Object and fill it in
36  std::unique_ptr<PixelDeadMapCondData> writeCdo(std::make_unique<PixelDeadMapCondData>());
37 
38  const EventIDBase start{EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, 0,
39  0, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
40  const EventIDBase stop {EventIDBase::UNDEFNUM, EventIDBase::UNDEFEVT, EventIDBase::UNDEFNUM-1,
41  EventIDBase::UNDEFNUM-1, EventIDBase::UNDEFNUM, EventIDBase::UNDEFNUM};
42 
43  EventIDRange rangeW{start, stop};
44  if (!m_readKey.empty()) {
46  const CondAttrListCollection* readCdo = *readHandle;
47  if (readCdo==nullptr) {
48  ATH_MSG_FATAL("Null pointer to the read conditions object");
49  return StatusCode::FAILURE;
50  }
51  // Get the validitiy range
52  if (not readHandle.range(rangeW)) {
53  ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
54  return StatusCode::FAILURE;
55  }
56  ATH_MSG_INFO("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
57  ATH_MSG_INFO("Range of input is " << rangeW);
58 
59  for (const auto & attrList : *readCdo) {
60  const CondAttrListCollection::AttributeList &payload = attrList.second;
61  // RUN-3 format
62  if (payload.exists("data_array") and not payload["data_array"].isNull()) {
63  const std::string &stringStatus = payload["data_array"].data<std::string>();
64  const auto & hashStatusVector = parseDeadMapString(stringStatus);
65  for (const auto & [hash, status] : hashStatusVector){
66  //status ==0 means its the module status to be set to '1'
67  if (status==0) writeCdo->setModuleStatus(hash, 1);
68  //...any other status will set the chip status
69  else writeCdo->setChipStatus(hash, status);
70  }
71  }
72  }
73  }
74 
75  if (rangeW.stop().isValid() and rangeW.start()>rangeW.stop()) {
76  ATH_MSG_FATAL("Invalid intersection rangeW: " << rangeW);
77  return StatusCode::FAILURE;
78  }
79 
80  if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
81  ATH_MSG_FATAL("Could not record PixelDeadMapCondData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store");
82  return StatusCode::FAILURE;
83  }
84  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
85 
86  return StatusCode::SUCCESS;
87 }
88 
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
PixelDeadMapCondAlg.h
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition: ReadCondHandle.h:60
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
PixelConditionsAlgorithms::parseDeadMapString
std::vector< std::pair< int, int > > parseDeadMapString(const std::string &s)
Definition: StringUtilities.cxx:19
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition: ReadCondHandle.h:223
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
PixelDeadMapCondAlg::PixelDeadMapCondAlg
PixelDeadMapCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelDeadMapCondAlg.cxx:12
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
PixelDeadMapCondData::setModuleStatus
void setModuleStatus(const int chanNum, const int value)
Definition: PixelDeadMapCondData.cxx:16
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
PixelDeadMapCondAlg::m_writeKey
SG::WriteCondHandleKey< PixelDeadMapCondData > m_writeKey
Definition: PixelDeadMapCondAlg.h:37
PixelDeadMapCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: PixelDeadMapCondAlg.cxx:26
PixelDeadMapCondAlg::m_readKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey
Definition: PixelDeadMapCondAlg.h:34
PixelDeadMapCondData::setChipStatus
void setChipStatus(const int chanNum, const int value)
Definition: PixelDeadMapCondData.cxx:27
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
PixelDeadMapCondAlg::initialize
virtual StatusCode initialize() override final
Definition: PixelDeadMapCondAlg.cxx:17
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
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
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
StringUtilities.h
merge.status
status
Definition: merge.py:17
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