Geant Monte Carlo for CEBAF Hall A


                                      update March, 1996                                    
                                      A. Gasparian, R. Michaels

   This code is obsolete !!

    The Geant monte carlo for Hall A was written with 
  contributions from several people:

     A. Gasparian   manager of initial version
                    preshower and shower detectors
                    layout of magnets and overall geometry
     J. Marroncle   scintillator detectors
     G. Fournier    gas cherenkov detectors
     M.J. Kim       CODA format output
                    Installation of EJB geometry database
     R. Michaels    VDC detectors
                    interface to mceep
                    port code to Hewlett Packard (unix)
                    present manager of code
                      


  ** COMPILING, RUNNING THE CODE **

    All sources and the makefile are available on the CEBAF
 anonymous ftp site.  Login by 'ftp ftp.cebaf.gov' with username
 'anonymous' and password anything.  Then 'cd pub/halla/geant' 
 and get geant.tar.Z.  Uncompress with 'uncompress geant.tar',
 and untar with 'tar xvf geant.tar'.  The files will appear.
 Read the README file first. Note that the Hall A field map is
 GEANTMAP.TXT.Z which has been compressed; you must 'uncompress' 
 it before running.  
    If you want to obtain the CODA evio library, you may try
 the tar file on the ftp site 'pub/halla/coda/EVIO.tar'.  It is
 an unofficial copy, unsupported by me.  Contact the DAQ group
 (group leader heyes@cebaf.gov) for questions about CODA.
    To compile, type 'make'.  If you are running on the CEBAF
 computers, you must first 'setup coda' in order to have the
 CERN libraries and CODA libraries.  The executible is hag321. 
 To run with mceep input, use the command 'gogeant' (see further 
 instructions on mceep below.)  Once Geant starts up type 'trig' 
 for 1 event, or 'trig 50' for 50 events.  To end a run type 'exit'.
 The ffread control cards are HAG321_INTER.DAT.  There is some 
 documentation at the beginning of hag321_inter.f and on the microvax
 in [gasparian.hagean]read_me_first.txt.  The documentation is 
 a bit old but contains fairly good information about the cards.

 ** Use of MCEEP **

   It is possible to run with mceep event generator using mceep 
 ntuples. Mceep is a popular monte carlo written by Paul Ulmer
 for Hall A, and one of its output options is an ntuple.  Ask
 Paul for details on how to obtain and run mceep !
   To use the mceep ntuple, follow these steps:
   (i) Make sure the first line of the ntuple file reads
            TRANS  FOCAL
        if the ntuple is generated at the focal plane, or
            TRANS  TARGET
        if the ntuple is generated at the target.  Paul's recent
        version writes 'TRANS' but not the second word.  
   (ii) Put the mceep input file in the directory and 
        assign it to unit 20.  'ln -s mceep.inp ftn20'
   (iii) Set the flag MCFL = 1 in the ffread cards HAG321_INTER.DAT
   (iv) Use a command like 'gogeant' which makes logical assignments
        to the mceep ntuple.  Unit 21 and 22 are the electron and
        hadron arm ntuples. 


 ** OTHER EVENT GENERATORS **
     In addition to mceep, there are two other generators used
  by subroutine gukine.f.  If the ffread card, MCFL = 0, the code
  uses A.Gasparian's original generator.  If MCFL = 2, the code 
  makes a spray of tracks at the focal plane with mean multiplicity
  of 4 and a spread of positions and angles.

  ** HISTOGRAMMING **
    To put in a new histogram, I suggest using hbook and adding
 the hbook call in subroutine UHINIT in file hag321_inter.f. 
 Histograms appear in the file hag321_inter.hist after you 'exit' Geant.

  ** OUTPUT DATA **
    To obtain output data from hit banks, use ffread card GROU.  The
 options are : (i) GROU = 0.  No output.  (ii) GROU = 1, write a
 CODA data file.  The data is written in CODA format.  To read it
 with our standard analyzer, you must have the detector map file
 'GEANT_detmap.config'.  (iii) GROU = 2, write an ascii file to 
 logical unit 2 (ftn02).  To read this and interpret it use gfread.f 
 which prints a self-explanatory output to unit 3 (ftn03). 
 (iv) GROU = 3, for making both CODA and ascii data output.
     When CODA output is selected, the CODA file also contains
 information about the track positions, momentum 3-vector, and
 time of flight.  Some comments about the data are in appendix A
 below, and a section of code for interpreting the data are in 
 appendix B below 

  

 ** APPENDIX A **
      Comments about the geometry and calibration 
   used by Geant:
      The geometry uses EJB's scheme: geom_database.dat.
   The u plane is 1st.  In your "spectrometer detector
   system", the u sense wires run along the (+x,+y)
   direction.  The distance in Z between u and v planes
   is 2.5 cm.  The velocity is 0.005 cm/nsec, the tdc
   scale is 0.5 nsec/count, and the T0 for both the
   vdc hits and scintillator hits is the time-of-flight
   from the particle origin.  The particle origin is
   just beneath the VDCs, so T0 for VDCs is about zero.
        If you don't use a precise calibration, the
   angles calculated within one VDC u/v package may
   disagree with the global angles.  The global angles
   are less sensitive since they depend mainly on cluster
   centers.  The field model used was: radial out to
   1/2 the wire spacing, then vertical.  The drift time
   recorded is the minimum drift time within the cell.
       Let d = abs(v0*(t-t0))
           D_v = vertical distance
           wsp = wirespacing = 0.6/sqrt(2) = 0.424 cm
           m  = slope of track in a single projection
       if(d.lt.wsp/2) then D_v = d * sqrt(1+m**2)
       if(d.gt.wsp/2) then D_v = d + 0.5*wsp*(sqrt(1+m**2)-1)
     There is also an edge effect near bottom of cell.
   (Note: if m=0, D_v = d.  Avg m is ~1.36 in the data.)

 ** APPENDIX B **

   Following is some code for decoding the Geant kinematics.
   The position and momentum are in your "spectrometer detector
   frame" - a right handed system with X along an increase in
   momentum, Z perpindicular up from the focal plane.  The
   coordinate origin is presumably shifted from your definition.

