added rejection filter for Event Builder

This commit is contained in:
Ryan Tang 2024-05-29 16:54:55 -04:00
parent dff1bcaae6
commit a0fc38669e

View File

@ -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("%s [timeWindows] [mapping file] [Reject Flag] [SaveFileName] [*.evt File1] [*.evt File2] ...\n", argv[0]);
printf(" timeWindows [int]: 1 unit = 10 ns \n"); printf(" timeWindows [int]: 1 unit = 10 ns \n");
printf(" mapping file path [str]: the path of mapping file. \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"); printf(" SaveFileName [str]: custom save file name \n");
return 1; return 1;
} }
@ -68,6 +73,12 @@ int main(int argn, char **argv){
printf("%2ld | %s \n", i, inFileList[i].c_str()); 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"); printf("================================== Digesting Mapping file\n");
std::ifstream mapFile( mappingFilePath.Data() ); std::ifstream mapFile( mappingFilePath.Data() );
@ -168,7 +179,7 @@ int main(int argn, char **argv){
hitList = reader->ReadBatchPos(BUFFERSIZE, DEBUG); hitList = reader->ReadBatchPos(BUFFERSIZE, DEBUG);
blockCount += hitList.size(); 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; if( hitList.size() == 0 ) break;
for( size_t k = 0; k < hitList.size(); k++ ){ 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); printf("%6d, %12llu \n", event[0].energy, event[0].time);
} }
if( (rejectFlag & 0x8 ) && e[0] != 0 ) {
saveFile->cd(); saveFile->cd();
newtree->Fill(); newtree->Fill();
eventID ++; eventID ++;
}
event.clear(); event.clear();
} }
@ -209,21 +222,56 @@ int main(int argn, char **argv){
}else{ }else{
//save event //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); int nBGO = 0;
for( size_t p = 0; p < multi; p++ ) { int nClover = 0;
if( DEBUG ) printf("%lu | %6d, %12llu \n", p, event[p].energy, event[p].time); 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; 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]; id[count] = mapping[index];
e[p] = event[p].energy;
e_t[p] = event[p].time; 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 ++;
} }
multi = count;
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(); saveFile->cd();
newtree->Fill(); newtree->Fill();
eventID ++; eventID ++;
}
//clear event //clear event
event.clear(); event.clear();