/********************************************* * write_geant_file.c * * * May 18, 1998 Kathy Turner *********************************************/ #include "write_geant_file.h" #include #include #include long write_geant_file_ (TABLE_HEAD_ST *g2t_tpc_hit_h, G2T_TPC_HIT_ST *g2t_tpc_hit, TABLE_HEAD_ST *g2t_track_h, G2T_TRACK_ST *g2t_track, TABLE_HEAD_ST *wgf_params_h, WGF_PARAMS_ST *wgf_params) { /* Initialize counters */ int ievent = 0; int nchans = 0; int ip; /* local variable */ FILE *outtrackFile; FILE *outtpchitFile; /* ----------------------------------------------------------*/ /* increase event counter */ ievent++; printf("IN write_geant_file.c!! - nevents = %d\n",ievent); printf(" output file name is %s\n",wgf_params[0].fntrack); printf(" output file name is %s\n",wgf_params[0].fntpchit); printf(" write(1=yes) g2t_track,g2t_tpc_hit table? %d\n", wgf_params[0].dump_track,wgf_params[0].dump_tpc_hits); printf(" --> IN write_geant_file.c, number of g2t_track rows = %d\n", g2t_track_h->nok); printf(" --> IN write_geant_file.c, number of g2t_tpc_hit rows = %d\n", g2t_tpc_hit_h->nok); /* Open the file */ errno=0; if (ievent == 1) { if (wgf_params[0].dump_track == 1) { outtrackFile = fopen(wgf_params[0].fntrack,"w"); if(outtrackFile == NULL) { printf("Could not open output track file!\n Exiting...\n"); printf(" error message is: %s\n",strerror(errno)); exit(1); } } if (wgf_params[0].dump_tpc_hits == 1) { outtpchitFile = fopen(wgf_params[0].fntpchit,"w"); if(outtpchitFile == NULL) { printf("Could not open output tpc hits file!\n Exiting...\n"); printf(" error message is: %s\n",strerror(errno)); exit(1); } } } /* WRITE OUT TO track FILE */ if (wgf_params[0].dump_track == 1) { fprintf(outtrackFile," dump g2t track, Event --> %d\n",ievent); nchans = 0; for(ip=0; ipnok; ip++) { nchans++; fprintf(outtrackFile,"%d %d %d %f %f %f %f %f %d\n", nchans, g2t_track[ip].id, g2t_track[ip].ge_pid, g2t_track[ip].eta, g2t_track[ip].pt, g2t_track[ip].p[0], g2t_track[ip].p[1], g2t_track[ip].p[2], g2t_track[ip].n_tpc_hit); } } /* WRITE OUT TO tpc hit FILE */ if (wgf_params[0].dump_tpc_hits == 1) { fprintf(outtpchitFile," dump g2t tpc hits, Event --> %d\n",ievent); nchans = 0; for(ip=0; ipnok; ip++) { nchans++; fprintf(outtpchitFile,"%d %d %d %f %f %f %f %f %f\n", nchans, g2t_tpc_hit[ip].track_p, g2t_tpc_hit[ip].volume_id, g2t_tpc_hit[ip].p[0], g2t_tpc_hit[ip].p[1], g2t_tpc_hit[ip].p[2], g2t_tpc_hit[ip].x[0], g2t_tpc_hit[ip].x[1], g2t_tpc_hit[ip].x[2]); } } /*===================================================*/ return STAFCV_OK; }