20#include <trg/gdl/modules/trggdlSummary/trggdlSummaryModule.h>
22#include <framework/datastore/StoreArray.h>
24#include <mdst/dataobjects/TRGSummary.h>
26#include <framework/database/DBObjPtr.h>
27#include <mdst/dbobjects/TRGGDLDBInputBits.h>
28#include <mdst/dbobjects/TRGGDLDBFTDLBits.h>
51 if (
_debugLevel > 9) printf(
"TRGGDLSummaryModule::initialize() start\n");
54 for (
int i = 0; i < 320; i++) {
55 LeafBitMap[i] = m_unpacker->getLeafMap(i);
57 for (
int i = 0; i < 320; i++) {
58 strcpy(LeafNames[i], m_unpacker->getLeafnames(i));
63 for (
int i = 0; i < 10; i++) {
68 for (
int i = 0; i < 320; i++) {
69 if (strcmp(LeafNames[i],
"timtype") == 0)_e_timtype = LeafBitMap[i];
70 if (strcmp(LeafNames[i],
"rvcout") == 0) _e_rvcout = LeafBitMap[i];
71 if (strcmp(LeafNames[i],
"psn0") == 0) ee_psn[0] = LeafBitMap[i];
72 if (strcmp(LeafNames[i],
"psn1") == 0) ee_psn[1] = LeafBitMap[i];
73 if (strcmp(LeafNames[i],
"psn2") == 0) ee_psn[2] = LeafBitMap[i];
74 if (strcmp(LeafNames[i],
"psn3") == 0) ee_psn[3] = LeafBitMap[i];
75 if (strcmp(LeafNames[i],
"psn4") == 0) ee_psn[4] = LeafBitMap[i];
76 if (strcmp(LeafNames[i],
"psn5") == 0) ee_psn[5] = LeafBitMap[i];
77 if (strcmp(LeafNames[i],
"psn6") == 0) ee_psn[6] = LeafBitMap[i];
78 if (strcmp(LeafNames[i],
"psn7") == 0) ee_psn[7] = LeafBitMap[i];
79 if (strcmp(LeafNames[i],
"psn8") == 0) ee_psn[8] = LeafBitMap[i];
80 if (strcmp(LeafNames[i],
"psn9") == 0) ee_psn[9] = LeafBitMap[i];
81 if (strcmp(LeafNames[i],
"ftd0") == 0) ee_ftd[0] = LeafBitMap[i];
82 if (strcmp(LeafNames[i],
"ftd1") == 0) ee_ftd[1] = LeafBitMap[i];
83 if (strcmp(LeafNames[i],
"ftd2") == 0) ee_ftd[2] = LeafBitMap[i];
84 if (strcmp(LeafNames[i],
"ftd3") == 0) ee_ftd[3] = LeafBitMap[i];
85 if (strcmp(LeafNames[i],
"ftd4") == 0) ee_ftd[4] = LeafBitMap[i];
86 if (strcmp(LeafNames[i],
"ftd5") == 0) ee_ftd[5] = LeafBitMap[i];
87 if (strcmp(LeafNames[i],
"ftd6") == 0) ee_ftd[6] = LeafBitMap[i];
88 if (strcmp(LeafNames[i],
"ftd7") == 0) ee_ftd[7] = LeafBitMap[i];
89 if (strcmp(LeafNames[i],
"ftd8") == 0) ee_ftd[8] = LeafBitMap[i];
90 if (strcmp(LeafNames[i],
"ftd9") == 0) ee_ftd[9] = LeafBitMap[i];
91 if (strcmp(LeafNames[i],
"itd0") == 0) ee_itd[0] = LeafBitMap[i];
92 if (strcmp(LeafNames[i],
"itd1") == 0) ee_itd[1] = LeafBitMap[i];
93 if (strcmp(LeafNames[i],
"itd2") == 0) ee_itd[2] = LeafBitMap[i];
94 if (strcmp(LeafNames[i],
"itd3") == 0) ee_itd[3] = LeafBitMap[i];
95 if (strcmp(LeafNames[i],
"itd4") == 0) ee_itd[4] = LeafBitMap[i];
96 if (strcmp(LeafNames[i],
"itd5") == 0) ee_itd[5] = LeafBitMap[i];
97 if (strcmp(LeafNames[i],
"itd6") == 0) ee_itd[6] = LeafBitMap[i];
98 if (strcmp(LeafNames[i],
"itd7") == 0) ee_itd[7] = LeafBitMap[i];
99 if (strcmp(LeafNames[i],
"itd8") == 0) ee_itd[8] = LeafBitMap[i];
100 if (strcmp(LeafNames[i],
"itd9") == 0) ee_itd[9] = LeafBitMap[i];
104 if (
_debugLevel > 9) printf(
"TRGGDLSummaryModule::initialize() end\n");
110 if (
_debugLevel > 9) printf(
"TRGGDLSummaryModule::event() start\n");
113 n_leafs = m_unpacker->getnLeafs();
114 int n_leafsExtra = 0;
115 n_leafsExtra = m_unpacker->getnLeafsExtra();
116 int n_clocks = m_unpacker->getnClks();
117 int nconf = m_unpacker->getconf();
118 int nword_input = m_unpacker->get_nword_input();
119 int nword_output = m_unpacker->get_nword_output();
122 printf(
"trggdlSummaryModule:n_leafs(%d), n_leafsExtra(%d), n_clocks(%d), nconf(%d), nword_input(%d), nword_output(%d)\n",
123 n_leafs, n_leafsExtra, n_clocks, nconf, nword_input, nword_output);
130 for (
int i = 0; i < 320; i++) {
131 if (strcmp(entAry[0]->m_unpackername[i],
"clk") == 0) clk_map = i;
134 printf(
"trggdlSummaryModule:clk_map(%d)\n", clk_map);
136 std::vector<std::vector<int> > _data(n_leafs + n_leafsExtra);
137 for (
int leaf = 0; leaf < n_leafs + n_leafsExtra; leaf++) {
138 std::vector<int> _v(n_clocks);
143 for (
int ii = 0; ii < entAry.
getEntries(); ii++) {
145 printf(
"trggdlSummaryModule:a:ii(%d)\n", ii);
146 std::vector<int*> Bits(n_leafs + n_leafsExtra);
148 for (
int i = 0; i < 320; i++) {
149 if (LeafBitMap[i] != -1) {
150 Bits[LeafBitMap[i]] = &(entAry[ii]->m_unpacker[i]);
152 printf(
"trggdlSummaryModule:ab:i(%d), LeafBitMap[i](%d), *Bits[LeafBitMap[i]](%d)\n",
153 i, LeafBitMap[i], *Bits[LeafBitMap[i]]);
156 printf(
"trggdlSummaryModule:ab:i(%d), LeafBitMap[i](%d)\n",
160 for (
int leaf = 0; leaf < n_leafs + n_leafsExtra; leaf++) {
162 printf(
"trggdlSummaryModule:ad:leaf(%d),ii(%d),clk_map(%d),*Bits[leaf](%d), entAry[ii]->m_unpacker[clk_map](%d)\n",
163 leaf, ii, clk_map, *Bits[leaf], entAry[ii]->m_unpacker[clk_map]);
164 _data[leaf][entAry[ii]->m_unpacker[clk_map]] = *Bits[leaf];
172 for (
int j = 0; j < (int)nword_input; j++) {
175 for (
int clk = 0; clk < n_clocks; clk++) {
177 ored |= _data[ee_itd[j]][clk];
185 for (
int clk = 0; clk < n_clocks; clk++) {
186 ored |= _data[ee_ftd[0]][clk];
191 for (
int clk = 0; clk < n_clocks; clk++) {
192 ored |= (_data[ee_ftd[2]][clk] << 16) + _data[ee_ftd[1]][clk];
197 for (
int clk = 0; clk < n_clocks; clk++) {
198 ored |= _data[ee_psn[0]][clk];
203 for (
int clk = 0; clk < n_clocks; clk++) {
204 ored |= (_data[ee_psn[2]][clk] << 16) + _data[ee_psn[1]][clk];
208 for (
int j = 0; j < (int)nword_output; j++) {
210 for (
int clk = 0; clk < n_clocks; clk++) {
211 ored |= _data[ee_ftd[j]][clk];
216 for (
int j = 0; j < (int)nword_output; j++) {
218 for (
int clk = 0; clk < n_clocks; clk++) {
219 ored |= _data[ee_psn[j]][clk];
226 GDL::EGDLTimingType gtt = (GDL::EGDLTimingType)_data[_e_timtype][0];
229 for (
int i = 0; i < 320; i++) {
232 GDLResult->setPreScale(bit1, bit2, m_prescales->getprescales(i));
236 if (gtt == GDL::e_tt_cdc) {
238 }
else if (gtt == GDL::e_tt_ecl) {
240 }
else if (gtt == GDL::e_tt_top) {
242 }
else if (gtt == GDL::e_tt_dphy) {
244 }
else if (gtt == GDL::e_tt_rand) {
246 }
else if (gtt == GDL::e_tt_psnm) {
253 unsigned _exp = bevt->getExperiment();
254 unsigned _run = bevt->getRun();
255 unsigned exprun = _exp * 1000000 + _run;
256 if (exprun < 13000500) {
257 GDLResult->setTimQuality(TRGSummary::TTYQ_CORS);
259 int rvcout = _data[_e_rvcout][0];
260 int q = (rvcout >> 1) & 3;
264 timQuality = TRGSummary::TTYQ_CORS;
267 timQuality = TRGSummary::TTYQ_FINE;
270 timQuality = TRGSummary::TTYQ_SFIN;
273 timQuality = TRGSummary::TTYQ_NONE;
279 if (exprun > 16000271) {
281 int i_poissonin =
GDLResult->getInputBitNumber(std::string(
"poissonin"));
284 int i_veto =
GDLResult->getInputBitNumber(std::string(
"veto"));
287 for (
int clk = 5; clk < n_clocks - 5; clk++) {
288 if ((1 << k_poissonin) & _data[ee_itd[j_poissonin]][clk]) {
290 if ((1 << k_veto) & _data[ee_itd[j_veto]][clk]) {
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
Type-safe access to single objects in the data store.
int _debugLevel
Debug Level.
virtual void initialize() override
initialize
virtual void event() override
Event.
TRGGDLSummaryModule()
Costructor.
StoreObjPtr< TRGSummary > GDLResult
output for TRGSummary
static const unsigned int c_trgWordSize
size of a l1 trigger word
ETimingType
types of trigger timing source defined in b2tt firmware
@ TTYP_DPHY
delayed physics events for background
@ TTYP_SELF
events triggered by self trigger
@ TTYP_POIS
poisson random trigger
@ TTYP_NONE
reserved (not defined yet)
@ TTYP_TOP
events triggered by TOP timing
@ TTYP_CDC
events triggered by CDC timing
@ TTYP_ECL
events triggered by ECL timing
@ TTYP_RAND
random trigger events
ETimingQuality
trigger timing type quality
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.