ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
15PixelReadoutSpeedAlg::PixelReadoutSpeedAlg(const std::string& name, ISvcLocator* pSvcLocator):
16 ::AthReentrantAlgorithm(name, pSvcLocator)
17{
18}
19
21 ATH_MSG_DEBUG("PixelReadoutSpeedAlg::initialize()");
22
23 ATH_CHECK(m_readKey.initialize());
24 ATH_CHECK(m_writeKey.initialize());
25
26 return StatusCode::SUCCESS;
27}
28
29StatusCode 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
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
An algorithm that can be simultaneously executed in multiple threads.
An AttributeList represents a logical row of attributes in a metadata table.
SG::WriteCondHandleKey< PixelReadoutSpeedData > m_writeKey
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
PixelReadoutSpeedAlg(const std::string &name, ISvcLocator *pSvcLocator)
bool range(EventIDRange &r)
const std::string & key() const
const DataObjID & fullKey() const
const std::string & key() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const