From 80eb7cb56bcff85ca278e7dbfcb877615dbcdfeb Mon Sep 17 00:00:00 2001 From: splitPoleDAQ Date: Sat, 20 Jan 2024 13:35:19 -0500 Subject: [PATCH] bugs fix for EventBuilder. use 600 data size due to max event /agg is 511 --- Aux/EventBuilder.cpp | 34 ++++++++++++++++++++++++++++++---- Aux/EventBuilderNoTrace.cpp | 14 ++++++++++---- ClassData.h | 2 ++ DigiSettingsPanel.cpp | 6 +++++- 4 files changed, 47 insertions(+), 9 deletions(-) diff --git a/Aux/EventBuilder.cpp b/Aux/EventBuilder.cpp index 0749507..604dc74 100644 --- a/Aux/EventBuilder.cpp +++ b/Aux/EventBuilder.cpp @@ -63,11 +63,14 @@ int main(int argc, char **argv) { printf("\n"); printf("=========================== Working flow\n"); printf(" 1) Break down the fsu files into dual channel, save in tempFolder as *.fsu.X\n"); + printf(" 1a) if the *.fsu file has trace, *.fsu.ts will also has trace.\n"); printf(" 2) Load the *.fsu.X files and do the event building\n"); printf("\n\n"); return 1; } + uInt runStartTime = get_time_us(); + /// File format must be YYY...Y_runXXX_AAA_BBB_TT_CCC.fsu /// YYY...Y = prefix /// XXX = runID, 3 digits @@ -126,8 +129,16 @@ int main(int argc, char **argv) { // file name format is expName_runID_SN_DPP_tick2ns_order.fsu for( int i = 0; i < nFile; i++){ printf("Processing %s (%d/%d) ..... \n", inFileName[i].Data(), i+1, nFile); - reader[i] = new FSUReader(inFileName[i].Data(), 1, false); - if( !reader[i]->isOpen() ) continue; + reader[i] = new FSUReader(inFileName[i].Data(), 600, false); + + if( !reader[i]->isOpen() ){ + printf("------- cannot open file.\n"); + continue; + } + if( reader[i]->GetFileByteSize() == 0 ){ + printf("------- file size is ZERO.\n"); + continue; + } reader[i]->ScanNumBlock(false, 2); @@ -183,6 +194,8 @@ int main(int argc, char **argv) { } + nFile = (int) fileInfo.size(); + std::sort(fileInfo.begin(), fileInfo.end(), [](const FileInfo& a, const FileInfo& b) { return a.ID < b.ID; }); @@ -281,6 +294,9 @@ int main(int argc, char **argv) { ullong t0 = -1; uShort gp0 = -1; + ullong tStart = 0; + ullong tEnd = 0; + bool hasEvent = false; for( int i = 0; i < nGroup; i++){ @@ -317,6 +333,9 @@ int main(int argc, char **argv) { if( tsReader[gpID]->GetHit()->timestamp - t0 <= timeWindow ) { + if( evID == 0) tStart = tsReader[gpID]->GetHit()->timestamp; + if( hitProcessed >= totHitCount ) tEnd = tsReader[gpID]->GetHit()->timestamp; + sn[multi] = tsReader[gpID]->GetHit()->sn; ch[multi] = tsReader[gpID]->GetHit()->ch; e[multi] = tsReader[gpID]->GetHit()->energy; @@ -367,7 +386,6 @@ int main(int argc, char **argv) { printf("hit Porcessed %u/%u....%.2f%%\n\033[A\r", hitProcessed, totHitCount, hitProcessed*100./totHitCount); - ///===================== find the next first timestamp t0 = -1; gp0 = -1; @@ -420,8 +438,16 @@ int main(int argc, char **argv) { tree->Write(); + uInt runEndTime = get_time_us(); + double runTime = (runEndTime - runStartTime) * 1e-6; + printf("========================= finished.\n"); - printf("total events built = %llu(%llu)\n", evID, tree->GetEntriesFast()); + printf(" event building time = %.2f sec = %.2f min\n", runTime, runTime/60.); + printf(" total events built = %llu by event builder (%llu in tree)\n", evID, tree->GetEntriesFast()); + double tDuration_sec = (tEnd - tStart) * 1e-9; + printf(" first timestamp = %20llu ns\n", tStart); + printf(" last timestamp = %20llu ns\n", tEnd); + printf(" total data duration = %.2f sec = %.2f min\n", tDuration_sec, tDuration_sec/60.); printf("=======> saved to %s \n", outFileName.Data()); outRootFile->Close(); diff --git a/Aux/EventBuilderNoTrace.cpp b/Aux/EventBuilderNoTrace.cpp index 6c07679..b655130 100644 --- a/Aux/EventBuilderNoTrace.cpp +++ b/Aux/EventBuilderNoTrace.cpp @@ -54,7 +54,12 @@ int main(int argc, char **argv) { printf("%s [timeWindow] [verbose] [inFile1] [inFile2] .... \n", argv[0]); printf(" timeWindow : in ns \n"); printf(" verbose : > 0 for debug \n"); - printf(" Output file name is contructed from inFile1 \n"); + printf(" Output file name is contructed from inFile1 \n"); + printf("\n"); + printf("=========================== Working flow\n"); + printf(" 1) Load all data into memories as vector and sort\n"); + printf(" 2) Build event.\n"); + printf("\n\n"); return 1; } @@ -104,9 +109,10 @@ int main(int argc, char **argv) { printf("Processing %s (%d/%d) ..... \n\033[A\r", inFileName[i].Data(), i+1, nFile); - reader[i] = new FSUReader(inFileName[i].Data(), 50, 0); // the 1000 is expecting each agg, there are maximum 1000 hit/ch. + reader[i] = new FSUReader(inFileName[i].Data(), 600, 0); // the 600 is expecting each agg, there are maximum 1000 hit/ch. reader[i]->ScanNumBlock(1, 1); - // reader[i]->FillHitList(); + + reader[i]->GetData()->ClearDataPointer(); FileInfo tempInfo; tempInfo.fileName = inFileName[i]; @@ -293,7 +299,7 @@ int main(int argc, char **argv) { if( evID == 0) tStart = event.front().timestamp; if( multi > 0 ) { - tEnd = event.back().timestamp; + if( hitProcessed >= totHitCount ) tEnd = event.back().timestamp; for( size_t j = 0; j < multi ; j++){ sn[j] = event[j].sn; diff --git a/ClassData.h b/ClassData.h index 72c6628..cdb3683 100644 --- a/ClassData.h +++ b/ClassData.h @@ -206,6 +206,8 @@ inline void Data::AllocateDataSize(uShort dataSize){ inline void Data::ClearDataPointer(){ + if( dataSize == 0) return; + for(int ch = 0; ch < numInputCh; ch++){ delete [] Timestamp[ch] ; delete [] fineTime[ch]; diff --git a/DigiSettingsPanel.cpp b/DigiSettingsPanel.cpp index b167084..f667bec 100644 --- a/DigiSettingsPanel.cpp +++ b/DigiSettingsPanel.cpp @@ -210,7 +210,11 @@ DigiSettingsPanel::DigiSettingsPanel(Digitizer ** digi, unsigned int nDigi, QStr bhAutoSetEventPulling = new QPushButton("Autoset Reading Conf.", this); buttonLayout->addWidget(bhAutoSetEventPulling, rowID, 1); - connect(bhAutoSetEventPulling, &QPushButton::clicked, this, [=](){ digi[ID]->AutoSetDPPEventAggregation(); UpdateBoardAndChannelsStatus();}); + connect(bhAutoSetEventPulling, &QPushButton::clicked, this, [=](){ + SendLogMsg("Digi-" +QString::number(digi[ID]->GetSerialNumber()) + " : AutoSetDPPEventAggregation()"); + digi[ID]->AutoSetDPPEventAggregation(); + UpdateBoardAndChannelsStatus(); + }); // bnSendSoftwareClockSyncSignal = new QPushButton("Send SW Clock-Sync Signal", this); // buttonLayout->addWidget(bnSendSoftwareClockSyncSignal, rowID, 1);