Compare commits
No commits in common. "06f9191095f147c18547dcec1f1d3396c505b2ce" and "39cda3bc3ce09d0489dec6f3ee4b0fc7c1ebc685" have entirely different histories.
06f9191095
...
39cda3bc3c
|
@ -8,7 +8,42 @@
|
|||
#include "TFile.h"
|
||||
#include "TTree.h"
|
||||
|
||||
#define MAX_MULTI 1000
|
||||
#define MAX_MULTI 100
|
||||
|
||||
#define ORDERSHIFT 100000
|
||||
|
||||
struct FileInfo {
|
||||
std::string fileName;
|
||||
unsigned int fileSize;
|
||||
unsigned int SN;
|
||||
unsigned long hitCount;
|
||||
unsigned short DPPType;
|
||||
unsigned short tick2ns;
|
||||
unsigned short order;
|
||||
unsigned short readerID;
|
||||
|
||||
unsigned long long t0;
|
||||
|
||||
unsigned long ID; // sn + 100000 * order
|
||||
|
||||
void CalOrder(){ ID = ORDERSHIFT * SN + order; }
|
||||
|
||||
void Print(){
|
||||
printf(" %10lu | %3d | %50s | %2d | %6lu | %10u Bytes = %.2f MB\n",
|
||||
ID, DPPType, fileName.c_str(), tick2ns, hitCount, fileSize, fileSize/1024./1024.);
|
||||
}
|
||||
};
|
||||
|
||||
struct GroupInfo{
|
||||
|
||||
std::vector<unsigned short> fileIDList;
|
||||
uInt sn;
|
||||
unsigned short currentID ; // the ID of the readerIDList;
|
||||
ulong hitCount ; // this is the hitCount for the currentID;
|
||||
uInt usedHitCount ;
|
||||
bool finished;
|
||||
|
||||
};
|
||||
|
||||
//^#############################################################
|
||||
//^#############################################################
|
||||
|
@ -28,14 +63,19 @@ 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
|
||||
/// AAA = board Serial Number, 3 digits
|
||||
/// BBB = DPPtype, 3 digits
|
||||
/// TT = tick2ns, any digits
|
||||
/// CCC = over size index, 3 digits
|
||||
|
||||
///============= read input
|
||||
unsigned int timeWindow = atoi(argv[1]);
|
||||
bool traceOn = atoi(argv[2]);
|
||||
|
@ -86,16 +126,8 @@ 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(), 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] = new FSUReader(inFileName[i].Data(), 1, false);
|
||||
if( !reader[i]->isOpen() ) continue;
|
||||
|
||||
reader[i]->ScanNumBlock(false, 2);
|
||||
|
||||
|
@ -130,17 +162,8 @@ int main(int argc, char **argv) {
|
|||
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(0);
|
||||
|
||||
if( reader[i]->GetNumHit() == 0 ){
|
||||
printf("------- file has no data.\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
FileInfo tempInfo;
|
||||
tempInfo.fileName = inFileName[i].Data();
|
||||
tempInfo.readerID = i;
|
||||
|
@ -160,8 +183,6 @@ 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;
|
||||
});
|
||||
|
@ -245,7 +266,9 @@ int main(int argc, char **argv) {
|
|||
for( int i = 0; i < nGroup; i++){
|
||||
std::string fileName = fileInfo[group[i].fileIDList[0]].fileName;
|
||||
tsReader[i] = new FSUTSReader(fileName);
|
||||
tsReader[i]->ScanFile(0);
|
||||
|
||||
tsReader[i]->ScanFile(1);
|
||||
|
||||
group[i].usedHitCount = 0;
|
||||
}
|
||||
|
||||
|
@ -258,9 +281,6 @@ 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++){
|
||||
|
@ -271,6 +291,9 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if( debug ) printf("First timestamp is %llu, group : %u\n", t0, gp0);
|
||||
|
||||
unsigned int maxUInt = -1;
|
||||
|
||||
do{
|
||||
|
||||
if( debug ) printf("################################ ev build %llu \n", evID);
|
||||
|
@ -278,11 +301,14 @@ int main(int argc, char **argv) {
|
|||
///===================== 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( group[gpID].usedHitCount > tsReader[gpID]->GetHitID() || tsReader[gpID]->GetHitID() == maxUInt){
|
||||
if( tsReader[gpID]->ReadNextHit(traceOn, 0) == 0 ){
|
||||
hitProcessed ++;
|
||||
if( debug ){ printf("............ Get Data | "); tsReader[gpID]->GetHit()->Print();}
|
||||
|
@ -291,9 +317,6 @@ 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;
|
||||
|
@ -321,10 +344,6 @@ int main(int argc, char **argv) {
|
|||
if( debug ){ printf("..Get Data after fill | "); tsReader[gpID]->GetHit()->Print();}
|
||||
}
|
||||
|
||||
if( multi > MAX_MULTI) {
|
||||
printf(" !!!!!! multi > %d\n", MAX_MULTI);
|
||||
}
|
||||
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
|
@ -348,6 +367,7 @@ 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;
|
||||
|
@ -400,16 +420,8 @@ int main(int argc, char **argv) {
|
|||
|
||||
tree->Write();
|
||||
|
||||
uInt runEndTime = get_time_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("total events built = %llu(%llu)\n", evID, tree->GetEntriesFast());
|
||||
printf("=======> saved to %s \n", outFileName.Data());
|
||||
|
||||
outRootFile->Close();
|
||||
|
|
|
@ -7,7 +7,40 @@
|
|||
#include "TFile.h"
|
||||
#include "TTree.h"
|
||||
|
||||
#define MAX_MULTI 1000
|
||||
#define MAX_MULTI 10000
|
||||
|
||||
#define ORDERSHIFT 100000
|
||||
|
||||
struct FileInfo {
|
||||
TString fileName;
|
||||
unsigned int fileSize;
|
||||
unsigned int SN;
|
||||
unsigned long hitCount;
|
||||
unsigned short DPPType;
|
||||
unsigned short tick2ns;
|
||||
unsigned short order;
|
||||
unsigned short readerID;
|
||||
|
||||
unsigned long ID; // sn + 100000 * order
|
||||
|
||||
void CalOrder(){ ID = ORDERSHIFT * SN + order; }
|
||||
|
||||
void Print(){
|
||||
printf(" %10lu | %3d | %50s | %2d | %6lu | %10u Bytes = %.2f MB\n",
|
||||
ID, DPPType, fileName.Data(), tick2ns, hitCount, fileSize, fileSize/1024./1024.);
|
||||
}
|
||||
};
|
||||
|
||||
struct GroupInfo{
|
||||
|
||||
std::vector<unsigned short> readerIDList;
|
||||
uInt sn;
|
||||
unsigned short currentID ; // the ID of the readerIDList;
|
||||
ulong hitCount ; // this is the hitCount for the currentID;
|
||||
ulong hitID ; // this is the ID for the reader->GetHit(hitID);
|
||||
bool finished;
|
||||
|
||||
};
|
||||
|
||||
//^#############################################################
|
||||
//^#############################################################
|
||||
|
@ -21,16 +54,19 @@ 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("\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");
|
||||
printf(" Output file name is contructed from inFile1 \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
|
||||
/// AAA = board Serial Number, 3 digits
|
||||
/// BBB = DPPtype, 3 digits
|
||||
/// TT = tick2ns, any digits
|
||||
/// CCC = over size index, 3 digits
|
||||
|
||||
///============= read input
|
||||
unsigned int timeWindow = atoi(argv[1]);
|
||||
|
@ -68,10 +104,9 @@ 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(), 600, 0); // the 600 is expecting each agg, there are maximum 1000 hit/ch.
|
||||
reader[i] = new FSUReader(inFileName[i].Data(), 50, 0); // the 1000 is expecting each agg, there are maximum 1000 hit/ch.
|
||||
reader[i]->ScanNumBlock(1, 1);
|
||||
|
||||
reader[i]->GetData()->ClearDataPointer();
|
||||
// reader[i]->FillHitList();
|
||||
|
||||
FileInfo tempInfo;
|
||||
tempInfo.fileName = inFileName[i];
|
||||
|
@ -139,6 +174,7 @@ int main(int argc, char **argv) {
|
|||
unsigned long long evID = 0;
|
||||
unsigned int multi = 0;
|
||||
unsigned short sn[MAX_MULTI] = {0}; /// board SN
|
||||
//unsigned short bd[MAX_MULTI] = {0}; /// boardID
|
||||
unsigned short ch[MAX_MULTI] = {0}; /// chID
|
||||
unsigned short e[MAX_MULTI] = {0}; /// 15 bit
|
||||
unsigned short e2[MAX_MULTI] = {0}; /// 15 bit
|
||||
|
@ -148,6 +184,7 @@ int main(int argc, char **argv) {
|
|||
tree->Branch("evID", &evID, "event_ID/l");
|
||||
tree->Branch("multi", &multi, "multi/i");
|
||||
tree->Branch("sn", sn, "sn[multi]/s");
|
||||
//tree->Branch("bd", bd, "bd[multi]/s");
|
||||
tree->Branch("ch", ch, "ch[multi]/s");
|
||||
tree->Branch("e", e, "e[multi]/s");
|
||||
tree->Branch("e2", e2, "e2[multi]/s");
|
||||
|
@ -165,6 +202,7 @@ int main(int argc, char **argv) {
|
|||
// arrayTrace->BypassStreamer();
|
||||
// }
|
||||
|
||||
|
||||
//*====================================== build events
|
||||
printf("================= Building events....\n");
|
||||
|
||||
|
@ -203,7 +241,7 @@ int main(int argc, char **argv) {
|
|||
group[gpID].hitID = 0;
|
||||
uShort rID = group[gpID].readerIDList[group[gpID].currentID];
|
||||
group[gpID].hitCount = reader[rID]->GetHitCount();
|
||||
printf("-----> go to the next file, %s \n", fileInfo[rID].fileName.c_str() );
|
||||
printf("-----> go to the next file, %s \n", fileInfo[rID].fileName.Data() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -215,7 +253,7 @@ int main(int argc, char **argv) {
|
|||
group0 = gpID;
|
||||
}
|
||||
}
|
||||
if (debug ) printf("the eariliest time is %llu at Group : %u, hitID : %lu, %s\n", t0, group0, group[group0].hitID, fileInfo[group[group0].currentID].fileName.c_str());
|
||||
if (debug ) printf("the eariliest time is %llu at Group : %u, hitID : %lu, %s\n", t0, group0, group[group0].hitID, fileInfo[group[group0].currentID].fileName.Data());
|
||||
|
||||
printf("hit Porcessed %u/%u....%.2f%%\n\033[A\r", hitProcessed, totHitCount, hitProcessed*100./totHitCount);
|
||||
|
||||
|
@ -255,7 +293,7 @@ int main(int argc, char **argv) {
|
|||
if( evID == 0) tStart = event.front().timestamp;
|
||||
|
||||
if( multi > 0 ) {
|
||||
if( hitProcessed >= totHitCount ) tEnd = event.back().timestamp;
|
||||
tEnd = event.back().timestamp;
|
||||
for( size_t j = 0; j < multi ; j++){
|
||||
|
||||
sn[j] = event[j].sn;
|
||||
|
|
|
@ -3,47 +3,6 @@
|
|||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
|
||||
#define ORDERSHIFT 100000
|
||||
|
||||
struct FileInfo {
|
||||
std::string fileName;
|
||||
unsigned int fileSize;
|
||||
unsigned int SN;
|
||||
unsigned long hitCount;
|
||||
unsigned short DPPType;
|
||||
unsigned short tick2ns;
|
||||
unsigned short order;
|
||||
unsigned short readerID;
|
||||
|
||||
unsigned long long t0;
|
||||
|
||||
unsigned long ID; // sn + 100000 * order
|
||||
|
||||
void CalOrder(){ ID = ORDERSHIFT * SN + order; }
|
||||
|
||||
void Print(){
|
||||
printf(" %10lu | %3d | %50s | %2d | %6lu | %10u Bytes = %.2f MB\n",
|
||||
ID, DPPType, fileName.c_str(), tick2ns, hitCount, fileSize, fileSize/1024./1024.);
|
||||
}
|
||||
};
|
||||
|
||||
struct GroupInfo{
|
||||
|
||||
std::vector<unsigned short> fileIDList;
|
||||
uInt usedHitCount ;
|
||||
|
||||
std::vector<unsigned short> readerIDList;
|
||||
ulong hitID ; // this is the ID for the reader->GetHit(hitID);
|
||||
|
||||
unsigned short currentID ; // the ID of the readerIDList;
|
||||
ulong hitCount ; // this is the hitCount for the currentID;
|
||||
uInt sn;
|
||||
bool finished;
|
||||
|
||||
unsigned long long timeShift;
|
||||
|
||||
};
|
||||
|
||||
class FSUReader{
|
||||
|
||||
public:
|
||||
|
@ -148,14 +107,6 @@ inline FSUReader::FSUReader(std::string fileName, uShort dataSize, int verbose){
|
|||
|
||||
inline void FSUReader::OpenFile(std::string fileName, uShort dataSize, int verbose){
|
||||
|
||||
/// File format must be YYY...Y_runXXX_AAA_BBB_TT_CCC.fsu
|
||||
/// YYY...Y = prefix
|
||||
/// XXX = runID, 3 digits
|
||||
/// AAA = board Serial Number, 3 digits
|
||||
/// BBB = DPPtype, 3 digits
|
||||
/// TT = tick2ns, any digits
|
||||
/// CCC = over size index, 3 digits
|
||||
|
||||
inFile = fopen(fileName.c_str(), "r");
|
||||
|
||||
if( inFile == NULL ){
|
||||
|
|
|
@ -30,7 +30,6 @@ class FSUTSReader{
|
|||
|
||||
std::string GetFileName() const {return fileName;}
|
||||
unsigned long GetFileByteSize() const {return inFileSize;}
|
||||
unsigned int GetFilePos() const {return filePos;}
|
||||
int GetFileOrder() const {return order;}
|
||||
uShort GetSN() const {return sn;}
|
||||
ullong GetT0() const {return t0;}
|
||||
|
@ -111,7 +110,7 @@ inline void FSUTSReader::OpenFile(std::string fileName, int verbose){
|
|||
|
||||
fseek(inFile, 0L, SEEK_END);
|
||||
inFileSize = ftell(inFile);
|
||||
if(verbose) printf("###### %50s | %11ld Byte = %.2f MB\n", fileName.c_str() , inFileSize, inFileSize/1024./1024.);
|
||||
if(verbose) printf("###### %s | file size : %ld Byte = %.2f MB\n", fileName.c_str() , inFileSize, inFileSize/1024./1024.);
|
||||
fseek(inFile, 0L, SEEK_SET);
|
||||
filePos = 0;
|
||||
|
||||
|
|
|
@ -206,8 +206,6 @@ 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];
|
||||
|
|
|
@ -210,11 +210,7 @@ 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, [=](){
|
||||
SendLogMsg("Digi-" +QString::number(digi[ID]->GetSerialNumber()) + " : AutoSetDPPEventAggregation()");
|
||||
digi[ID]->AutoSetDPPEventAggregation();
|
||||
UpdateBoardAndChannelsStatus();
|
||||
});
|
||||
connect(bhAutoSetEventPulling, &QPushButton::clicked, this, [=](){ digi[ID]->AutoSetDPPEventAggregation(); UpdateBoardAndChannelsStatus();});
|
||||
|
||||
// bnSendSoftwareClockSyncSignal = new QPushButton("Send SW Clock-Sync Signal", this);
|
||||
// buttonLayout->addWidget(bnSendSoftwareClockSyncSignal, rowID, 1);
|
||||
|
|
Loading…
Reference in New Issue
Block a user