AMS simulation consists of 2 major steps: Reverse mode and flesh mode, which
use skeleton/flesh function of Cosmos. (not a new skeleton/flesh function).

A) data creation phase

1) Reverse mode (backtracking).

  Isotropic primaries are assumed at a height of 400 km and sampled
  primaries are charge-conjugated and the direction is inverted 
  to be traced backward; if it reaches to a 10Re height (radius of
  11Re from the Earth center),  it is regarded as the real primary
  and the random nubmer Seed is recored.  Otherwise, or the flight time 
  exceeds 20 sec, it is regarded not a primary. The output file name
  here will take such a form  that hostname_xxxx, where xxxx depends on
  the content, hostname is the hostname on which the job ran.
    
  The main output from this 1st step is
      Seed file (seed for the priamries; hostname_Seed) ~ 10 B / event
      cutoff file ( hostname_cutoff )    188 B /event
  The cutoff file contains  examined particle type, energy, charge, 
  flag (for real 1ry or not), it's injection position, 
  direction, and escape positon and direction, flight time. 

  There are some other files:
     cont file,  (hostname_Contfile)
     skeleton file (hostname_Skeleton)
     error file    (hostname_error)

  The Seed file is most important and must be kept for the 2nd step 
  but others are not needed in the 2nd step. The cont file is needed 
  if the 1st step job is to be continued for more statistics. 
  Skeleton file is not needed at all if the
  1st step is ended. The error file shows error output and shows the
  event number processed at its last.  

