diff --git a/CALIBRATION/hodo_calib/.gitignore b/CALIBRATION/hodo_calib/.gitignore index 40514c5fb4efe423e5d1ee0f591e78e884595fe5..016c032149ef893d377ab44447f60deaef632e6a 100644 --- a/CALIBRATION/hodo_calib/.gitignore +++ b/CALIBRATION/hodo_calib/.gitignore @@ -1,10 +1,4 @@ -fort.15 -hmsfort.37 -hmstofcal.179 -shmsfort.37 -tofcal.adchist -tofcal.out +*.37 tofcal.param tofcal.parampass1 -tofcal.tdchist tofcal diff --git a/CALIBRATION/hodo_calib/README.md b/CALIBRATION/hodo_calib/README.md new file mode 100644 index 0000000000000000000000000000000000000000..d8eeda006003541d5f8b349e688351afe57d26ad --- /dev/null +++ b/CALIBRATION/hodo_calib/README.md @@ -0,0 +1,50 @@ +Hodoscope Calibrations +============================================ +This is directory contains the code for calibrating the hodoscope timing +in SHMS and HMS + +Directory structure +---------------------- +* tofcal.f : Fortran code which execute the calibration. +* Maketof : Script to compile tofcal.f and make executable tofcal +* tofcal.inp : Input file for tofcal.f +* shmstofcal.inp : Version of tofcal.inp for SHMS +* hmstofcal.inp : Version of tofcal.inp for HMS + + + +Compiling code +-------------- +* Execute ./Maketof + +Running code +----------- +* First replay data with either +** HMS: gHcParms->Load("PARAM/HMS/HODO/htofcal.param"); +** SHMS: gHcParms->Load("PARAM/HMS/HODO/ptofcal.param"); +* The replay should put the new file : hfort.37 or pfort.37 in the CALIBRATION/hodo_calib directory +* Copy either hmstofcal.inp or shmstofcal.inp to tofcal.inp +* Execute ./tofcal +* Print out info on the initial chi2 of data and final chi2 of the fit. +* Creates file tofcal.param +* Edit the parameters in tofcal.param into either PARAM/HMS/HODO/hhodo.param or PARAM/SHMS/HODO/phodo.param + +Brief decription of code +------------------------ +* The code fits tcorr = time - offset - path * velocity - adccor / sqrt(ADC) +* Uses paddle 10 positive PMT on plane 1 as the reference PMT ( offset fixed at 0) +* To get data file name. Reads-in the input file: tofcal.inp +* Opens data file +** "0" line separates events +** Should have pair of neg and pos PMTs for each paddle +** Format is : iside ipl ipad tdcval_uncorr pathl zcor tdcval_corr adcval +*** iside =1,2 for pos and neg PMT +*** ipl = plane number +*** tdcval_uncorr = raw time in ns. The program uses this in optimization. +*** pathl = distance for focal plane to the paddle using the track +*** zcor = time (ns) for the particle to go from focal plane to paddle. Correction subtracted from tdcval_uncrr +*** tdcval_corr = the corrected time in ns. Not used by program. Just gives the initial chi2. +*** adcval = ADC value used in fit +* Loops through data determines the number of hits in each PMT. Will only include PMT if the number of hits > 100. +* Again loops through the data filling array with time difference between all pairs PMTs, pathl and adcval. +* Use the CERNLIB routine deqn to invert the matrix and determine the fit parameters. \ No newline at end of file diff --git a/CALIBRATION/hodo_calib/hmstofcal.inp b/CALIBRATION/hodo_calib/hmstofcal.inp index 325dbd14d83cd7cd629217f788fdc97b58a26240..74c9201d09ee6fe80fc9ebae35b01583bc0ec14d 100644 --- a/CALIBRATION/hodo_calib/hmstofcal.inp +++ b/CALIBRATION/hodo_calib/hmstofcal.inp @@ -1,8 +1,4 @@ -hmsfort.37 -hmstofcal.53411 -sostofcal.46765 -htmp -hmstofcal +hfort.37 diff --git a/CALIBRATION/hodo_calib/shmstofcal.inp b/CALIBRATION/hodo_calib/shmstofcal.inp index bfb05b8427e4f06ac0ae9ff00a7eb951871e4aa9..dfa7acf81725110f68e703df566aead6d3eb3453 100644 --- a/CALIBRATION/hodo_calib/shmstofcal.inp +++ b/CALIBRATION/hodo_calib/shmstofcal.inp @@ -1,8 +1,4 @@ -shmsfort.37 -hmstofcal.53411 -sostofcal.46765 -htmp -shmstofcal +pfort.37 diff --git a/CALIBRATION/hodo_calib/tofcal.f b/CALIBRATION/hodo_calib/tofcal.f index 5fe197d5b13077a475d28e153079eb8bab20ed41..0239fbedd69aac9b680d4e6654a167e3584c8e3b 100644 --- a/CALIBRATION/hodo_calib/tofcal.f +++ b/CALIBRATION/hodo_calib/tofcal.f @@ -37,20 +37,20 @@ open(unit=7,file='tofcal.inp') read(7,'(a)') filename - open(unit=8,file='tofcal.out') +c open(unit=8,file='tofcal.out') open(unit=11,file='tofcal.parampass1') open(unit=12,file='tofcal.param') - open(unit=13,file='tofcal.adchist') - write(13,'(1x,'' xv'',50f5.0)') (20.*(j-0.5),j=1,50) - open(unit=14,file='tofcal.tdchist') - write(14,'(1x,'' xv'',50f5.1)') (-5.0+0.2*(j-0.5),j=1,50) +c open(unit=13,file='tofcal.adchist') +c write(13,'(1x,'' xv'',50f5.0)') (20.*(j-0.5),j=1,50) +c open(unit=14,file='tofcal.tdchist') +c write(14,'(1x,'' xv'',50f5.1)') (-5.0+0.2*(j-0.5),j=1,50) ! first see how many hits per PMT: need at least 100 for fitting ! also make ADC histograms open(unit=9,file=filename,err=998) - if(filename(1:1).ne.'h'.and.filename(1:1).ne.'s') then + if(filename(1:1).ne.'h'.and.filename(1:1).ne.'p') then write(6,'(1x,''error, input file name '', - > '' sould start with h or s'')') + > '' should start with h or p'')') goto 999 endif write(*,*) ' filling adc histograms' @@ -77,7 +77,7 @@ 10 do i=1,200 adcmin(i)=50. if(nhit0(i).gt.0.) then - write(13,'(i3,50i4)') i,(min(999,adchistf(i,j)),j=1,50) +c write(13,'(i3,50i4)') i,(min(999,adchistf(i,j)),j=1,50) hival=0. k=0 do j=1,17 @@ -102,7 +102,7 @@ c write(13,'(1x,''adcmin='',f6.1)') adcmin(i) ! Do everything twice, 2nd time with tighter tolerance (ttol) on ! time differences, based on first pass - ttol=20.0 + ttol=10.0 do iloop=1,2 write(*,*) ' loop = ',iloop ! Initialize the fitting arrays @@ -179,7 +179,7 @@ c adc(n) = min(500, max(0., adc(n))) ipdet(nparam)=idet(j) iptyp(nparam)=3 k=idet(j) - write(8,'(1x,i3,4i5)') k,nhit(k),ip1(k),ip2(k),ip3(k) +c write(8,'(1x,i3,4i5)') k,nhit(k),ip1(k),ip2(k),ip3(k) endif enddo ! loop over n @@ -275,7 +275,7 @@ c adc(n) = min(500, max(0., adc(n))) if(iloop.eq.1) then do i=1,200 if(sum1(i).gt.0.) then - write(13,'(i3,18i4)') i,(phist(i,j),j=1,18) +c write(13,'(i3,18i4)') i,(phist(i,j),j=1,18) endif enddo endif @@ -285,8 +285,8 @@ c adc(n) = min(500, max(0., adc(n))) mean0(i)=sum2(i)/sum1(i) sig0(i)=sqrt(sum3(i)/sum1(i) - mean0(i)**2) endif - write(8,'(1x,i3,i5,2f6.2,10i5)') i,nhit(i), - > mean0(i),sig0(i),(min(9999,thist(i,j)),j=1,10) +c write(8,'(1x,i3,i5,2f6.2,10i5)') i,nhit(i), +c > mean0(i),sig0(i),(min(9999,thist(i,j)),j=1,10) sum1(i)=0. sum2(i)=0. sum3(i)=0. @@ -297,12 +297,12 @@ c adc(n) = min(500, max(0., adc(n))) df = max(1., df - nparam) write(6,'(1x,''initial chi2/d.f.='',f8.3,'' for '',f7.0, > '' deg. freedom'')') chisq/df,df - write(8,'(1x,''initial chi2/d.f.='',f8.3,'' for '',f7.0, - > '' deg. freedom'')') chisq/df,df +c write(8,'(1x,''initial chi2/d.f.='',f8.3,'' for '',f7.0, +c > '' deg. freedom'')') chisq/df,df ! find the solutions call deqn (nparam,ax,1000,iwork,ifail,1,bx) - write(8,'(1x,''ifail='',i10)') ifail +c write(8,'(1x,''ifail='',i10)') ifail ! association of parameters with detectors do i=1,nparam @@ -429,10 +429,10 @@ c adc(n) = min(500, max(0., adc(n))) mean(i)=sum2(i)/sum1(i) sig(i)=sqrt(sum3(i)/sum1(i) - mean(i)**2) endif - write(8,'(1x,i3,i5,2f6.2,10i5)') i,nhit(i), - > mean(i),sig(i),(min(9999,thist(i,j)),j=1,10) - if(iloop.eq.2) - > write(14,'(1x,i3,50i5)') i,(min(9999,thistf(i,j)),j=1,50) +c write(8,'(1x,i3,i5,2f6.2,10i5)') i,nhit(i), +c > mean(i),sig(i),(min(9999,thist(i,j)),j=1,10) +c if(iloop.eq.2) +c > write(14,'(1x,i3,50i5)') i,(min(9999,thistf(i,j)),j=1,50) sum1(i)=0. sum2(i)=0. sum3(i)=0. @@ -443,8 +443,8 @@ c adc(n) = min(500, max(0., adc(n))) df = max(1., df - nparam) write(6,'(1x,'' final chi2/d.f.='',f8.3,'' for '',f7.0, > '' deg. freedom'')') chisq/df,df - write(8,'(1x,'' final chi2/d.f.='',f8.3,'' for '',f7.0, - > '' deg. freedom'')') chisq/df,df +c write(8,'(1x,'' final chi2/d.f.='',f8.3,'' for '',f7.0, +c > '' deg. freedom'')') chisq/df,df write(10+iloop,'(/a,''hodo_pos_sigma ='',3(f8.2,'',''), > f8.2)')filename(1:1),(sig(i),i= 1, 80,20) @@ -462,8 +462,8 @@ c adc(n) = min(500, max(0., adc(n))) enddo ! loop over time tolerance do i=1,200 - write(15,'(1x,i3,20i4)') i,(adchistpm(i,j,1),j=1,20) - write(15,'(1x,i3,20i4)') i,(adchistpm(i,j,2),j=1,20) +c write(15,'(1x,i3,20i4)') i,(adchistpm(i,j,1),j=1,20) +c write(15,'(1x,i3,20i4)') i,(adchistpm(i,j,2),j=1,20) enddo goto 999 diff --git a/CALIBRATION/hodo_calib/tofcal.inp b/CALIBRATION/hodo_calib/tofcal.inp index bfb05b8427e4f06ac0ae9ff00a7eb951871e4aa9..dfa7acf81725110f68e703df566aead6d3eb3453 100644 --- a/CALIBRATION/hodo_calib/tofcal.inp +++ b/CALIBRATION/hodo_calib/tofcal.inp @@ -1,8 +1,4 @@ -shmsfort.37 -hmstofcal.53411 -sostofcal.46765 -htmp -shmstofcal +pfort.37 diff --git a/PARAM/HMS/HODO/htofcal.param b/PARAM/HMS/HODO/htofcal.param index 46f40459312706fb19092a1500a152997036f0af..8ace71250d5a69df7036c903f5c617f9f9bd76bd 100644 --- a/PARAM/HMS/HODO/htofcal.param +++ b/PARAM/HMS/HODO/htofcal.param @@ -1,2 +1,2 @@ hdumptof=1 -hdumptof_filename="CALIBRATION/hodo_calib/hmsfort.37" +hdumptof_filename="CALIBRATION/hodo_calib/hfort.37" diff --git a/PARAM/SHMS/HODO/ptofcal.param b/PARAM/SHMS/HODO/ptofcal.param index 70d469af77a4f6c151681b0b84faaebbc3ab8439..3f0ae425484645481556fb9c581494d65500e53b 100644 --- a/PARAM/SHMS/HODO/ptofcal.param +++ b/PARAM/SHMS/HODO/ptofcal.param @@ -1,2 +1,2 @@ pdumptof=1 -pdumptof_filename="CALIBRATION/hodo_calib/shmsfort.37" +pdumptof_filename="CALIBRATION/hodo_calib/pfort.37"