ATLAS Offline Software
TgcDigitASDposCondAlg.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 "CxxUtils/StringUtils.h"
9 #include "CoralBase/Blob.h"
10 #include <string_view>
11 
12 
13 TgcDigitASDposCondAlg::TgcDigitASDposCondAlg(const std::string& name, ISvcLocator* pSvcLocator) :
14  AthReentrantAlgorithm(name, pSvcLocator)
15 {}
16 
18 {
19  ATH_MSG_DEBUG("initialize " << name());
20 
23 
24  return StatusCode::SUCCESS;
25 }
26 
27 StatusCode TgcDigitASDposCondAlg::execute(const EventContext& ctx) const
28 {
30  if (writeHandle.isValid()) {
31  ATH_MSG_DEBUG("CondHandle " << writeHandle.fullKey() << " is already valid."
32  << ". In theory this should not be called, but may happen"
33  << " if multiple concurrent events are being processed out of order.");
34  return StatusCode::SUCCESS;
35  }
36 
38  if (!readHandle_ASDpos.isValid()) {
39  ATH_MSG_ERROR("Null pointer to the read conditions object");
40  return StatusCode::FAILURE;
41  }
42  writeHandle.addDependency(readHandle_ASDpos);
43 
44  // Fill
45  auto outputCdo = std::make_unique<TgcDigitASDposData>();
46  constexpr std::string_view delimiter{";"};
47  for(const auto &[channel, attribute] : **readHandle_ASDpos) {
48  const coral::Blob& blob = attribute["bASDPos"].data<coral::Blob>();
49  const std::string blobline{static_cast<const char*>(blob.startingAddress())};
50  std::vector<std::string> tokens = CxxUtils::tokenize(blobline, delimiter);
51  auto it = std::begin(tokens);
52  uint16_t station = static_cast<uint16_t>(CxxUtils::atoi(*it));
53  ++it;
54  uint16_t eta = static_cast<uint16_t>(CxxUtils::atoi(*it));
55  ++it;
56  uint16_t phi = (CxxUtils::atoi(*it) == -99) ? 0x1f : static_cast<uint16_t>(CxxUtils::atoi(*it));
57  uint16_t chamberId = (station << 8) + (eta << 5) + phi;
58 
59  std::vector<float> strip_pos(TgcDigitASDposData::N_STRIPASDPOS, 0);
60  //strip_pos initialized to size N_STRIPASDPOS
61  for (int i=0; i < TgcDigitASDposData::N_STRIPASDPOS; i++) {
62  ++it;
63  strip_pos[i] = CxxUtils::atof(*it);
64  }
65  outputCdo->stripAsdPos.emplace(chamberId, std::move(strip_pos));
66 
67  std::vector<float> wire_pos(TgcDigitASDposData::N_WIREASDPOS, 0);
68  //TgcDigitASDposData initialized to size N_WIREASDPOS
69  for (int i=0; i < TgcDigitASDposData::N_WIREASDPOS; i++) {
70  ++it;
71  wire_pos[i] = CxxUtils::atof(*it);
72  }
73  outputCdo->wireAsdPos.emplace(chamberId, std::move(wire_pos));
74  } // end of for(attrmap)
75 
76  // Record
77  ATH_CHECK(writeHandle.record(std::move(outputCdo)));
78  ATH_MSG_DEBUG("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
79 
80  return StatusCode::SUCCESS;
81 }
TgcDigitASDposCondAlg::initialize
virtual StatusCode initialize() override
Definition: TgcDigitASDposCondAlg.cxx:17
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
CxxUtils::tokenize
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
Definition: Control/CxxUtils/Root/StringUtils.cxx:15
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
skel.it
it
Definition: skel.GENtoEVGEN.py:423
StringUtils.h
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
ReadCondHandle.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
TgcDigitASDposData::N_WIREASDPOS
@ N_WIREASDPOS
Definition: TgcDigitASDposData.h:30
TgcDigitASDposCondAlg::m_writeKey
SG::WriteCondHandleKey< TgcDigitASDposData > m_writeKey
Definition: TgcDigitASDposCondAlg.h:24
python.AthDsoLogger.delimiter
delimiter
Definition: AthDsoLogger.py:71
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
lumiFormat.i
int i
Definition: lumiFormat.py:92
TgcDigitASDposCondAlg::TgcDigitASDposCondAlg
TgcDigitASDposCondAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: TgcDigitASDposCondAlg.cxx:13
TgcDigitASDposCondAlg::m_readKey_ASDpos
SG::ReadCondHandleKey< CondAttrListCollection > m_readKey_ASDpos
Definition: TgcDigitASDposCondAlg.h:23
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
WriteCondHandle.h
TgcDigitASDposData::N_STRIPASDPOS
@ N_STRIPASDPOS
Definition: TgcDigitASDposData.h:31
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TgcDigitASDposCondAlg.h
CxxUtils::atof
double atof(std::string_view str)
Converts a string into a double / float.
Definition: Control/CxxUtils/Root/StringUtils.cxx:91
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
TgcDigitASDposCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition: TgcDigitASDposCondAlg.cxx:27
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96