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