From a0fc38669e13dc1506bb6352441b479f95de0d30 Mon Sep 17 00:00:00 2001 From: "Ryan@SOLARIS_testStation" Date: Wed, 29 May 2024 16:54:55 -0400 Subject: [PATCH] added rejection filter for Event Builder --- armory/EventBuilder.cpp | 78 +++++++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 15 deletions(-) diff --git a/armory/EventBuilder.cpp b/armory/EventBuilder.cpp index a06a4e9..6a4f6b2 100644 --- a/armory/EventBuilder.cpp +++ b/armory/EventBuilder.cpp @@ -45,7 +45,12 @@ int main(int argn, char **argv){ printf("%s [timeWindows] [mapping file] [Reject Flag] [SaveFileName] [*.evt File1] [*.evt File2] ...\n", argv[0]); printf(" timeWindows [int]: 1 unit = 10 ns \n"); printf(" mapping file path [str]: the path of mapping file. \n"); - printf(" Reject Flag [int]: 0 = no rejection, 1 = reject no gamma, 2 = reject no GAGG. see mapping.h\n"); + printf(" Reject Flag [int]: 0 = no rejection. see mapping.h\n"); + printf(" 1 = reject BGO\n"); + printf(" 2 = reject no gamma\n"); + printf(" 4 = reject no GAGG\n"); + printf(" 8 = reject zero energy data-point\n"); + printf(" 3 = reject BGO + no gamma, 5 = reject BGO + no GAGG, etc.\n"); printf(" SaveFileName [str]: custom save file name \n"); return 1; } @@ -68,6 +73,12 @@ int main(int argn, char **argv){ printf("%2ld | %s \n", i, inFileList[i].c_str()); } + if( rejectFlag > 0 ) printf("================================== Rejection Filter Conditions\n"); + if( ( rejectFlag & 0x1 ) ) printf("\033[31m !!!! Reject event with BGO !!!! \033[0m\n"); + if( ( rejectFlag & 0x2 ) ) printf("\033[31m !!!! Reject event w/o Clover !!!! \033[0m\n"); + if( ( rejectFlag & 0x4 ) ) printf("\033[31m !!!! Reject event w/o GAGG !!!! \033[0m\n"); + if( ( rejectFlag & 0x8 ) ) printf("\033[31m !!!! Reject Zero-Energy Data Point !!!! \033[0m\n"); + if( rejectFlag > 0 ) printf(" Rejection filter does not apply to the last event when timeWindow >= 0 \n"); printf("================================== Digesting Mapping file\n"); std::ifstream mapFile( mappingFilePath.Data() ); @@ -168,7 +179,7 @@ int main(int argn, char **argv){ hitList = reader->ReadBatchPos(BUFFERSIZE, DEBUG); blockCount += hitList.size(); - printf(" %lu block %lu / %lu | %u \n", hitList.size(), blockCount, totalBlock, eventID); + printf("File-%ld %10lu block %10lu / %lu | %u \n", i, hitList.size(), blockCount, totalBlock, eventID); if( hitList.size() == 0 ) break; for( size_t k = 0; k < hitList.size(); k++ ){ @@ -193,10 +204,12 @@ int main(int argn, char **argv){ printf("%6d, %12llu \n", event[0].energy, event[0].time); } - saveFile->cd(); - newtree->Fill(); + if( (rejectFlag & 0x8 ) && e[0] != 0 ) { + saveFile->cd(); + newtree->Fill(); + eventID ++; + } - eventID ++; event.clear(); } @@ -209,21 +222,56 @@ int main(int argn, char **argv){ }else{ //save event - multi = event.size(); + if( DEBUG ) printf("====================== event %u, event size %lu\n", eventID, event.size()); - if( DEBUG ) printf("====================== event %u, event size %u\n", eventID, multi); - for( size_t p = 0; p < multi; p++ ) { - if( DEBUG ) printf("%lu | %6d, %12llu \n", p, event[p].energy, event[p].time); + int nBGO = 0; + int nClover = 0; + int nGagg = 0; + + int count = 0 ; + for( size_t p = 0; p < event.size(); p++ ) { + if( (rejectFlag & 0x8 ) && event[p].energy == 0 ) continue; + + e[count] = event[p].energy; + e_t[count] = event[p].time; int index = event[p].crate*MAX_BOARDS_PER_CRATE*MAX_CHANNELS_PER_BOARD + (event[p].slot-BOARD_START)*MAX_CHANNELS_PER_BOARD + event[p].ch; - id[p] = mapping[index]; - e[p] = event[p].energy; - e_t[p] = event[p].time; + id[count] = mapping[index]; + + if( DEBUG ) printf("%u | %3d, %6d, %12llu \n", count, id[count], e[count], e_t[count]); + if( 0 <= id[count] && id[count] < 100 ) nClover ++; + if( 100 <= id[count] && id[count] < 200 ) nBGO ++; + if( 200 <= id[count] && id[count] < 400 ) nGagg ++; + count ++; } - saveFile->cd(); - newtree->Fill(); + multi = count; - eventID ++; + if( DEBUG ) printf("nBGO %d, nClover %d, nGagg %d \n", nBGO, nClover, nGagg); + + if( (rejectFlag & 0x1) && nBGO > 0 ) { + event.clear(); + event.push_back(*(reader->data)); + continue; + } + + if( (rejectFlag & 0x2) && nClover == 0 ) { + event.clear(); + event.push_back(*(reader->data)); + continue; + } + + if( (rejectFlag & 0x4) && nGagg == 0 ) { + event.clear(); + event.push_back(*(reader->data)); + continue; + } + + if( multi > 0 ){ + if( DEBUG ) printf("---------------> fill tree\n"); + saveFile->cd(); + newtree->Fill(); + eventID ++; + } //clear event event.clear();