28 m_name = getAttribute(
"name",
true, m_name);
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;
38 throw std::runtime_error(
"Unknown connector type " + connType);
42 bool oldConfiguration = hasChild(
"triggerlines.clock0") || hasChild(
"triggerlines.fpga0");
45 bool hasMultipleFPGAs = ! hasChild(
"triggerlines.clock0");
46 if(
m_type == ConnectorType::ELECTRICAL) {
48 m_maxFpga = hasMultipleFPGAs ? 2 : 1;
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) {
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>(),
71 m_lineByName[
name] = & m_triggerLines[fpga][clock].back();
78 std::string
path =
"triggerlines";
79 int ntl[2][2] = {{0,0},{0,0}};
80 if(
m_type == ConnectorType::ELECTRICAL) {
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>();
92 clock =
tl.second.get_child(
"clock").get_value<
unsigned int>();
94 ntl[fpga][clock] += 1;
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]);
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>();
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();
118 m_isLegacy = getAttribute<bool>(
"legacy",
true,
false);
126 case ConnectorType::ELECTRICAL:
128 case ConnectorType::OPTICAL:
130 case ConnectorType::CTPIN:
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();
154 std::vector<std::string>
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());
168 const std::vector<TrigConf::TriggerLine> &
171 return m_triggerLines[fpga][clock];
177 return m_lineByName.count(lineName);
183 return *m_lineByName.at(lineName);