c  Geant data 
        integer MAXGTRK
        parameter (MAXGTRK=50)
        integer nvdctrack(2)
        real xyz_geant(2,MAXGTRK,3),pmom_geant(2,MAXGTRK,3),
     &       tof_geant(2,MAXGTRK)
        common/geant_tracks/nvdctrack,xyz_geant,pmom_geant,
     &       tof_geant
c
c
c The GEANT kinematic data
c evbuffer is the CODA data buffer.
c Search for pointer = 'acebf', it cannot be fastbus data
c
        do i = 1,2 
           nvdctrack(i) = 0
        end do
        jpoint = 0
        do i = 1,evbuffer(1)+1
           if(evbuffer(i).eq.'acebf'x) jpoint = i
        end do
        if(jpoint.eq.0) goto 250  ! no kinematic bank 
        jpoint = jpoint + 1
        ntot = evbuffer(jpoint)  ! total number of charged tracks in vdc
          do 280 itrk = 1,ntot   
             jpoint = jpoint + 1
             iarm = evbuffer(jpoint)  ! spectrometer arms 1,2 (e,h)
             if(iarm.lt.1.or.iarm.gt.2) goto 280
             if(nvdctrack(iarm).ge.MAXGTRK) goto 280
             nvdctrack(iarm) = nvdctrack(iarm) + 1
               do j = 1,3
                 jpoint = jpoint + 1
c Why 0.001 ?  evbuffer is integer, data was stored as 1000*xyz, 1000*pmom.
                 xyz_geant(iarm,nvdctrack(iarm),j) 
     &               = 0.001*evbuffer(jpoint)
               end do
               do j = 1,3
                 jpoint = jpoint + 1
                 pmom_geant(iarm,nvdctrack(iarm),j) 
     &               = 0.001*evbuffer(jpoint)
               end do
               jpoint = jpoint + 1
               tof_geant(iarm,nvdctrack(iarm)) = float(evbuffer(jpoint))
 280       end do
 250    continue
c
        if(debug_flag.eq.1) then
            if(jpoint.eq.0) then
                write(26,*) 'NO GEANT KINEMATIC DATA' 
                goto 290 
            endif
            write(26,9501)
 9501       format(1x,//,50('-'),//,'Geant kinematic data:',/)
            do iarm = 1,2
                write(26,9502) event_ctr,iarm,nvdctrack(iarm)
 9502           format(1x,//,2x,'Event ',i2,5x,
     &             'Arm = ',i3,5x,'Num tracks = ',i5,//,
     &             2x,'track ',12x,'xyz at fp',
     &             10x,'momentum',8x,'tof (nsec)'/)
                do itrk = 1,nvdctrack(iarm)
                   write(26,9503) itrk,xyz_geant(iarm,itrk,1),
     &             xyz_geant(iarm,itrk,2),xyz_geant(iarm,itrk,3),
     &             pmom_geant(iarm,itrk,1),pmom_geant(iarm,itrk,2),
     &             pmom_geant(iarm,itrk,3),tof_geant(iarm,itrk)
 9503              format(1x,i2,2x,3(2x,f7.3),3x,3(2x,f6.3),4x,f4.1)
                end do
            end do
        endif
 290    continue


 ** APPENDIX C **

    A few comments about the quality of data and known problems.  

    Comparing the optics for mceep transport and Geant field map
 showed that the resulting focal plane tracks agreed reasonably 
 well in all their parameters (x,y,angles) if I scaled the Geant
 field by +2.5%.  The Geant field model is NOT considered to be 
 good enough for detailed optics studies (see Eddy Offermann for 
 a better monte carlo).
     The electron arm gas cerenkov has hits in ADC1 normally; 
 the hadron arm has low adc value because it's below threshold.
 It may seem strange that there are multiple hits in gas Cerenkov. 
 Ashot explained that we should take the first ADC value of the 
 first hit (for each detector) and ignore all the rest (a hist-
 orical quirk). The VDC's, shower, and scintillator data seem 
 reasonable.  The scintillator data doesn't look very much like
 our real cosmics ray data.  I think some parameters need tuning. 
 The S3 (hadron arm) appears screwed up, or perhaps distorted 
 by the carbon block.
     Otherwise the S1,S2 data make sense, adding left and right TDC 
 times from scintillators gives a narrow peak, and the separation 
 of peaks from one plane to another is the 2* time of flight.



Last update 16 March 1996
R. Michaels, rom@cebaf.gov