-------------
Below, * means that you probably don't need do it. 


 a)* making executable

   In UserHook/AMS;

    make clean; make -f chookReverse.mk 

  This will create cosmosReverse in UserHook/AMS/Reverse/

      
 b) execution.

  Goto UserHook/AMS/Reverse.
 b-0)  Edit 'hostlist' where you want to run the program.
 b-1)  Make sure that you can enter all the hosts in hostlist
       by the 'rsh' command without the passwd from a certain
       host (which may be a different host other than the hosts
       in 'hostlist', say, icrsrv, at ICR).
 b-2)*  Edit config, if necessry.
 b-3)*  Edit paramReversTemp and adjust 2nd term of DestEventNo,
       say, DestEventNo = -10000000, -20000.  This meas that
       at each 20000 event generation, the program run stops.
       You can continue the job as explained later. Negative sign
       means that event counting is done even for the primaries 
       below the cutoff.
       If needed, change the  tracking method by given a new
       value in UseRungeKutta= and LamorDiv =
 b-4)  Issue 
        ./binfirstrun X
       where X must be one of L, M, H or A.
       L:  primaries are below 1.5 GeV (K.E/n)  UserHook/AMS/BESS+e+e-Low
                                                is used.  
       M:  primaries are  1.5 ~ 15 GeV          BESS+e+e-Mid
       H:  primaries are  15  ~ 30000 GeV       BESS+e+e-High
       A:  primaries are  entire energy region. BESS+e+e-All

       The output data will be created in
            UserHook/AMS/Data/Low/, ...Mid/, ...High/, ...All/,
            depending on X.

       bin* are the commands prepared for submitting jobs, killing jobs,
            seeing status, etc.
       bin_* are also the commands but are used internally from bin*. 

   binfirstrun: 

        ./binfirstrun  X  (X is one of L, M, H, A)
                    To submit jobs over hosts in hostlist. 
        ./binfirstrun  X  host1 host2...
                    The 2nd form is to submit jobs on specified hosts by
                    the command line.

         The output files, even if they already exist, will be deleted and
         new ones will be created.
         If the same program (cosmosReverse) is running on a given host,
         warning will be issued, and you have to determine to continue or
         stop submission of the job.  If the running job uses the same X
         as the job being submitted,  no correct  output will be  obtained,
         so you must stop the submission. If X is different from the
         running one, there will be no interfarence except for slowing
         job execution.

   binshowrunjob:
        ./binshowrunjob   
                 To see the cpu time etc of the running jobs on hosts
                 specified in hostlist.
        ./binshowrunjob  host1 host2 ...
                 To see the cpu time etc of the running jobs on hosts
                 specified by the command line.

        ./binshowrunjob  -h
                 To show the usage.

   binseed :

	./binseed X
        ./binsssd X host1 host2...
           To see the last part of the Seed file created by the
           specified hosts. The first and 2nd forms mean the same 
           as above.

   binstatus:
        
        ./binstatus X
        ./binstatus X host1 host2 ..
                To see the last part of the error file. When a
            job is finished successfully, you will see the event
            number created.
   bintail:
        ./bintail X
        ./bintail X host1 host2 ...
             To see the last part of the cutoff file.
 
   binkilljob:
        ./binkilljob 
        ./binkilljob host1 host2
           To kill the running job
        ./binkilljob -h
           To see the usage
   binwatch:
        ./binwatch n
        ./binwatch n host1 host2 ...

         (After this, you must use 
            Control z (^Z)
            bg 
            logout (If you remain the session, sometimes the process
            becomes 'sustained' insidiously and not effective; I don't
            know the correct treatment. logout once and login again
	    is probably good.)
         To watch if the programme is still running on the hosts.
         n is the time interval (sec) when the binwatch examins the
         job status.   If the job is not running, mail is sent to 
	 you to notify the host on which the job has been finished.
         (n<20 is not permitted).

         Mail is sent only once.   After the mail is sent, if a new
         job is submitted on that host, this binwatch will not examine
         the new job status.  You have to start another binwatch to
         watch the new job.  Binwatch will terminate if there is no
         more jobs to examine.
 
   bincontrun:
        ./bincontrun X 
        ./bincontrun X host1 host2 ...
           Once a job is finished, you can continue the job by this
         command. The program utilizes Data/X/host_Contfile to continue
         the job.

         The output data on the cutoff, Seed and error will be appended,
         if the files are already exist.

         If the same programme is running on the same host, warning is
         issued like the binfirstrun case.
         
         As noted in binwatch, the currently running binwatch will not see
        this new job, so that  you have to submit a new binwatch if you
        want to watch the job.

         
2) Flesh mode.  

  In this mode, the Seed file created in the 1st step is read and
 the sampled primaries (the same on as in the 1st step) are injected
 at 400 km.  Interactions in the atmosphere, synchrotron radiations
 are considered and all produced particles are tracked down to the
 earth surface or to the escape sphere (at 11Re), or until the flight
 time exceeds 20 sec.  The neutrinos are recorded at the time of birth
 if it is directed to the earth and not traced further.  Neutral particles
 going up above 100 km are discarded.  The charged particles passing thru
 380 km are recorded.

 The output files are:
    obsv file.   hostname_obsv.  created in UserHook/AMS/Data/X
    nutrino file. hostname_nu.   //
    error file.   hostname_obsverror.  //
    cont file.    hostname_ContFlesh. //

 The most important file is obsv file. The error file will show that
 the job is finished normally or not. The cont file is used when you got
 a new Seed file and continue the job to append the output data.
 The job will continue until the all seeds in the Seed file are exhasted. 
 If the Seed file contains seeds that have been already processed in 
 previous jobs, the cont job will skip such events and do the job for
 only new seeds.


 
  a)* making programme.

        Go to UserHook/AMS
        make clean
        make -f chookFlesh.mk

      This will create cosmosFlesh in UserHook/AMS/Flesh.

  b) Exectuion.
     b-0)   goto UserHook/AMS/Flesh
     b-1)  Edit hostlist.
     b-2)*  Edit config
     b-3)* Edit paramFleshTemp if needed.
           The nutrino output will be large. If you want to make it
           binary, change the following part which is located in the
           last part of the namelist.
              UserHooki = 0,  --->    UserHooki = 1,
          If you want to change the interaction model, give
         Intmodel =...
         Say,  Intmodel = '"dpmjet3"'. This can be different from the one
         given in 1st step.
	 Give UseRungekutta and LamorDiv to be the same as the ones in
         the 1st step.
         
     b-4)  Issue
            ./binfirstrun  X
           or
            ./binfirstrun X host1 host2 ..
       This will delete existing output files, if any and create
       new ones.

    watching, seeing status etc are the same as in the Reverse mode.
    
     If you have already some output files, and want to append new data,
    use
 
      ./bincontrun  X
    or
      ./bincontrun X host1 host2 ...
 


