*------------------------------------------------------------------------ * RECONG Gen Target & HMS reconstruction * -======- * * HMS reconstruction including the effects of vertical beam offsets * and the Gen target magnetic field * - reads the data from a PAW/hbook ntuple written by hms.f * - writtes the results to a new PAW/hbook ntuple file * * written by Markus Muehlbauer *------------------------------------------------------------------------ IMPLICIT NONE REAL pi180 PARAMETER (pi180 = 3.141592653/180.) INTEGER nwpawc,icycle,istat PARAMETER (nwpawc = 1000000) REAL paw(nwpawc) COMMON /pawc/paw CHARACTER*8 tags(17) REAL event(17),param(20) CHARACTER name1*80,name2*80,name3*80 CHARACTER filename1*80,filename2*80 DATA tags/'x0','dx0dz','y0','dy0dz','z0','delta0', + 'x', 'dxdz', 'y', 'dydz', 'z', + 'x1','dx1dz','y1','dy1dz','z1','delta1'/ ! other variables REAL tht_e,tht_B,E,x,y INTEGER i,j,cnt 10 FORMAT (X,A,$) 20 FORMAT (A) PRINT *,'RECON - struct simulated Gen data' PRINT *,'===== (including the Gen target effects)' PRINT * PRINT * PRINT 10,'Enter the name of the event file: ' READ (5,20) filename1 PRINT 10,'Enter the name of the reconstruction matrix: ' READ (5,20) filename2 ! init HBOOK CALL hlimit(nwpawc) ! open the data ntuple file name1 = filename1(:INDEX(filename1,' ')-1)//'.hbook' print *, 'Opening the event data file '//name1(:index(name1,' ')) CALL hropen(20,'Input',name1,' ',4096,istat) CALL hcdir ('//Input',' ') CALL hrin (0,999999,0) ! get the parameters CALL hunpak (1,param,' ',20) tht_e = param(2) tht_B = param(3) E = param(4) - param(5) ! and prepare for the access of the data n-tuple CALL hgnpar(20,'MAIN') CALL hnoent(20,cnt) ! read the transport and field matrices name1 = 'fwd_maps.dat' name2 = filename2(:INDEX(filename2,' ')-1)//'.map' name3 = 'field_map.dat' print *,'Reading the transport ('// > name1(:index(name1,' ')-1)//')' print *,' reconstruction ('// > name2(:index(name2,' ')-1)//')' print *,' and field ('// > name3(:index(name3,' ')-1)//') maps' CALL genInitRecon (name2,name3,tht_B,name1,9,tht_e,E) ! open the data ntuple file name1 = filename1(:INDEX(filename1,' ')-1)//'.hbook' print *, 'Reading the event data '//name1(:index(name1,' ')) ! open the reconstructed data ntuple file name1 = filename1(:INDEX(filename1,' ')-1)//'_'// > filename2(:INDEX(filename2,' ')-1)//'.hbook' print *, 'Writing the reconstructed data ' > //name1(:index(name1,' ')) CALL hropen(21,'Output',name1,'NX',4096,istat) CALL hcdir ('//Output',' ') CALL hbookn(30,'Reconstructed Events',17,'//Output',4096,tags) tht_e = tht_e*pi180 DO i=1,cnt CALL hcdir ('//Input',' ') CALL hgnf (20,i,event,j) ! calculate beam coordinates x = event(1) y = cos(tht_e)*event(3) - sin(tht_e)*event(5) ! reconstruct target coordinates CALL genRecon (event(7),x,y,event(12)) ! print *,event(3),event(5),event(14),event(16) ! print *,cos(tht_e),sin(tht_e) ! print *,cos(tht_e)*event(3) - sin(tht_e)*event(5), ! > cos(tht_e)*event(5) + sin(tht_e)*event(3) ! print *,cos(tht_e)*event(14) - sin(tht_e)*event(16), ! > cos(tht_e)*event(16) + sin(tht_e)*event(14) CALL hcdir ('//Output',' ') CALL hfn (30,event) ENDDO CALL hdelet(10) CALL hdelet(20) CALL hrout(0,ICYCLE,' ') CALL hrend('Output') CALL hrend('Input') STOP END