bugfix on EventBuilder

This commit is contained in:
Ryan Tang 2022-01-06 20:34:41 -05:00
parent c13738e699
commit 6b7f165ac2

View File

@ -13,7 +13,7 @@
#include "../mapping.h" #include "../mapping.h"
#define MAXMULTI 200 #define MAXMULTI 100
int main(int argn, char **argv){ int main(int argn, char **argv){
printf("=====================================\n"); printf("=====================================\n");
@ -91,9 +91,9 @@ int main(int argn, char **argv){
Int_t multiCry = 0 ; /// thi is total multiplicity for all crystal Int_t multiCry = 0 ; /// thi is total multiplicity for all crystal
newtree->Branch("multiCry", &multiCry, "multiplicity_crystal/I"); newtree->Branch("multiCry", &multiCry, "multiplicity_crystal/I");
int id[MAXMULTI]; int id[MAXMULTI] = {0};
double e[MAXMULTI]; double e[MAXMULTI] = {TMath::QuietNaN()};
ULong64_t e_t[MAXMULTI]; ULong64_t e_t[MAXMULTI] = {0};
newtree->Branch("id", id, "id[multi]/I" ); newtree->Branch("id", id, "id[multi]/I" );
newtree->Branch("e", e, "e[multi]/D" ); newtree->Branch("e", e, "e[multi]/D" );
newtree->Branch("e_t", e_t, "e_timestamp[multi]/l"); newtree->Branch("e_t", e_t, "e_timestamp[multi]/l");
@ -103,8 +103,9 @@ int main(int argn, char **argv){
TStopwatch StpWatch; TStopwatch StpWatch;
StpWatch.Start(); StpWatch.Start();
for( Long64_t entry = 0; entry < totnumEntry; entry++){ int multiOverflow = 0;
for( Long64_t entry = 0; entry < totnumEntry; entry++){
/*********** Progress Bar ******************************************/ /*********** Progress Bar ******************************************/
if (entry>totnumEntry*Frac-1) { if (entry>totnumEntry*Frac-1) {
@ -116,11 +117,11 @@ int main(int argn, char **argv){
Frac+=0.1; Frac+=0.1;
} }
entry = index[entry]; Long64_t ev = index[entry];
b_ID->GetEntry(entry, 0); b_ID->GetEntry(ev, 0);
b_energy->GetEntry(entry, 0); b_energy->GetEntry(ev, 0);
b_energy_timestamp->GetEntry(entry, 0); b_energy_timestamp->GetEntry(ev, 0);
if( time0 == 0) { if( time0 == 0) {
time0 = energy_t; time0 = energy_t;
@ -130,12 +131,15 @@ int main(int argn, char **argv){
if( timeDiff < timeWindow ) { if( timeDiff < timeWindow ) {
id[multi] = detID; if( multi > MAXMULTI ){
e[multi] = energy; multiOverflow++;
e_t[multi] = energy_t; }else{
multi ++; id[multi] = detID;
if( detID < NCRYSTAL ) multiCry++; e[multi] = energy;
e_t[multi] = energy_t;
multi ++;
if( detID < NCRYSTAL ) multiCry++;
}
}else{ }else{
///---- end of event ///---- end of event
saveFile->cd(); saveFile->cd();
@ -143,7 +147,7 @@ int main(int argn, char **argv){
eventID ++; eventID ++;
///---- clear data ///---- clear data
for( int i = 0; i < multi ; i ++){ for( int i = 0; i < MAXMULTI ; i ++){
id[i] = 0; id[i] = 0;
e[i] = TMath::QuietNaN(); e[i] = TMath::QuietNaN();
e_t[i] = 0; e_t[i] = 0;
@ -161,9 +165,7 @@ int main(int argn, char **argv){
e_t[multi] = energy_t; e_t[multi] = energy_t;
multi++; multi++;
if( detID < NCRYSTAL ) multiCry++; if( detID < NCRYSTAL ) multiCry++;
} }
} }
printf("============================== finished.\n"); printf("============================== finished.\n");
@ -172,6 +174,6 @@ int main(int argn, char **argv){
newtree->Write(); newtree->Write();
saveFile->Close(); saveFile->Close();
printf(" total number of event Built : %d \n", eventID); printf(" total number of event Built : %d \n", eventID);
printf(" total event has multi > %6d : %d \n", MAXMULTI, multiOverflow);
} }