ATLAS Offline Software
PixelReadoutSpeedAlg.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 "PixelReadoutSpeedAlg.h"
6 #include "GaudiKernel/EventIDRange.h"
7 
8 #include "CoralBase/Blob.h"
9 
10 #include <cstdint>
11 #include <istream>
12 #include <map>
13 #include <string>
14 
15 PixelReadoutSpeedAlg::PixelReadoutSpeedAlg(const std::string& name, ISvcLocator* pSvcLocator):
16  ::AthReentrantAlgorithm(name, pSvcLocator)
17 {
18 }
19 
21  ATH_MSG_DEBUG("PixelReadoutSpeedAlg::initialize()");
22 
25 
26  return StatusCode::SUCCESS;
27 }
28 
29 StatusCode PixelReadoutSpeedAlg::execute(const EventContext& ctx) const {
30  ATH_MSG_DEBUG("PixelReadoutSpeedAlg::execute()");
31 
33  if (writeHandle.isValid()) {
34  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.");
35  return StatusCode::SUCCESS;
36  }
37 
39  const AthenaAttributeList* readCdo = *readHandle;
40  if (readCdo==nullptr) {
41  ATH_MSG_FATAL("Null pointer to the read conditions object");
42  return StatusCode::FAILURE;
43  }
44  // Get the validitiy range
45  EventIDRange rangeW;
46  if (not readHandle.range(rangeW)) {
47  ATH_MSG_FATAL("Failed to retrieve validity range for " << readHandle.key());
48  return StatusCode::FAILURE;
49  }
50  ATH_MSG_INFO("Size of AthenaAttributeList " << readHandle.fullKey() << " readCdo->size()= " << readCdo->size());
51  ATH_MSG_INFO("Range of input is " << rangeW);
52 
53  // Construct the output Cond Object and fill it in
54  std::unique_ptr<PixelReadoutSpeedData> writeCdo(std::make_unique<PixelReadoutSpeedData>());
55 
56  const coral::Blob& blob=(*readCdo)["readoutspeed_per_ROD"].data<coral::Blob>();
57  const char* p = static_cast<const char*>(blob.startingAddress());
58  unsigned int len = blob.size();
59  std::map<uint32_t,bool> rodReadoutMap; // save readout speed for each ROD. Is set to 40 MBit (false) by default
60  std::string dataString;
61  dataString.resize(len);
62  for (unsigned int i=0; i!=len; ++i) { dataString[i]=*p++; }
63 
64  int pos=0;
65  while (dataString.find(',',pos)!=std::string::npos) {
66  std::istringstream iss(dataString.substr(pos,dataString.find(',',pos)));
67  uint32_t rod;
68  iss >> std::hex >> rod;
69 
70  const std::string speed = dataString.substr(dataString.find(',',pos)+1,dataString.find('\n',pos)-dataString.find(',',pos)-1);
71 
72  if (speed!="SINGLE_40") { rodReadoutMap[rod]=true; }
73  else { rodReadoutMap[rod]=false; }
74 
75  pos = dataString.find('\n',pos)+1;
76  }
77  writeCdo -> setReadoutMap(rodReadoutMap);
78 
79  if (writeHandle.record(rangeW, std::move(writeCdo)).isFailure()) {
80  ATH_MSG_FATAL("Could not record PixelReadoutSpeedData " << writeHandle.key() << " with EventRange " << rangeW << " into Conditions Store");
81  return StatusCode::FAILURE;
82  }
83  ATH_MSG_INFO("recorded new CDO " << writeHandle.key() << " with range " << rangeW << " into Conditions Store");
84 
85  return StatusCode::SUCCESS;
86 }
87 
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
SG::ReadCondHandle::fullKey
const DataObjID & fullKey() const
Definition: ReadCondHandle.h:60
PixelReadoutSpeedAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition: PixelReadoutSpeedAlg.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
PixelReadoutSpeedAlg::m_writeKey
SG::WriteCondHandleKey< PixelReadoutSpeedData > m_writeKey
Definition: PixelReadoutSpeedAlg.h:37
PixelReadoutSpeedAlg::initialize
virtual StatusCode initialize() override
Definition: PixelReadoutSpeedAlg.cxx:20
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
SG::ReadCondHandle::range
bool range(EventIDRange &r)
Definition: ReadCondHandle.h:224
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition: WriteCondHandle.h:157
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
SG::WriteCondHandle::fullKey
const DataObjID & fullKey() const
Definition: WriteCondHandle.h:41
lumiFormat.i
int i
Definition: lumiFormat.py:85
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
PixelReadoutSpeedAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: PixelReadoutSpeedAlg.cxx:29
PixelReadoutSpeedAlg::PixelReadoutSpeedAlg
PixelReadoutSpeedAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: PixelReadoutSpeedAlg.cxx:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
RunTileMonitoring.rod
rod
Definition: RunTileMonitoring.py:134
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
SG::WriteCondHandle::key
const std::string & key() const
Definition: WriteCondHandle.h:40
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
SG::WriteCondHandle::isValid
bool isValid() const
Definition: WriteCondHandle.h:248
PixelReadoutSpeedAlg.h
SG::ReadCondHandle::key
const std::string & key() const
Definition: ReadCondHandle.h:59
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96