update Eventbuilder(s), add pileUp, and change the fsu.ts, add hitCount at the header
This commit is contained in:
parent
f1f1de91ef
commit
99bb47c25e
|
@ -34,7 +34,7 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
uInt runStartTime = get_time_us();
|
||||
uInt runStartTime = getTime_us();
|
||||
|
||||
///============= read input
|
||||
unsigned int timeWindow = atoi(argv[1]);
|
||||
|
@ -50,6 +50,7 @@ int main(int argc, char **argv) {
|
|||
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";
|
||||
|
@ -135,9 +136,9 @@ int main(int argc, char **argv) {
|
|||
printf("------- cannot open file.\n");
|
||||
continue;
|
||||
}
|
||||
reader[i]->ScanFile(0);
|
||||
//reader[i]->ScanFile(1);
|
||||
|
||||
if( reader[i]->GetNumHit() == 0 ){
|
||||
if( reader[i]->GetNumHitFromHeader() == 0 ){
|
||||
printf("------- file has no data.\n");
|
||||
continue;
|
||||
}
|
||||
|
@ -146,7 +147,7 @@ int main(int argc, char **argv) {
|
|||
tempInfo.fileName = inFileName[i].Data();
|
||||
tempInfo.readerID = i;
|
||||
tempInfo.SN = reader[i]->GetSN();
|
||||
tempInfo.hitCount = reader[i]->GetNumHit();
|
||||
tempInfo.hitCount = reader[i]->GetNumHitFromHeader();
|
||||
tempInfo.fileSize = reader[i]->GetFileByteSize();
|
||||
tempInfo.order = reader[i]->GetFileOrder();
|
||||
tempInfo.CalOrder();
|
||||
|
@ -246,7 +247,7 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -323,7 +324,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if( multi > MAX_MULTI) {
|
||||
printf(" !!!!!! multi > %d\n", MAX_MULTI);
|
||||
printf(" !!!!!! multi > MAX_MULTI = %d\n", MAX_MULTI);
|
||||
}
|
||||
|
||||
}else{
|
||||
|
@ -332,7 +333,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
if( timeWindow == 0) break;
|
||||
|
||||
if( tsReader[gpID]->GetHitID() + 1 >= tsReader[gpID]->GetNumHit() ) endCount ++;
|
||||
if( tsReader[gpID]->GetHitID() + 1 >= tsReader[gpID]->GetNumHitFromHeader() ) endCount ++;
|
||||
if( endCount == 2 ) break;
|
||||
|
||||
}while(true);
|
||||
|
@ -371,7 +372,7 @@ int main(int argc, char **argv) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if( group[gpID].usedHitCount >= tsReader[gpID]->GetNumHit() ) {
|
||||
if( group[gpID].usedHitCount >= tsReader[gpID]->GetNumHitFromHeader() ) {
|
||||
|
||||
group[gpID].currentID ++;
|
||||
|
||||
|
@ -401,7 +402,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
tree->Write();
|
||||
|
||||
uInt runEndTime = get_time_us();
|
||||
uInt runEndTime = getTime_us();
|
||||
double runTime = (runEndTime - runStartTime) * 1e-6;
|
||||
|
||||
printf("========================= finished.\n");
|
||||
|
|
|
@ -30,7 +30,7 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
uInt runStartTime = get_time_us();
|
||||
uInt runStartTime = getTime_us();
|
||||
|
||||
///============= read input
|
||||
unsigned int timeWindow = atoi(argv[1]);
|
||||
|
@ -45,8 +45,9 @@ int main(int argc, char **argv) {
|
|||
/// Form outFileName;
|
||||
TString outFileName = inFileName[0];
|
||||
int pos = outFileName.Last('/');
|
||||
pos = outFileName.Index("_", pos+1); // find next "_"
|
||||
pos = outFileName.Index("_", pos+1); // find next "_"
|
||||
pos = outFileName.Index("_", pos+1); // find next "_", expName
|
||||
pos = outFileName.Index("_", pos+1); // find next "_", runID
|
||||
if( nFile == 1 ) pos = outFileName.Index("_", pos+1); // find next "_", S/N
|
||||
outFileName.Remove(pos); // remove the rest
|
||||
outFileName += "_" + std::to_string(timeWindow) + "_noTrace";
|
||||
outFileName += ".root";
|
||||
|
@ -145,6 +146,7 @@ int main(int argc, char **argv) {
|
|||
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
|
||||
bool pileUp[MAX_MULTI] = {false};
|
||||
|
||||
tree->Branch("evID", &evID, "event_ID/l");
|
||||
tree->Branch("multi", &multi, "multi/i");
|
||||
|
@ -154,6 +156,7 @@ int main(int argc, char **argv) {
|
|||
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("pileUp", pileUp, "pileUp[multi]/O");
|
||||
|
||||
//TClonesArray * arrayTrace = nullptr;
|
||||
//unsigned short traceLength[MAX_MULTI] = {0};
|
||||
|
@ -218,7 +221,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
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());
|
||||
|
||||
printf("hit Porcessed %u/%u....%.2f%%\n\033[A\r", hitProcessed, totHitCount, hitProcessed*100./totHitCount);
|
||||
if( hitProcessed % 10000 == 0 ) printf("hit Porcessed %u/%u....%.2f%%\n\033[A\r", hitProcessed, totHitCount, hitProcessed*100./totHitCount);
|
||||
|
||||
for(int i = 0; i < nGroup; i++){
|
||||
uShort gpID = (i + group0) % nGroup;
|
||||
|
@ -259,12 +262,13 @@ int main(int argc, char **argv) {
|
|||
if( hitProcessed >= totHitCount ) tEnd = event.back().timestamp;
|
||||
for( size_t j = 0; j < multi ; j++){
|
||||
|
||||
sn[j] = event[j].sn;
|
||||
ch[j] = event[j].ch;
|
||||
e[j] = event[j].energy;
|
||||
e2[j] = event[j].energy2;
|
||||
e_t[j] = event[j].timestamp;
|
||||
e_f[j] = event[j].fineTime;
|
||||
sn[j] = event[j].sn;
|
||||
ch[j] = event[j].ch;
|
||||
e[j] = event[j].energy;
|
||||
e2[j] = event[j].energy2;
|
||||
e_t[j] = event[j].timestamp;
|
||||
e_f[j] = event[j].fineTime;
|
||||
pileUp[j] = event[j].pileUp;
|
||||
|
||||
if (debug )event[j].Print();
|
||||
}
|
||||
|
@ -287,7 +291,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
tree->Write();
|
||||
|
||||
uInt runEndTime = get_time_us();
|
||||
uInt runEndTime = getTime_us();
|
||||
double runTime = (runEndTime - runStartTime) * 1e-6;
|
||||
|
||||
printf("========================= finished.\n");
|
||||
|
|
|
@ -22,7 +22,7 @@ struct FileInfo {
|
|||
void CalOrder(){ ID = ORDERSHIFT * SN + order; }
|
||||
|
||||
void Print(){
|
||||
printf(" %10lu | %3d | %50s | %2d | %6lu | %10u Bytes = %.2f MB\n",
|
||||
printf(" %10lu | %3d | %60s | %2d | %6lu | %10u Bytes = %.2f MB\n",
|
||||
ID, DPPType, fileName.c_str(), tick2ns, hitCount, fileSize, fileSize/1024./1024.);
|
||||
}
|
||||
};
|
||||
|
@ -236,7 +236,8 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
|||
fseek(inFile, -4, SEEK_CUR);
|
||||
|
||||
if( dummy != 1) {
|
||||
printf("fread error, should read 4 bytes, but read %ld x 4 byte, file pos: %ld byte\n", dummy, ftell(inFile));
|
||||
printf("fread error, should read 4 bytes, but read %ld x 4 byte, file pos: %ld / %ld byte\n",
|
||||
dummy, ftell(inFile), inFileSize);
|
||||
return -10;
|
||||
}
|
||||
short header = ((word[0] >> 28 ) & 0xF);
|
||||
|
@ -250,7 +251,8 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
|||
dummy = fread(buffer, aggSize, 1, inFile);
|
||||
filePos = ftell(inFile);
|
||||
if( dummy != 1) {
|
||||
printf("fread error, should read %d bytes, but read %ld x %d byte, file pos: %ld byte \n", aggSize, dummy, aggSize, ftell(inFile));
|
||||
printf("fread error, should read %d bytes, but read %ld x %d byte, file pos: %ld / %ld byte \n",
|
||||
aggSize, dummy, aggSize, ftell(inFile), inFileSize);
|
||||
return -30;
|
||||
}
|
||||
|
||||
|
@ -289,6 +291,7 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
|||
temp.energy2 = data->Energy2[ch][k];
|
||||
temp.timestamp = data->Timestamp[ch][k];
|
||||
temp.fineTime = data->fineTime[ch][k];
|
||||
temp.pileUp = data->PileUp[ch][k];
|
||||
if( saveData > 1 ) {
|
||||
temp.traceLength = data->Waveform1[ch][k].size();
|
||||
temp.trace = data->Waveform1[ch][k];
|
||||
|
@ -375,7 +378,7 @@ inline void FSUReader::ScanNumBlock(int verbose, uShort saveData){
|
|||
if( hitCount != hit.size() ){
|
||||
printf("!!!!!! the Data::dataSize is not big enough. !!!!!!!!!!!!!!!\n");
|
||||
}else{
|
||||
SortHit(verbose);
|
||||
SortHit(verbose+1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,6 +417,7 @@ inline std::string FSUReader::SaveHit2NewFile(std::string saveFolder){
|
|||
uint32_t header = 0xAA000000;
|
||||
header += sn;
|
||||
fwrite( &header, 4, 1, outFile );
|
||||
fwrite( &hitCount, 8, 1, outFile);
|
||||
|
||||
for( ulong i = 0; i < hitCount; i++){
|
||||
|
||||
|
@ -425,6 +429,7 @@ inline std::string FSUReader::SaveHit2NewFile(std::string saveFolder){
|
|||
fwrite( &(hit[i].energy2), 2, 1, outFile);
|
||||
fwrite( &(hit[i].timestamp), 8, 1, outFile);
|
||||
fwrite( &(hit[i].fineTime), 2, 1, outFile);
|
||||
fwrite( &(hit[i].pileUp), 1, 1, outFile);
|
||||
fwrite( &(hit[i].traceLength), 2, 1, outFile);
|
||||
|
||||
for( uShort j = 0; j < hit[i].traceLength; j++){
|
||||
|
|
|
@ -27,6 +27,7 @@ class FSUTSReader{
|
|||
|
||||
unsigned int GetHitID() const {return hitIndex;}
|
||||
unsigned long GetNumHit() const {return hitCount;}
|
||||
unsigned long GetNumHitFromHeader() const {return hitCount0;}
|
||||
|
||||
std::string GetFileName() const {return fileName;}
|
||||
unsigned long GetFileByteSize() const {return inFileSize;}
|
||||
|
@ -45,6 +46,7 @@ class FSUTSReader{
|
|||
unsigned long inFileSize;
|
||||
unsigned int filePos;
|
||||
unsigned long hitCount;
|
||||
unsigned long hitCount0; // hit count from file
|
||||
|
||||
uShort sn;
|
||||
int order;
|
||||
|
@ -131,7 +133,10 @@ inline void FSUTSReader::OpenFile(std::string fileName, int verbose){
|
|||
}
|
||||
sn = (header & 0xFFFFFF);
|
||||
hit->sn = sn;
|
||||
printf(" S/N : %u \n", sn);
|
||||
printf(" S/N : %u, ", sn);
|
||||
|
||||
dummy = fread(&hitCount0, 8, 1, inFile);
|
||||
printf(" hitCount : %lu \n", hitCount0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -149,6 +154,7 @@ inline int FSUTSReader::ReadNextHit(bool withTrace, int verbose){
|
|||
dummy = fread(&(hit->timestamp), 8, 1, inFile);
|
||||
dummy = fread(&(hit->fineTime), 2, 1, inFile);
|
||||
dummy = fread(&(hit->traceLength), 2, 1, inFile);
|
||||
dummy = fread(&(hit->pileUp), 1, 1, inFile);
|
||||
|
||||
if( hit->trace.size() > 0 ) hit->trace.clear();
|
||||
|
||||
|
@ -195,6 +201,7 @@ inline void FSUTSReader::ScanFile(int verbose){
|
|||
hitStartPos.clear();
|
||||
fseek(inFile, 0L, SEEK_SET);
|
||||
dummy = fread(&header, 4, 1, inFile);
|
||||
dummy = fread(&hitCount0, 8, 1, inFile);
|
||||
filePos = ftell(inFile);
|
||||
hitStartPos.push_back(filePos);
|
||||
hitIndex = -1;
|
||||
|
@ -206,15 +213,21 @@ inline void FSUTSReader::ScanFile(int verbose){
|
|||
|
||||
if(verbose > 1 ) printf("hitIndex : %u, Pos : %u - %u\n" , hitIndex, hitStartPos[hitIndex], hitStartPos[hitIndex+1]);
|
||||
|
||||
if(verbose) printf(" %u, %.2f%% %u/%lu byte \n\033[A\r", hitIndex, filePos*100./inFileSize, filePos, inFileSize);
|
||||
if(verbose && hitIndex%10000 == 0 ) printf(" %u, %.2f%% %u/%lu byte \n\033[A\r", hitIndex, filePos*100./inFileSize, filePos, inFileSize);
|
||||
}
|
||||
|
||||
hitCount = hitIndex + 1;
|
||||
if(verbose) printf("-----> Scan complete: number of hit : %lu\n", hitCount);
|
||||
|
||||
rewind(inFile);
|
||||
dummy = fread(&header, 4, 1, inFile);
|
||||
hitIndex = -1;
|
||||
filePos = ftell(inFile);
|
||||
if(verbose) {
|
||||
printf("\n-----> Scan complete\n");
|
||||
printf(" number of hit : %lu\n", hitCount);
|
||||
printf(" first timestamp : %16llu\n", t0);
|
||||
printf(" last timestamp : %16llu\n", hit->timestamp);
|
||||
double dt = (hit->timestamp - t0)*1e-9;
|
||||
printf(" duration : %.2f sec = %.2f min\n", dt, dt/60.);
|
||||
}
|
||||
|
||||
fseek(inFile, 0L, SEEK_SET);
|
||||
fseek(inFile, hitStartPos[0], SEEK_CUR);
|
||||
filePos = hitStartPos[0];
|
||||
hitIndex = -1;
|
||||
}
|
||||
|
|
4
Hit.h
4
Hit.h
|
@ -10,6 +10,7 @@ public:
|
|||
unsigned short energy2;
|
||||
unsigned long long timestamp;
|
||||
unsigned short fineTime;
|
||||
bool pileUp;
|
||||
|
||||
unsigned short traceLength;
|
||||
std::vector<short> trace;
|
||||
|
@ -27,11 +28,12 @@ public:
|
|||
timestamp = 0;
|
||||
fineTime = 0;
|
||||
traceLength = 0;
|
||||
pileUp = false;
|
||||
trace.clear();
|
||||
}
|
||||
|
||||
void Print(){
|
||||
printf("(%5d, %2d) %6d %16llu, %6d, %5ld\n", sn, ch, energy, timestamp, fineTime, trace.size());
|
||||
printf("(%5d, %2d) %6d %16llu, %6d, %d, %5ld\n", sn, ch, energy, timestamp, fineTime, pileUp, trace.size());
|
||||
}
|
||||
|
||||
void PrintTrace(){
|
||||
|
|
Loading…
Reference in New Issue
Block a user