ATLAS Offline Software
L1Connector.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 using namespace std;
7 
8 #include <stdexcept>
9 
11 {}
12 
15 {
16  m_name = connName;
18 }
19 
20 std::string
22  return "L1Connector";
23 }
24 
25 void
27 {
28  m_name = getAttribute("name", true, m_name);
29 
30  std::string connType(getAttribute("type"));
31  if( connType == "electrical" ) {
32  m_type = ConnectorType::ELECTRICAL;
33  } else if( connType == "optical" ) {
34  m_type = ConnectorType::OPTICAL;
35  } else if( connType == "ctpin" ) {
36  m_type = ConnectorType::CTPIN;
37  } else {
38  throw std::runtime_error("Unknown connector type " + connType);
39  }
40 
41  // triggerlines
42  bool oldConfiguration = hasChild("triggerlines.clock0") || hasChild("triggerlines.fpga0");
43  // old configuration
44  if(oldConfiguration){
45  bool hasMultipleFPGAs = ! hasChild("triggerlines.clock0"); // connector from merger board (no fpga)
46  if(m_type == ConnectorType::ELECTRICAL) {
47  m_maxClock = 2;
48  m_maxFpga = hasMultipleFPGAs ? 2 : 1;
49  }
50 
51  for( size_t fpga = 0; fpga < m_maxFpga; ++fpga ) {
52  for( size_t clock = 0; clock < m_maxClock; ++clock ) {
53  std::string path = "triggerlines";
54  if( m_type == ConnectorType::ELECTRICAL ) {
55  if(hasMultipleFPGAs) {
56  path += ".fpga";
57  path += std::to_string(fpga);
58  }
59  path += ".clock";
60  path += std::to_string(clock);
61  }
62  const auto & triggerlines = data().get_child(path);
63  m_triggerLines[fpga][clock].reserve(triggerlines.size());
64  for( auto & tl : triggerlines ) {
65  const std::string & name = tl.second.get_child("name").data();
66  m_triggerLines[fpga][clock].emplace_back( name,
67  tl.second.get_child("startbit").get_value<unsigned int>(),
68  tl.second.get_child("nbits").get_value<unsigned int>(),
69  tl.second.get_child("startbit").get_value<unsigned int>(),
70  fpga, clock, m_name);
71  m_lineByName[name] = & m_triggerLines[fpga][clock].back();
72  }
73  }
74  }
75  }
76  // new configuration
77  else {
78  std::string path = "triggerlines";
79  int ntl[2][2] = {{0,0},{0,0}};
80  if(m_type == ConnectorType::ELECTRICAL) {
81  m_maxClock = 2;
82  }
83  const auto & triggerlines = data().get_child(path);
84  for( auto & tl : triggerlines ) {
85  unsigned int fpga = 0;
86  unsigned int clock = 0;
87  if(m_type == ConnectorType::ELECTRICAL) {
88  if( m_name.find("MuCTPiEl") != std::string::npos || m_name.find("Topo2El") != std::string::npos || m_name.find("Topo3El") != std::string::npos || m_name.find("LegacyTopo0") != std::string::npos || m_name.find("LegacyTopo1") != std::string::npos){
89  fpga = tl.second.get_child("fpga").get_value<unsigned int>();
90  m_maxFpga = 2;
91  }
92  clock = tl.second.get_child("clock").get_value<unsigned int>();
93  }
94  ntl[fpga][clock] += 1;
95  }
96  for( size_t fpga = 0; fpga < m_maxFpga; ++fpga ) {
97  for( size_t clock = 0; clock < m_maxClock; ++clock ) {
98  m_triggerLines[fpga][clock].reserve(ntl[fpga][clock]);
99  }
100  }
101  for( auto & tl : triggerlines ) {
102  unsigned int fpga = 0;
103  unsigned int clock = 0;
104  unsigned int flatindex = 0;
105  if(m_type == ConnectorType::ELECTRICAL) {
106  if(m_maxFpga==2) fpga = tl.second.get_child("fpga").get_value<unsigned int>();
107  clock = tl.second.get_child("clock").get_value<unsigned int>();
108  }
109  flatindex = tl.second.get_optional<unsigned int>("flatindex").get_value_or(0);
110  const std::string & name = tl.second.get_child("name").data();
111  m_triggerLines[fpga][clock].emplace_back( name,
112  tl.second.get_child("startbit").get_value<unsigned int>(),
113  tl.second.get_child("nbits").get_value<unsigned int>(),
114  flatindex, fpga, clock, m_name);
115  m_lineByName[name] = & m_triggerLines[fpga][clock].back();
116  }
117  }
118  m_isLegacy = getAttribute<bool>("legacy", true, false);
119 }
120 
121 
122 std::string
124 {
125  switch( m_type ) {
126  case ConnectorType::ELECTRICAL:
127  return "electrical";
128  case ConnectorType::OPTICAL:
129  return "optical";
130  case ConnectorType::CTPIN:
131  return "ctpin";
132  }
133  return "";
134 }
135 
138 {
139  return m_type;
140 }
141 
142 std::size_t
144 {
145  size_t nlines{0};
146  for( size_t fpga = 0; fpga<m_maxFpga; ++fpga) {
147  for( size_t clock = 0; clock<m_maxClock; ++clock) {
148  nlines += m_triggerLines[fpga][clock].size();
149  }
150  }
151  return nlines;
152 }
153 
154 std::vector<std::string>
156 {
157  std::vector<std::string> tln{};
158  for( size_t fpga = 0; fpga<m_maxFpga; ++fpga) {
159  for( size_t clock = 0; clock<m_maxClock; ++clock) {
160  for( auto & tl : m_triggerLines[fpga][clock] ) {
161  tln.emplace_back(tl.name());
162  }
163  }
164  }
165  return tln;
166 }
167 
168 const std::vector<TrigConf::TriggerLine> &
169 TrigConf::L1Connector::triggerLines(unsigned int fpga, unsigned int clock) const
170 {
171  return m_triggerLines[fpga][clock];
172 }
173 
174 bool
175 TrigConf::L1Connector::hasLine( const std::string & lineName ) const
176 {
177  return m_lineByName.count(lineName);
178 }
179 
180 const TrigConf::TriggerLine &
181 TrigConf::L1Connector::triggerLine( const std::string & lineName ) const
182 {
183  return *m_lineByName.at(lineName);
184 }
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
TrigConf::L1Connector::connectorType
ConnectorType connectorType() const
Accessor to the connector type.
Definition: L1Connector.cxx:137
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
TrigConf::L1Connector::type
std::string type() const
Definition: L1Connector.cxx:123
TrigConf::L1Connector::triggerLine
const TrigConf::TriggerLine & triggerLine(const std::string &lineName) const
Definition: L1Connector.cxx:181
TrigConf::L1Connector::ConnectorType
ConnectorType
Definition: L1Connector.h:48
TrigConf::L1Connector::className
virtual std::string className() const override
A string that is the name of the class.
Definition: L1Connector.cxx:21
TrigConf::DataStructure::m_name
std::string m_name
Definition: DataStructure.h:259
TrigConf::L1Connector::L1Connector
L1Connector()
Constructor.
Definition: L1Connector.cxx:10
m_type
TokenType m_type
the type
Definition: TProperty.cxx:44
TrigConf::TriggerLine
a TriggerLine entry describes the location of a threshold multiplicity on a cable (connector)
Definition: L1Connector.h:21
TrigConf::L1Connector::update
virtual void update() override
Update the internal members.
Definition: L1Connector.cxx:26
L1Connector.h
TrigConf::name
Definition: HLTChainList.h:35
ptree
boost::property_tree::ptree ptree
Definition: JsonFileLoader.cxx:16
TrigConf::L1Connector::hasLine
bool hasLine(const std::string &lineName) const
Definition: L1Connector.cxx:175
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
TrigConf::L1Connector::triggerLines
const std::vector< TrigConf::TriggerLine > & triggerLines(unsigned int fpga=0, unsigned int clock=0) const
Accessor to the triggerlines on the connector.
Definition: L1Connector.cxx:169
TrigConf::DataStructure
Base class for Trigger configuration data and wrapper around underlying representation.
Definition: DataStructure.h:37
TrigConf::L1Connector::size
std::size_t size() const
Accessor to the number of trigger lines.
Definition: L1Connector.cxx:143
dqt_zlumi_alleff_HIST.tl
tl
Definition: dqt_zlumi_alleff_HIST.py:73
TrigConf::L1Connector::triggerLineNames
std::vector< std::string > triggerLineNames() const
names of all trigger lines
Definition: L1Connector.cxx:155