/************************************************ * usr_halld.c * This routine is called from usr_analysis.F to * write out the smeared mc tracks to stdhep format. * Paul Eugenio * Carnegie Mellon University * 28 Sept 98 **********************************************/ #include #include #include #include #include #include /******************************** * Prototypes for StdHep functions. *********************************/ int StdHepXdrWiteInit(char *fileName,char *title, int ntries, int istream); int StdHepXdrWrite(int ilbl,int istream); int StdHepXdrEnd(int istream); /****************** * Local Structure ******************/ typedef struct { double x,y,z; } dvector3_t; typedef struct { double t; dvector3_t space; } dvector4_t; typedef struct { int statusCode; /* 1 is a final state particle */ int pid; /* this use the PDG MC numbering scheme */ double mass; dvector4_t p; /* four momentum */ dvector3_t v; /* a point on the track */ }mc_part_t; /******************************** * Local Prototypes *********************************/ int fill_hepevt(int nparts, mc_part_t *parts); #define MAX_PARTS 2000 #define MAX_NTRIES 1000 void pri_(int *nrec,int *nhep,int *trk_off_num,int *trk_gen_num){ fprintf(stderr,"nrec= %d nhep= %d trk_off_num= %d trk+gen_num=%d\n", *nrec, *nhep, *trk_off_num, *trk_gen_num); } void usr_halld_(int *nrec){ int ret; static int written=0; mc_part_t parts[MAX_PARTS]; int ilbl=1,istream=3,ntries = MAX_NTRIES; char *title="Halld MCFast output"; char *outputfile="halldMCFasted.evt"; /* * FOR TEST ONLY */ fprintf(stderr,"\n\n\tNREC is %d\n\n",*nrec); /* *nrec=5; */ /* * get the fortran common block structure */ fill_parts(*nrec,parts); /* * fill the stdhep event stucture */ fill_hepevt(*nrec, parts); /* * write the stdhep event to file */ /* ret=StdHepXdrWrite(ilbl,istream); */ if(!(++written %100)) fprintf(stderr,"McFast events Written: %d\r",written); } /******************** * fill_parts *******************/ int fill_parts(int nparts, mc_part_t *part){ int i; extern struct trk_off2 trk_off2_ ; for(i=0;i1) fprintf(stderr,"EventNo: %d\n",nevent); /* now loop over the particle in the event */ for(i=0;i