      subroutine readalignparam

      include '../common/commontracker.f'
      include '../common/common_align.f'

      character*50 fname_param
      integer sensor
c      character*120 cmd1
c      character*120 cmd2
      
c 100  format('../common/align_param/parameters_l',i1,'s',i1,'.dat')
 100  format('parameters_l',i1,'s',i1,'.dat')

      do ilad=1,nladders_view
         do is=1,2

            write(fname_param,100)ilad,is
c$$$            cmd1='cp $TRK_GRND/source/common/align_param/'
c$$$     $           //fname_param(1:LNBLNK(fname_param))//' .'         
c$$$            call system(cmd1)         
            print *,'Opening file: ',fname_param

            open(10,
     $           FILE='./bin-aux/'//fname_param(1:LNBLNK(fname_param))
     $           ,STATUS='UNKNOWN'
     $           )
            
            do ip=1,nplanes
*
*     NB! NB! NB! NB! NB!
*     The file labelled for example "l1s1" include the alignment
*     parameters of the column of sensors:
*
*     PLANE LADDER SENSOR
*     -------------------
*     1     1      2
*     2     1      1
*     3     1      1
*     4     1      1
*     5     1      1
*     6     1      1
*
*     This is becouse the plane 1 (bottom plane) is up-side-down
*
               sensor=is
               if(ip.eq.1)sensor=mod(is,2)+1 
               read(10,*)omega(ip,ilad,sensor)
               read(10,*)beta(ip,ilad,sensor)
               read(10,*)gamma(ip,ilad,sensor)
               
c     N.B. I convert angles from microradiants to radiant
               omega(ip,ilad,sensor)=omega(ip,ilad,sensor)/1.d6
               beta(ip,ilad,sensor)=beta(ip,ilad,sensor)/1.d6
               gamma(ip,ilad,sensor)=gamma(ip,ilad,sensor)/1.d6

               read(10,*)dx(ip,ilad,sensor)
               read(10,*)dy(ip,ilad,sensor)
               read(10,*)dz(ip,ilad,sensor)
            enddo
            
            close(10)
c$$$            cmd2='rm -f '
c$$$     $           //fname_param(1:LNBLNK(fname_param))
c$$$            call system(cmd2)
         enddo
      enddo
      
  

      end
