13 #include <trg/gdl/modules/trggdlSummary/trggdlSummaryModule.h>
15 #include <framework/datastore/StoreArray.h>
17 #include <mdst/dataobjects/TRGSummary.h>
19 #include <framework/database/DBObjPtr.h>
20 #include <mdst/dbobjects/TRGGDLDBInputBits.h>
21 #include <mdst/dbobjects/TRGGDLDBFTDLBits.h>
44 if (
_debugLevel > 9) printf(
"TRGGDLSummaryModule::initialize() start\n");
47 for (
int i = 0; i < 320; i++) {
48 LeafBitMap[i] = m_unpacker->getLeafMap(i);
50 for (
int i = 0; i < 320; i++) {
51 strcpy(LeafNames[i], m_unpacker->getLeafnames(i));
56 for (
int i = 0; i < 10; i++) {
61 for (
int i = 0; i < 320; i++) {
62 if (strcmp(LeafNames[i],
"timtype") == 0)_e_timtype = LeafBitMap[i];
63 if (strcmp(LeafNames[i],
"rvcout") == 0) _e_rvcout = LeafBitMap[i];
64 if (strcmp(LeafNames[i],
"psn0") == 0) ee_psn[0] = LeafBitMap[i];
65 if (strcmp(LeafNames[i],
"psn1") == 0) ee_psn[1] = LeafBitMap[i];
66 if (strcmp(LeafNames[i],
"psn2") == 0) ee_psn[2] = LeafBitMap[i];
67 if (strcmp(LeafNames[i],
"psn3") == 0) ee_psn[3] = LeafBitMap[i];
68 if (strcmp(LeafNames[i],
"psn4") == 0) ee_psn[4] = LeafBitMap[i];
69 if (strcmp(LeafNames[i],
"psn5") == 0) ee_psn[5] = LeafBitMap[i];
70 if (strcmp(LeafNames[i],
"psn6") == 0) ee_psn[6] = LeafBitMap[i];
71 if (strcmp(LeafNames[i],
"psn7") == 0) ee_psn[7] = LeafBitMap[i];
72 if (strcmp(LeafNames[i],
"psn8") == 0) ee_psn[8] = LeafBitMap[i];
73 if (strcmp(LeafNames[i],
"psn9") == 0) ee_psn[9] = LeafBitMap[i];
74 if (strcmp(LeafNames[i],
"ftd0") == 0) ee_ftd[0] = LeafBitMap[i];
75 if (strcmp(LeafNames[i],
"ftd1") == 0) ee_ftd[1] = LeafBitMap[i];
76 if (strcmp(LeafNames[i],
"ftd2") == 0) ee_ftd[2] = LeafBitMap[i];
77 if (strcmp(LeafNames[i],
"ftd3") == 0) ee_ftd[3] = LeafBitMap[i];
78 if (strcmp(LeafNames[i],
"ftd4") == 0) ee_ftd[4] = LeafBitMap[i];
79 if (strcmp(LeafNames[i],
"ftd5") == 0) ee_ftd[5] = LeafBitMap[i];
80 if (strcmp(LeafNames[i],
"ftd6") == 0) ee_ftd[6] = LeafBitMap[i];
81 if (strcmp(LeafNames[i],
"ftd7") == 0) ee_ftd[7] = LeafBitMap[i];
82 if (strcmp(LeafNames[i],
"ftd8") == 0) ee_ftd[8] = LeafBitMap[i];
83 if (strcmp(LeafNames[i],
"ftd9") == 0) ee_ftd[9] = LeafBitMap[i];
84 if (strcmp(LeafNames[i],
"itd0") == 0) ee_itd[0] = LeafBitMap[i];
85 if (strcmp(LeafNames[i],
"itd1") == 0) ee_itd[1] = LeafBitMap[i];
86 if (strcmp(LeafNames[i],
"itd2") == 0) ee_itd[2] = LeafBitMap[i];
87 if (strcmp(LeafNames[i],
"itd3") == 0) ee_itd[3] = LeafBitMap[i];
88 if (strcmp(LeafNames[i],
"itd4") == 0) ee_itd[4] = LeafBitMap[i];
89 if (strcmp(LeafNames[i],
"itd5") == 0) ee_itd[5] = LeafBitMap[i];
90 if (strcmp(LeafNames[i],
"itd6") == 0) ee_itd[6] = LeafBitMap[i];
91 if (strcmp(LeafNames[i],
"itd7") == 0) ee_itd[7] = LeafBitMap[i];
92 if (strcmp(LeafNames[i],
"itd8") == 0) ee_itd[8] = LeafBitMap[i];
93 if (strcmp(LeafNames[i],
"itd9") == 0) ee_itd[9] = LeafBitMap[i];
97 if (
_debugLevel > 9) printf(
"TRGGDLSummaryModule::initialize() end\n");
103 if (
_debugLevel > 9) printf(
"TRGGDLSummaryModule::event() start\n");
106 n_leafs = m_unpacker->getnLeafs();
107 int n_leafsExtra = 0;
108 n_leafsExtra = m_unpacker->getnLeafsExtra();
109 int n_clocks = m_unpacker->getnClks();
110 int nconf = m_unpacker->getconf();
111 int nword_input = m_unpacker->get_nword_input();
112 int nword_output = m_unpacker->get_nword_output();
115 printf(
"trggdlSummaryModule:n_leafs(%d), n_leafsExtra(%d), n_clocks(%d), nconf(%d), nword_input(%d), nword_output(%d)\n",
116 n_leafs, n_leafsExtra, n_clocks, nconf, nword_input, nword_output);
123 for (
int i = 0; i < 320; i++) {
124 if (strcmp(entAry[0]->m_unpackername[i],
"clk") == 0) clk_map = i;
127 printf(
"trggdlSummaryModule:clk_map(%d)\n", clk_map);
129 std::vector<std::vector<int> > _data(n_leafs + n_leafsExtra);
130 for (
int leaf = 0; leaf < n_leafs + n_leafsExtra; leaf++) {
131 std::vector<int> _v(n_clocks);
136 for (
int ii = 0; ii < entAry.
getEntries(); ii++) {
138 printf(
"trggdlSummaryModule:a:ii(%d)\n", ii);
139 std::vector<int*> Bits(n_leafs + n_leafsExtra);
141 for (
int i = 0; i < 320; i++) {
142 if (LeafBitMap[i] != -1) {
143 Bits[LeafBitMap[i]] = &(entAry[ii]->m_unpacker[i]);
145 printf(
"trggdlSummaryModule:ab:i(%d), LeafBitMap[i](%d), *Bits[LeafBitMap[i]](%d)\n",
146 i, LeafBitMap[i], *Bits[LeafBitMap[i]]);
149 printf(
"trggdlSummaryModule:ab:i(%d), LeafBitMap[i](%d)\n",
153 for (
int leaf = 0; leaf < n_leafs + n_leafsExtra; leaf++) {
155 printf(
"trggdlSummaryModule:ad:leaf(%d),ii(%d),clk_map(%d),*Bits[leaf](%d), entAry[ii]->m_unpacker[clk_map](%d)\n",
156 leaf, ii, clk_map, *Bits[leaf], entAry[ii]->m_unpacker[clk_map]);
157 _data[leaf][entAry[ii]->m_unpacker[clk_map]] = *Bits[leaf];
165 for (
int j = 0; j < (int)nword_input; j++) {
168 for (
int clk = 0; clk < n_clocks; clk++) {
170 ored |= _data[ee_itd[j]][clk];
178 for (
int clk = 0; clk < n_clocks; clk++) {
179 ored |= _data[ee_ftd[0]][clk];
184 for (
int clk = 0; clk < n_clocks; clk++) {
185 ored |= (_data[ee_ftd[2]][clk] << 16) + _data[ee_ftd[1]][clk];
190 for (
int clk = 0; clk < n_clocks; clk++) {
191 ored |= _data[ee_psn[0]][clk];
196 for (
int clk = 0; clk < n_clocks; clk++) {
197 ored |= (_data[ee_psn[2]][clk] << 16) + _data[ee_psn[1]][clk];
201 for (
int j = 0; j < (int)nword_output; j++) {
203 for (
int clk = 0; clk < n_clocks; clk++) {
204 ored |= _data[ee_ftd[j]][clk];
209 for (
int j = 0; j < (int)nword_output; j++) {
211 for (
int clk = 0; clk < n_clocks; clk++) {
212 ored |= _data[ee_psn[j]][clk];
219 GDL::EGDLTimingType gtt = (GDL::EGDLTimingType)_data[_e_timtype][0];
222 for (
int i = 0; i < 320; i++) {
225 GDLResult->setPreScale(bit1, bit2, m_prescales->getprescales(i));
229 if (gtt == GDL::e_tt_cdc) {
231 }
else if (gtt == GDL::e_tt_ecl) {
233 }
else if (gtt == GDL::e_tt_top) {
235 }
else if (gtt == GDL::e_tt_dphy) {
237 }
else if (gtt == GDL::e_tt_rand) {
239 }
else if (gtt == GDL::e_tt_psnm) {
246 unsigned _exp = bevt->getExperiment();
247 unsigned _run = bevt->getRun();
248 unsigned exprun = _exp * 1000000 + _run;
249 if (exprun < 13000500) {
250 GDLResult->setTimQuality(TRGSummary::TTYQ_CORS);
252 int rvcout = _data[_e_rvcout][0];
253 int q = (rvcout >> 1) & 3;
257 timQuality = TRGSummary::TTYQ_CORS;
260 timQuality = TRGSummary::TTYQ_FINE;
263 timQuality = TRGSummary::TTYQ_SFIN;
266 timQuality = TRGSummary::TTYQ_NONE;
272 if (exprun > 16000271) {
274 int i_poissonin =
GDLResult->getInputBitNumber(std::string(
"poissonin"));
277 int i_veto =
GDLResult->getInputBitNumber(std::string(
"veto"));
280 for (
int clk = 5; clk < n_clocks - 5; clk++) {
281 if ((1 << k_poissonin) & _data[ee_itd[j_poissonin]][clk]) {
283 if ((1 << k_veto) & _data[ee_itd[j_veto]][clk]) {