9#include <rawdata/modules/PrintDataTemplate.h>
11#include <rawdata/dataobjects/RawPXD.h>
34 B2INFO(
"PrintDataTemplate: Constructor done.");
42PrintDataTemplateModule::~PrintDataTemplateModule()
48 B2INFO(
"PrintDataTemplate: initialize() started.");
55 B2INFO(
"PrintDataTemplate: initialize() done.");
69 for (
int j = 0; j < nwords; j++) {
70 printf(
" %.8x", buf[ j ]);
71 if ((j + 1) % 8 == 0) {
88 printf(
"*******FTSW data**********: nwords %d\n", nwords);
97 rawftsw.
SetBuffer(buf, nwords, delete_flag, num_event, num_nodes);
106 printf(
"HdrNwords %d nodeID %.8x runsub %.8x run %.4x sub %.4x exp %.4x eve %.8x trl %.8x\n",
117 printf(
"ctimetrg %.8x utime %.8x ctime %.8x trg %d TTD(sec %.8x usec %.8x) PC(sec %.8x usec %.8x)\n",
122 (
unsigned int)(tv.tv_sec),
123 (
unsigned int)(tv.tv_usec),
124 (
unsigned int)(tv_pc.tv_sec),
125 (
unsigned int)(tv_pc.tv_usec));
131 printf(
"IsHER %d TimeLastInj %u TimePrevTrg %u BunchNum %u FrameCnt %u \n",
155 int runno_subrunno = buf[ 3 ] & 0x3fffff;
156 int runno = (buf[ 3 ] >> 8) & 0x3fff;
157 int subrunno = buf[ 3 ] & 0xff;
158 int expno = (buf[ 3 ] >> 22) & 0x3ff;
159 unsigned int eveno = (
unsigned int)buf[ 4 ];
161 unsigned int ctime_trgtype = (
unsigned int)buf[ 8 ];
162 unsigned int utime = (
unsigned int)buf[ 9 ];
163 unsigned int ctime = (
unsigned int)(buf[ 8 ] >> 4);
164 int trgtype = buf[ 8 ] & 0xf;
165 int tv_sec = (
unsigned int)buf[ 9 ];
166 int tv_usec = (int)(ctime / 127.216);
168 unsigned int frame_cnt = buf[ 11 ];
169 unsigned int time_prevtrg = buf[ 12 ];
171 int is_her = buf[ 13 ] >> 31;
172 unsigned int time_lastinj = buf[ 13 ] & 0x7fffffff;
173 unsigned int bunch_num = buf[ 14 ] & 0x7ff;
193 B2FATAL(
"Magic " << runno_subrunno <<
" != " << rawftsw->
GetRunNoSubRunNo(i));
196 if (runno != rawftsw->
GetRunNo(i)) {
197 B2FATAL(
"RunNo " << runno <<
" != " << rawftsw->
GetRunNo(i));
201 B2FATAL(
"SubRunNo " << subrunno <<
" != " << rawftsw->
GetSubRunNo(i));
204 if (expno != rawftsw->
GetExpNo(i)) {
205 B2FATAL(
"ExpNo" << expno <<
" != " << rawftsw->
GetExpNo(i));
208 if (eveno != rawftsw->
GetEveNo(i)) {
209 B2FATAL(
"EveNo " << eveno <<
" != " << rawftsw->
GetEveNo(i));
213 B2FATAL(
"ctime_trg " << ctime_trgtype <<
" != " << rawftsw->
GetTTCtimeTRGType(i));
217 B2FATAL(
"utime " << utime <<
" != " << rawftsw->
GetTTUtime(i));
220 if (ctime != (
unsigned int)rawftsw->
GetTTCtime(i)) {
221 B2FATAL(
"ctime " << ctime <<
" != " << rawftsw->
GetTTCtime(i));
225 B2FATAL(
"trgtype " << trgtype <<
" != " << rawftsw->
GetTRGType(i));
228 if (tv_sec != (
int)(tv.tv_sec)) {
229 B2FATAL(
"tv_sec " << tv_sec <<
" != " << (
int)(tv.tv_sec));
232 if (tv_usec != (
int)(tv.tv_usec)) {
233 B2FATAL(
"tv_usec " << tv_usec <<
" != " << (
int)(tv.tv_usec));
237 B2FATAL(
"frame_cnt " << frame_cnt <<
" != " << rawftsw->
GetFrameCount(i));
244 if (is_her != rawftsw->
GetIsHER(i)) {
245 B2FATAL(
"is_her " << is_her <<
" != " << rawftsw->
GetIsHER(i));
253 B2FATAL(
"bunch_num " << bunch_num <<
" != " << rawftsw->
GetBunchNumber(i));
262 printf(
": Event %8u node 0x%.8x block %d by: sum det %d by : A %d by B %d by C %d by D %d by\n",
272 printf(
"EventMetaData : exp %d run %d subrun %d eve %.8d\n",
m_eventMetaDataPtr->getExperiment(),
276 printf(
"!!!!!!!!! ERROR event !!!!!!!!!! : eve %u errflag %.8x\n", raw_copper->
GetEveNo(i),
m_eventMetaDataPtr->getErrorFlag());
284 for (
int j = 0; j < max_num_ch ; j++) {
286 printf(
"===== Detector Buffer(ch %d) 0x%x words (finesse 0x%x) \n", j
297 printf(
": block size %d bytes : bebafeca = %04x :\n",
298 (
int)raw_pxd->
size(), raw_pxd->
data()[0]);
299 printf(
"******* Raw PXD data block (including Detector Buffer) **********\n");
302 int* temp_buf = raw_pxd->
data();
303 vector <int> nframesv;
304 int nframes = ((temp_buf[ 1 ] >> 24) & 0xff) | (((temp_buf[ 1 ] >> 16) & 0xff) << 8) |
305 (((temp_buf[ 1 ] >> 8) & 0xff) << 16) | (((temp_buf[ 1 ] >> 0) & 0xff) << 24);
307 for (
int i = 0; i < nframes; i++) {
309 ((temp_buf[ i + 2 ] >> 24) & 0xff) | (((temp_buf[ i + 2 ] >> 16) & 0xff) << 8) |
310 (((temp_buf[ i + 2 ] >> 8) & 0xff) << 16) | (((temp_buf[ i + 2 ] >> 0) & 0xff) << 24);
311 nframesv.push_back(temp_nframes);
315 unsigned int onsen_trg = temp_buf[ nframes + 2 ];
316 onsen_trg = ((onsen_trg >> 24) & 0xff) | (((onsen_trg >> 16) & 0xff) << 8) |
317 (((onsen_trg >> 8) & 0xff) << 16) | (((onsen_trg >> 0) & 0xff) << 24);
318 unsigned int hlttrg = ((temp_buf[ nframes + 4 ] >> 24) & 0xff) | (((temp_buf[ nframes + 4 ] >> 16) & 0xff) << 8) |
319 (((temp_buf[ nframes + 4 ] >> 8) & 0xff) << 16) | (((temp_buf[ nframes + 4 ] >> 0) & 0xff) << 24);
325 int pos = nframesv[ 0 ] / 4 + nframes + 2 ;
327 for (
int i = 1; i < (int)(nframesv.size()); i++) {
328 if ((nframesv[ i ] % 4) != 0)
break;
329 int dhh_trg1 = (temp_buf[ pos ] >> 24) & 0xff;
330 int dhh_trg2 = (temp_buf[ pos ] >> 16) & 0xff;
331 int dhh_trg3 = (temp_buf[ pos + 1 ] >> 8) & 0xff;
332 int dhh_trg4 = (temp_buf[ pos + 1 ] >> 0) & 0xff;
333 unsigned int dhh_trg = dhh_trg1 | (dhh_trg2 << 8) | (dhh_trg3 << 16) | (dhh_trg4 << 24);
336 if (((temp_buf[ pos ] >> 4) & 0x7) == 5) {
337 ctime_type = ((temp_buf[ pos + 2 ] & 0xff) << 24) |
338 (((temp_buf[ pos + 2 ] >> 8) & 0xff) << 16) |
339 (((temp_buf[ pos + 1 ] >> 16) & 0xff) << 8) |
340 ((temp_buf[ pos + 1 ] >> 24) & 0xff);
343 if (((temp_buf[ pos ] >> 4) & 0x7) == 1) {
344 dhe_time = ((temp_buf[ pos + 2 ] & 0xff) << 24) |
345 (((temp_buf[ pos + 2 ] >> 8) & 0xff) << 16) |
346 (((temp_buf[ pos + 1 ] >> 16) & 0xff) << 8) |
347 ((temp_buf[ pos + 1 ] >> 24) & 0xff);
352 printf(
"Event tag(16bits) in PXD data : frame %.2d hlt %.4x onsen %.4x dhh %.4x\n", i + 1, hlttrg & 0xffff, onsen_trg & 0xffff,
354 if (((dhh_trg & 0xffff) != (hlttrg & 0xffff)) || ((dhh_trg & 0xffff) != (onsen_trg & 0xffff))) {
355 printf(
"### ERROR !! Event mixing occured. : frame %d hlt %.4x onsen %.4x dhh %.4x\n", i + 1, hlttrg & 0xffff, onsen_trg & 0xffff,
358 pos += nframesv[ i ] / 4;
361 printf(
"PXD FTSW %d TRG %u DHE %d\n", ctime_type, hlttrg, dhe_time);
370 B2INFO(
"PrintDataTemplate: event() started.");
377 for (
int i = 0; i < raw_datablkarray.
getEntries(); i++) {
378 for (
int j = 0; j < raw_datablkarray[ i ]->GetNumEntries(); j++) {
379 int* temp_buf = raw_datablkarray[ i ]->GetBuffer(j);
380 int nwords = raw_datablkarray[ i ]->GetBlockNwords(j);
384 if (raw_datablkarray[ i ]->CheckFTSWID(j)) {
386 printf(
"\n===== DataBlock( RawDataBlock(FTSW) ) : Block # %d ", i);
388 temp_raw_ftsw.
SetBuffer(temp_buf, nwords, delete_flag, num_nodes, num_events);
390 }
else if (raw_datablkarray[ i ]->CheckTLUID(j)) {
395 printf(
"\n===== DataBlock( RawDataBlock(COPPER) ) : Block # %d ", i);
397 temp_raw_copper.
SetBuffer(temp_buf, nwords, delete_flag, num_nodes, num_events);
408 for (
int i = 0; i < raw_tluarray.
getEntries(); i++) {
409 for (
int j = 0; j < raw_tluarray[ i ]->GetNumEntries(); j++) {
410 printf(
"\n===== DataBlock(RawTLU) : Block # %d ", i);
419 for (
int i = 0; i < raw_ftswarray.
getEntries(); i++) {
420 for (
int j = 0; j < raw_ftswarray[ i ]->GetNumEntries(); j++) {
421 printf(
"\n===== DataBlock(RawFTSW): Block # %d ", i);
423 if (raw_ftswarray[ i ]->m_version == 2) {
434 for (
int i = 0; i < rawcprarray.
getEntries(); i++) {
435 for (
int j = 0; j < rawcprarray[ i ]->GetNumEntries(); j++) {
436 printf(
"\n===== DataBlock(RawCOPPER): Block # %d ", i);
445 for (
int i = 0; i < raw_svdarray.
getEntries(); i++) {
446 for (
int j = 0; j < raw_svdarray[ i ]->GetNumEntries(); j++) {
447 printf(
"\n===== DataBlock(RawSVD) : Block # %d ", i);
457 for (
int i = 0; i < raw_cdcarray.
getEntries(); i++) {
458 for (
int j = 0; j < raw_cdcarray[ i ]->GetNumEntries(); j++) {
459 printf(
"\n===== DataBlock(RawCDC) : Block # %d ", i);
468 for (
int i = 0; i < raw_pxdarray.
getEntries(); i++) {
469 printf(
"\n===== DataBlock(RawPXD) : Block # %d ", i);
474 for (
int i = 0; i < raw_bpidarray.
getEntries(); i++) {
475 for (
int j = 0; j < raw_bpidarray[ i ]->GetNumEntries(); j++) {
476 printf(
"\n===== DataBlock(RawTOP) : Block # %d ", i);
482 for (
int i = 0; i < raw_epidarray.
getEntries(); i++) {
483 for (
int j = 0; j < raw_epidarray[ i ]->GetNumEntries(); j++) {
484 printf(
"\n===== DataBlock(RawARICH) : Block # %d ", i);
490 for (
int i = 0; i < raw_klmarray.
getEntries(); i++) {
491 for (
int j = 0; j < raw_klmarray[ i ]->GetNumEntries(); j++) {
492 printf(
"\n===== DataBlock(RawKLM) : Block # %d ", i);
498 for (
int i = 0; i < raw_eclarray.
getEntries(); i++) {
499 for (
int j = 0; j < raw_eclarray[ i ]->GetNumEntries(); j++) {
500 printf(
"\n===== DataBlock(RawECL) : Block # %d ", i);
507 for (
int i = 0; i < raw_trgarray.
getEntries(); i++) {
508 for (
int j = 0; j < raw_trgarray[ i ]->GetNumEntries(); j++) {
509 printf(
"\n===== DataBlock(RawTRg) : Block # %d ", i);
void setDescription(const std::string &description)
Sets the description of the module.
virtual void checkFTSWver2(RawFTSW *raw_array, int i)
check the contents of a RawFTSW event ver.2
virtual void initialize() override
Module functions to be called from main process.
virtual void printFTSWEvent(RawDataBlock *raw_array, int i)
print the contents of a RawFTSW event
virtual void printBuffer(int *buf, int nwords)
print a buffer
virtual void event() override
Module functions to be called from event process.
int n_basf2evt
No. of sent events.
PrintDataTemplateModule()
Constructor / Destructor.
int m_compressionLevel
Compression parameter.
virtual void printCOPPEREvent(RawCOPPER *raw_array, int i)
print the contents of a RawCOPPER event
StoreObjPtr< EventMetaData > m_eventMetaDataPtr
Event Meta Data.
virtual void printPXDEvent(RawPXD *raw_pxd)
print a PXD event
The Raw COPPER class This class stores data received by COPPER via belle2linkt Data from all detector...
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
The RawDataBlock class Base class for rawdata handling.
virtual int * GetBuffer(int n)
get nth buffer pointer
virtual int GetBlockNwords(int n)
get size of a data block
virtual int * GetWholeBuffer()
get pointer to buffer(m_buffer)
virtual int TotalBufNwords()
Get total length of m_buffer.
unsigned int GetTTCtimeTRGType(int n)
Get a word containing ctime and trigger type info.
int GetIsHER(int n)
HER injection = 1 or LER injection = 0.
int GetExpNo(int n)
Get Exp #.
void GetPCTimeVal(int n, struct timeval *tv)
Get timeval obtained from gettimeval()
unsigned int GetFTSWNodeID(int n)
Get Node # ( should be "TTD " )
unsigned int GetFrameCount(int n)
Get a frame count.
unsigned int GetTimeSinceLastInjection(int n)
Get time since the last injection.
unsigned int GetEveNo(int n)
Get event #.
unsigned int GetTTUtime(int n)
get unixtime of the trigger
int GetRunNoSubRunNo(int n)
get a word cotaining run # and subrun #
int GetSubRunNo(int n)
Get subrun #.
int GetNwordsHeader(int n)
Get # of words of header.
unsigned int GetMagicTrailer(int n)
Get magic number for data corruption check.
unsigned int GetTimeSincePrevTrigger(int n)
Get time since the previous trigger.
void GetTTTimeVal(int n, struct timeval *tv)
Get timeval from ctime and utime.
int GetTTCtime(int n)
Get ctime of the trigger.
unsigned int GetBunchNumber(int n)
Get a bunch number.
void SetBuffer(int *bufin, int nwords, int delete_flag, int num_events, int num_nodes) OVERRIDE_CPP17
set buffer ( delete_flag : m_buffer is freeed( = 0 )/ not freeed( = 1 ) in Destructer )
int GetTRGType(int n)
Get trgtype.
int GetRunNo(int n)
Get run #.
virtual int * data(void)
get pointer to data
virtual int size() const
get size of buffer in 32 Bit words
Accessor to arrays stored in the data store.
int getEntries() const
Get the number of objects in the array.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
unsigned int GetEveNo(int n)
get subrun #(8bit)
int GetDetectorNwords(int n, int finesse_num)
get Detector buffer length
int * GetDetectorBuffer(int n, int finesse_num)
get Detector buffer
int GetFINESSENwords(int n, int finesse)
get data size of FINESSE buffer
unsigned int GetNodeID(int n)
get node-ID from data
int GetMaxNumOfCh(int n)
Get the max number of channels in a readout board.
Abstract base class for different kinds of events.