add some debug code in EventBuilder and fsuReader.h, ReadBatch can switch off trace
This commit is contained in:
parent
06592c6aca
commit
8baa37142c
|
@ -89,6 +89,8 @@ int main(int argc, char **argv) {
|
|||
FSUReader * readerA = new FSUReader(inFileName[0].Data(), 1, 1);
|
||||
readerA->ScanNumBlock(0,0);
|
||||
if( readerA->GetOptimumBatchSize() > batchSize ) batchSize = readerA->GetOptimumBatchSize();
|
||||
//printf("Hit count : %7ld | opt. batch size : %7ld\n", readerA->GetTotalHitCount(), readerA->GetOptimumBatchSize());
|
||||
|
||||
FileInfo fileInfo = {inFileName[0].Data(), readerA->GetSN() * 1000 + readerA->GetFileOrder(), readerA->GetTotalHitCount()};
|
||||
fileList.push_back(fileInfo);
|
||||
totalHitCount += readerA->GetTotalHitCount();
|
||||
|
@ -98,6 +100,7 @@ int main(int argc, char **argv) {
|
|||
readerB->ScanNumBlock(0,0);
|
||||
// if( readerB->GetOptimumBatchSize() > batchSize ) batchSize = readerB->GetOptimumBatchSize();
|
||||
batchSize = readerB->GetOptimumBatchSize();
|
||||
//printf("Hit count : %7ld | opt. batch size : %7ld\n", readerB->GetTotalHitCount(), readerB->GetOptimumBatchSize());
|
||||
|
||||
totalHitCount += readerB->GetTotalHitCount();
|
||||
fileInfo = {inFileName[i].Data(), readerB->GetSN() * 1000 + readerB->GetFileOrder(), readerB->GetTotalHitCount()};
|
||||
|
@ -162,9 +165,8 @@ int main(int argc, char **argv) {
|
|||
tree->GetBranch("trace")->SetCompressionSettings(205);
|
||||
}
|
||||
|
||||
|
||||
//*======================================= Open files
|
||||
printf("========================================= Open files & Build Events.\n");
|
||||
printf("========================================= Open files & reading 1st batch.\n");
|
||||
|
||||
const short nGroup = fileGroupList.size();
|
||||
std::vector<Hit> hitList[nGroup];
|
||||
|
@ -177,7 +179,7 @@ int main(int argc, char **argv) {
|
|||
fList.push_back( fileGroupList[i][j].fileName );
|
||||
}
|
||||
reader[i] = new FSUReader(fList, 1024, debug); // 1024 is the maximum event / agg.
|
||||
hitList[i] = reader[i]->ReadBatch(batchSize, debug );
|
||||
hitList[i] = reader[i]->ReadBatch(batchSize, traceOn, debug );
|
||||
reader[i]->PrintHitListInfo(&hitList[i], "hitList-" + std::to_string(reader[i]->GetSN()));
|
||||
ID[i] = 0;
|
||||
if( debug ) {
|
||||
|
@ -212,6 +214,7 @@ int main(int argc, char **argv) {
|
|||
std::vector<Hit> events;
|
||||
|
||||
unsigned long long hitProcessed = 0;
|
||||
printf("========================================= Start Building Events....\n");
|
||||
|
||||
do{
|
||||
|
||||
|
@ -226,7 +229,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
//chekc if reached the end of hitList
|
||||
if( ID[ig] >= hitList[ig].size() ) {
|
||||
hitList[ig] = reader[ig]->ReadBatch(batchSize, debug + 1);
|
||||
hitList[ig] = reader[ig]->ReadBatch(batchSize, traceOn, debug + 1);
|
||||
if( debug ) reader[ig]->PrintHitListInfo( &hitList[ig], "hitList-" + std::to_string(ig));
|
||||
ID[ig] = 0;
|
||||
if( hitList[ig].size() == 0 ) continue;
|
||||
|
@ -245,7 +248,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
//check if reached the end of hitList
|
||||
if( ID[ig] >= hitList[ig].size() ) {
|
||||
hitList[ig] = reader[ig]->ReadBatch(batchSize, debug);
|
||||
hitList[ig] = reader[ig]->ReadBatch(batchSize, traceOn, debug);
|
||||
if( debug ) reader[ig]->PrintHitListInfo( &hitList[ig], "hitList-" + std::to_string(ig));
|
||||
ID[ig] = 0;
|
||||
if( hitList[ig].size() == 0 ) break;
|
||||
|
@ -334,7 +337,7 @@ int main(int argc, char **argv) {
|
|||
continue;
|
||||
}else{
|
||||
if( ID[i] >= hitList[i].size( )) {
|
||||
hitList[i] = reader[i]->ReadBatch(batchSize, debug);
|
||||
hitList[i] = reader[i]->ReadBatch(batchSize, traceOn, debug);
|
||||
ID[i] = 0;
|
||||
if( hitList[i].size() == 0 ) nFileFinished ++;
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ class FSUReader{
|
|||
void ClearTotalHitCount() {totalHitCount = 0;}
|
||||
ulong GetTotalHitCount() const{return totalHitCount;}
|
||||
|
||||
std::vector<Hit> ReadBatch(unsigned int batchSize = 1000000, bool verbose = false); // output the sorted Hit
|
||||
std::vector<Hit> ReadBatch(unsigned int batchSize = 1000000, bool traceOn = false, bool verbose = false); // output the sorted Hit
|
||||
|
||||
void PrintHit(ulong numHit = -1, ulong startIndex = 0) {
|
||||
for( ulong i = startIndex; i < std::min(numHit, totalHitCount); i++){
|
||||
|
@ -296,7 +296,7 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
|||
if( inFile == NULL ) return -1;
|
||||
if( feof(inFile) || filePos >= inFileSize) {
|
||||
if( fileID >= 0 && fileID + 1 < (short) fileList.size() ){
|
||||
printf("-------------- next file\n");
|
||||
printf("-------------- next file | hit size : %zu\n", hit.size());
|
||||
fileID ++;
|
||||
OpenFile(fileList[fileID], data->GetDataSize(), 1 );
|
||||
}else{
|
||||
|
@ -375,7 +375,11 @@ inline int FSUReader::ReadNextBlock(bool traceON, int verbose, uShort saveData){
|
|||
temp.ch = ch;
|
||||
temp.energy = data->GetEnergy(ch, k);
|
||||
temp.energy2 = data->GetEnergy2(ch, k);
|
||||
|
||||
temp.timestamp = data->GetTimestamp(ch, k);
|
||||
// unsigned long long offset = 1000000;
|
||||
// if( sn == 405 && ch == 0) temp.timestamp -= offset;
|
||||
|
||||
temp.fineTime = data->GetFineTime(ch, k);
|
||||
temp.pileUp = data->GetPileUp(ch, k);
|
||||
if( saveData > 1 ) {
|
||||
|
@ -498,7 +502,7 @@ inline void FSUReader::ScanNumBlock(int verbose, uShort saveData){
|
|||
}
|
||||
|
||||
//^==============================================================
|
||||
inline std::vector<Hit> FSUReader::ReadBatch(unsigned int batchSize, bool verbose){
|
||||
inline std::vector<Hit> FSUReader::ReadBatch(unsigned int batchSize, bool traceOn, bool verbose){
|
||||
|
||||
// printf("%s sn:%d. filePos : %lu\n", __func__, sn, ftell(inFile));
|
||||
|
||||
|
@ -512,7 +516,7 @@ inline std::vector<Hit> FSUReader::ReadBatch(unsigned int batchSize, bool verbos
|
|||
if( hit.size() == 0 ){
|
||||
int res = 0;
|
||||
do{
|
||||
res = ReadNextBlock(true, 0, 3);
|
||||
res = ReadNextBlock(traceOn, 0, 3);
|
||||
}while ( hit.size() < batchSize && res == 0);
|
||||
SortHit();
|
||||
uLong t0_B = hit.at(0).timestamp;
|
||||
|
@ -538,7 +542,7 @@ inline std::vector<Hit> FSUReader::ReadBatch(unsigned int batchSize, bool verbos
|
|||
|
||||
int res = 0;
|
||||
do{
|
||||
res = ReadNextBlock(true, 0, 3);
|
||||
res = ReadNextBlock(traceOn, 0, 3);
|
||||
}while ( hit.size() < batchSize && res == 0);
|
||||
SortHit();
|
||||
uLong t0_B = hit.at(0).timestamp;
|
||||
|
|
Loading…
Reference in New Issue
Block a user