added qdc flag

This commit is contained in:
Ryan Tang 2024-05-29 17:45:33 -04:00
parent a0fc38669e
commit 31f125e143
2 changed files with 31 additions and 16 deletions

View File

@ -42,7 +42,7 @@ int main(int argn, char **argv){
if (argn < 6 ) { if (argn < 6 ) {
printf("Usage :\n"); printf("Usage :\n");
printf("%s [timeWindows] [mapping file] [Reject Flag] [SaveFileName] [*.evt File1] [*.evt File2] ...\n", argv[0]); printf("%s [timeWindows] [mapping file] [Reject Flag] [QDC 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. see mapping.h\n"); printf(" Reject Flag [int]: 0 = no rejection. see mapping.h\n");
@ -51,6 +51,7 @@ int main(int argn, char **argv){
printf(" 4 = reject no GAGG\n"); printf(" 4 = reject no GAGG\n");
printf(" 8 = reject zero energy data-point\n"); printf(" 8 = reject zero energy data-point\n");
printf(" 3 = reject BGO + no gamma, 5 = reject BGO + no GAGG, etc.\n"); printf(" 3 = reject BGO + no gamma, 5 = reject BGO + no GAGG, etc.\n");
printf(" QDC Flag [int]: 0 = no qdc, 1 = with qdc\n");
printf(" SaveFileName [str]: custom save file name \n"); printf(" SaveFileName [str]: custom save file name \n");
return 1; return 1;
} }
@ -58,10 +59,11 @@ int main(int argn, char **argv){
int timeWindow = atoi(argv[1]); int timeWindow = atoi(argv[1]);
TString mappingFilePath = argv[2]; TString mappingFilePath = argv[2];
unsigned short rejectFlag = atoi(argv[3]); unsigned short rejectFlag = atoi(argv[3]);
TString outFileName = argv[4]; unsigned short qdcFlag = atoi(argv[4]);
TString outFileName = argv[5];
std::vector<std::string> inFileList; std::vector<std::string> inFileList;
for( int i = 5; i < argn; i++) inFileList.push_back(argv[i]); for( int i = 6; i < argn; i++) inFileList.push_back(argv[i]);
printf(" Mapping file Path : %s \n", mappingFilePath.Data()); printf(" Mapping file Path : %s \n", mappingFilePath.Data());
printf(" Time window : %d ticks\n", timeWindow); printf(" Time window : %d ticks\n", timeWindow);
@ -145,9 +147,12 @@ int main(int argn, char **argv){
UInt_t id[MAXMULTI] = {0}; UInt_t id[MAXMULTI] = {0};
Int_t e[MAXMULTI] = {-1}; Int_t e[MAXMULTI] = {-1};
ULong64_t e_t[MAXMULTI] = {0}; ULong64_t e_t[MAXMULTI] = {0};
UInt_t qdc[MAXMULTI][8] = {0};
newtree->Branch("id", id, "id[multi]/i" ); newtree->Branch("id", id, "id[multi]/i" );
newtree->Branch("e", e, "e[multi]/I" ); newtree->Branch("e", e, "e[multi]/I" );
newtree->Branch("e_t", e_t, "e_timestamp[multi]/l"); newtree->Branch("e_t", e_t, "e_timestamp[multi]/l");
if( qdcFlag ) newtree->Branch("qdc", qdc, "qdc[multi][8]/I");
saveFile->cd(); saveFile->cd();
@ -179,7 +184,9 @@ int main(int argn, char **argv){
hitList = reader->ReadBatchPos(BUFFERSIZE, DEBUG); hitList = reader->ReadBatchPos(BUFFERSIZE, DEBUG);
blockCount += hitList.size(); blockCount += hitList.size();
printf("File-%ld %10lu block %10lu / %lu | %u \n", i, hitList.size(), blockCount, totalBlock, eventID); // std::cout << "please wait.....";
printf("File-%ld %10lu block %10lu / %lu [%4.1f%%] | %u \r", i, hitList.size(), blockCount, totalBlock, blockCount*100./totalBlock, eventID);
fflush(stdout);
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++ ){
@ -199,16 +206,21 @@ int main(int argn, char **argv){
e[0] = event[0].energy; e[0] = event[0].energy;
e_t[0] = event[0].time; e_t[0] = event[0].time;
if( qdcFlag ) for( int i = 0; i < 8; i++) qdc[0][i] = event[0].QDCsum[i];
if( DEBUG ){ if( DEBUG ){
printf("====================== event %u, event size %u\n", eventID, multi); printf("====================== event %u, event size %u\n", eventID, multi);
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 ) { if( (rejectFlag & 0x8 ) && e[0] == 0 ) {
event.clear();
continue;
}
saveFile->cd(); saveFile->cd();
newtree->Fill(); newtree->Fill();
eventID ++; eventID ++;
}
event.clear(); event.clear();
} }
@ -236,6 +248,7 @@ int main(int argn, char **argv){
e_t[count] = event[p].time; 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[count] = mapping[index]; id[count] = mapping[index];
if( qdcFlag ) for( int i = 0; i < 8; i++) qdc[count][i] = event[p].QDCsum[i];
if( DEBUG ) printf("%u | %3d, %6d, %12llu \n", count, id[count], e[count], e_t[count]); 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( 0 <= id[count] && id[count] < 100 ) nClover ++;
@ -297,6 +310,7 @@ int main(int argn, char **argv){
id[p] = mapping[index]; id[p] = mapping[index];
e[p] = event[p].energy; e[p] = event[p].energy;
e_t[p] = event[p].time; e_t[p] = event[p].time;
if( qdcFlag ) for( int i = 0; i < 8; i++) qdc[p][i] = event[p].QDCsum[i];
} }
saveFile->cd(); saveFile->cd();
newtree->Fill(); newtree->Fill();

View File

@ -1,4 +1,5 @@
CC=g++ CC=g++
CFLAG= -O2 -w
#all: to2root evt2hist MergeEVT ev22txt EventBuilder pxi-time-order #all: to2root evt2hist MergeEVT ev22txt EventBuilder pxi-time-order
all: to2root evt2hist ev22txt EventBuilder pxi-fsu-time-order all: to2root evt2hist ev22txt EventBuilder pxi-fsu-time-order
@ -12,7 +13,7 @@ all: to2root evt2hist ev22txt EventBuilder pxi-fsu-time-order
#this is for eventbuild #this is for eventbuild
to2root: ../armory/to2root.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h to2root: ../armory/to2root.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h
$(CC) ../armory/to2root.cpp -o to2root `root-config --cflags --glibs` $(CC) $(CFLAG) ../armory/to2root.cpp -o to2root `root-config --cflags --glibs`
#this is for online root #this is for online root
# MergeEVT: ../armory/MergeEVT.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h # MergeEVT: ../armory/MergeEVT.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h
@ -20,19 +21,19 @@ to2root: ../armory/to2root.cpp ../armory/DataBlock.h ../armory/evtReader.h ../ma
#this is for online spectrums #this is for online spectrums
evt2hist: ../armory/evt2hist.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h evt2hist: ../armory/evt2hist.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h
$(CC) ../armory/evt2hist.cpp -o evt2hist `root-config --cflags --glibs` $(CC) $(CFLAG) ../armory/evt2hist.cpp -o evt2hist `root-config --cflags --glibs`
pxi-fsu-time-order: ../armory/pxi-fsu-time-order.cpp pxi-fsu-time-order: ../armory/pxi-fsu-time-order.cpp
$(CC) ../armory/pxi-fsu-time-order.cpp -o pxi-fsu-time-order $(CC) $(CFLAG) ../armory/pxi-fsu-time-order.cpp -o pxi-fsu-time-order
ev22txt: ../armory/ev22txt.cpp ev22txt: ../armory/ev22txt.cpp
$(CC) ../armory/ev22txt.cpp -o ev22txt $(CC) $(CFLAG) ../armory/ev22txt.cpp -o ev22txt
EventBuilder: ../armory/EventBuilder.cpp EventBuilder: ../armory/EventBuilder.cpp
$(CC) ../armory/EventBuilder.cpp -o EventBuilder `root-config --cflags --glibs` $(CC) $(CFLAG) ../armory/EventBuilder.cpp -o EventBuilder `root-config --cflags --glibs`
test: ../armory/test.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h test: ../armory/test.cpp ../armory/DataBlock.h ../armory/evtReader.h ../mapping.h
$(CC) ../armory/test.cpp -o test `root-config --cflags --glibs` $(CC) $(CFLAG) ../armory/test.cpp -o test `root-config --cflags --glibs`
clean: clean:
-rm xia2root to2root MergeEVT evt2hist pxi-time-order ev22txt EventBuilder test -rm xia2root to2root MergeEVT evt2hist pxi-time-order ev22txt EventBuilder test