fixed pxi-time-order.c for g++ compiler. add tDiff (commented out) for evt2root.cpp
This commit is contained in:
parent
bbb58ecc09
commit
3e19117a49
|
@ -31,6 +31,8 @@ public:
|
|||
UShort_t trace_length;
|
||||
Bool_t trace_out_of_range;
|
||||
|
||||
Long64_t timeDiff;
|
||||
|
||||
UShort_t id;
|
||||
|
||||
measurment(){};
|
||||
|
@ -46,6 +48,7 @@ public:
|
|||
energy = 0;
|
||||
trace_length = 0;
|
||||
trace_out_of_range = 0;
|
||||
timeDiff = 0;
|
||||
id = 0;
|
||||
}
|
||||
|
||||
|
@ -72,12 +75,12 @@ int main(int argn, char **argv) {
|
|||
outFileName.Remove(inFileName.First('.'));
|
||||
outFileName.Append("_raw.root");
|
||||
|
||||
long int inFilePos;
|
||||
long int inFilePos = 0;
|
||||
TBenchmark gClock;
|
||||
gClock.Reset();
|
||||
gClock.Start("timer");
|
||||
|
||||
ULong64_t measureID = 0;
|
||||
Long64_t measureID = -1;
|
||||
|
||||
measurment data;
|
||||
|
||||
|
@ -102,23 +105,26 @@ int main(int argn, char **argv) {
|
|||
TFile * outFile = new TFile(outFileName, "recreate");
|
||||
TTree * tree = new TTree("tree", "tree");
|
||||
|
||||
tree->Branch("evID", &measureID, "data_ID/l");
|
||||
tree->Branch("evID", &measureID, "data_ID/L");
|
||||
tree->Branch("detID", &data.id, "det_ID/s");
|
||||
tree->Branch("e", &data.energy, "energy/s");
|
||||
tree->Branch("t", &data.time, "time_stamp/l");
|
||||
//tree->Branch("tdiff", &data.timeDiff, "time_Diff/L");
|
||||
|
||||
//=======TODO online event building
|
||||
|
||||
unsigned int header[4]; //read 4 header, unsigned int = 4 byte = 32 bits.
|
||||
unsigned long long nWords = 0;
|
||||
|
||||
ULong64_t timeLast = 0;
|
||||
|
||||
//=============== Read File
|
||||
/// while ( ! feof(inFile) ){
|
||||
while ( inFilePos <= inFileSize ){ // need to check is the last data included.
|
||||
while ( inFilePos <= inFileSize ){
|
||||
|
||||
fread(header, sizeof(header), 1, inFile);
|
||||
inFilePos = ftell(inFile);
|
||||
measureID ++;
|
||||
measureID ++;
|
||||
|
||||
/// see the Pixie-16 user manual, Table4-2
|
||||
data.ch = header[0] & 0xF ;
|
||||
|
@ -137,11 +143,20 @@ int main(int argn, char **argv) {
|
|||
|
||||
nWords += data.eventLength;
|
||||
|
||||
///printf("----------------------nWords: %llu, inFilePos: %llu\n", nWords, inFilePos);
|
||||
///for(int i = 0; i < 4; i++){
|
||||
/// printf(" %x\n", header[i]);
|
||||
///}
|
||||
///data.Print();
|
||||
//if( measureID == 0 ) {
|
||||
// data.timeDiff = 0;
|
||||
//}else{
|
||||
// data.timeDiff = (Long64_t) data.time - timeLast;
|
||||
//}
|
||||
//timeLast = data.time;
|
||||
|
||||
//if( data.timeDiff == false ){
|
||||
// printf("----------------------nWords: %llu, inFilePos: %lu\n", nWords, inFilePos);
|
||||
// for(int i = 0; i < 4; i++){
|
||||
// printf(" %x\n", header[i]);
|
||||
// }
|
||||
// data.Print();
|
||||
//}
|
||||
|
||||
//=== jump to next measurement
|
||||
if( data.eventLength > 4 ){
|
||||
|
@ -156,7 +171,7 @@ int main(int argn, char **argv) {
|
|||
gClock.Stop("timer");
|
||||
double time = gClock.GetRealTime("timer");
|
||||
gClock.Start("timer");
|
||||
printf("Total measurements: \x1B[32m%llu \x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\nTime used:%3.0f min %5.2f sec\033[A\033[A\r",
|
||||
printf("Total measurements: \x1B[32m%lld \x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\nTime used:%3.0f min %5.2f sec\033[A\033[A\r",
|
||||
measureID, (100*inFilePos/inFileSize), tempf, TMath::Floor(time/60.), time - TMath::Floor(time/60.)*60.);
|
||||
}
|
||||
|
||||
|
@ -171,7 +186,7 @@ int main(int argn, char **argv) {
|
|||
double time = gClock.GetRealTime("timer");
|
||||
gClock.Start("timer");
|
||||
float tempf = (float)inFileSize/(1024.*1024.*1024.);
|
||||
printf("Total measurements: \x1B[32m%llu \x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\nTime used:%3.0f min %5.2f sec\033[A\r",
|
||||
printf("Total measurements: \x1B[32m%lld \x1B[0m\nPercent Complete: \x1B[32m%ld%% of %.3f GB\x1B[0m\nTime used:%3.0f min %5.2f sec\033[A\r",
|
||||
measureID, (100*inFilePos/inFileSize), tempf, TMath::Floor(time/60.), time - TMath::Floor(time/60.)*60.);
|
||||
|
||||
fclose(inFile);
|
||||
|
|
|
@ -170,7 +170,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
//Get memory for default number of subevents per channel id
|
||||
for (i=0; i<MAX_ID; i++){
|
||||
subevents[i] = malloc(sizeof(struct subevent)*DEF_SUB_EVENTS);
|
||||
subevents[i] = (struct subevent *)malloc(sizeof(struct subevent)*DEF_SUB_EVENTS);
|
||||
if (subevents[i] == NULL) {
|
||||
printf("malloc failed\n");
|
||||
return -1;
|
||||
|
@ -261,7 +261,7 @@ int main(int argc, char **argv) {
|
|||
if (maxevts[id] == M5_SUB_EVENTS) {evts_old = M5_SUB_EVENTS; evts_new = MAX_SUB_EVENTS;}
|
||||
|
||||
if (maxevts[id]==evts_old && totmem + (evts_new-evts_old)*(sizeof(struct subevent) + sizeof(unsigned int)*length) < MAX_MALLOC) {
|
||||
subevents[id] = realloc(subevents[id], sizeof(struct subevent)*evts_new);
|
||||
subevents[id] = (struct subevent *) realloc(subevents[id], sizeof(struct subevent)*evts_new);
|
||||
if (subevents[id] == NULL) {
|
||||
printf("realloc failed\n");
|
||||
return -1;
|
||||
|
@ -278,7 +278,7 @@ int main(int argc, char **argv) {
|
|||
if (iptr[id] + nevts[id] > evts_old) {
|
||||
for (j=0; j<iptr[id] + nevts[id] - evts_old; j++) {
|
||||
if (subevents[id][evts_old+j].data == NULL) {
|
||||
subevents[id][evts_old+j].data = malloc(sizeof(unsigned int)*subevents[id][j].length);
|
||||
subevents[id][evts_old+j].data = (unsigned int *)malloc(sizeof(unsigned int)*subevents[id][j].length);
|
||||
if (subevents[id][evts_old+j].data == NULL) {
|
||||
printf("malloc failed\n");
|
||||
return -1;
|
||||
|
@ -318,7 +318,7 @@ int main(int argc, char **argv) {
|
|||
subevents[id][j].timestamp = time;
|
||||
|
||||
if (subevents[id][j].data == NULL) {
|
||||
subevents[id][j].data = malloc(sizeof(unsigned int)*length);
|
||||
subevents[id][j].data = (unsigned int * )malloc(sizeof(unsigned int)*length);
|
||||
if (subevents[id][j].data == NULL) {
|
||||
printf("malloc failed\n");
|
||||
return -1;
|
||||
|
@ -326,7 +326,7 @@ int main(int argc, char **argv) {
|
|||
totmem += sizeof(unsigned int)*length;
|
||||
}
|
||||
else if (length != subevents[id][j].length) { //not needed anymore since always free data after use now. Keep for future ...
|
||||
subevents[id][j].data = realloc(subevents[id][j].data, sizeof(unsigned int)*length);
|
||||
subevents[id][j].data = (unsigned int *)realloc(subevents[id][j].data, sizeof(unsigned int)*length);
|
||||
if (subevents[id][j].data == NULL) {
|
||||
printf("realloc failed\n");
|
||||
return -1;
|
||||
|
@ -402,8 +402,7 @@ int main(int argc, char **argv) {
|
|||
|
||||
|
||||
//print statistics
|
||||
e_div=div(evts_tot_read,10000);
|
||||
if ( e_div.rem == 0)
|
||||
if ( evts_tot_read % 10000 == 0)
|
||||
printf("Malloc (%d MB) : evts in (\x1B[34m%lld\x1B[0m) : evts out (\x1B[32m%lld\x1B[0m) : diff (\x1B[31m%lld\x1B[0m)\r", (totmem)/1024/1024, evts_tot_read, evts_tot_write, evts_tot_read-evts_tot_write);
|
||||
|
||||
} //end main while
|
||||
|
|
6
makefile
6
makefile
|
@ -2,7 +2,7 @@ CC=g++
|
|||
|
||||
#all: xia2root xia2ev2_nopart pixie2root scan pxi-time-order
|
||||
#all: xia2root xia2ev2_nopart pixie2root scan evt2root evt2hist
|
||||
all: xia2root pixie2root evt2root evt2hist
|
||||
all: xia2root pixie2root evt2root evt2hist pxi-time-order
|
||||
|
||||
#this is FSU evt to root
|
||||
xia2root: armory/xia2root.cpp
|
||||
|
@ -23,5 +23,5 @@ evt2root: armory/evt2root.cpp
|
|||
evt2hist: armory/evt2hist.cpp
|
||||
$(CC) armory/evt2hist.cpp -o evt2hist `root-config --cflags --glibs`
|
||||
|
||||
#pxi-time-order: pxi-time-order.c
|
||||
# $(CC) pxi-time-order.c -o pxi-time-order
|
||||
pxi-time-order: armory/pxi-time-order.c
|
||||
$(CC) armory/pxi-time-order.c -o pxi-time-order
|
||||
|
|
Loading…
Reference in New Issue
Block a user