Belle II Software development
trgrawdataModule.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#include <trg/gdl/modules/trggdlUnpacker/trggdlUnpackerModule.h>
10#include <trg/trg/modules/trgrawdata/trgrawdataModule.h>
11
12#include <rawdata/modules/PrintDataTemplate.h>
13#include <framework/datastore/StoreObjPtr.h>
14#include <framework/datastore/StoreArray.h>
15#include <framework/dbobjects/RunInfo.h>
16#include <framework/datastore/DataStore.h>
17
18#include <string.h>
19#include <unistd.h>
20
21#include <TPostScript.h>
22#include <TCanvas.h>
23#include <TStyle.h>
24
25using namespace std;
26using namespace Belle2;
27using namespace GDL;
28
29
30REG_MODULE(TRGRAWDATA);
31
32// TRGRAWDATAModule::TRGRAWDATAModule() : Module()
34{
35
36 setDescription("TRG rawdata analyer");
38
39 addParam("histRecord", m_histRecord,
40 "Recording event by event timing distribution histogram or not",
41 false);
42 addParam("mydebug", m_mydebug, "debug flag", 0);
43 addParam("cc_check", m_cc_check, "cc mode", true);
44 addParam("print_cc", m_print_cc, "Print Disordered clocks", true);
45 addParam("print_clkcyc_err", m_print_clkcyc_err, "Print Errs of Disordered clocks", false);
46 addParam("print_dbmap", m_print_dbmap, "Print Database Bit Map", false);
47
48 addParam("hdr_nwd_2d0", m_hdr_nwd_2d0, "Number of word for 2D0 Header", 3);
49 addParam("hdr_nwd_2d1", m_hdr_nwd_2d1, "Number of word for 2D1 Header", 3);
50 addParam("hdr_nwd_2d2", m_hdr_nwd_2d2, "Number of word for 2D2 Header", 3);
51 addParam("hdr_nwd_2d3", m_hdr_nwd_2d3, "Number of word for 2D3 Header", 3);
52 addParam("hdr_nwd_3d0", m_hdr_nwd_3d0, "Number of word for 3D0 Header", 3);
53 addParam("hdr_nwd_3d1", m_hdr_nwd_3d1, "Number of word for 3D1 Header", 3);
54 addParam("hdr_nwd_3d2", m_hdr_nwd_3d2, "Number of word for 3D2 Header", 3);
55 addParam("hdr_nwd_3d3", m_hdr_nwd_3d3, "Number of word for 3D3 Header", 3);
56 addParam("hdr_nwd_nn0", m_hdr_nwd_nn0, "Number of word for NN0 Header", 3);
57 addParam("hdr_nwd_nn1", m_hdr_nwd_nn1, "Number of word for NN1 Header", 3);
58 addParam("hdr_nwd_nn2", m_hdr_nwd_nn2, "Number of word for NN2 Header", 3);
59 addParam("hdr_nwd_nn3", m_hdr_nwd_nn3, "Number of word for NN3 Header", 3);
60 addParam("hdr_nwd_sl0", m_hdr_nwd_sl0, "Number of word for TSF0 Header", 3);
61 addParam("hdr_nwd_sl1", m_hdr_nwd_sl1, "Number of word for TSF1 Header", 3);
62 addParam("hdr_nwd_sl2", m_hdr_nwd_sl2, "Number of word for TSF2 Header", 3);
63 addParam("hdr_nwd_sl3", m_hdr_nwd_sl3, "Number of word for TSF3 Header", 3);
64 addParam("hdr_nwd_sl4", m_hdr_nwd_sl4, "Number of word for TSF4 Header", 3);
65 addParam("hdr_nwd_sl5", m_hdr_nwd_sl5, "Number of word for TSF5 Header", 3);
66 addParam("hdr_nwd_sl6", m_hdr_nwd_sl6, "Number of word for TSF6 Header", 3);
67 addParam("hdr_nwd_sl8", m_hdr_nwd_sl8, "Number of word for TSF8 Header", 3);
68 addParam("hdr_nwd_etf", m_hdr_nwd_etf, "Number of word for ETF Header", 3);
69 addParam("hdr_nwd_grl", m_hdr_nwd_grl, "Number of word for GRL Header", 3);
70 addParam("hdr_nwd_top", m_hdr_nwd_top, "Number of word for TOP Header", 3);
71 addParam("hdr_nwd_gdl", m_hdr_nwd_gdl, "Number of word for GDL Header", 6);
72
73 addParam("cpr_2d0", m_cpr_2d0, "Copper number of 2D0", 0x11000001U);
74 addParam("cpr_2d1", m_cpr_2d1, "Copper number of 2D1", 0x11000001U);
75 addParam("cpr_2d2", m_cpr_2d2, "Copper number of 2D2", 0x11000002U);
76 addParam("cpr_2d3", m_cpr_2d3, "Copper number of 2D3", 0x11000002U);
77 addParam("cpr_3d0", m_cpr_3d0, "Copper number of 3D0", 0x11000003U);
78 addParam("cpr_3d1", m_cpr_3d1, "Copper number of 3D1", 0x11000003U);
79 addParam("cpr_3d2", m_cpr_3d2, "Copper number of 3D2", 0x11000004U);
80 addParam("cpr_3d3", m_cpr_3d3, "Copper number of 3D3", 0x11000004U);
81 addParam("cpr_nn0", m_cpr_nn0, "Copper number of NN0", 0x11000005U);
82 addParam("cpr_nn1", m_cpr_nn1, "Copper number of NN1", 0x11000005U);
83 addParam("cpr_nn2", m_cpr_nn2, "Copper number of NN2", 0x11000006U);
84 addParam("cpr_nn3", m_cpr_nn3, "Copper number of NN3", 0x11000006U);
85 addParam("cpr_sl0", m_cpr_sl0, "Copper number of SL0", 0x11000007U);
86 addParam("cpr_sl1", m_cpr_sl1, "Copper number of SL1", 0x11000009U);//*
87 addParam("cpr_sl2", m_cpr_sl2, "Copper number of SL2", 0x11000008U);
88 addParam("cpr_sl3", m_cpr_sl3, "Copper number of SL3", 0x11000008U);
89 addParam("cpr_sl4", m_cpr_sl4, "Copper number of SL4", 0x11000007U);//*
90 addParam("cpr_sl5", m_cpr_sl5, "Copper number of SL5", 0x11000009U);
91 addParam("cpr_sl6", m_cpr_sl6, "Copper number of SL6", 0x1100000aU);
92 addParam("cpr_sl7", m_cpr_sl7, "Copper number of SL7", 0x1100000a);
93 addParam("cpr_sl8", m_cpr_sl8, "Copper number of SL8", 0x1100000aU);
94 addParam("cpr_gdl", m_cpr_gdl, "Copper number of GDL", 0x15000001U);
95 addParam("cpr_etf", m_cpr_etf, "Copper number of ETF", 0x15000001U);
96 addParam("cpr_grl", m_cpr_grl, "Copper number of GRL", 0x15000002);
97 addParam("cpr_top", m_cpr_top, "Copper number of TOP", 0x12000001U);
98
99 addParam("on_2d0", m_on_2d0, "ON/OFF of 2D0", true);
100 addParam("on_2d1", m_on_2d1, "ON/OFF of 2D1", true);
101 addParam("on_2d2", m_on_2d2, "ON/OFF of 2D2", true);
102 addParam("on_2d3", m_on_2d3, "ON/OFF of 2D3", true);
103 addParam("on_3d0", m_on_3d0, "ON/OFF of 3D0", true);
104 addParam("on_3d1", m_on_3d1, "ON/OFF of 3D1", true);
105 addParam("on_3d2", m_on_3d2, "ON/OFF of 3D2", true);
106 addParam("on_3d3", m_on_3d3, "ON/OFF of 3D3", true);
107 addParam("on_nn0", m_on_nn0, "ON/OFF of NN0", true);
108 addParam("on_nn1", m_on_nn1, "ON/OFF of NN1", true);
109 addParam("on_nn2", m_on_nn2, "ON/OFF of NN2", true);
110 addParam("on_nn3", m_on_nn3, "ON/OFF of NN3", true);
111 addParam("on_sl0", m_on_sl0, "ON/OFF of SL0", true);
112 addParam("on_sl1", m_on_sl1, "ON/OFF of SL1", true);
113 addParam("on_sl2", m_on_sl2, "ON/OFF of SL2", true);
114 addParam("on_sl3", m_on_sl3, "ON/OFF of SL3", true);
115 addParam("on_sl4", m_on_sl4, "ON/OFF of SL4", true);
116 addParam("on_sl5", m_on_sl5, "ON/OFF of SL5", true);
117 addParam("on_sl6", m_on_sl6, "ON/OFF of SL6", true);
118 addParam("on_sl7", m_on_sl7, "ON/OFF of SL7", true);
119 addParam("on_sl8", m_on_sl8, "ON/OFF of SL8", true);
120 addParam("on_gdl", m_on_gdl, "ON/OFF of GDL", true);
121 addParam("on_etf", m_on_etf, "ON/OFF of ETF", true);
122 addParam("on_grl", m_on_grl, "ON/OFF of GRL", true);
123 addParam("on_top", m_on_top, "ON/OFF of TOP", true);
124
125 addParam("nwd_2ds", m_nwd_2ds, "N word of 2Ds", 3939); // 2624x48
126 addParam("nwd_3ds", m_nwd_3ds, "N word of 3Ds", 3939); // 2624x48
127 addParam("nwd_nns", m_nwd_nns, "N word of NNs", 0xc03); // 2048x48
128 addParam("nwd_sl0", m_nwd_sl0, "N word of SL0", 0xc03); // 2048x48
129 addParam("nwd_sl1", m_nwd_sl1, "N word of SL1", 0x1803); // 4096x48
130 addParam("nwd_sl2", m_nwd_sl2, "N word of SL2", 0x1803); // 4096x48
131 addParam("nwd_sl3", m_nwd_sl3, "N word of SL3", 0x1803); // 4096x48
132 addParam("nwd_sl4", m_nwd_sl4, "N word of SL4", 0xc03); // 2048x48
133 addParam("nwd_sl5", m_nwd_sl5, "N word of SL5", 0x1803); // 4096x48
134 addParam("nwd_sl6", m_nwd_sl6, "N word of SL6", 0xc03); // 2048x48
135 addParam("nwd_sl7", m_nwd_sl7, "N word of SL7", 0x603); // 1024x48
136 addParam("nwd_sl8", m_nwd_sl8, "N word of SL8", 0x603); // 1024x48
137 addParam("nwd_gdl", m_nwd_gdl, "N word of GDL", 646); // 640x32
138 addParam("nwd_etf", m_nwd_etf, "N word of ETF", 1539); // 1024x48
139 addParam("nwd_grl", m_nwd_grl, "N word of GRL", 0xc03); // 1024x48
140 addParam("nwd_top", m_nwd_top, "N word of TOP", 0x303); // 1024*24
141
142 addParam("nclk_2ds", m_nclk_2ds, "N clk of 2Ds", 48);
143 addParam("nclk_3ds", m_nclk_3ds, "N clk of 3Ds", 48);
144 addParam("nclk_nns", m_nclk_nns, "N clk of NNs", 48);
145 addParam("nclk_sl0", m_nclk_sl0, "N clk of SL0", 48);
146 addParam("nclk_sl1", m_nclk_sl1, "N clk of SL1", 48);
147 addParam("nclk_sl2", m_nclk_sl2, "N clk of SL2", 48);
148 addParam("nclk_sl3", m_nclk_sl3, "N clk of SL3", 48);
149 addParam("nclk_sl4", m_nclk_sl4, "N clk of SL4", 48);
150 addParam("nclk_sl5", m_nclk_sl5, "N clk of SL5", 48);
151 addParam("nclk_sl6", m_nclk_sl6, "N clk of SL6", 48);
152 addParam("nclk_sl7", m_nclk_sl7, "N clk of SL7", 48);
153 addParam("nclk_sl8", m_nclk_sl8, "N clk of SL8", 48);
154 addParam("nclk_gdl", m_nclk_gdl, "N clk of GDL", 32);
155 addParam("nclk_etf", m_nclk_etf, "N clk of ETF", 48);
156 addParam("nclk_grl", m_nclk_grl, "N clk of GRL", 48);
157 addParam("nclk_top", m_nclk_top, "N clk of TOP", 24);
158
159 addParam("nclk_cdctrg", m_nclk_cdctrg, "N clock of CDCTRG", 48);
160
161 addParam("scale_2ds", m_scale_2ds, "Scale factor of 2Ds", 256);
162 addParam("scale_3ds", m_scale_3ds, "Scale factor of 3Ds", 256);
163 addParam("scale_nns", m_scale_nns, "Scale factor of NNs", 256);
164 addParam("scale_sl0", m_scale_sl0, "Scale factor of SL0", 256);
165 addParam("scale_sl1", m_scale_sl1, "Scale factor of SL1", 256);
166 addParam("scale_sl2", m_scale_sl2, "Scale factor of SL2", 256);
167 addParam("scale_sl3", m_scale_sl3, "Scale factor of SL3", 256);
168 addParam("scale_sl4", m_scale_sl4, "Scale factor of SL4", 256);
169 addParam("scale_sl5", m_scale_sl5, "Scale factor of SL5", 256);
170 addParam("scale_sl6", m_scale_sl6, "Scale factor of SL6", 256);
171 addParam("scale_sl7", m_scale_sl7, "Scale factor of SL7", 256);
172 addParam("scale_sl8", m_scale_sl8, "Scale factor of SL8", 256);
173 addParam("scale_gdl", m_scale_gdl, "Scale factor of GDL", 1);
174 addParam("scale_etf", m_scale_etf, "Scale factor of ETF", 512);
175 addParam("scale_grl", m_scale_grl, "Scale factor of GRL", 1);
176 addParam("scale_top", m_scale_top, "Scale factor of TOP", 32);
177
178 addParam("fmid_2d0", m_fmid_2d0, "Firmware ID of 2D0", 0x32442020);
179 addParam("fmid_2d1", m_fmid_2d1, "Firmware ID of 2D1", 0x32442020);
180 addParam("fmid_2d2", m_fmid_2d2, "Firmware ID of 2D2", 0x32442020);
181 addParam("fmid_2d3", m_fmid_2d3, "Firmware ID of 2D3", 0x32442020);
182 addParam("fmid_3d0", m_fmid_3d0, "Firmware ID of 3D0", 0x33440001);
183 addParam("fmid_3d1", m_fmid_3d1, "Firmware ID of 3D1", 0x33440001);
184 addParam("fmid_3d2", m_fmid_3d2, "Firmware ID of 3D2", 0x33440001);
185 addParam("fmid_3d3", m_fmid_3d3, "Firmware ID of 3D3", 0x33440001);
186 addParam("fmid_nn0", m_fmid_nn0, "Firmware ID of NN0", 0x4e4e5402);
187 addParam("fmid_nn1", m_fmid_nn1, "Firmware ID of NN1", 0x4e4e5402);
188 addParam("fmid_nn2", m_fmid_nn2, "Firmware ID of NN2", 0x4e4e5402);
189 addParam("fmid_nn3", m_fmid_nn3, "Firmware ID of NN3", 0x4e4e5402);
190 addParam("fmid_sl0", m_fmid_sl0, "Firmware ID of SL0", 0x54534630);
191 addParam("fmid_sl1", m_fmid_sl1, "Firmware ID of SL1", 0x54534631);
192 addParam("fmid_sl2", m_fmid_sl2, "Firmware ID of SL2", 0x54534632);
193 addParam("fmid_sl3", m_fmid_sl3, "Firmware ID of SL3", 0x54534633);
194 addParam("fmid_sl4", m_fmid_sl4, "Firmware ID of SL4", 0x54534634);
195 addParam("fmid_sl5", m_fmid_sl5, "Firmware ID of SL5", 0x54534635);
196 addParam("fmid_sl6", m_fmid_sl6, "Firmware ID of SL6", 0x54534636);
197 addParam("fmid_sl7", m_fmid_sl7, "Firmware ID of SL7", 0x54534637);
198 addParam("fmid_sl8", m_fmid_sl8, "Firmware ID of SL8", 0x54534d38);
199 addParam("fmid_gdl", m_fmid_gdl, "Firmware ID of GDL", 0x47444c20U);
200 addParam("fmid_etf", m_fmid_etf, "Firmware ID of ETF", 0x45544620);
201 addParam("fmid_grl", m_fmid_grl, "Firmware ID of GRL", 0x47824c20);
202 addParam("fmid_top", m_fmid_top, "Firmware ID of TOP", 0);
203
204}
205
207{
208 B2INFO("trgrawdata: initialize() started.");
209 if (! m_unpacker) {
210 B2INFO("no database of gdl unpacker");
211 }
212 if (m_print_dbmap) {
213
214 //const int nword_header = m_unpacker->get_nword_header(); //not used for now
215 //const int n_clocks = m_unpacker->getnClks(); //not used for now
216 //const int nBits = m_unpacker->getnBits(); //not used for now
217 const int n_leafs = m_unpacker->getnLeafs();
218 const int n_leafsExtra = m_unpacker->getnLeafsExtra();
219 //const int conf = m_unpacker->getconf(); //not used for now
220
221 int aBitMap[320][2] = {{0}};
222 int aBitMap_extra[100][3] = {{ -1}};
223 for (int i = 0; i < n_leafsExtra; i++) {
224 aBitMap_extra[i][0] = m_unpacker->getBitMap_extra(i, 0);
225 aBitMap_extra[i][1] = m_unpacker->getBitMap_extra(i, 1);
226 aBitMap_extra[i][2] = m_unpacker->getBitMap_extra(i, 2);
227 }
228
229 for (int i = 0; i < 200; i++) {
230 LeafBitMap[i] = m_unpacker->getLeafMap(i);
231 std::cout << "LeafBitMap[" << i << "] = " << m_unpacker->getLeafMap(i) << std::endl;
232 strcpy(LeafNames[i], m_unpacker->getLeafnames(i));
233 std::cout << "LeafNames[" << i << "] = " << m_unpacker->getLeafnames(i) << std::endl;
234 }
235 for (int i = 0; i < n_leafs; i++) {
236 aBitMap[i][0] = m_unpacker->getBitMap(i, 0);
237 aBitMap[i][1] = m_unpacker->getBitMap(i, 1);
238 }
239 for (int i = 0; i < 200; i++) {
240 int bin = m_unpacker->getLeafMap(i) + 1;
241 if (0 < bin && bin <= n_leafs) {
242 std::cout << "leaf(" << i
243 << "), bin(" << bin
244 << "), LeafNames[leaf](" << LeafNames[i]
245 << "), BitMap[bin-1][0](" << aBitMap[bin - 1][0]
246 << "), BitMap[bin-1][1](" << aBitMap[bin - 1][1]
247 << ")" << std::endl;
248 }
249 }
250 // for leafsExtra
251 for (int i = 0; i < 200; i++) {
252 int bin = m_unpacker->getLeafMap(i) + 1;
253 int j = bin - n_leafs - 1;
254 if (n_leafs < bin && bin <= n_leafs + n_leafsExtra) {
255 std::cout << "i(" << i
256 << "), bin(" << bin
257 << "), LeafNames[leaf](" << LeafNames[i]
258 << "), BitMap_extra[j][0](buf[" << aBitMap_extra[j][0]
259 << "]), BitMap_extra[j][1](downto " << aBitMap_extra[j][1]
260 << "), BitMap_extra[j][2](" << aBitMap_extra[j][2]
261 << " bit length)" << std::endl;
262 }
263 }
264
265 }
266 for (int i = 0; i < 50; i++) {
267 cntr_bad_odr[i] = 0;
268 cntr_bad_ddd[i] = 0;
269 cntr_bad_nwd[i] = 0;
270
271 cntr_nw3[i] = 0;
272 cntr_nw3_badvet[i] = 0;
273 cntr_nw3_badtrg[i] = 0;
274 cntr_nw3_badrvc[i] = 0;
275
276 cntr_nwn[i] = 0;
277 cntr_nwn_badvet[i] = 0;
278 cntr_nwn_badtrg[i] = 0;
279 cntr_nwn_badrvc[i] = 0;
280
281 cntr_nwn_badbbb[i] = 0;
282 cntr_nwn_badddd[i] = 0;
283
284 cntr_nwe_badnwd[i] = 0;
285
286 }
287
288}
289
291{
292
293 B2INFO("trgrawdata: event() started.");
294 StoreArray<RawTRG> raw_trgarray;
295
297 int _exp = bevt->getExperiment();
298 int _run = bevt->getRun();
299 unsigned _eve = bevt->getEvent();
300 if (0)
301 std::cout << "**************_eve(" << _eve
302 << "), c_nModules(" << c_nModules
303 << "), m_nclk_cdctrg(" << m_nclk_cdctrg
304 << "), _exp(" << _exp
305 << "), _run(" << _run
306 << "), _eve(" << _eve
307 << "), _Form(" << Form("he%010d", (int)_eve)
308 << ")" << std::endl;
309
310 TH2D* h_0 = new TH2D(Form("he%010d", (int)_eve),
311 Form("e%02dr%04d ev %08d", _exp, _run, (int)_eve),
312 c_nModules * 4, 0, c_nModules * 4,
313 m_nclk_cdctrg, 0, m_nclk_cdctrg);
314
315 for (unsigned i = 0; i < c_nModules; ++i) {
316 h_0->GetXaxis()->SetBinLabel(4 * i + 1, Form("%s hdevt", moduleNames[i]));
317 h_0->GetXaxis()->SetBinLabel(4 * i + 2, Form("%s dtevt", moduleNames[i]));
318 h_0->GetXaxis()->SetBinLabel(4 * i + 3, Form("%s L1rvc", moduleNames[i]));
319 h_0->GetXaxis()->SetBinLabel(4 * i + 4, Form("%s cc", moduleNames[i]));
320 }
321
322 /*
323 GDL only. To get gdlrvc12
324 */
325 unsigned gdlrvc12 = -1;
326 for (int i = 0; i < raw_trgarray.getEntries(); i++) {
327 for (int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
328 int cprid = (int)raw_trgarray[i]->GetNodeID(j);
329 unsigned eve20 = (_eve & 0xfffff);
330 for (int hslb = 0; hslb < 2; hslb++) {
331 int nword = raw_trgarray[i]->GetDetectorNwords(j, hslb);
332 int* buf = raw_trgarray[i]->GetDetectorBuffer(j, hslb);
333 if (0x15000001 == cprid && hslb == 0) {
334
335 if (m_mydebug) {
336 printf("aa:GDL start: 0x%x%c exp(%d), run(%d), eve(%u), eve(0x%x), nword(%d)\n",
337 cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword);
338 }
339
340 unsigned buf0 = 0;
341 if (nword > 0) buf0 = (unsigned)buf[0];
342 unsigned buf1 = 0;
343 if (nword > 1) buf1 = (unsigned)buf[1];
344 unsigned buf2 = 0;
345 if (nword > 2) buf2 = (unsigned)buf[2];
346 //unsigned buf2cnttrg20 = (buf2 >> 12) & 0xfffff;
347 //unsigned buf2rvc12 = (buf2 & 0xfff);
348
349 if (nword < 3) {
350 cntr_nwe_badnwd[e_gdl]++;
351 printf("ab:GDL(0x%x%c) exp(%d), run(%d), eve(%u), eve(0x%x), nword(%d), ",
352 cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword);
353 printf("buf0(0x%x), buf1(0x%x), buf2(0x%x)\n", buf0, buf1, buf2);
354 continue;
355 }
356
357 if (nword < 8) {
358 printf("ad:GDL(0x%x%c) exp(%d), run(%d), eve(%u), eve(0x%x), nword(%d)\n",
359 cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword);
360 cntr_nwe_badnwd[e_gdl]++;
361 } else {
362 unsigned buf5 = (unsigned)buf[m_hdr_nwd_gdl - 1];
363 // 626 = 646 -
364 unsigned buf6 = (unsigned)buf[626]; // 1st wd in the last clock cycle
365 unsigned buf7 = (unsigned)buf[627]; // 2nd wd in the last clock cycle
366 unsigned lastdd = (buf6 >> 24) & 0xff;
367 unsigned last_rvc = (buf6 >> 4) & 0xfff;
368 unsigned cnttrg_data_15to12 = buf6 & (0xf);
369 unsigned cnttrg_data_12 = (buf7 >> 20) & (0xfff);
370 gdlrvc12 = (buf5 & 0xfff);
371 unsigned gdlhdrcnttrg20 = (buf5 >> 12) & 0xfffff;
372
373 //unsigned wdperclk = (m_nwd_gdl - m_hdr_nwd_gdl) / m_nclk_gdl;
374 //unsigned ibuf_lastclk_msw = m_nwd_gdl - wdperclk;
375 //unsigned buf_lastclk_msw = (unsigned)buf[ibuf_lastclk_msw];
376 //unsigned buf_lastclk_msw2 = (unsigned)buf[ibuf_lastclk_msw + 1];
377 //unsigned buf_lastclk_msw3 = (unsigned)buf[ibuf_lastclk_msw + 2];
378 unsigned cnttrg_data_16 = (cnttrg_data_15to12 << 12) + cnttrg_data_12;
379 unsigned eve16 = (_eve & 0xffff);
380
381 h_0->SetBinContent(4 * (int)e_gdl + 1, m_nclk_gdl, gdlhdrcnttrg20);
382 h_0->SetBinContent(4 * (int)e_gdl + 2, m_nclk_gdl, cnttrg_data_16);
383 h_0->SetBinContent(4 * (int)e_gdl + 3, m_nclk_gdl, gdlrvc12);
384
385 if (nword != m_nwd_gdl || buf0 != m_fmid_gdl || lastdd != 0xdd ||
386 gdlhdrcnttrg20 != eve20 ||
387 !(eve16 == cnttrg_data_16 + 1 || (eve16 == 0 && cnttrg_data_16 == 0xffff))
388 ) {
389
390 unsigned diag = 0;
391 diag |= (nword != m_nwd_gdl) ? 1 : 0;
392 diag |= (buf0 != m_fmid_gdl) ? 2 : 0;
393 diag |= (lastdd != 0xdd) ? 4 : 0;
394 diag |= (gdlhdrcnttrg20 != eve20) ? 8 : 0;
395 diag |= !(eve16 == cnttrg_data_16 + 1 || (eve16 == 0 && cnttrg_data_16 == 0xffff)) ? 16 : 0;
396 printf("ae:GDL(0x%x%c) exp(%d), run(%d), evedaq(%u=0x%x), gdlhdrcnttrg20(%u,0x%x), "
397 "cnttrg_data16(%u=0x%x), l1rvc(%u)-lastrvc(%u)=%u, nword(%d), diag(%u)\n",
398 cprid, 'a' + hslb, _exp, _run, _eve, _eve, gdlhdrcnttrg20, gdlhdrcnttrg20,
399 cnttrg_data_16, cnttrg_data_16, gdlrvc12, last_rvc, gdlrvc12 - last_rvc, nword, diag); //TODO can the difference be negative?
400 printf("\n");
401 cntr_nwn_badtrg[e_gdl]++;
402 } else {
403 cntr_nwn[e_gdl]++;
404 }
405 }
406 }
407 }
408 }
409 }
410
411 /* Other than GDL */
412 for (int i = 0; i < raw_trgarray.getEntries(); i++) {
413 for (int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
414 unsigned cprid = raw_trgarray[i]->GetNodeID(j);
415 //unsigned eve16 = (_eve & 0xffff);
416 unsigned eve20 = (_eve & 0xfffff);
417 for (int hslb = 0; hslb < 2; hslb++) {
418 unsigned e_mdl = -1;
419 unsigned _nwd = -1;
420 unsigned _scale = -1;
421 unsigned _nclk = -1;
422 unsigned _hdr_nwd = 3;
423 if (m_cpr_2d0 == cprid && hslb == 0 && m_on_2d0) {
424 e_mdl = e_2d0; _nwd = m_nwd_2ds; _scale = m_scale_2ds; _nclk = m_nclk_2ds; _hdr_nwd = m_hdr_nwd_2d0;
425 } else if (m_cpr_2d1 == cprid && hslb == 1 && m_on_2d1) {
426 e_mdl = e_2d1; _nwd = m_nwd_2ds; _scale = m_scale_2ds; _nclk = m_nclk_2ds; _hdr_nwd = m_hdr_nwd_2d1;
427 } else if (m_cpr_2d2 == cprid && hslb == 0 && m_on_2d2) {
428 e_mdl = e_2d2; _nwd = m_nwd_2ds; _scale = m_scale_2ds; _nclk = m_nclk_2ds; _hdr_nwd = m_hdr_nwd_2d2;
429 } else if (m_cpr_2d3 == cprid && hslb == 1 && m_on_2d3) {
430 e_mdl = e_2d3; _nwd = m_nwd_2ds; _scale = m_scale_2ds; _nclk = m_nclk_2ds; _hdr_nwd = m_hdr_nwd_2d3;
431 } else if (m_cpr_3d0 == cprid && hslb == 0 && m_on_3d0) {
432 e_mdl = e_3d0; _nwd = m_nwd_3ds; _scale = m_scale_3ds; _nclk = m_nclk_3ds; _hdr_nwd = m_hdr_nwd_3d0;
433 } else if (m_cpr_3d1 == cprid && hslb == 1 && m_on_3d1) {
434 e_mdl = e_3d1; _nwd = m_nwd_3ds; _scale = m_scale_3ds; _nclk = m_nclk_3ds; _hdr_nwd = m_hdr_nwd_3d1;
435 } else if (m_cpr_3d2 == cprid && hslb == 0 && m_on_3d2) {
436 e_mdl = e_3d2; _nwd = m_nwd_3ds; _scale = m_scale_3ds; _nclk = m_nclk_3ds; _hdr_nwd = m_hdr_nwd_3d2;
437 } else if (m_cpr_3d3 == cprid && hslb == 1 && m_on_3d3) {
438 e_mdl = e_3d3; _nwd = m_nwd_3ds; _scale = m_scale_3ds; _nclk = m_nclk_3ds; _hdr_nwd = m_hdr_nwd_3d3;
439 } else if (m_cpr_nn0 == cprid && hslb == 0 && m_on_nn0) {
440 e_mdl = e_nn0; _nwd = m_nwd_nns; _scale = m_scale_nns; _nclk = m_nclk_nns; _hdr_nwd = m_hdr_nwd_nn0;
441 } else if (m_cpr_nn1 == cprid && hslb == 1 && m_on_nn1) {
442 e_mdl = e_nn1; _nwd = m_nwd_nns; _scale = m_scale_nns; _nclk = m_nclk_nns; _hdr_nwd = m_hdr_nwd_nn1;
443 } else if (m_cpr_nn2 == cprid && hslb == 0 && m_on_nn2) {
444 e_mdl = e_nn2; _nwd = m_nwd_nns; _scale = m_scale_nns; _nclk = m_nclk_nns; _hdr_nwd = m_hdr_nwd_nn2;
445 } else if (m_cpr_nn3 == cprid && hslb == 1 && m_on_nn3) {
446 e_mdl = e_nn3; _nwd = m_nwd_nns; _scale = m_scale_nns; _nclk = m_nclk_nns; _hdr_nwd = m_hdr_nwd_nn3;
447 } else if (m_cpr_sl0 == cprid && hslb == 0 && m_on_sl0) {
448 e_mdl = e_sl0; _nwd = m_nwd_sl0; _scale = m_scale_sl0; _nclk = m_nclk_sl0; _hdr_nwd = m_hdr_nwd_sl0;
449 } else if (m_cpr_sl1 == cprid && hslb == 0 && m_on_sl1) { //ex w/ 1
450 e_mdl = e_sl1; _nwd = m_nwd_sl1; _scale = m_scale_sl1; _nclk = m_nclk_sl1; _hdr_nwd = m_hdr_nwd_sl1;
451 } else if (m_cpr_sl2 == cprid && hslb == 0 && m_on_sl2) {
452 e_mdl = e_sl2; _nwd = m_nwd_sl2; _scale = m_scale_sl2; _nclk = m_nclk_sl2; _hdr_nwd = m_hdr_nwd_sl2;
453 } else if (m_cpr_sl3 == cprid && hslb == 1 && m_on_sl3) {
454 e_mdl = e_sl3; _nwd = m_nwd_sl3; _scale = m_scale_sl3; _nclk = m_nclk_sl3; _hdr_nwd = m_hdr_nwd_sl3;
455 } else if (m_cpr_sl4 == cprid && hslb == 1 && m_on_sl4) { //ex w/ 4
456 e_mdl = e_sl4; _nwd = m_nwd_sl4; _scale = m_scale_sl4; _nclk = m_nclk_sl4; _hdr_nwd = m_hdr_nwd_sl4;
457 } else if (m_cpr_sl5 == cprid && hslb == 1 && m_on_sl5) {
458 e_mdl = e_sl5; _nwd = m_nwd_sl5; _scale = m_scale_sl5; _nclk = m_nclk_sl5; _hdr_nwd = m_hdr_nwd_sl5;
459 } else if (m_cpr_sl6 == cprid && hslb == 0 && m_on_sl6) {
460 e_mdl = e_sl6; _nwd = m_nwd_sl6; _scale = m_scale_sl6; _nclk = m_nclk_sl6; _hdr_nwd = m_hdr_nwd_sl6;
461 } else if (m_cpr_sl8 == cprid && hslb == 0 && m_on_sl8) {
462 e_mdl = e_sl8; _nwd = m_nwd_sl8; _scale = m_scale_sl8; _nclk = m_nclk_sl8; _hdr_nwd = m_hdr_nwd_sl8;
463 } else if (m_cpr_etf == cprid && hslb == 1 && m_on_etf) {
464 e_mdl = e_etf; _nwd = m_nwd_etf; _scale = m_scale_etf; _nclk = m_nclk_etf; _hdr_nwd = m_hdr_nwd_etf;
465 } else if (m_cpr_top == cprid && hslb == 0 && m_on_top) {
466 e_mdl = e_top; _nwd = m_nwd_top; _scale = m_scale_top; _nclk = m_nclk_top; _hdr_nwd = m_hdr_nwd_top;
467 } else {
468 continue;
469 }
470
471 unsigned nword = raw_trgarray[i]->GetDetectorNwords(j, hslb);
472 int* buf = raw_trgarray[i]->GetDetectorBuffer(j, hslb);
473 unsigned buf0 = 0;
474 if (nword > 0) buf0 = (unsigned)buf[0];
475 unsigned buf1 = 0;
476 if (nword > 1) buf1 = (unsigned)buf[1];
477 unsigned buf2 = 0;
478 if (nword > 2) buf2 = (unsigned)buf[2];
479 unsigned buf2cnttrg20 = (buf2 >> 12) & 0xfffff;
480 unsigned buf2rvc12 = (buf2 & 0xfff);
481
482 if (nword < 3) {
483 // err
484 cntr_nwe_badnwd[e_mdl]++;
485 printf("ah:%s(0x%x%c) exp(%d), run(%d), eve(%u), eve(0x%x), nword(%u), ",
486 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword);
487 printf("buf0(0x%x), buf1(0x%x), buf2(0x%x)\n", buf0, buf1, buf2);
488 continue;
489 } else if (nword == _hdr_nwd) {
490 // header-only event
491 if (gdlrvc12 != buf2rvc12) {
492 printf("ai:%s(0x%x%c) exp(%d), run(%d), eve(%u,0x%x), nword(%u), gdlrvc12(0x%x), buf2rvc12(0x%x)\n",
493 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword, gdlrvc12, buf2rvc12);
494 cntr_nw3_badrvc[e_mdl]++;
495 } else if (eve20 != buf2cnttrg20) {
496 printf("aj:%s(0x%x%c) exp(%d), run(%d), eve(%u,0x%x), nword(%u), cnttrg20(0x%x)\n",
497 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword, buf2cnttrg20);
498 cntr_nw3_badtrg[e_mdl]++;
499 } else if ((_eve % _scale) == 0) {
500 cntr_nw3_badvet[e_mdl]++;
501 } else {
502 cntr_nw3[e_mdl]++;
503 }
504 continue;
505 } else if (nword != _nwd) {
506 // err
507 printf("bo:wrong nword: %s(0x%x%c) exp(%d), run(%d), eve(%u,0x%x), nword(%u), buf0(0x%x), buf2(0x%x)\n",
508 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword, buf0, buf2);
509 cntr_nwe_badnwd[e_mdl]++;
510 continue;
511 }
512
513 unsigned buf3 = (unsigned)buf[_hdr_nwd];
514 unsigned buf3dddd = ((buf3 >> 16) & 0xffff);
515 unsigned buf4 = (unsigned)buf[_hdr_nwd + 1];
516 unsigned buf5 = (unsigned)buf[_hdr_nwd + 2];
517 unsigned wdperclk = (_nwd - _hdr_nwd) / _nclk;
518 //unsigned ibuf_lsw = _nwd - 1;
519 unsigned ibuf_lastclk_msw = _nwd - wdperclk;
520 //unsigned buf_lastclk_msw = (unsigned)buf[ibuf_lastclk_msw];
521 unsigned buf_lastclk_msw2 = (unsigned)buf[ibuf_lastclk_msw + 1];
522 unsigned buf_lastclk_msw3 = (unsigned)buf[ibuf_lastclk_msw + 2];
523 //unsigned dddd_lastclk = ((buf_lastclk_msw >> 16) & 0xffff);
524 unsigned datacnttrg32 = 0;
525 unsigned buf4_msb16 = (buf4 & 0xffff);
526 unsigned buf5_lsb16 = ((buf5 >> 16) & 0xffff);
527
528 if (m_mydebug) {
529 printf("af:Debug0: %s(0x%x%c) exp(%d), run(%d), eve(%u), eve(0x%x), nword(%u)\n",
530 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword);
531 }
532
533 /*
534 *
535 * Module Start
536 *
537 *
538 */
539
540 if ((0x11000009 == cprid && hslb == 0) || // SL1
541 (0x11000008 == cprid && hslb == 1) || // SL1
542 (0x11000009 == cprid && hslb == 1) // SL5
543 ) {
544 /* SL1 SL3 SL5 4096x48
545 data_b2l_r(4095 downto 4048) <= x"dddd" & "00000" & revoclk & cntr125M(15 downto 0);--i=0..5
546 data_b2l_r(4031 downto 4000) <= cnttrg;--i=6..9
547 buf[3] = dddd * revoclk
548 buf[4] = cntr125M & x"0000"
549 buf[5] = cnttrg
550 */
551 datacnttrg32 = buf5;
552
553 } else if ((0x11000007 == cprid && hslb == 0) || // SL0
554 (0x11000007 == cprid && hslb == 1) || // SL4
555 (0x1100000a == cprid && hslb == 0) // SL6
556 ) {
557 /* SL0 SL4 SL6 2048*48
558 data_b2l_r(2047 downto 2000) <= x"dddd" &"00000"& revoclk & cntr125M(15 downto 0);
559 data_b2l_r(1999 downto 1968) <= cnttrg;
560
561 data_b2l(2047, 2016) <= buf[3]
562 data_b2l(2015, 1984) <= buf[4]
563 data_b2l(1983, 1952) <= buf[5]
564 data_b2l(1999, 1968) <= cnttrg;
565 */
566 datacnttrg32 = (buf4_msb16 << 16) + buf5_lsb16;
567
568 } else if ((m_cpr_2d0 == cprid && hslb == 0 && m_on_2d0) ||
569 (m_cpr_2d1 == cprid && hslb == 1 && m_on_2d1) ||
570 (m_cpr_2d2 == cprid && hslb == 0 && m_on_2d2) ||
571 (m_cpr_2d3 == cprid && hslb == 1 && m_on_2d3)) {
572 /*
573 2D2D2D: 2048 bit x 48 clock = 64 word x 48 clock
574 */
575
576 unsigned buf_lastclk_lsb = (unsigned)buf[_nwd - 1];
577 unsigned buf_lastclk_lsb2 = (unsigned)buf[_nwd - 2];
578 //unsigned nworking = (buf_lastclk_lsb2 >> 24) & 0xff;
579 //unsigned idbuf = (buf_lastclk_lsb2 >> 16) & 0xff;
580 //unsigned ihdr = (buf_lastclk_lsb2 >> 8) & 0xff;
581 datacnttrg32 = ((buf_lastclk_lsb2 & 0xff) << 24) + (buf_lastclk_lsb >> 8);
582
583 } else if ((m_cpr_3d0 == cprid && hslb == 0 && m_on_3d0) ||
584 (m_cpr_3d1 == cprid && hslb == 1 && m_on_3d1) ||
585 (m_cpr_3d2 == cprid && hslb == 0 && m_on_3d2) ||
586 (m_cpr_3d3 == cprid && hslb == 1 && m_on_3d3)) {
587 /*
588 3D3D3D: 2048 bit x 48 clock = 64 word x 48 clock
589 */
590
591 // data_b2l_r(2623 downto 2576) <= x"dddd" &"00000"& revoclk & cntr125M(15 downto 0);
592 // data_b2l_r(2575 downto 2544) <= cnttrg;
593 // [3] (2623, 2592)
594 // [4] (2591, 2560)
595 // [5] (2559, 2528)
596 unsigned datacnttrg_msb16 = (buf_lastclk_msw2 & 0xffff);
597 unsigned datacnttrg_lsb16 = ((buf_lastclk_msw3 >> 16) & 0xffff);
598 datacnttrg32 = (datacnttrg_msb16 << 16) + datacnttrg_lsb16;
599
600 } else if ((m_cpr_nn0 == cprid && hslb == 0 && m_on_nn0) ||
601 (m_cpr_nn1 == cprid && hslb == 1 && m_on_nn1) ||
602 (m_cpr_nn2 == cprid && hslb == 0 && m_on_nn2) ||
603 (m_cpr_nn3 == cprid && hslb == 1 && m_on_nn3)) {
604 /*
605 int e_mdl = -1;
606 if (m_cpr_nn0 == cprid && hslb == 0 && m_on_nn0) e_mdl = e_nn0;
607 if (m_cpr_nn1 == cprid && hslb == 1 && m_on_nn1) e_mdl = e_nn1;
608 if (m_cpr_nn2 == cprid && hslb == 0 && m_on_nn2) e_mdl = e_nn2;
609 if (m_cpr_nn3 == cprid && hslb == 1 && m_on_nn3) e_mdl = e_nn3;
610 */
611 /*
612 NNNNNN: 2048 bit x 48 clock = 64 word x 48 clock
613 data_b2l_r(1999 downto 1968) <= cnttrg;
614 */
615
616 // [3] 2047 2016
617 // [4] 2015 1984
618 // [5] 1983 1952
619 // [3 + 64] = [m_hdr_nwd + wdperclk]
620 // [3 + 65] = [m_hdr_nwd + wdperclk + 1]
621 // [3 + 66] = [m_hdr_nwd + wdperclk + 2]
622 // [3 + 64 * 47] = [m_hdr_nwd + wdperclk * (_nclk - 1)]
623 // [3 + 65 * 47] = [m_hdr_nwd + wdperclk * (_nclk - 1) + 1]
624 // [3 + 66 * 47] = [m_hdr_nwd + wdperclk * (_nclk - 1) + 2]
625 unsigned datacnttrg_msb16 = (buf_lastclk_msw2 & 0xffff);
626 unsigned datacnttrg_lsb16 = ((buf_lastclk_msw3 >> 16) & 0xffff);
627 datacnttrg32 = (datacnttrg_msb16 << 16) + datacnttrg_lsb16;
628 } else if (m_cpr_top == cprid && hslb == 0 && m_on_top) {
629 // TOPTRG
630 } // Modules
631
632 bool something_bad = false;
633 h_0->SetBinContent(4 * e_mdl + 1, _nclk, buf2cnttrg20);
634 h_0->SetBinContent(4 * e_mdl + 2, _nclk, datacnttrg32);
635 h_0->SetBinContent(4 * e_mdl + 3, _nclk, buf2rvc12);
636 if (gdlrvc12 != buf2rvc12) {
637 printf("ba:%s(0x%x%c) exp(%d), run(%d), eve(%u,0x%x), nword(%u), gdlrvc12(0x%x), buf2rvc12(0x%x)\n",
638 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword, gdlrvc12, buf2rvc12);
639 cntr_nwn_badrvc[e_mdl]++;
640 something_bad = true;
641 }
642 if (buf3dddd == 0xbbbb) {
643 cntr_nwn_badbbb[e_mdl]++;
644 printf("bv:%s(0x%x%c) exp(%d), run(%d), eve(%u,0x%x), nword(%u), cnttrg20(0x%x), dddd(0x%x), datacnttrg32(0x%x)\n",
645 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword, buf2cnttrg20, buf3dddd, datacnttrg32);
646 something_bad = true;
647 }
648 if (buf3dddd != 0xdddd) {
649 cntr_nwn_badddd[e_mdl]++;
650 printf("bb:%s(0x%x%c) exp(%d), run(%d), eve(%u,0x%x), nword(%u), cnttrg20(0x%x), dddd(0x%x), datacnttrg32(0x%x)\n",
651 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword, buf2cnttrg20, buf3dddd, datacnttrg32);
652 something_bad = true;
653 }
654 if (datacnttrg32 + 1 != _eve) {
655 if (!(
656 (m_cpr_top == cprid) ||
657 (m_cpr_3d0 <= cprid && cprid <= m_cpr_3d3)
658 )
659 ) {
660 printf("bc:%s(0x%x%c) exp(%d), run(%d), eve(%u,0x%x), nword(%u), cnttrg20(0x%x), dddd(0x%x), datacnttrg32(0x%x)\n",
661 moduleNames[e_mdl], cprid, 'a' + hslb, _exp, _run, _eve, _eve, nword, buf2cnttrg20, buf3dddd, datacnttrg32);
662 cntr_nwn_badtrg[e_mdl]++;
663 something_bad = true;
664 }
665 }
666 if (! something_bad) cntr_nwn[e_mdl]++;
667
668 } // for hslb
669 }
670 }
671
672 if (m_cc_check) {
673 for (int i = 0; i < raw_trgarray.getEntries(); i++) {
674 for (int j = 0; j < raw_trgarray[i]->GetNumEntries(); j++) {
675 unsigned cprid = raw_trgarray[i]->GetNodeID(j);
676// int _exp = raw_trgarray[i]->GetExpNo(j);
677// int _run = raw_trgarray[i]->GetRunNo(j);
678 unsigned _eveRaw = raw_trgarray[i]->GetEveNo(j);
679 if ((0x11000001 <= cprid && cprid <= 0x1100000a) ||
680 (0x15000001 <= cprid && cprid <= 0x15000002) ||
681 (0x12000001 == cprid) // TOPTRG
682 ) {
683 } else {
684 continue;
685 }
686 for (int hslb = 0; hslb < 2; hslb++) {
687 int nclks = m_nclk_cdctrg;
688 unsigned _hdr_nwd = 3;
689 unsigned e_mdl = -1;
690 unsigned _nwd = -1;
691 if (m_cpr_top == cprid && hslb == 0 && m_on_top) {
692 e_mdl = e_top; _nwd = m_nwd_top;
693 nclks = m_nclk_top; _hdr_nwd = m_hdr_nwd_top;
694 } else if (m_cpr_2d0 == cprid && hslb == 0 && m_on_2d0) {
695 e_mdl = e_2d0; _nwd = m_nwd_2ds; _hdr_nwd = m_hdr_nwd_2d0;
696 } else if (m_cpr_2d1 == cprid && hslb == 1 && m_on_2d1) {
697 e_mdl = e_2d1; _nwd = m_nwd_2ds; _hdr_nwd = m_hdr_nwd_2d1;
698 } else if (m_cpr_2d2 == cprid && hslb == 0 && m_on_2d2) {
699 e_mdl = e_2d2; _nwd = m_nwd_2ds; _hdr_nwd = m_hdr_nwd_2d2;
700 } else if (m_cpr_2d3 == cprid && hslb == 1 && m_on_2d3) {
701 e_mdl = e_2d3; _nwd = m_nwd_2ds; _hdr_nwd = m_hdr_nwd_2d3;
702 } else if (m_cpr_3d0 == cprid && hslb == 0 && m_on_3d0) {
703 e_mdl = e_3d0; _nwd = m_nwd_3ds; _hdr_nwd = m_hdr_nwd_3d0;
704 } else if (m_cpr_3d1 == cprid && hslb == 1 && m_on_3d1) {
705 e_mdl = e_3d1; _nwd = m_nwd_3ds; _hdr_nwd = m_hdr_nwd_3d1;
706 } else if (m_cpr_3d2 == cprid && hslb == 0 && m_on_3d2) {
707 e_mdl = e_3d2; _nwd = m_nwd_3ds; _hdr_nwd = m_hdr_nwd_3d2;
708 } else if (m_cpr_3d3 == cprid && hslb == 1 && m_on_3d3) {
709 e_mdl = e_3d3; _nwd = m_nwd_3ds; _hdr_nwd = m_hdr_nwd_3d3;
710 } else if (m_cpr_nn0 == cprid && hslb == 0 && m_on_nn0) {
711 e_mdl = e_nn0; _nwd = m_nwd_nns; _hdr_nwd = m_hdr_nwd_nn0;
712 } else if (m_cpr_nn1 == cprid && hslb == 1 && m_on_nn1) {
713 e_mdl = e_nn1; _nwd = m_nwd_nns; _hdr_nwd = m_hdr_nwd_nn1;
714 } else if (m_cpr_nn2 == cprid && hslb == 0 && m_on_nn2) {
715 e_mdl = e_nn2; _nwd = m_nwd_nns; _hdr_nwd = m_hdr_nwd_nn2;
716 } else if (m_cpr_nn3 == cprid && hslb == 1 && m_on_nn3) {
717 e_mdl = e_nn3; _nwd = m_nwd_nns; _hdr_nwd = m_hdr_nwd_nn3;
718 } else if (m_cpr_sl0 == cprid && hslb == 0 && m_on_sl0) {
719 e_mdl = e_sl0; _nwd = m_nwd_sl0; _hdr_nwd = m_hdr_nwd_sl0;
720 } else if (m_cpr_sl1 == cprid && hslb == 0 && m_on_sl1) {//ex w/ 4
721 e_mdl = e_sl1; _nwd = m_nwd_sl1; _hdr_nwd = m_hdr_nwd_sl1;
722 } else if (m_cpr_sl2 == cprid && hslb == 0 && m_on_sl2) {
723 e_mdl = e_sl2; _nwd = m_nwd_sl2; _hdr_nwd = m_hdr_nwd_sl2;
724 } else if (m_cpr_sl3 == cprid && hslb == 1 && m_on_sl3) {
725 e_mdl = e_sl3; _nwd = m_nwd_sl3; _hdr_nwd = m_hdr_nwd_sl3;
726 } else if (m_cpr_sl4 == cprid && hslb == 1 && m_on_sl4) {//ex w/ 1
727 e_mdl = e_sl4; _nwd = m_nwd_sl4; _hdr_nwd = m_hdr_nwd_sl4;
728 } else if (m_cpr_sl5 == cprid && hslb == 1 && m_on_sl5) {
729 e_mdl = e_sl5; _nwd = m_nwd_sl5; _hdr_nwd = m_hdr_nwd_sl5;
730 } else if (m_cpr_sl6 == cprid && hslb == 0 && m_on_sl6) {
731 e_mdl = e_sl6; _nwd = m_nwd_sl6; _hdr_nwd = m_hdr_nwd_sl6;
732 } else if (m_cpr_sl8 == cprid && hslb == 0 && m_on_sl8) {
733 e_mdl = e_sl8; _nwd = m_nwd_sl8; _hdr_nwd = m_hdr_nwd_sl8;
734 } else if (m_cpr_etf == cprid && hslb == 1 && m_on_etf) {
735 e_mdl = e_etf; _nwd = m_nwd_etf; _hdr_nwd = m_hdr_nwd_etf;
736 } else if (m_cpr_gdl == cprid && hslb == 0 && m_on_gdl) {
737 e_mdl = e_gdl; _nwd = m_nwd_gdl;
738 nclks = m_nclk_gdl; _hdr_nwd = 6;
739 } else {
740 continue;
741 }
742 unsigned nword = raw_trgarray[i]->GetDetectorNwords(j, hslb);
743 if (nword == _hdr_nwd) continue;
744 if (nword != _nwd) {
745 printf("bu:Nword mismatch:nword(%u),expected(%u). eve(%u), %s(0x%x%c), nword(%u)\n",
746 nword, _nwd, _eveRaw, moduleNames[e_mdl], cprid, 'a' + hslb, nword);
747 }
748 int* buf = raw_trgarray[i]->GetDetectorBuffer(j, hslb);
749 int i47 = _hdr_nwd + (nclks - 1) * (_nwd - _hdr_nwd) / nclks;
750 if (i47 > int(nword) - 1) {
751 if (m_print_clkcyc_err)
752 printf("bp:data truncation. eve(%u), %s(0x%x%c), nword(%u)\n",
753 _eveRaw, moduleNames[e_mdl], cprid, 'a' + hslb, nword);
754 break;
755 }
756 unsigned buf47 = buf[i47];
757 bool break_this_module = false;
758 bool cc_disorder = false;
759
760 unsigned prev_cc = buf47 & 0xffff;
761 if (e_mdl == e_gdl) {
762 prev_cc = (buf47 >> 4) & 0xfff;
763 }
764 char ccc[400];
765 sprintf(ccc, "i47(%d),buf47(0x%x),%x", i47, buf47, prev_cc);
766 std::string ccs(ccc);
767 for (int clk = 0; clk < nclks; clk++) {
768 unsigned ibuf = _hdr_nwd + clk * (nword - _hdr_nwd) / nclks;
769 if (ibuf > nword - 1) {
770 if (m_print_clkcyc_err)
771 printf("bq:data truncation. eve(%u), %s(0x%x%c), nword(%u)\n",
772 _eveRaw, moduleNames[e_mdl], cprid, 'a' + hslb, nword);
773 break_this_module = true;
774 cntr_bad_nwd[e_mdl]++;
775 break;
776 }
777 unsigned ddddcc = buf[ibuf];
778 unsigned dddd = (ddddcc >> 16) & 0xffff;
779 unsigned cc = ddddcc & 0xffff;
780 if (e_mdl == e_gdl) {
781 cc = (ddddcc >> 4) & 0xfff;
782 }
783 h_0->SetBinContent(4 * e_mdl + 4, clk + 1, cc);
784 sprintf(ccc, ",%x", cc);
785 if ((int)e_2d0 <= (int)e_mdl && (int)e_mdl <= (int)e_2d3 &&
786 m_nwd_2ds == 3939/* =2624bit */) {
787 // (downto) = wd i
788 // ( ) = 75 300
789 // ( ) = 76 304
790 // ( ) = 79 316
791 // (79, 72) = 79 318 addr_o
792 // (71, 64) = 79 319 addr_i
793 // (63, 56) = 80 320 nworking
794 // (55, 48) = 80 321 rennum
795 // (47, 40) = 80 322 itarget
796 // (39, 8) = 80 323-326 = cnttrg
797 // ( 7, 0) = 81
798 int i_addr = ibuf + 79; // addr_i and addr_o
799 int val_addr = buf[i_addr];
800 int addr_o = (val_addr >> 8) & 0xff;
801 int addr_i = val_addr & 0xff;
802 sprintf(ccc, ",%x(%d,%d)", cc, addr_i, addr_o);
803 }
804 ccs += ccc;
805 if (e_mdl == e_gdl) {
806 dddd = (ddddcc >> 24);
807 if (dddd != 0xdd) {
808 if (m_print_clkcyc_err)
809 printf("br:dddd not found. eve(%u), %s(0x%x%c), nword(%u)\n",
810 _eveRaw, moduleNames[e_mdl], cprid, 'a' + hslb, nword);
811 break_this_module = true;
812 cntr_bad_ddd[e_mdl]++;
813 break;
814 }
815 } else if (dddd != 0xdddd) {
816 if (m_print_clkcyc_err)
817 printf("bs:dddd not found. eve(%u), %s(0x%x%c), nword(%u)\n",
818 _eveRaw, moduleNames[e_mdl], cprid, 'a' + hslb, nword);
819 break_this_module = true;
820 cntr_bad_ddd[e_mdl]++;
821 break;
822 }
823 // 0x500 == 1280
824 if (!(cc == prev_cc + 4 || prev_cc == cc + 4 * (nclks - 1) || prev_cc + 0x500 == cc + 4 * (nclks - 1)
825 || cc + 0x500 == prev_cc + 4)) {
826 cc_disorder = true;
827 ccs += "*";
828 }
829 prev_cc = cc;
830 } // clk
831 if (break_this_module) continue; // bad dddd
832 if (cc_disorder) {
833 cntr_bad_odr[e_mdl]++;
834 if (m_print_cc) {
835 printf("bt:ccdisorder: eve(%u), %s(0x%x%c), nword(%u), %s\n",
836 _eveRaw, moduleNames[e_mdl], cprid, 'a' + hslb, nword, ccs.c_str());
837 }
838 } else {
839 cntr_good_odr[e_mdl]++;
840 }
841 } // hslb
842 } // j < raw_trgarray[i]->GetNumEntries()
843 } // i < raw_trgarray.getEntries()
844 }
845
846 if (! m_histRecord) {
847 h_0->Delete();
848 }
849}
850
852{
853}
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
Definition: HistoModule.h:29
void setDescription(const std::string &description)
Sets the description of the module.
Definition: Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition: Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition: Module.h:80
Accessor to arrays stored in the data store.
Definition: StoreArray.h:113
int getEntries() const
Get the number of objects in the array.
Definition: StoreArray.h:216
Type-safe access to single objects in the data store.
Definition: StoreObjPtr.h:96
static const unsigned int c_nModules
number of modules
virtual void initialize() override
initialize
virtual void event() override
Event.
virtual void defineHisto() override
Define Histogram.
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition: Module.h:560
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition: Module.h:650
Abstract base class for different kinds of events.
STL namespace.