B) Analysis step.
  In UserHook/AMS/Ana
  There are several progaramms that are needed to analyse the obsv data.

  They are
      ana1.f
      cgmCoord.f
      read70.f
      copy70.f

  
  The main analysis program is ana1.f with cgmCoord.f

     make -f ana1.mk  will create ana1

  It reads standard input and write result to standard output.

  The input data is the 'obsv' data.  
  
    read7o.f and copy79.f are to read and copy the binary nutrino data.





--------------flux

# -----------------# of Component defined= 5----------------------
# Seq.#  Code  Comp.    E_ Unit  E_type Diff/Integ  Emin    Emax   # of seg. inte.flux 
#   1     6  p             gev     ke/n       d     0.147    0.440E+09  53 0.270E+04
#   2    10  he            gev     ke/n       d     0.108    0.800E+09  53  254.    
#   3    12  cno           gev     ke/n       d     0.100    0.300E+10  25  8.32    
#   4     2  e-            gev     ke         d     0.200    0.100E+05  28  53.1    
#   5     2  e+            gev     ke         d     0.200     100.      20  8.27    

all region
  No rigidity cut is assumed
  primary  Int(dI/dE)  sum(cumlative);
  p                2700.249         2700.249    
  he               254.1633         2954.412    
  cno              8.322241         2962.735    
  e-               53.12925         3015.864    
  e+               8.269000         3024.133    

# -----------------# of Component defined= 5----------------------
# Seq.#  Code  Comp.    E_ Unit  E_type Diff/Integ  Emin    Emax   # of seg. inte.flux 
#   1     6  p             gev     ke/n       d      1.50    0.440E+09  53 0.122E+04
#   2    10  he            gev     ke/n       d      1.50    0.800E+09  53  82.7    
#   3    12  cno           gev     ke/n       d      1.50    0.300E+10  25  2.56    
#   4     2  e-            gev     ke         d      1.50    0.100E+05  28  24.5    
#   5     2  e+            gev     ke         d      1.50     100.      20  2.60    
K.E/n > 1.5GeV
  No rigidity cut is assumed
  primary  Int(dI/dE)  sum(cumlative);
  p                1220.752         1220.752    
  he               82.68592         1303.438    
  cno              2.557847         1305.995    
  e-               24.50445         1330.500    
  e+               2.602623         1333.103    
# -----------------# of Component defined= 5----------------------
# Seq.#  Code  Comp.    E_ Unit  E_type Diff/Integ  Emin    Emax   # of seg. inte.flux 
#   1     6  p             gev     ke/n       d      15.0    0.440E+09  53  69.7    
#   2    10  he            gev     ke/n       d      15.0    0.800E+09  53  3.90    
#   3    12  cno           gev     ke/n       d      15.0    0.300E+10  25 0.150    
#   4     2  e-            gev     ke         d      15.0    0.100E+05  28 0.286    
#   5     2  e+            gev     ke         d      15.0     100.      20 0.491E-01

K.E/n> 15 GeV.
  No rigidity cut is assumed
  primary  Int(dI/dE)  sum(cumlative);
  p                69.68089         69.68089    
  he               3.901824         73.58272    
  cno             0.1496740         73.73239    
  e-              0.2863639         74.01875    
  e+              4.9131569E-02     74.06789    
 If N primaries are generated in simulation,
  STdOmega= N/sum

      energy interval (GeV)
                   p       He      CNO        e-       e+       all   ratio     all - cno
K.E/n < 1.5     1479       171.5  5.76       28.62    5.66     1691    1         1685
    1.5~15      1150       78.78  2.407      24.22    2.55     1259    0.7445    1257
    > 15         69.68     3.90   0.15        0.286   4.9e-2   74.07   0.0438    73.9

if N events without CNO are generated, CNO events should be
           no CNO     CNO                 total 
< 1.5        N        N x 3.418x10^-3    1.0034xN
1.5 ~15      N        N x 1.915x10^-3    1.0019xN
> 15         N        N x 2.03x10^-3     1.002 xN

