41 {
42
44
45
46
47 unordered_set<unsigned short> scrodIDs;
48 unordered_set<string> coppers;
49 unordered_set<int> modules;
50
51
52 int numModules = 0;
53 for (const GearDir& topModule : frontEndMapping.getNodes("TOPModule")) {
54
55 int moduleCNumber = topModule.getInt("@CNumber");
56 int moduleID = topModule.getInt("moduleID");
57 if (moduleID == 0) continue;
58 if (moduleID < 0 or moduleID > c_numModules) {
59 B2ERROR("TOP::FrontEndMapper: invalid moduleID in xml file"
60 <<
LogVar(
"moduleID", moduleID)
61 <<
LogVar(
"path", topModule.getPath()));
62 return;
63 }
64
65 bool moduleMapped = false;
66 for (const GearDir& boardstack : topModule.getNodes("Boardstack")) {
67
68 int col = boardstack.getInt("@col");
69 if (col < 0 or col >= c_numColumns) {
70 B2ERROR("TOP::FrontEndMapper: invalid boardstack number in xml file"
71 <<
LogVar(
"moduleID", moduleID)
72 <<
LogVar(
"boardstack", col)
73 <<
LogVar(
"path", boardstack.getPath()));
74 return;
75 }
76 if (!modules.insert(moduleID * c_numColumns + col).second) {
77 B2ERROR("TOP::FrontEndMapper: this boardstack is already mapped."
78 <<
LogVar(
"moduleID", moduleID)
79 <<
LogVar(
"boardstack", col)
80 <<
LogVar(
"path", boardstack.getPath()));
81 return;
82 }
83
84 unsigned short scrodID = (unsigned short) boardstack.getInt("SCRODid");
85 if (!scrodIDs.insert(scrodID).second) {
86 B2ERROR("TOP::FrontEndMapper: this SCROD ID is already used."
87 <<
LogVar(
"moduleID", moduleID)
88 <<
LogVar(
"boardstack", col)
89 <<
LogVar(
"scrod", scrodID)
90 <<
LogVar(
"path", boardstack.getPath() +
"/SCRODid"));
91 return;
92 }
93
94 string finesseSlot = boardstack.getString("FinesseSlot");
95 int finesse = 0;
96 if (finesseSlot == "A") {finesse = 0;}
97 else if (finesseSlot == "B") {finesse = 1;}
98 else if (finesseSlot == "C") {finesse = 2;}
99 else if (finesseSlot == "D") {finesse = 3;}
100 else {
101 B2ERROR("TOP::FrontEndMapper: invalid finesse slot (valid are A, B, C, D)."
102 <<
LogVar(
"FinesseSlot", finesseSlot)
103 <<
LogVar(
"path", boardstack.getPath() +
"/FinesseSlot"));
104 return;
105 }
106
107 unsigned copperID = (unsigned) boardstack.getInt("COPPERid");
109 string copper = boardstack.getString("COPPERid") + " " + finesseSlot;
110 if (!coppers.insert(copper).second) {
111 B2ERROR("TOP::FrontEndMapper: this COPPER ID is already used."
112 <<
LogVar(
"moduleID", moduleID)
113 <<
LogVar(
"boardstack", col)
114 <<
LogVar(
"copperID", copper)
115 <<
LogVar(
"path", boardstack.getPath() +
"/COPPERid"));
116 return;
117 }
118
119 TOPFrontEndMap feemap(moduleID, moduleCNumber, col, scrodID, copperID, finesse,
122 moduleMapped = true;
123 }
124 if (moduleMapped) numModules++;
125 }
126
127
128
130 m_fromModule[feemap.getModuleID() - 1][feemap.getBoardstackNumber()] = &feemap;
132 m_fromCopper[feemap.getCopperID() * 4 + feemap.getFinesseSlot()] = &feemap;
133 }
135
136 B2INFO(
"TOP::FrontEndMapper: " <<
m_mapping.size() <<
" SCROD's mapped to "
137 << numModules << " TOP module(s)");
138
139
143 }
144
145 }
Class to store variables with their name which were sent to the logging service.