ATLAS Offline Software
Loading...
Searching...
No Matches
SCT_ReadoutTestAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
13
14// Athena includes
15#include "SCT_ReadoutTestAlg.h"
16
17#include "Identifier/Identifier.h"
18
19// Constructor
20SCT_ReadoutTestAlg::SCT_ReadoutTestAlg(const std::string& name, ISvcLocator* pSvcLocator) :
21 AthAlgorithm(name, pSvcLocator)
22{
23}
24
25// Initialize
27 ATH_MSG_INFO("Calling initialize");
28
29 // Retrieve readout tool
30 ATH_CHECK(m_readout.retrieve());
31
32 // Initalise chips configured in job options and add to vector
33 std::vector<std::string>::const_iterator itr{m_chipConfigs.begin()};
34 std::vector<std::string>::const_iterator end{m_chipConfigs.end()};
35
36 for (short ichip{0}; itr != end; ++itr, ++ichip) {
37 m_chips.push_back(initialiseChip(ichip, *itr));
38 }
39
40 return StatusCode::SUCCESS;
41}
42
43// Execute
45 //This method is only used to test the readout tool, and only used within this package,
46 // so the INFO level messages have no impact on performance of the tool when used by clients
47
48 ATH_MSG_INFO("Calling execute");
49
50 ATH_MSG_INFO( "Chips before readout ..." );
51 for (const SCT_Chip& chip: m_chips) ATH_MSG_INFO(chip);
52
53 // Determin readout for this module
54 ATH_CHECK(m_readout->determineReadout(Identifier{m_moduleId}, m_chips, m_link0ok, m_link1ok));
55
56 ATH_MSG_INFO("Chips after readout ...");
57 for (const SCT_Chip& chip: m_chips) ATH_MSG_INFO(chip);
58
59 return StatusCode::SUCCESS;
60}
61
62// Finalize
64 ATH_MSG_INFO("Calling finalize");
65
66 return StatusCode::SUCCESS;
67}
68
69// Connvert a binary number to decimal
71{
72 short b, k, m, n;
73 short len;
74 short sum{0};
75
76 len = strlen(bin) - 1;
77 for (k = 0; k <= len; k++) {
78 n = (bin[k] - '0'); // char to numeric value
79 if ((n > 1) or (n < 0)) {
80 ATH_MSG_ERROR("ERROR! BINARY has only 1 and 0!");
81 return 0;
82 }
83
84 for (b = 1, m = len; m > k; m--) {
85 // 1 2 4 8 16 32 64 ... place-values, reversed here
86 b *= 2;
87 }
88
89 // sum it up
90 sum = sum + n * b;
91 }
92 return sum;
93}
94
95// Initalise chip from id and config string (all channels are initially good)
96SCT_Chip SCT_ReadoutTestAlg::initialiseChip(short id, std::string configString) {
97 // Opposite convention for LSB
98 std::reverse(configString.begin(), configString.end());
99 short config{bin2dec(configString.c_str())};
100 const int minus1{-1};
101 return {id, config, static_cast<uint32_t>(minus1), static_cast<uint32_t>(minus1), static_cast<uint32_t>(minus1), static_cast<uint32_t>(minus1)};
102}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
Header file for the SCT_ReadoutTestAlg class in package SCT_ConditionsAlgorithms.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Class which stores infomration on the SCT chips: id, config, mask.
Definition SCT_Chip.h:27
BooleanProperty m_link1ok
SCT_Chip initialiseChip(short id, std::string configString)
Initialise a chip given its id and configuration string.
virtual StatusCode finalize() override
short bin2dec(const char *bin)
Function to convert the configuration string into an int.
ToolHandle< ISCT_ReadoutTool > m_readout
List of chips for that module.
BooleanProperty m_link0ok
std::vector< SCT_Chip > m_chips
virtual StatusCode initialize() override
Usual framework methods for an Algorithm.
virtual StatusCode execute() override
SCT_ReadoutTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
StringArrayProperty m_chipConfigs
void reverse(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of reverse for DataVector/List.