:

nFirst=0
strCom="{}0"
MC="FCarlo{"
#strCom="\\06Vegas{{0"
nOld=1
nSub=1
run=0
pos=
pFirst=`grep \#Subprocess  session.dat |cut -f4 -d" "`

posFirst="{}0"

Wt=0

while(test 1 -eq  1)
do
    ./n_calchep -blind "{$pos{0"
    nSub=`grep \#Subprocess  session.dat |cut -f2 -d" "`
    if(test $nSub -eq 1) then 
      if(test $run -eq 0) then 
           run=1
      else 
         if(test $run -eq 1) then 
            echo width=$Wt[pb]
            run=2
         else 
            if(test $run -eq 2) then 
               exit 0
            fi
         fi
      fi
    fi   
    if(test $run -eq 1) then
       nSes=`grep Session_number session.dat | cut -f2 -d" "`
       ./n_calchep -blind  "fMonte{{[[[{[[{[{]]]{0"
       if(test $? -eq 0) then 
          if(test -r prt_$nSes) then 
             Wi=`grep "< >"  prt_$nSes|tail -1`
             Wi=`echo $Wi |cut -f3 -d" " `
             Wt=`$1/calc "$Wt + ($Wi)"`
             cp session.dat session.dat.$nSub
             cp prt_$nSes prt_$nSes.$nSub   
             ./n_calchep -blind  "fMonte{{fFreeze{{0"
          fi
       fi
       rm -f events_$nSes.txt
    else 
       if(test -r session.dat.$nSub) then
          cp  session.dat.$nSub session.dat 
          nSes=`grep Session_number session.dat | cut -f2 -d" "`
          cp prt_$nSes.$nSub prt_$nSes 
          Wi=`grep "< >"  prt_$nSes |tail -1`
          Wi=`echo $Wi| cut -f3 -d" "`
          Nevents=`$1/calc "10+floor($2*($Wi)/($Wt))"`
           ./n_calchep -blind "fMonte{{fevents{{$Nevents{[{0" 

       fi  
    fi
    pos=$pos"\8e"
done

