/******************************************************************************/ /* test of tracks from HEP list */ /******************************************************************************/ /**************************/ /* STANDARD INCLUDE FILES */ /**************************/ #include #include #include #include #include #include /*************************************/ /* EXPLORER AND mcf_explorer INCLUDE FILES */ /*************************************/ #include #include #include #include "Mcf_Explorer_typedefs.h" #include "Mcf_Explorer_prototypes.h" #include "Mcf_Explorer_externs.h" #include "McfReadEvent.h" #include "McfEvent.h" #include "McfPositionUtil.h" #define True 1 #define False 0 int GeomInitDone = False; void TraceDisplay ( cxGeometry * * geoOut, cxLattice * * heplat, cxParameter * File, int Fn_changed, int donext, int eventnumber, int eventnchanged, long PlotTrace, int PlotTraceChanged, long PlotTrack, int PlotTrackChanged, long PlotNeutr, int PlotNeutrChanged, long PlotHit, int PlotHitChanged, double EtaMin, int EtaMinChanged, double EtaMax, int EtaMaxChanged, long PlotAxis, int PlotAxisChanged, long MomSwitch, int MomSwitchChanged, double MomCut, int MomCutChanged, int PickTraceInfo, int PickHepNum, int PickHepNumChanged, int Reset, double RadMax, int RadMaxChanged); void open_display(cxGeometry **geoOut); void geom_init(); void geom_exit(cxGeometry *geoOut); void cleanup_selected(cxGeometry *geoLocal); void cleanup_geometry(cxGeometry *geoLocal); int TraceDisplayAddAxis(void); void TraceDisplay ( cxGeometry * * geoOut, cxLattice * * heplat, cxParameter * File, int Fn_changed, int donext, int eventnumber, int eventnchanged, long PlotTrace, int PlotTraceChanged, long PlotTrack, int PlotTrackChanged, long PlotNeutr, int PlotNeutrChanged, long PlotHit, int PlotHitChanged, double EtaMin, int EtaMinChanged, double EtaMax, int EtaMaxChanged, long PlotAxis, int PlotAxisChanged, long MomSwitch, int MomSwitchChanged, double MomCut, int MomCutChanged, int PickTraceInfo, int PickHepNum, int PickHepNumChanged, int Reset, double RadMax, int RadMaxChanged){ int evenno; int status = 0; long nhep = 0; static int first = 0; static int stream = 0; int firstevent = 0; int count; int icount, info; float *hepdata; float *latdata; char *FileName; char string[30]; char font[] = "-sgi-fixed-bold-r-normal--24-170-100-100-c-120-iso8859-3"; if(first == 0){ mcfioC_Init(); first = 1; PlotTrace = 1; PlotTrack = 1; PlotNeutr = 0; PlotHit = 0; PlotAxis = 1; EtaMin = -10.; EtaMax = 10.; MomSwitch = 0; MomCut = 0.0; return; } if(Fn_changed != 0) { FileName = (char *) malloc(FILENAME_MAX * sizeof(char)); FileName = cxParamPathnameGet( File ); printf("filename = %s\n",FileName); stream = Mcf_OpenFile(FileName); firstevent = 1; } if (stream < 0){ printf("open failure, file %s\n",FileName); printf("Check to make sure file exists and is McFio output\n"); return; } if(donext != 0 || firstevent !=0){ status = Mcf_ReadEvent(stream,&evenno); if(status < 0){ printf("Problem with McFio next event. Try reopening file\n"); return; } cxInWdgtLongSet("EventNumber",evenno); McfDefineTrace(); Reset = 1; if(status<0){ return; } } count = sprintf(string,"Event Number = %d",evenno); if(donext != 0 || firstevent != 0 || PlotTraceChanged != 0 || PlotTrackChanged != 0 || PlotNeutrChanged != 0 || PlotHitChanged != 0 || PlotAxisChanged != 0 || EtaMinChanged != 0 || EtaMaxChanged != 0 || MomCutChanged != 0 || MomSwitchChanged != 0 || eventnchanged != 0 || RadMaxChanged != 0 || McfSetDisp(Reset,PickTraceInfo,PickHepNum) != 0){ open_display(geoOut); McfTracePosition(PlotTrack, PlotTrace, PlotNeutr, PlotHit, EtaMin, EtaMax, MomSwitch, MomCut, RadMax); if(PlotAxis == 1){ TraceDisplayAddAxis(); } geom_exit(*geoOut); } McfHepLattice(&nhep, &hepdata); *heplat = cxLatDataNew( 1, &nhep, HEPLATDATASIZE, cx_prim_float); cxLatPtrGet(*heplat,NULL,(void **)&latdata,NULL,NULL); for(icount = 0; icount < nhep; icount++){ for(info = 0; info < HEPLATDATASIZE; info++){ latdata[icount*HEPLATDATASIZE + info] = hepdata[icount*HEPLATDATASIZE + info]; } } free(hepdata); /*hepdata gets malloced in McfHepLattice*/ } void open_display(cxGeometry **geoOut) { cxGeometry *geoLocal; printf("ENTER: open_display()\n"); if(GeomInitDone == False ) { cxGeoInit(); printf("initializing geometry\n"); GeomInitDone = True; } /* Initialize geometry object and prepare for data; */ geoLocal = cxGeoNew(); if( cxDataAllocErrorGet() ) cleanup_geometry(geoLocal); cxGeoBufferSelect(geoLocal); cxGeoRoot(); if( cxDataAllocErrorGet() ) cleanup_selected(geoLocal); cxGeoDelete(); if( cxDataAllocErrorGet() ) cleanup_selected(geoLocal); *geoOut = geoLocal; printf("LEAVE: open_display()\n"); } /********************************************/ /* Display close down and output procedures */ /********************************************/ void geom_exit(cxGeometry *geoOut) { printf("\n\n\nENTER: geom_exit()\n"); cxGeoBufferClose(geoOut); printf("LEAVE: geom_exit()\n"); return; } /* Clean up geometry if out of memory */ void cleanup_selected(cxGeometry *geoLocal) { printf("ENTER: cleanup_selected()\n"); cxGeoBufferClose(geoLocal); cleanup_geometry(geoLocal); printf("LEAVE: cleanup_selected()\n"); } void cleanup_geometry(cxGeometry *geoLocal) { printf("ENTER: cleanup_geometry()\n"); cxDataRefDec(geoLocal); printf("LEAVE: cleanup_geometry()\n"); return; } void Mcf_HepTrackDisplay(struct Position begin, struct Position end, float color[3]){ int nvert = 3; float vert[9]; float radius = 10.; float radius2 = 20.; int check; printf("entering Mcf_HepTrackDisplay\n"); /* cxGeoColorAdd(1,&color[0],CX_GEO_PER_OBJECT); */ printf("called geometry Mcf_HepTrackDisplay\n"); vert[0] = begin.x; vert[1] = begin.y; vert[2] = begin.z; vert[3] = end.x; vert[4] = end.y; vert[5] = end.z; vert[6] = end.x + 10; vert[7] = end.y + 10; vert[8] = end.z; cxGeoCylindersDefine(1,&vert[0],&vert[3],&radius); /*cxGeoConesDefine(1,&vert[3],&vert[6],&radius2);*/ cxGeoColorAdd(1,&color[0],CX_GEO_PER_OBJECT); } int McfTraceDisplay(int nvert, struct Position *pos, float *color, int id){ /* first version--nice green lines, connect the dots */ int n, count; double len; static double avelen = 0.0; int nvcomp = 0; float *pv; char sid[30]; if(nvert < 1){ printf(" McfTraceDisplay: must define vertices before call\n"); return -1; } if(nvert < 2){ printf(" McfTraceDisplay: not enough traces on track\n"); return -2; } nvcomp = TraceCompress(nvert, pos); pv = (float *) malloc((nvcomp*3)*sizeof(float)); for(n=0; n=cutoff){ next = n3 + 1; n2 = n3; n3 = next; }else{ nvcomp++; p[nvcomp].x = temp[n2].x; p[nvcomp].y = temp[n2].y; p[nvcomp].z = temp[n2].z; next = n3 + 1; n1 = n2; n2 = n3; n3 = next; } } nvcomp++; p[nvcomp].x = temp[nvert-1].x; p[nvcomp].y = temp[nvert-1].y; p[nvcomp].z = temp[nvert-1].z; nvcomp++; free(temp); return nvcomp; }