	subroutine ptlevel1()
	
c	LOGICAL         CHAIN
c	CHARACTER*128   CFILE
c	INTEGER         IDNEVT,NCHEVT,ICHEVT
c	REAL            OBS(13)
*       
c	COMMON /PAWIDN/ IDNEVT,OBS
c	COMMON /PAWCHN/ CHAIN, NCHEVT, ICHEVT
c	COMMON /PAWCHC/ CFILE
*       
*--     Ntuple Variable Declarations
*       
	REAL DEDX(500),CLSIGNAL(8500),CNEV(12,24)
	INTEGER NEV1,NCLSTR1,VIEW(500),LADDER(500),MAXS(500),MULT(500)
     &    ,INDSTART(500),INDMAX(500),TOTCLLENGTH
	LOGICAL GOOD1
*       
	integer ncl(2)
	real clp(3,500)
	real cls(2,500)
	real clz(2,500)
	real sigma_matrix(12,3072)
c
	Integer pkt_type1
	Integer pkt_num1
	Integer obt1
c	Integer which_calib1

c
c	parameter(NWPAWC=8)
c	common/pawc/hmem(NWPAWC)
c	save/pawc/
c	common/quest/iquest(1)
c	save/quest/
c
c	

	LOGICAL crc1(12)
	integer cpu_crc1
	integer whic_calib1, swcode1
C     

	COMMON /PWCR4/ GOOD1,NEV1,whic_calib1,swcode1,crc1,
     &    pkt_type1,pkt_num1,obt1,cpu_crc1,
     &    NCLSTR1,VIEW,LADDER,MAXS,MULT,DEDX
     &    ,INDSTART,INDMAX,TOTCLLENGTH,CLSIGNAL,CNEV,
     &    ncl,clp,cls,clz,sigma_matrix    
	SAVE /PWCR4/
	
*
       
*--     Enter user code here
*       
c       integer ,nstripsview(12)
	integer ind,ic,cllength,lows,highs,nstrips,is
c	integer sflag(12,3072)	!to avoid putting more than one time a 
c       strip in a histogram when a cluster is more than one time contained in 
c       clsignal array (usually these are the double peaked clusters)
	real sign,noise,clinclcut
	
	real zlevel(12)
	data zlevel/22.28,22.28,13.38,13.38,4.48,4.48,
     +	-4.42,-4.42,-13.32,-13.32,-22.23,-22.23/

	parameter(incut=5)
	parameter(signcut=50.)
      
c      parameter(traslys=2151)
	parameter(traslys=2115)	!INVERSIONE?????????????

c	call hlimit(nwpawc)


*     ***********

c	PRINT *,'TRACKER: evento ',nev1
c	event_num_trk(1) = nev1
c	event_num_trk(1) = mod(nev1,1000000)
c	
c	do i = 1, 12
c	   do j = 1, 3072
c	      if ( sigma_matrix(i,j).ne.0. )
c     &         print *,'sigma(',i,',',j,') = ',sigma_matrix(i,j)
c	   enddo
c	enddo
c	print *,' nclstr = ',nclstr1
c	do i = 1, nclstr1
c	   print *,' view(',i,') ',view(i)
c	   print *,' ladder(',i,') ',ladder(i)
c	enddo
c

	ind=0

	nclx = 0
	ncly = 0
	
c	print*,'acidenti a me ',event_num_trk(1),nclstr1

      do ic=1,nclstr1
         
         if(ic.ne.nclstr1) then
            cllength=indstart(ic+1)-indstart(ic)
         else
            cllength=(totCLlength+1)-indstart(ic)
         endif

         lows=maxs(ic)-(indmax(ic)-indstart(ic))
         highs=lows+cllength-1

         sign=0.            
         noise=0.            
         nstrips=0
	   posx = 0.
	   posy1 = 0.
	   posy2 = 0.
	   posz = 0.
	   pposx = 0.
	   pposy1 = 0.
	   pposy2 = 0.
	   pposz = 0.
	   
C	   print *,'qua ',ic
         do is=lows,highs
            ind=ind+1
C	    print *,'qui view(ic) ',view(ic),' is ',is
C	    print *,'qui clsignal(ind) ',clsignal(ind),' ind ',is
            clinclcut=incut*sigma_matrix(view(ic),is)
            if (clsignal(ind).gt.clinclcut) then
C	       print *,'qua ci arrivo'
               sign=sign+clsignal(ind)
               noise=noise+sigma_matrix(view(ic),is) 
               nstrips=nstrips+1
               posz = zlevel(view(ic))
C	       print *,'qua anche sign ',sign,' noise ',noise
               if (mod(view(ic),2).eq.1) then !!! Y Y Y Y 
		  if (view(ic).ne.11) then
		     str=float(mod(is-1,1024)+1) !Y
		     posy1 = -6.9541 + (str-1)*0.00665
		     posy2 = 0.1 + (str-1)*0.00665
		  else		!??????????????????INVERSIONE??????????
		     str=float(mod(is-1,1024)+1) !Y11
c       str=traslys-str
		     str=1024-str + 67
		     posy1 = -6.9541 + (str-1)*0.00665 !-0.5
		     posy2 = 0.1 + (str-1)*0.00665 !-0.5
		  endif
		  pposy1 = pposy1 + posy1*clsignal(ind)
		  pposy2 = pposy2 + posy2*clsignal(ind)
               else
                   str=float(is) !X
		   srt = mod(is-1,1024)+1
		   lad = int((is-1)/1024) + 1
		   if(lad.eq.1) posx=-7.8798+(srt-1)*0.005
		   if(lad.eq.2) posx=-2.5575+(srt-1)*0.005
		   if(lad.eq.3) posx= 2.7648+(srt-1)*0.005
		   pposx = pposx + posx*clsignal(ind)
               endif
            endif
         enddo
	   if(mod(view(ic),2).eq.1)then
C	      print *,'qui ci sono e pposy1 ',pposy1,' pposy2 ',pposy2,' sign ',sign
	      ncly = ncly + 1 
	      clp(2,ncly) = pposy1/sign
	      clp(3,ncly) = pposy2/sign
	      clz(2,ncly) = posz
	      cls(2,ncly) = sign
	   else	
	      nclx = nclx + 1 
	      clp(1,nclx) = pposx/sign
	      clz(1,nclx) = posz
	      cls(1,nclx) = sign
c       call hfill(99,posx,posz,sign)
	   endif			   
	enddo
c	do i = 1, 19
c	   print *,'cls(2,',i,') = ',cls(2,i)
c	   print *,'cls(1,',i,') = ',cls(1,i)
c	enddo
	ncl(1) = nclx
	ncl(2) = ncly
c	project_trk_level1 = 1
C	print *,'****'
	return
	end
