ATLAS Offline Software
Loading...
Searching...
No Matches
TgcDigitASDposCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
9#include "CoralBase/Blob.h"
10#include <string_view>
11
12
13namespace Muon{
15{
16 ATH_MSG_DEBUG("initialize " << name());
17
18 ATH_CHECK(m_readKey_ASDpos.initialize());
19 ATH_CHECK(m_writeKey.initialize());
20
21 return StatusCode::SUCCESS;
22}
23
24StatusCode TgcDigitASDposCondAlg::execute(const EventContext& ctx) const
25{
26 SG::WriteCondHandle writeHandle{m_writeKey, ctx};
27 if (writeHandle.isValid()) {
28 ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
29 << ". In theory this should not be called, but may happen"
30 << " if multiple concurrent events are being processed out of order.");
31 return StatusCode::SUCCESS;
32 }
33
34 SG::ReadCondHandle readHandle_ASDpos{m_readKey_ASDpos, ctx};
35 if (!readHandle_ASDpos.isValid()) {
36 ATH_MSG_ERROR("Null pointer to the read conditions object");
37 return StatusCode::FAILURE;
38 }
39 writeHandle.addDependency(readHandle_ASDpos);
40
41 // Fill
42 auto outputCdo = std::make_unique<TgcDigitASDposData>();
43 constexpr std::string_view delimiter{";"};
44 for(const auto &[channel, attribute] : **readHandle_ASDpos) {
45 const coral::Blob& blob = attribute["bASDPos"].data<coral::Blob>();
46 const std::string blobline{static_cast<const char*>(blob.startingAddress())};
47 std::vector<std::string> tokens = CxxUtils::tokenize(blobline, delimiter);
48 auto it = std::begin(tokens);
49 uint16_t station = static_cast<uint16_t>(CxxUtils::atoi(*it));
50 ++it;
51 uint16_t eta = static_cast<uint16_t>(CxxUtils::atoi(*it));
52 ++it;
53 uint16_t phi = (CxxUtils::atoi(*it) == -99) ? 0x1f : static_cast<uint16_t>(CxxUtils::atoi(*it));
54 uint16_t chamberId = (station << 8) + (eta << 5) + phi;
55
56 std::vector<float> strip_pos(TgcDigitASDposData::N_STRIPASDPOS, 0);
57 //strip_pos initialized to size N_STRIPASDPOS
58 for (int i=0; i < TgcDigitASDposData::N_STRIPASDPOS; i++) {
59 ++it;
60 strip_pos[i] = CxxUtils::atof(*it);
61 }
62 outputCdo->stripAsdPos.emplace(chamberId, std::move(strip_pos));
63
64 std::vector<float> wire_pos(TgcDigitASDposData::N_WIREASDPOS, 0);
65 //TgcDigitASDposData initialized to size N_WIREASDPOS
66 for (int i=0; i < TgcDigitASDposData::N_WIREASDPOS; i++) {
67 ++it;
68 wire_pos[i] = CxxUtils::atof(*it);
69 }
70 outputCdo->wireAsdPos.emplace(chamberId, std::move(wire_pos));
71 } // end of for(attrmap)
72
73 // Record
74 ATH_CHECK(writeHandle.record(std::move(outputCdo)));
75 ATH_MSG_DEBUG("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
76
77 return StatusCode::SUCCESS;
78}
79}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
SG::WriteCondHandleKey< TgcDigitASDposData > m_writeKey
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_ASDpos
virtual StatusCode initialize() override
virtual StatusCode execute(const EventContext &ctx) const override
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
const DataObjID & fullKey() const
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
double atof(std::string_view str)
Converts a string into a double / float.
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.