ATLAS Offline Software
SCT_ReadoutTestAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
14 // Athena includes
15 #include "SCT_ReadoutTestAlg.h"
16 
17 #include "Identifier/Identifier.h"
18 
19 // Constructor
20 SCT_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  // Retrive 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
70 short SCT_ReadoutTestAlg::bin2dec(const char *bin)
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)
96 SCT_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 }
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SCT_ReadoutTestAlg::execute
virtual StatusCode execute() override
Definition: SCT_ReadoutTestAlg.cxx:44
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SCT_ReadoutTestAlg::SCT_ReadoutTestAlg
SCT_ReadoutTestAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: SCT_ReadoutTestAlg.cxx:20
SCT_ReadoutTestAlg::m_chipConfigs
StringArrayProperty m_chipConfigs
Definition: SCT_ReadoutTestAlg.h:53
SCT_Chip
Class which stores infomration on the SCT chips: id, config, mask.
Definition: SCT_Chip.h:27
SCT_ReadoutTestAlg::m_readout
ToolHandle< ISCT_ReadoutTool > m_readout
List of chips for that module.
Definition: SCT_ReadoutTestAlg.h:48
bin
Definition: BinsDiffFromStripMedian.h:43
SCT_ReadoutTestAlg::initialiseChip
SCT_Chip initialiseChip(short id, std::string configString)
Initialise a chip given its id and configuration string.
Definition: SCT_ReadoutTestAlg.cxx:96
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
DeMoUpdate.reverse
reverse
Definition: DeMoUpdate.py:563
SCT_ReadoutTestAlg::m_link1ok
BooleanProperty m_link1ok
Definition: SCT_ReadoutTestAlg.h:56
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
SCT_ReadoutTestAlg.h
Header file for the SCT_ReadoutTestAlg class in package SCT_ConditionsAlgorithms.
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
SCT_ReadoutTestAlg::m_link0ok
BooleanProperty m_link0ok
Definition: SCT_ReadoutTestAlg.h:55
config
std::vector< std::string > config
Definition: fbtTestBasics.cxx:74
SCT_ReadoutTestAlg::finalize
virtual StatusCode finalize() override
Definition: SCT_ReadoutTestAlg.cxx:63
SCT_ReadoutTestAlg::m_chips
std::vector< SCT_Chip > m_chips
Definition: SCT_ReadoutTestAlg.h:51
SCT_ReadoutTestAlg::initialize
virtual StatusCode initialize() override
Usual framework methods for an Algorithm.
Definition: SCT_ReadoutTestAlg.cxx:26
SCT_ReadoutTestAlg::bin2dec
short bin2dec(const char *bin)
Function to convert the configuration string into an int.
Definition: SCT_ReadoutTestAlg.cxx:70
fitman.k
k
Definition: fitman.py:528
Identifier
Definition: IdentifierFieldParser.cxx:14