rebuild the eventbuilder using wonderful method
This commit is contained in:
parent
663d99a5f8
commit
ed7ee00510
|
@ -9,10 +9,18 @@
|
||||||
#include "TTree.h"
|
#include "TTree.h"
|
||||||
#include "TMacro.h"
|
#include "TMacro.h"
|
||||||
|
|
||||||
#include "CustomStruct.h"
|
//#include "CustomStruct.h"
|
||||||
|
|
||||||
#define MAX_MULTI 1000
|
#define MAX_MULTI 1000
|
||||||
|
|
||||||
|
struct FileInfo{
|
||||||
|
|
||||||
|
std::string fileName;
|
||||||
|
int fileID;
|
||||||
|
unsigned long hitCount;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
//^#############################################################
|
//^#############################################################
|
||||||
//^#############################################################
|
//^#############################################################
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -20,30 +28,28 @@ int main(int argc, char **argv) {
|
||||||
printf("=========================================\n");
|
printf("=========================================\n");
|
||||||
printf("=== *.fsu Events Builder ===\n");
|
printf("=== *.fsu Events Builder ===\n");
|
||||||
printf("=========================================\n");
|
printf("=========================================\n");
|
||||||
if (argc <= 6) {
|
if (argc < 6) {
|
||||||
printf("Incorrect number of arguments:\n");
|
printf("Incorrect number of arguments:\n");
|
||||||
printf("%s [timeWindow] [withTrace] [verbose] [tempFolder] [inFile1] [inFile2] .... \n", argv[0]);
|
printf("%s [timeWindow] [withTrace] [verbose] [batchSize] [inFile1] [inFile2] .... \n", argv[0]);
|
||||||
printf(" timeWindow : in ns \n");
|
printf(" timeWindow : in ns \n");
|
||||||
printf(" withTrace : 0 for no trace, 1 for trace \n");
|
printf(" withTrace : 0 for no trace, 1 for trace \n");
|
||||||
printf(" verbose : > 0 for debug \n");
|
printf(" verbose : > 0 for debug \n");
|
||||||
printf(" tempFolder : temperary folder for file breakdown \n");
|
printf(" batchSize : the size of hit in a batch \n");
|
||||||
printf(" Output file name is contructed from inFile1 \n");
|
printf(" Output file name is contructed from inFile1 \n");
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("=========================== Working flow\n");
|
printf(" Example: %s 0 0 0 10000 '\\ls -1 *001*.fsu'\n", argv[0]);
|
||||||
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");
|
printf("\n\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uInt runStartTime = getTime_us();
|
uInt runStartTime = getTime_us();
|
||||||
|
|
||||||
///============= read input
|
///============= read input
|
||||||
unsigned int timeWindow = atoi(argv[1]);
|
long timeWindow = atoi(argv[1]);
|
||||||
bool traceOn = atoi(argv[2]);
|
bool traceOn = atoi(argv[2]);
|
||||||
unsigned int debug = atoi(argv[3]);
|
unsigned int debug = atoi(argv[3]);
|
||||||
std::string tempFolder = argv[4];
|
unsigned int batchSize = atoi(argv[4]);
|
||||||
int nFile = argc - 5;
|
int nFile = argc - 5;
|
||||||
TString inFileName[nFile];
|
TString inFileName[nFile];
|
||||||
for( int i = 0 ; i < nFile ; i++){ inFileName[i] = argv[i+5];}
|
for( int i = 0 ; i < nFile ; i++){ inFileName[i] = argv[i+5];}
|
||||||
|
@ -58,156 +64,61 @@ int main(int argc, char **argv) {
|
||||||
outFileName += "_" + std::to_string(timeWindow);
|
outFileName += "_" + std::to_string(timeWindow);
|
||||||
outFileName += ".root";
|
outFileName += ".root";
|
||||||
printf("-------> Out file name : %s \n", outFileName.Data());
|
printf("-------> Out file name : %s \n", outFileName.Data());
|
||||||
|
printf("========================================= Number of Files : %d \n", nFile);
|
||||||
|
|
||||||
printf(" Number of Files : %d \n", nFile);
|
|
||||||
for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].Data());
|
for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].Data());
|
||||||
printf("=====================================\n");
|
printf("=========================================\n");
|
||||||
printf(" Time Window = %u ns = %.1f us\n", timeWindow, timeWindow/1000.);
|
printf(" Time Window = %ld ns = %.1f us\n", timeWindow, timeWindow/1000.);
|
||||||
//printf(" Buffer size = %.0f event/channel\n", MaxNData * bufferSize);
|
printf(" Include Trace = %s\n", traceOn ? "Yes" : "No");
|
||||||
printf("===================================== Breaking down files\n");
|
printf(" Debug level = %d\n", debug);
|
||||||
|
printf(" Batch size = %d events/file\n", batchSize);
|
||||||
///========================================
|
printf(" Max multiplity = %d hits/event (hard coded)\n", MAX_MULTI);
|
||||||
printf("===================================== Load the files\n");
|
printf("========================================= Grouping files\n");
|
||||||
|
|
||||||
//check if all input files is ts file;
|
std::vector<std::vector<FileInfo>> fileGroupList; // fileName and ID = SN * 1000 + index
|
||||||
bool isTSFiles = false;
|
std::vector<FileInfo> fileList;
|
||||||
int count = 0;
|
|
||||||
for( int i = 0; i < nFile; i++){
|
|
||||||
FILE * temp = fopen(inFileName[i].Data(), "r");
|
|
||||||
uint32_t header;
|
|
||||||
fread(&header, 4, 1, temp);
|
|
||||||
if( (header >> 24) == 0xAA ) count++;
|
|
||||||
}
|
|
||||||
if( count == nFile ) isTSFiles = true;
|
|
||||||
|
|
||||||
std::vector<FileInfo> fileInfo;
|
unsigned long long int totalHitCount = 0;
|
||||||
|
|
||||||
if( !isTSFiles ){
|
FSUReader * readerA = new FSUReader(inFileName[0].Data(), 1, 1);
|
||||||
printf("######### All files are not time-sorted files\n");
|
readerA->ScanNumBlock(0,0);
|
||||||
|
FileInfo fileInfo = {inFileName[0].Data(), readerA->GetSN() * 1000 + readerA->GetFileOrder(), readerA->GetHitCount()};
|
||||||
|
fileList.push_back(fileInfo);
|
||||||
|
totalHitCount += readerA->GetHitCount();
|
||||||
|
|
||||||
///============= sorting file by the serial number & order
|
for( int i = 1; i < nFile; i++){
|
||||||
FSUReader ** reader = new FSUReader*[nFile];
|
FSUReader * readerB = new FSUReader(inFileName[i].Data(), 1, 0);
|
||||||
// file name format is expName_runID_SN_DPP_tick2ns_order.fsu
|
readerB->ScanNumBlock(0,0);
|
||||||
for( int i = 0; i < nFile; i++){
|
totalHitCount += readerB->GetHitCount();
|
||||||
printf("Processing %s (%d/%d) ..... \n", inFileName[i].Data(), i+1, nFile);
|
fileInfo = {inFileName[i].Data(), readerB->GetSN() * 1000 + readerB->GetFileOrder(), readerB->GetHitCount()};
|
||||||
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);
|
|
||||||
|
|
||||||
std::string outFileName = reader[i]->SaveHit2NewFile(tempFolder);
|
if( readerA->GetSN() == readerB->GetSN() ){
|
||||||
|
fileList.push_back(fileInfo);
|
||||||
FileInfo tempInfo;
|
|
||||||
tempInfo.fileName = outFileName;
|
|
||||||
tempInfo.readerID = i;
|
|
||||||
tempInfo.SN = reader[i]->GetSN();
|
|
||||||
tempInfo.hitCount = reader[i]->GetHitCount();
|
|
||||||
tempInfo.fileSize = reader[i]->GetTSFileSize();
|
|
||||||
tempInfo.tick2ns = reader[i]->GetTick2ns();
|
|
||||||
tempInfo.DPPType = reader[i]->GetDPPType();
|
|
||||||
tempInfo.order = reader[i]->GetFileOrder();
|
|
||||||
tempInfo.CalOrder();
|
|
||||||
|
|
||||||
tempInfo.t0 = reader[i]->GetHit(0).timestamp;
|
|
||||||
|
|
||||||
fileInfo.push_back(tempInfo);
|
|
||||||
|
|
||||||
delete reader[i];
|
|
||||||
}
|
|
||||||
delete [] reader;
|
|
||||||
|
|
||||||
}else{
|
|
||||||
|
|
||||||
printf("######### All files are time sorted files\n");
|
|
||||||
|
|
||||||
FSUTSReader ** reader = new FSUTSReader*[nFile];
|
|
||||||
// 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 FSUTSReader(inFileName[i].Data(), false);
|
|
||||||
|
|
||||||
if( !reader[i]->isOpen() ){
|
|
||||||
printf("------- cannot open file.\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
//reader[i]->ScanFile(1);
|
|
||||||
|
|
||||||
if( reader[i]->GetNumHitFromHeader() == 0 ){
|
|
||||||
printf("------- file has no data.\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
FileInfo tempInfo;
|
|
||||||
tempInfo.fileName = inFileName[i].Data();
|
|
||||||
tempInfo.readerID = i;
|
|
||||||
tempInfo.SN = reader[i]->GetSN();
|
|
||||||
tempInfo.hitCount = reader[i]->GetNumHitFromHeader();
|
|
||||||
tempInfo.fileSize = reader[i]->GetFileByteSize();
|
|
||||||
tempInfo.order = reader[i]->GetFileOrder();
|
|
||||||
tempInfo.CalOrder();
|
|
||||||
|
|
||||||
tempInfo.t0 = reader[i]->GetT0();;
|
|
||||||
|
|
||||||
fileInfo.push_back(tempInfo);
|
|
||||||
|
|
||||||
delete reader[i];
|
|
||||||
}
|
|
||||||
delete [] reader;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
nFile = (int) fileInfo.size();
|
|
||||||
|
|
||||||
std::sort(fileInfo.begin(), fileInfo.end(), [](const FileInfo& a, const FileInfo& b) {
|
|
||||||
return a.ID < b.ID;
|
|
||||||
});
|
|
||||||
|
|
||||||
unsigned int totHitCount = 0;
|
|
||||||
|
|
||||||
printf("===================================== number of file %d.\n", nFile);
|
|
||||||
for( int i = 0 ; i < nFile; i++){
|
|
||||||
printf("%d |", i);
|
|
||||||
fileInfo[i].Print();
|
|
||||||
totHitCount += fileInfo[i].hitCount;
|
|
||||||
//printf(" %30s | ID %10ld \n", fileInfo[i].fileName.Data(), fileInfo[i].ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("----- total number of hit : %u.\n", totHitCount);
|
|
||||||
|
|
||||||
//*======================================= Sort files into groups
|
|
||||||
std::vector<GroupInfo> group; // group by SN and chMask
|
|
||||||
|
|
||||||
for( int i = 0; i < nFile; i++){
|
|
||||||
if( i == 0 || group.back().sn != fileInfo[i].SN ){
|
|
||||||
group.push_back(GroupInfo());
|
|
||||||
group.back().fileIDList.push_back(i); // an empty struct
|
|
||||||
group.back().currentID = 0;
|
|
||||||
group.back().hitCount = fileInfo[i].hitCount;
|
|
||||||
group.back().sn = fileInfo[i].SN;
|
|
||||||
group.back().finished = false;
|
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
group.back().fileIDList.push_back(i);
|
fileGroupList.push_back(fileList);
|
||||||
|
fileList.clear();
|
||||||
|
fileList.push_back(fileInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete readerA;
|
||||||
|
readerA = readerB;
|
||||||
}
|
}
|
||||||
|
fileGroupList.push_back(fileList);
|
||||||
|
delete readerA;
|
||||||
|
|
||||||
int nGroup = group.size();
|
printf("======================= total Hit Count : %llu\n", totalHitCount);
|
||||||
printf("===================================== number of file Group by digitizer %d.\n", nGroup);
|
|
||||||
for( int i = 0; i < nGroup; i++){
|
for( size_t i = 0; i < fileGroupList.size(); i++){
|
||||||
printf(" Digi-%d, DPPType: %d \n", group[i].sn, fileInfo[group[i].currentID].DPPType);
|
printf("group ----- %ld \n", i);
|
||||||
for( int j = 0; j< (int) group[i].fileIDList.size(); j++){
|
|
||||||
uShort fID = group[i].fileIDList[j];
|
//sort by ID
|
||||||
printf(" %s \n", fileInfo[fID].fileName.c_str());
|
std::sort(fileGroupList[i].begin(), fileGroupList[i].end(), [](const FileInfo & a, const FileInfo & b) {
|
||||||
|
return a.fileID < b.fileID;
|
||||||
|
});
|
||||||
|
|
||||||
|
for( size_t j = 0; j < fileGroupList[i].size(); j++){
|
||||||
|
printf("%3ld | %8d | %9lu| %s \n", j, fileGroupList[i][j].fileID, fileGroupList[i][j].hitCount, fileGroupList[i][j].fileName.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// //*====================================== create tree
|
// //*====================================== create tree
|
||||||
|
@ -231,7 +142,7 @@ int main(int argc, char **argv) {
|
||||||
tree->Branch("e", e, "e[multi]/s");
|
tree->Branch("e", e, "e[multi]/s");
|
||||||
tree->Branch("e2", e2, "e2[multi]/s");
|
tree->Branch("e2", e2, "e2[multi]/s");
|
||||||
tree->Branch("e_t", e_t, "e_timestamp[multi]/l");
|
tree->Branch("e_t", e_t, "e_timestamp[multi]/l");
|
||||||
tree->Branch("e_f", e_f, "e_timestamp[multi]/s");
|
tree->Branch("e_f", e_f, "e_fineTime[multi]/s");
|
||||||
tree->Branch("traceLength", traceLength, "traceLength[multi]/s");
|
tree->Branch("traceLength", traceLength, "traceLength[multi]/s");
|
||||||
|
|
||||||
TClonesArray * arrayTrace = nullptr;
|
TClonesArray * arrayTrace = nullptr;
|
||||||
|
@ -243,192 +154,197 @@ int main(int argc, char **argv) {
|
||||||
arrayTrace->BypassStreamer();
|
arrayTrace->BypassStreamer();
|
||||||
}
|
}
|
||||||
|
|
||||||
//*======================================= Open time-sorted files
|
//*======================================= Open files
|
||||||
printf("===================================== Open time-sorted files.\n");
|
printf("========================================= Open files & Build Events.\n");
|
||||||
|
|
||||||
FSUTSReader ** tsReader = new FSUTSReader * [nGroup];
|
const short nGroup = fileGroupList.size();
|
||||||
for( int i = 0; i < nGroup; i++){
|
std::vector<Hit> hitList[nGroup];
|
||||||
std::string fileName = fileInfo[group[i].fileIDList[0]].fileName;
|
|
||||||
tsReader[i] = new FSUTSReader(fileName);
|
FSUReader ** reader = new FSUReader * [nGroup];
|
||||||
// tsReader[i]->ScanFile(1);
|
ulong ID[nGroup];
|
||||||
group[i].usedHitCount = 0;
|
for( short i = 0; i < nGroup; i++){
|
||||||
|
std::vector<std::string> fList;
|
||||||
|
for( size_t j = 0; j < fileGroupList[i].size(); j++){
|
||||||
|
fList.push_back( fileGroupList[i][j].fileName );
|
||||||
|
}
|
||||||
|
reader[i] = new FSUReader(fList, 1, debug);
|
||||||
|
hitList[i] = reader[i]->ReadBatch(batchSize, debug );
|
||||||
|
reader[i]->PrintHitListInfo(hitList[i], "hitList-" + std::to_string(reader[i]->GetSN()));
|
||||||
|
ID[i] = 0;
|
||||||
|
if( debug ) {
|
||||||
|
|
||||||
|
for( size_t p = 0; p < 10; p ++ ){
|
||||||
|
if( hitList[i].size() <= p ) break;
|
||||||
|
hitList[i][p].Print();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//*====================================== build events
|
unsigned long long tStart = 0;
|
||||||
printf("================= Building events....\n");
|
unsigned long long tEnd = 0;
|
||||||
|
|
||||||
uInt hitProcessed = 0;
|
|
||||||
|
|
||||||
//find the earliest time
|
//find earliest time group;
|
||||||
ullong t0 = -1;
|
unsigned long long t0 = -1;
|
||||||
uShort gp0 = -1;
|
short g0 = 0 ;
|
||||||
|
for( short i = 0; i < nGroup; i++){
|
||||||
ullong tStart = 0;
|
if( hitList[i].size() == 0 ) continue;
|
||||||
ullong tEnd = 0;
|
if( hitList[i][0].timestamp < t0 ) {
|
||||||
|
t0 = hitList[i][0].timestamp;
|
||||||
bool hasEvent = false;
|
g0 = i;
|
||||||
|
|
||||||
for( int i = 0; i < nGroup; i++){
|
|
||||||
if( fileInfo[group[i].fileIDList[0]].t0 < t0 ) {
|
|
||||||
t0 = fileInfo[group[i].fileIDList[0]].t0;
|
|
||||||
gp0 = i;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
tStart = t0;
|
||||||
|
if( debug ) printf("First timestamp is %llu, group : %u\n", t0, g0);
|
||||||
|
|
||||||
|
int nFileFinished = 0;
|
||||||
|
multi = 0;
|
||||||
|
evID = 0;
|
||||||
|
std::vector<Hit> events;
|
||||||
|
|
||||||
|
unsigned long long hitProcessed = 0;
|
||||||
|
|
||||||
if( debug ) printf("First timestamp is %llu, group : %u\n", t0, gp0);
|
|
||||||
do{
|
do{
|
||||||
|
|
||||||
|
//*============= Build events from hitList[i]
|
||||||
if( debug ) printf("################################ ev build %llu \n", evID);
|
if( debug ) printf("################################ ev build %llu \n", evID);
|
||||||
|
events.clear();
|
||||||
|
|
||||||
///===================== check if the file is finished.
|
for( short i = 0; i < nGroup; i++){
|
||||||
for( int i = 0; i < nGroup; i++){
|
short ig = (i + g0 ) % nGroup;
|
||||||
uShort gpID = (i + gp0) % nGroup;
|
|
||||||
if( group[gpID].finished ) continue;
|
|
||||||
short endCount = 0;
|
|
||||||
do{
|
|
||||||
|
|
||||||
if( group[gpID].usedHitCount > tsReader[gpID]->GetHitID() || tsReader[gpID]->GetFilePos() <= 4){
|
if( hitList[ig].size() == 0 ) continue;
|
||||||
if( tsReader[gpID]->ReadNextHit(traceOn, 0) == 0 ){
|
|
||||||
hitProcessed ++;
|
|
||||||
if( debug ){ printf("............ Get Data | "); tsReader[gpID]->GetHit()->Print();}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if( tsReader[gpID]->GetHit()->timestamp - t0 <= timeWindow ) {
|
//chekc if reached the end of hitList
|
||||||
|
if( ID[ig] >= hitList[ig].size() ) {
|
||||||
|
hitList[ig] = reader[ig]->ReadBatch(batchSize, debug + 1);
|
||||||
|
ID[ig] = 0;
|
||||||
|
if( hitList[ig].size() == 0 ) continue;
|
||||||
|
}
|
||||||
|
|
||||||
if( evID == 0) tStart = tsReader[gpID]->GetHit()->timestamp;
|
if( timeWindow >= 0 ){
|
||||||
if( hitProcessed >= totHitCount ) tEnd = tsReader[gpID]->GetHit()->timestamp;
|
|
||||||
|
do{
|
||||||
|
|
||||||
sn[multi] = tsReader[gpID]->GetHit()->sn;
|
if( (long int)(hitList[ig].at(ID[ig]).timestamp - t0) <= timeWindow ){
|
||||||
ch[multi] = tsReader[gpID]->GetHit()->ch;
|
events.push_back(hitList[ig].at(ID[ig]));
|
||||||
e[multi] = tsReader[gpID]->GetHit()->energy;
|
ID[ig] ++;
|
||||||
e2[multi] = tsReader[gpID]->GetHit()->energy2;
|
}else{
|
||||||
e_t[multi] = tsReader[gpID]->GetHit()->timestamp;
|
break;
|
||||||
e_f[multi] = tsReader[gpID]->GetHit()->fineTime;
|
|
||||||
|
|
||||||
traceLength[multi] = tsReader[gpID]->GetHit()->traceLength;
|
|
||||||
if( traceOn ){
|
|
||||||
trace = (TGraph *) arrayTrace->ConstructedAt(multi, "C");
|
|
||||||
trace->Clear();
|
|
||||||
for( int hh = 0; hh < traceLength[multi]; hh++){
|
|
||||||
trace->SetPoint(hh, hh, tsReader[gpID]->GetHit()->trace[hh]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( debug ) printf("(%5d, %2d) %6d %16llu, %u\n", sn[multi], ch[multi], e[multi], e_t[multi], traceLength[multi]);
|
//check if reached the end of hitList
|
||||||
|
if( ID[ig] >= hitList[ig].size() ) {
|
||||||
hasEvent = true;
|
hitList[ig] = reader[ig]->ReadBatch(batchSize, debug);
|
||||||
multi ++;
|
ID[ig] = 0;
|
||||||
|
if( hitList[ig].size() == 0 ) break;
|
||||||
group[gpID].usedHitCount ++;
|
|
||||||
if( tsReader[gpID]->ReadNextHit(traceOn, 0) == 0 ){
|
|
||||||
hitProcessed ++;
|
|
||||||
if( debug ){ printf("..Get Data after fill | "); tsReader[gpID]->GetHit()->Print();}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}while(ID[ig] < hitList[ig].size());
|
||||||
|
|
||||||
if( multi > MAX_MULTI) {
|
}else{
|
||||||
printf(" !!!!!! multi > MAX_MULTI = %d\n", MAX_MULTI);
|
events.push_back(hitList[ig].at(ID[ig]));
|
||||||
}
|
ID[ig] ++;
|
||||||
|
}
|
||||||
|
|
||||||
}else{
|
if( timeWindow < 0) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( timeWindow == 0) break;
|
|
||||||
|
|
||||||
if( tsReader[gpID]->GetHitID() + 1 >= tsReader[gpID]->GetNumHitFromHeader() ) endCount ++;
|
|
||||||
if( endCount == 2 ) break;
|
|
||||||
|
|
||||||
}while(true);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( hasEvent ){
|
if( events.size() > 1 ){
|
||||||
outRootFile->cd();
|
std::sort(events.begin(), events.end(), [](const Hit& a, const Hit& b) {
|
||||||
tree->Fill();
|
return a.timestamp < b.timestamp;
|
||||||
multi = 0;
|
});
|
||||||
evID ++;
|
|
||||||
hasEvent = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( hitProcessed % 10000 == 0 ) printf("hit Porcessed %u/%u hit....%.2f%%\n\033[A\r", hitProcessed, totHitCount, hitProcessed*100./totHitCount);
|
|
||||||
|
|
||||||
|
tEnd = events.back().timestamp;
|
||||||
|
|
||||||
|
hitProcessed += events.size();
|
||||||
|
if( hitProcessed % 10000 == 0 ) printf("hit Porcessed %llu/%llu hit....%.2f%%\n\033[A\r", hitProcessed, totalHitCount, hitProcessed*100./totalHitCount);
|
||||||
|
|
||||||
|
|
||||||
|
multi = events.size() ;
|
||||||
|
if( events.size() >= MAX_MULTI ) {
|
||||||
|
printf("event %lld has size = %d > MAX_MULTI = %d\n", evID, multi, MAX_MULTI);
|
||||||
|
multi = MAX_MULTI;
|
||||||
|
}
|
||||||
|
if( debug ) printf("=================================== filling data | %u \n", multi);
|
||||||
|
for( size_t p = 0; p < multi ; p ++ ) {
|
||||||
|
if( debug ) {printf("%4zu | ", p); events[p].Print();}
|
||||||
|
|
||||||
|
sn[p] = events[p].sn;
|
||||||
|
ch[p] = events[p].ch;
|
||||||
|
e[p] = events[p].energy;
|
||||||
|
e2[p] = events[p].energy2;
|
||||||
|
e_t[p] = events[p].timestamp;
|
||||||
|
e_f[p] = events[p].fineTime;
|
||||||
|
|
||||||
|
traceLength[p] = events[p].traceLength;
|
||||||
|
if( traceOn ){
|
||||||
|
trace = (TGraph *) arrayTrace->ConstructedAt(multi, "C");
|
||||||
|
trace->Clear();
|
||||||
|
for( int hh = 0; hh < traceLength[multi]; hh++){
|
||||||
|
trace->SetPoint(hh, hh, events[p].trace[hh]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
outRootFile->cd();
|
||||||
|
tree->Fill();
|
||||||
|
// tree->Write();
|
||||||
|
multi = 0;
|
||||||
|
evID ++;
|
||||||
|
|
||||||
///===================== find the next first timestamp
|
///===================== find the next first timestamp
|
||||||
t0 = -1;
|
t0 = -1;
|
||||||
gp0 = -1;
|
g0 = -1;
|
||||||
|
|
||||||
for( int i = 0; i < nGroup; i++) {
|
for( int i = 0; i < nGroup; i++) {
|
||||||
if( group[i].finished ) continue;
|
if( hitList[i].size() == 0 ) continue;
|
||||||
if( tsReader[i]->GetHit()->timestamp < t0) {
|
if( hitList[i][ID[i]].timestamp < t0 ) {
|
||||||
t0 = tsReader[i]->GetHit()->timestamp;
|
t0 = hitList[i][ID[i]].timestamp;
|
||||||
gp0 = i;
|
g0 = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( debug ) printf("Next First timestamp is %llu, group : %u\n", t0, gp0);
|
if( debug ) printf("Next First timestamp is %llu, group : %u\n", t0, g0);
|
||||||
|
|
||||||
|
//*=============
|
||||||
///===================== check if the file is finished.
|
nFileFinished = 0;
|
||||||
int gpCount = 0;
|
for( int i = 0 ; i < nGroup; i++) {
|
||||||
for( int gpID = 0; gpID < nGroup; gpID ++) {
|
if( hitList[i].size() == 0 ) {
|
||||||
if( group[gpID].finished ) {
|
nFileFinished ++;
|
||||||
gpCount ++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}else{
|
||||||
|
if( ID[i] >= hitList[i].size( )) {
|
||||||
if( group[gpID].usedHitCount >= tsReader[gpID]->GetNumHitFromHeader() ) {
|
hitList[i] = reader[i]->ReadBatch(batchSize, debug);
|
||||||
|
ID[i] = 0;
|
||||||
group[gpID].currentID ++;
|
if( hitList[i].size() == 0 ) nFileFinished ++;
|
||||||
|
|
||||||
if( group[gpID].currentID >= group[gpID].fileIDList.size() ) {
|
|
||||||
group[gpID].finished = true;
|
|
||||||
printf("-----> no more file for this group, S/N : %d.\n", group[gpID].sn);
|
|
||||||
|
|
||||||
}else{
|
|
||||||
uShort fID = group[gpID].fileIDList[group[gpID].currentID];
|
|
||||||
std::string fileName = fileInfo[fID].fileName;
|
|
||||||
|
|
||||||
delete tsReader[gpID];
|
|
||||||
tsReader[gpID] = new FSUTSReader(fileName);
|
|
||||||
tsReader[gpID]->ScanFile(1);
|
|
||||||
printf("-----> go to the next file, %s \n", fileName.c_str() );
|
|
||||||
|
|
||||||
group[gpID].usedHitCount = 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( group[gpID].finished ) gpCount ++;
|
|
||||||
}
|
}
|
||||||
if( gpCount == (int) group.size() ) break;
|
if( debug > 1 ) printf("========== nFileFinished : %d\n", nFileFinished);
|
||||||
|
|
||||||
}while(true);
|
}while( nFileFinished < nGroup);
|
||||||
|
|
||||||
tree->Write();
|
tree->Write();
|
||||||
|
|
||||||
uInt runEndTime = getTime_us();
|
uInt runEndTime = getTime_us();
|
||||||
double runTime = (runEndTime - runStartTime) * 1e-6;
|
double runTime = (runEndTime - runStartTime) * 1e-6;
|
||||||
|
printf("========================================= finished.\n");
|
||||||
printf("========================= finished.\n");
|
|
||||||
printf(" event building time = %.2f sec = %.2f min\n", runTime, runTime/60.);
|
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());
|
printf(" total events built = %llu by event builder (%llu in tree)\n", evID, tree->GetEntriesFast());
|
||||||
double tDuration_sec = (tEnd - tStart) * 1e-9;
|
double tDuration_sec = (tEnd - tStart) * 1e-9;
|
||||||
printf(" first timestamp = %20llu ns\n", tStart);
|
printf(" first timestamp = %20llu ns\n", tStart);
|
||||||
printf(" last timestamp = %20llu ns\n", tEnd);
|
printf(" last timestamp = %20llu ns\n", tEnd);
|
||||||
printf(" total data duration = %.2f sec = %.2f min\n", tDuration_sec, tDuration_sec/60.);
|
printf(" total data duration = %.2f sec = %.2f min\n", tDuration_sec, tDuration_sec/60.);
|
||||||
printf("=======> saved to %s \n", outFileName.Data());
|
printf("==============> saved to %s \n", outFileName.Data());
|
||||||
|
|
||||||
TMacro info;
|
|
||||||
info.AddLine(Form("tStart= %20llu ns",tStart));
|
|
||||||
info.AddLine(Form(" tEnd= %20llu ns",tEnd));
|
|
||||||
info.Write("info");
|
|
||||||
|
|
||||||
outRootFile->Close();
|
outRootFile->Close();
|
||||||
|
|
||||||
for( int i = 0; i < nGroup; i++){
|
for( int i = 0; i < nGroup; i++) delete reader[i];
|
||||||
delete tsReader[i];
|
delete [] reader;
|
||||||
}
|
|
||||||
delete [] tsReader;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
434
Aux/EventBuilder_clumsy.cpp
Normal file
434
Aux/EventBuilder_clumsy.cpp
Normal file
|
@ -0,0 +1,434 @@
|
||||||
|
#include "fsuReader.h"
|
||||||
|
#include "fsutsReader.h"
|
||||||
|
|
||||||
|
#include "TROOT.h"
|
||||||
|
#include "TSystem.h"
|
||||||
|
#include "TClonesArray.h"
|
||||||
|
#include "TGraph.h"
|
||||||
|
#include "TFile.h"
|
||||||
|
#include "TTree.h"
|
||||||
|
#include "TMacro.h"
|
||||||
|
|
||||||
|
#include "CustomStruct.h"
|
||||||
|
|
||||||
|
#define MAX_MULTI 1000
|
||||||
|
|
||||||
|
//^#############################################################
|
||||||
|
//^#############################################################
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
printf("=========================================\n");
|
||||||
|
printf("=== *.fsu Events Builder ===\n");
|
||||||
|
printf("=========================================\n");
|
||||||
|
if (argc <= 6) {
|
||||||
|
printf("Incorrect number of arguments:\n");
|
||||||
|
printf("%s [timeWindow] [withTrace] [verbose] [tempFolder] [inFile1] [inFile2] .... \n", argv[0]);
|
||||||
|
printf(" timeWindow : in ns \n");
|
||||||
|
printf(" withTrace : 0 for no trace, 1 for trace \n");
|
||||||
|
printf(" verbose : > 0 for debug \n");
|
||||||
|
printf(" tempFolder : temperary folder for file breakdown \n");
|
||||||
|
printf(" Output file name is contructed from inFile1 \n");
|
||||||
|
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 = getTime_us();
|
||||||
|
|
||||||
|
///============= read input
|
||||||
|
unsigned int timeWindow = atoi(argv[1]);
|
||||||
|
bool traceOn = atoi(argv[2]);
|
||||||
|
unsigned int debug = atoi(argv[3]);
|
||||||
|
std::string tempFolder = argv[4];
|
||||||
|
int nFile = argc - 5;
|
||||||
|
TString inFileName[nFile];
|
||||||
|
for( int i = 0 ; i < nFile ; i++){ inFileName[i] = argv[i+5];}
|
||||||
|
|
||||||
|
/// Form outFileName;
|
||||||
|
TString outFileName = inFileName[0];
|
||||||
|
int pos = outFileName.Last('/');
|
||||||
|
pos = outFileName.Index("_", pos+1); // find next "_"
|
||||||
|
pos = outFileName.Index("_", pos+1); // find next "_"
|
||||||
|
if( nFile == 1 ) pos = outFileName.Index("_", pos+1); // find next "_", S/N
|
||||||
|
outFileName.Remove(pos); // remove the rest
|
||||||
|
outFileName += "_" + std::to_string(timeWindow);
|
||||||
|
outFileName += ".root";
|
||||||
|
printf("-------> Out file name : %s \n", outFileName.Data());
|
||||||
|
|
||||||
|
|
||||||
|
printf(" Number of Files : %d \n", nFile);
|
||||||
|
for( int i = 0; i < nFile; i++) printf("%2d | %s \n", i, inFileName[i].Data());
|
||||||
|
printf("=====================================\n");
|
||||||
|
printf(" Time Window = %u ns = %.1f us\n", timeWindow, timeWindow/1000.);
|
||||||
|
//printf(" Buffer size = %.0f event/channel\n", MaxNData * bufferSize);
|
||||||
|
printf("===================================== Breaking down files\n");
|
||||||
|
|
||||||
|
///========================================
|
||||||
|
printf("===================================== Load the files\n");
|
||||||
|
|
||||||
|
//check if all input files is ts file;
|
||||||
|
bool isTSFiles = false;
|
||||||
|
int count = 0;
|
||||||
|
for( int i = 0; i < nFile; i++){
|
||||||
|
FILE * temp = fopen(inFileName[i].Data(), "r");
|
||||||
|
uint32_t header;
|
||||||
|
fread(&header, 4, 1, temp);
|
||||||
|
if( (header >> 24) == 0xAA ) count++;
|
||||||
|
}
|
||||||
|
if( count == nFile ) isTSFiles = true;
|
||||||
|
|
||||||
|
std::vector<FileInfo> fileInfo;
|
||||||
|
|
||||||
|
if( !isTSFiles ){
|
||||||
|
printf("######### All files are not time-sorted files\n");
|
||||||
|
|
||||||
|
///============= sorting file by the serial number & order
|
||||||
|
FSUReader ** reader = new FSUReader*[nFile];
|
||||||
|
// 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(), 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);
|
||||||
|
|
||||||
|
std::string outFileName = reader[i]->SaveHit2NewFile(tempFolder);
|
||||||
|
|
||||||
|
FileInfo tempInfo;
|
||||||
|
tempInfo.fileName = outFileName;
|
||||||
|
tempInfo.readerID = i;
|
||||||
|
tempInfo.SN = reader[i]->GetSN();
|
||||||
|
tempInfo.hitCount = reader[i]->GetHitCount();
|
||||||
|
tempInfo.fileSize = reader[i]->GetTSFileSize();
|
||||||
|
tempInfo.tick2ns = reader[i]->GetTick2ns();
|
||||||
|
tempInfo.DPPType = reader[i]->GetDPPType();
|
||||||
|
tempInfo.order = reader[i]->GetFileOrder();
|
||||||
|
tempInfo.CalOrder();
|
||||||
|
|
||||||
|
tempInfo.t0 = reader[i]->GetHit(0).timestamp;
|
||||||
|
|
||||||
|
fileInfo.push_back(tempInfo);
|
||||||
|
|
||||||
|
delete reader[i];
|
||||||
|
}
|
||||||
|
delete [] reader;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
printf("######### All files are time sorted files\n");
|
||||||
|
|
||||||
|
FSUTSReader ** reader = new FSUTSReader*[nFile];
|
||||||
|
// 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 FSUTSReader(inFileName[i].Data(), false);
|
||||||
|
|
||||||
|
if( !reader[i]->isOpen() ){
|
||||||
|
printf("------- cannot open file.\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//reader[i]->ScanFile(1);
|
||||||
|
|
||||||
|
if( reader[i]->GetNumHitFromHeader() == 0 ){
|
||||||
|
printf("------- file has no data.\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileInfo tempInfo;
|
||||||
|
tempInfo.fileName = inFileName[i].Data();
|
||||||
|
tempInfo.readerID = i;
|
||||||
|
tempInfo.SN = reader[i]->GetSN();
|
||||||
|
tempInfo.hitCount = reader[i]->GetNumHitFromHeader();
|
||||||
|
tempInfo.fileSize = reader[i]->GetFileByteSize();
|
||||||
|
tempInfo.order = reader[i]->GetFileOrder();
|
||||||
|
tempInfo.CalOrder();
|
||||||
|
|
||||||
|
tempInfo.t0 = reader[i]->GetT0();;
|
||||||
|
|
||||||
|
fileInfo.push_back(tempInfo);
|
||||||
|
|
||||||
|
delete reader[i];
|
||||||
|
}
|
||||||
|
delete [] reader;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
nFile = (int) fileInfo.size();
|
||||||
|
|
||||||
|
std::sort(fileInfo.begin(), fileInfo.end(), [](const FileInfo& a, const FileInfo& b) {
|
||||||
|
return a.ID < b.ID;
|
||||||
|
});
|
||||||
|
|
||||||
|
unsigned int totHitCount = 0;
|
||||||
|
|
||||||
|
printf("===================================== number of file %d.\n", nFile);
|
||||||
|
for( int i = 0 ; i < nFile; i++){
|
||||||
|
printf("%d |", i);
|
||||||
|
fileInfo[i].Print();
|
||||||
|
totHitCount += fileInfo[i].hitCount;
|
||||||
|
//printf(" %30s | ID %10ld \n", fileInfo[i].fileName.Data(), fileInfo[i].ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("----- total number of hit : %u.\n", totHitCount);
|
||||||
|
|
||||||
|
//*======================================= Sort files into groups
|
||||||
|
std::vector<GroupInfo> group; // group by SN and chMask
|
||||||
|
|
||||||
|
for( int i = 0; i < nFile; i++){
|
||||||
|
if( i == 0 || group.back().sn != fileInfo[i].SN ){
|
||||||
|
group.push_back(GroupInfo());
|
||||||
|
group.back().fileIDList.push_back(i); // an empty struct
|
||||||
|
group.back().currentID = 0;
|
||||||
|
group.back().hitCount = fileInfo[i].hitCount;
|
||||||
|
group.back().sn = fileInfo[i].SN;
|
||||||
|
group.back().finished = false;
|
||||||
|
|
||||||
|
}else{
|
||||||
|
group.back().fileIDList.push_back(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int nGroup = group.size();
|
||||||
|
printf("===================================== number of file Group by digitizer %d.\n", nGroup);
|
||||||
|
for( int i = 0; i < nGroup; i++){
|
||||||
|
printf(" Digi-%d, DPPType: %d \n", group[i].sn, fileInfo[group[i].currentID].DPPType);
|
||||||
|
for( int j = 0; j< (int) group[i].fileIDList.size(); j++){
|
||||||
|
uShort fID = group[i].fileIDList[j];
|
||||||
|
printf(" %s \n", fileInfo[fID].fileName.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// //*====================================== create tree
|
||||||
|
TFile * outRootFile = new TFile(outFileName, "recreate");
|
||||||
|
TTree * tree = new TTree("tree", outFileName);
|
||||||
|
|
||||||
|
unsigned long long evID = 0;
|
||||||
|
unsigned int multi = 0;
|
||||||
|
unsigned short sn[MAX_MULTI] = {0}; /// board SN
|
||||||
|
unsigned short ch[MAX_MULTI] = {0}; /// chID
|
||||||
|
unsigned short e[MAX_MULTI] = {0}; /// 15 bit
|
||||||
|
unsigned short e2[MAX_MULTI] = {0}; /// 15 bit
|
||||||
|
unsigned long long e_t[MAX_MULTI] = {0}; /// timestamp 47 bit
|
||||||
|
unsigned short e_f[MAX_MULTI] = {0}; /// fine time 10 bit
|
||||||
|
unsigned short traceLength[MAX_MULTI];
|
||||||
|
|
||||||
|
tree->Branch("evID", &evID, "event_ID/l");
|
||||||
|
tree->Branch("multi", &multi, "multi/i");
|
||||||
|
tree->Branch("sn", sn, "sn[multi]/s");
|
||||||
|
tree->Branch("ch", ch, "ch[multi]/s");
|
||||||
|
tree->Branch("e", e, "e[multi]/s");
|
||||||
|
tree->Branch("e2", e2, "e2[multi]/s");
|
||||||
|
tree->Branch("e_t", e_t, "e_timestamp[multi]/l");
|
||||||
|
tree->Branch("e_f", e_f, "e_timestamp[multi]/s");
|
||||||
|
tree->Branch("traceLength", traceLength, "traceLength[multi]/s");
|
||||||
|
|
||||||
|
TClonesArray * arrayTrace = nullptr;
|
||||||
|
TGraph * trace = nullptr;
|
||||||
|
|
||||||
|
if( traceOn ) {
|
||||||
|
arrayTrace = new TClonesArray("TGraph");
|
||||||
|
tree->Branch("trace", arrayTrace, 2560000);
|
||||||
|
arrayTrace->BypassStreamer();
|
||||||
|
}
|
||||||
|
|
||||||
|
//*======================================= Open time-sorted files
|
||||||
|
printf("===================================== Open time-sorted files.\n");
|
||||||
|
|
||||||
|
FSUTSReader ** tsReader = new FSUTSReader * [nGroup];
|
||||||
|
for( int i = 0; i < nGroup; i++){
|
||||||
|
std::string fileName = fileInfo[group[i].fileIDList[0]].fileName;
|
||||||
|
tsReader[i] = new FSUTSReader(fileName);
|
||||||
|
// tsReader[i]->ScanFile(1);
|
||||||
|
group[i].usedHitCount = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//*====================================== build events
|
||||||
|
printf("================= Building events....\n");
|
||||||
|
|
||||||
|
uInt hitProcessed = 0;
|
||||||
|
|
||||||
|
//find the earliest time
|
||||||
|
ullong t0 = -1;
|
||||||
|
uShort gp0 = -1;
|
||||||
|
|
||||||
|
ullong tStart = 0;
|
||||||
|
ullong tEnd = 0;
|
||||||
|
|
||||||
|
bool hasEvent = false;
|
||||||
|
|
||||||
|
for( int i = 0; i < nGroup; i++){
|
||||||
|
if( fileInfo[group[i].fileIDList[0]].t0 < t0 ) {
|
||||||
|
t0 = fileInfo[group[i].fileIDList[0]].t0;
|
||||||
|
gp0 = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( debug ) printf("First timestamp is %llu, group : %u\n", t0, gp0);
|
||||||
|
do{
|
||||||
|
|
||||||
|
if( debug ) printf("################################ ev build %llu \n", evID);
|
||||||
|
|
||||||
|
///===================== check if the file is finished.
|
||||||
|
for( int i = 0; i < nGroup; i++){
|
||||||
|
uShort gpID = (i + gp0) % nGroup;
|
||||||
|
if( group[gpID].finished ) continue;
|
||||||
|
short endCount = 0;
|
||||||
|
do{
|
||||||
|
|
||||||
|
if( group[gpID].usedHitCount > tsReader[gpID]->GetHitID() || tsReader[gpID]->GetFilePos() <= 4){
|
||||||
|
if( tsReader[gpID]->ReadNextHit(traceOn, 0) == 0 ){
|
||||||
|
hitProcessed ++;
|
||||||
|
if( debug ){ printf("............ Get Data | "); tsReader[gpID]->GetHit()->Print();}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
e2[multi] = tsReader[gpID]->GetHit()->energy2;
|
||||||
|
e_t[multi] = tsReader[gpID]->GetHit()->timestamp;
|
||||||
|
e_f[multi] = tsReader[gpID]->GetHit()->fineTime;
|
||||||
|
|
||||||
|
traceLength[multi] = tsReader[gpID]->GetHit()->traceLength;
|
||||||
|
if( traceOn ){
|
||||||
|
trace = (TGraph *) arrayTrace->ConstructedAt(multi, "C");
|
||||||
|
trace->Clear();
|
||||||
|
for( int hh = 0; hh < traceLength[multi]; hh++){
|
||||||
|
trace->SetPoint(hh, hh, tsReader[gpID]->GetHit()->trace[hh]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( debug ) printf("(%5d, %2d) %6d %16llu, %u\n", sn[multi], ch[multi], e[multi], e_t[multi], traceLength[multi]);
|
||||||
|
|
||||||
|
hasEvent = true;
|
||||||
|
multi ++;
|
||||||
|
|
||||||
|
group[gpID].usedHitCount ++;
|
||||||
|
if( tsReader[gpID]->ReadNextHit(traceOn, 0) == 0 ){
|
||||||
|
hitProcessed ++;
|
||||||
|
if( debug ){ printf("..Get Data after fill | "); tsReader[gpID]->GetHit()->Print();}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( multi > MAX_MULTI) {
|
||||||
|
printf(" !!!!!! multi > MAX_MULTI = %d\n", MAX_MULTI);
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( timeWindow == 0) break;
|
||||||
|
|
||||||
|
if( tsReader[gpID]->GetHitID() + 1 >= tsReader[gpID]->GetNumHitFromHeader() ) endCount ++;
|
||||||
|
if( endCount == 2 ) break;
|
||||||
|
|
||||||
|
}while(true);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hasEvent ){
|
||||||
|
outRootFile->cd();
|
||||||
|
tree->Fill();
|
||||||
|
multi = 0;
|
||||||
|
evID ++;
|
||||||
|
hasEvent = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hitProcessed % 10000 == 0 ) printf("hit Porcessed %u/%u hit....%.2f%%\n\033[A\r", hitProcessed, totHitCount, hitProcessed*100./totHitCount);
|
||||||
|
|
||||||
|
///===================== find the next first timestamp
|
||||||
|
t0 = -1;
|
||||||
|
gp0 = -1;
|
||||||
|
|
||||||
|
for( int i = 0; i < nGroup; i++) {
|
||||||
|
if( group[i].finished ) continue;
|
||||||
|
if( tsReader[i]->GetHit()->timestamp < t0) {
|
||||||
|
t0 = tsReader[i]->GetHit()->timestamp;
|
||||||
|
gp0 = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if( debug ) printf("Next First timestamp is %llu, group : %u\n", t0, gp0);
|
||||||
|
|
||||||
|
|
||||||
|
///===================== check if the file is finished.
|
||||||
|
int gpCount = 0;
|
||||||
|
for( int gpID = 0; gpID < nGroup; gpID ++) {
|
||||||
|
if( group[gpID].finished ) {
|
||||||
|
gpCount ++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( group[gpID].usedHitCount >= tsReader[gpID]->GetNumHitFromHeader() ) {
|
||||||
|
|
||||||
|
group[gpID].currentID ++;
|
||||||
|
|
||||||
|
if( group[gpID].currentID >= group[gpID].fileIDList.size() ) {
|
||||||
|
group[gpID].finished = true;
|
||||||
|
printf("-----> no more file for this group, S/N : %d.\n", group[gpID].sn);
|
||||||
|
|
||||||
|
}else{
|
||||||
|
uShort fID = group[gpID].fileIDList[group[gpID].currentID];
|
||||||
|
std::string fileName = fileInfo[fID].fileName;
|
||||||
|
|
||||||
|
delete tsReader[gpID];
|
||||||
|
tsReader[gpID] = new FSUTSReader(fileName);
|
||||||
|
tsReader[gpID]->ScanFile(1);
|
||||||
|
printf("-----> go to the next file, %s \n", fileName.c_str() );
|
||||||
|
|
||||||
|
group[gpID].usedHitCount = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( group[gpID].finished ) gpCount ++;
|
||||||
|
}
|
||||||
|
if( gpCount == (int) group.size() ) break;
|
||||||
|
|
||||||
|
}while(true);
|
||||||
|
|
||||||
|
tree->Write();
|
||||||
|
|
||||||
|
uInt runEndTime = getTime_us();
|
||||||
|
double runTime = (runEndTime - runStartTime) * 1e-6;
|
||||||
|
|
||||||
|
printf("========================= finished.\n");
|
||||||
|
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());
|
||||||
|
|
||||||
|
TMacro info;
|
||||||
|
info.AddLine(Form("tStart= %20llu ns",tStart));
|
||||||
|
info.AddLine(Form(" tEnd= %20llu ns",tEnd));
|
||||||
|
info.Write("info");
|
||||||
|
|
||||||
|
outRootFile->Close();
|
||||||
|
|
||||||
|
for( int i = 0; i < nGroup; i++){
|
||||||
|
delete tsReader[i];
|
||||||
|
}
|
||||||
|
delete [] tsReader;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
202
Aux/fsuReader.h
202
Aux/fsuReader.h
|
@ -14,7 +14,23 @@ class FSUReader{
|
||||||
~FSUReader();
|
~FSUReader();
|
||||||
|
|
||||||
void OpenFile(std::string fileName, uInt dataSize, int verbose = 1);
|
void OpenFile(std::string fileName, uInt dataSize, int verbose = 1);
|
||||||
bool isOpen() const{return inFile == nullptr ? false : true;}
|
bool IsOpen() const{return inFile == nullptr ? false : true;}
|
||||||
|
bool IsEndOfFile() const {
|
||||||
|
// printf("%s : %d | %ld |%ld\n", __func__, feof(inFile), ftell(inFile), inFileSize);
|
||||||
|
if(fileList.empty() ) {
|
||||||
|
if( (uLong )ftell(inFile) >= inFileSize){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
if( fileID + 1 == (int) fileList.size() && ((uLong)ftell(inFile) >= inFileSize) ) {
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ScanNumBlock(int verbose = 1, uShort saveData = 0); // saveData = 0 (no save), 1 (no trace), 2 (with trace);
|
void ScanNumBlock(int verbose = 1, uShort saveData = 0); // saveData = 0 (no save), 1 (no trace), 2 (with trace);
|
||||||
int ReadNextBlock(bool traceON = false, int verbose = 0, uShort saveData = 0); // saveData = 0 (no save), 1 (no trace), 2 (with trace);
|
int ReadNextBlock(bool traceON = false, int verbose = 0, uShort saveData = 0); // saveData = 0 (no save), 1 (no trace), 2 (with trace);
|
||||||
|
@ -43,27 +59,46 @@ class FSUReader{
|
||||||
if( id < 0 ) id = hit.size() + id;
|
if( id < 0 ) id = hit.size() + id;
|
||||||
return hit[id];
|
return hit[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearHitCount() {hitCount = 0;}
|
void ClearHitCount() {hitCount = 0;}
|
||||||
ulong GetHitCount() const{return hitCount;}
|
ulong GetHitCount() const{return hitCount;}
|
||||||
|
|
||||||
void SortAndSaveTS(int batchSize = 1000000, bool verbose = false);
|
std::vector<Hit> ReadBatch(unsigned int batchSize = 1000000, bool verbose = false); // output the sorted Hit
|
||||||
|
|
||||||
|
void SortAndSaveTS(unsigned int batchSize = 1000000, bool verbose = false);
|
||||||
|
|
||||||
std::string SaveHit(std::vector<Hit> hitList, bool isAppend = false);
|
std::string SaveHit(std::vector<Hit> hitList, bool isAppend = false);
|
||||||
|
|
||||||
// std::string SaveHit2NewFile(std::string saveFolder = "./", std::string indexStr = "");
|
// std::string SaveHit2NewFile(std::string saveFolder = "./", std::string indexStr = "");
|
||||||
off_t GetTSFileSize() const {return tsFileSize;}
|
off_t GetTSFileSize() const {return tsFileSize;}
|
||||||
|
|
||||||
|
//TODO
|
||||||
|
//void SplitFile(unsigned long hitSizePreFile);
|
||||||
|
|
||||||
void PrintHit(ulong numHit = -1, ulong startIndex = 0) {
|
void PrintHit(ulong numHit = -1, ulong startIndex = 0) {
|
||||||
for( ulong i = startIndex; i < std::min(numHit, hitCount); i++){
|
for( ulong i = startIndex; i < std::min(numHit, hitCount); i++){
|
||||||
printf("%10zu ", i); hit[i].Print();
|
printf("%10zu ", i); hit[i].Print();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void PrintHitList(std::vector<Hit> hitList, std::string name){
|
static void PrintHitListInfo(std::vector<Hit> hitList, std::string name){
|
||||||
printf("============== %s, size : %zu \n", name.c_str(), hitList.size());
|
size_t n = hitList.size();
|
||||||
printf("t0 : %15llu \n", hitList.at(0).timestamp);
|
size_t s = sizeof(Hit);
|
||||||
printf("t1 : %15llu \n", hitList.back().timestamp);
|
printf("============== %s, size : %zu | %.2f MByte\n", name.c_str(), n, n*s/1024./1024.);
|
||||||
|
if( n > 0 ){
|
||||||
|
printf("t0 : %15llu \n", hitList.at(0).timestamp);
|
||||||
|
printf("t1 : %15llu \n", hitList.back().timestamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintHitListInfo(){
|
||||||
|
size_t n = hit.size();
|
||||||
|
size_t s = sizeof(Hit);
|
||||||
|
printf("============== reader.hit, size : %zu | %.2f MByte\n", n, n*s/1024./1024.);
|
||||||
|
if( n > 0 ){
|
||||||
|
printf("t0 : %15llu \n", hit.at(0).timestamp);
|
||||||
|
printf("t1 : %15llu \n", hit.back().timestamp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +174,7 @@ inline FSUReader::FSUReader(std::string fileName, uInt dataSize, int verbose){
|
||||||
OpenFile(fileName, dataSize, verbose);
|
OpenFile(fileName, dataSize, verbose);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline FSUReader::FSUReader(std::vector<std::string> fileList, uInt dataSize = 100, int verbose = 1){
|
inline FSUReader::FSUReader(std::vector<std::string> fileList, uInt dataSize, int verbose){
|
||||||
inFile = nullptr;
|
inFile = nullptr;
|
||||||
data = nullptr;
|
data = nullptr;
|
||||||
|
|
||||||
|
@ -196,13 +231,13 @@ inline void FSUReader::OpenFile(std::string fileName, uInt dataSize, int verbose
|
||||||
std::string ext = fileName.substr(found + 1);
|
std::string ext = fileName.substr(found + 1);
|
||||||
|
|
||||||
if( ext.find("fsu") != std::string::npos ) {
|
if( ext.find("fsu") != std::string::npos ) {
|
||||||
if(verbose) printf("It is an raw data *.fsu format\n");
|
if(verbose > 1) printf("It is an raw data *.fsu format\n");
|
||||||
isDualBlock = false;
|
isDualBlock = false;
|
||||||
chMask = -1;
|
chMask = -1;
|
||||||
}else{
|
}else{
|
||||||
chMask = atoi(ext.c_str());
|
chMask = atoi(ext.c_str());
|
||||||
isDualBlock = true;
|
isDualBlock = true;
|
||||||
if(verbose) printf("It is a splitted dual block data *.fsu.X format, dual channel mask : %d \n", chMask);
|
if(verbose > 1) printf("It is a splitted dual block data *.fsu.X format, dual channel mask : %d \n", chMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string fileNameNoExt;
|
std::string fileNameNoExt;
|
||||||
|
@ -247,7 +282,7 @@ inline void FSUReader::OpenFile(std::string fileName, uInt dataSize, int verbose
|
||||||
inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
||||||
if( inFile == NULL ) return -1;
|
if( inFile == NULL ) return -1;
|
||||||
if( feof(inFile) || filePos >= inFileSize) {
|
if( feof(inFile) || filePos >= inFileSize) {
|
||||||
if( fileID >= 0 && fileID + 1 < fileList.size() ){
|
if( fileID >= 0 && fileID + 1 < (short) fileList.size() ){
|
||||||
printf("-------------- next file\n");
|
printf("-------------- next file\n");
|
||||||
fileID ++;
|
fileID ++;
|
||||||
OpenFile(fileList[fileID], data->GetDataSize(), 1 );
|
OpenFile(fileList[fileID], data->GetDataSize(), 1 );
|
||||||
|
@ -270,7 +305,8 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
||||||
|
|
||||||
if( header == 0xA ) { ///normal header
|
if( header == 0xA ) { ///normal header
|
||||||
|
|
||||||
unsigned int aggSize = (word[0] & 0x0FFFFFFF) * 4; ///byte
|
unsigned int aggSize = (word[0] & 0x0FFFFFFF) * 4; ///byte
|
||||||
|
if( aggSize > inFileSize - ftell(inFile)) aggSize = inFileSize - ftell(inFile);
|
||||||
buffer = new char[aggSize];
|
buffer = new char[aggSize];
|
||||||
dummy = fread(buffer, aggSize, 1, inFile);
|
dummy = fread(buffer, aggSize, 1, inFile);
|
||||||
filePos = ftell(inFile);
|
filePos = ftell(inFile);
|
||||||
|
@ -372,7 +408,7 @@ inline void FSUReader::ScanNumBlock(int verbose, uShort saveData){
|
||||||
blockPos.push_back(0);
|
blockPos.push_back(0);
|
||||||
|
|
||||||
data->ClearData();
|
data->ClearData();
|
||||||
fseek(inFile, 0L, SEEK_SET);
|
rewind(inFile);
|
||||||
filePos = 0;
|
filePos = 0;
|
||||||
|
|
||||||
bool isTraceOn = saveData < 2 ? false : true;
|
bool isTraceOn = saveData < 2 ? false : true;
|
||||||
|
@ -417,7 +453,131 @@ inline void FSUReader::ScanNumBlock(int verbose, uShort saveData){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FSUReader::SortAndSaveTS(int batchSize, bool verbose){
|
inline std::vector<Hit> FSUReader::ReadBatch(unsigned int batchSize, bool verbose){
|
||||||
|
|
||||||
|
// printf("%s sn:%d. filePos : %lu\n", __func__, sn, ftell(inFile));
|
||||||
|
|
||||||
|
std::vector<Hit> hitList_A;
|
||||||
|
if( IsEndOfFile() ) {
|
||||||
|
hitList_A = hit;
|
||||||
|
hit.clear();
|
||||||
|
return hitList_A;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( hit.size() == 0 ){
|
||||||
|
int res = 0;
|
||||||
|
do{
|
||||||
|
res = ReadNextBlock(true, 0, 3);
|
||||||
|
}while ( hit.size() < batchSize && res == 0);
|
||||||
|
SortHit();
|
||||||
|
uLong t0_B = hit.at(0).timestamp;
|
||||||
|
uLong t1_B = hit.back().timestamp;
|
||||||
|
if( verbose ) {
|
||||||
|
printf(" hit in memeory : %7zu | %u | %lu \n", hit.size(), filePos, inFileSize);
|
||||||
|
printf("t0 : %15lu\n", t0_B);
|
||||||
|
printf("t1 : %15lu\n", t1_B);
|
||||||
|
}
|
||||||
|
|
||||||
|
hitList_A = hit;
|
||||||
|
hit.clear();
|
||||||
|
}else{
|
||||||
|
|
||||||
|
hitList_A = hit;
|
||||||
|
hit.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if( IsEndOfFile() ) return hitList_A; // when file finished for 1st batch read
|
||||||
|
|
||||||
|
int res = 0;
|
||||||
|
do{
|
||||||
|
res = ReadNextBlock(true, 0, 3);
|
||||||
|
}while ( hit.size() < batchSize && res == 0);
|
||||||
|
SortHit();
|
||||||
|
uLong t0_B = hit.at(0).timestamp;
|
||||||
|
uLong t1_B = hit.back().timestamp;
|
||||||
|
|
||||||
|
if( verbose ) {
|
||||||
|
printf(" hit in memeory : %7zu | %u | %lu \n", hit.size(), filePos, inFileSize);
|
||||||
|
printf("t0 : %15lu\n", t0_B);
|
||||||
|
printf("t1 : %15lu\n", t1_B);
|
||||||
|
}
|
||||||
|
|
||||||
|
uLong t0_A = hitList_A.at(0).timestamp;
|
||||||
|
uLong t1_A = hitList_A.back().timestamp;
|
||||||
|
ulong ID_A = 0;
|
||||||
|
ulong ID_B = 0;
|
||||||
|
|
||||||
|
if( t0_A >= t0_B) {
|
||||||
|
printf("\033[0;31m!!!!!!!!!!!!!!!!! %s | Need to increase the batch size. \033[0m\n", __func__);
|
||||||
|
return std::vector<Hit> ();
|
||||||
|
}
|
||||||
|
|
||||||
|
if( t1_A > t0_B) { // need to sort between two hitList
|
||||||
|
|
||||||
|
if( verbose ) {
|
||||||
|
printf("############# need to sort \n");
|
||||||
|
printf("=========== sume of A + B : %zu \n", hitList_A.size() + hit.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Hit> hitTemp;
|
||||||
|
|
||||||
|
// find the hit that is >= t0_B, save them to hitTemp
|
||||||
|
for( size_t j = 0; j < hitList_A.size() ; j++){
|
||||||
|
if( hitList_A[j].timestamp < t0_B ) continue;;
|
||||||
|
if( ID_A == 0 ) ID_A = j;
|
||||||
|
hitTemp.push_back(hitList_A[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove hitList_A element that is >= t0_B
|
||||||
|
hitList_A.erase(hitList_A.begin() + ID_A, hitList_A.end() );
|
||||||
|
|
||||||
|
// find the hit that is <= t1_A, save them to hitTemp
|
||||||
|
for( size_t j = 0; j < hit.size(); j++){
|
||||||
|
if( hit[j].timestamp > t1_A ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
hitTemp.push_back(hit[j]);
|
||||||
|
ID_B = j + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove hit elements that is <= t1_A
|
||||||
|
hit.erase(hit.begin(), hit.begin() + ID_B );
|
||||||
|
|
||||||
|
// sort hitTemp
|
||||||
|
std::sort(hitTemp.begin(), hitTemp.end(), [](const Hit& a, const Hit& b) {
|
||||||
|
return a.timestamp < b.timestamp;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if( verbose ) {
|
||||||
|
printf("----------------- ID_A : %lu, Drop\n", ID_A);
|
||||||
|
printf("----------------- ID_B : %lu, Drop\n", ID_B);
|
||||||
|
PrintHitListInfo(hitList_A, "hitList_A");
|
||||||
|
PrintHitListInfo(hitTemp, "hitTemp");
|
||||||
|
PrintHitListInfo();
|
||||||
|
printf("=========== sume of A + B + Temp : %zu \n", hitList_A.size() + hit.size() + hitTemp.size());
|
||||||
|
printf("----------------- refill hitList_A \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
for( size_t j = 0; j < hitTemp.size(); j++){
|
||||||
|
hitList_A.push_back(hitTemp[j]);
|
||||||
|
}
|
||||||
|
hitTemp.clear();
|
||||||
|
|
||||||
|
if( verbose ) {
|
||||||
|
PrintHitListInfo(hitList_A, "hitList_A");
|
||||||
|
PrintHitListInfo();
|
||||||
|
printf("=========== sume of A + B : %zu \n", hitList_A.size() + hit.size());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return hitList_A;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void FSUReader::SortAndSaveTS(unsigned int batchSize, bool verbose){
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
std::vector<Hit> hitList_A ;
|
std::vector<Hit> hitList_A ;
|
||||||
|
@ -473,7 +633,7 @@ inline void FSUReader::SortAndSaveTS(int batchSize, bool verbose){
|
||||||
hitList_A.erase(hitList_A.begin() + ID_A, hitList_A.end() );
|
hitList_A.erase(hitList_A.begin() + ID_A, hitList_A.end() );
|
||||||
if( verbose ) {
|
if( verbose ) {
|
||||||
printf("----------------- ID_A : %lu, Drop\n", ID_A);
|
printf("----------------- ID_A : %lu, Drop\n", ID_A);
|
||||||
PrintHitList(hitList_A, "hitList_A");
|
PrintHitListInfo(hitList_A, "hitList_A");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -492,9 +652,9 @@ inline void FSUReader::SortAndSaveTS(int batchSize, bool verbose){
|
||||||
hit.erase(hit.begin(), hit.begin() + ID_B );
|
hit.erase(hit.begin(), hit.begin() + ID_B );
|
||||||
|
|
||||||
if( verbose ) {
|
if( verbose ) {
|
||||||
PrintHitList(hitTemp, "hitTemp");
|
PrintHitListInfo(hitTemp, "hitTemp");
|
||||||
printf("----------------- ID_B : %lu, Drop\n", ID_B);
|
printf("----------------- ID_B : %lu, Drop\n", ID_B);
|
||||||
PrintHitList(hit, "hit");
|
PrintHitListInfo(hit, "hit");
|
||||||
printf("=========== sume of A + B + Temp : %zu \n", hitList_A.size() + hit.size() + hitTemp.size());
|
printf("=========== sume of A + B + Temp : %zu \n", hitList_A.size() + hit.size() + hitTemp.size());
|
||||||
printf("----------------- refill hitList_A \n");
|
printf("----------------- refill hitList_A \n");
|
||||||
}
|
}
|
||||||
|
@ -514,8 +674,8 @@ inline void FSUReader::SortAndSaveTS(int batchSize, bool verbose){
|
||||||
SaveHit(hitList_A, count <= 1 ? false : true);
|
SaveHit(hitList_A, count <= 1 ? false : true);
|
||||||
|
|
||||||
if( verbose ) {
|
if( verbose ) {
|
||||||
PrintHitList(hitList_A, "hitList_A");
|
PrintHitListInfo(hitList_A, "hitList_A");
|
||||||
PrintHitList(hitTemp, "hitTemp");
|
PrintHitListInfo(hitTemp, "hitTemp");
|
||||||
printf("----------------- replace hitList_A by hitTemp \n");
|
printf("----------------- replace hitList_A by hitTemp \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -524,7 +684,7 @@ inline void FSUReader::SortAndSaveTS(int batchSize, bool verbose){
|
||||||
hit.clear();
|
hit.clear();
|
||||||
|
|
||||||
if( verbose ) {
|
if( verbose ) {
|
||||||
PrintHitList(hitList_A, "hitList_A");
|
PrintHitListInfo(hitList_A, "hitList_A");
|
||||||
printf("===========================================\n");
|
printf("===========================================\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -533,7 +693,7 @@ inline void FSUReader::SortAndSaveTS(int batchSize, bool verbose){
|
||||||
SaveHit(hitList_A, count <= 1? false : true);
|
SaveHit(hitList_A, count <= 1? false : true);
|
||||||
hitList_A.clear();
|
hitList_A.clear();
|
||||||
hitList_A = hit;
|
hitList_A = hit;
|
||||||
if( verbose ) PrintHitList(hitList_A, "hitList_A");
|
if( verbose ) PrintHitListInfo(hitList_A, "hitList_A");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,7 +194,7 @@ inline void Data::AllocateDataSize(int dataSize){
|
||||||
printf("dataSize cannot < 1, set dataSize = 1.\n");
|
printf("dataSize cannot < 1, set dataSize = 1.\n");
|
||||||
dataSize = 1;
|
dataSize = 1;
|
||||||
}
|
}
|
||||||
printf("Data::%s, size: %u, No. Ch: %u\n", __func__, dataSize, numInputCh);
|
//printf("Data::%s, size: %u, No. Ch: %u\n", __func__, dataSize, numInputCh);
|
||||||
|
|
||||||
this->dataSize = dataSize;
|
this->dataSize = dataSize;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user