# ESIM

• CAUTION: obsolete material *

ESIM is a detector simulation framework based on GEANT3, with a special language (Mortran) to simplify describing detector geometry. The geometrical description of a detector, or a part of the detector system, is written as a separate module which is dynamically compiled and loaded into the framework. More details on the simulation framework can be found in the ESIM manual. Some details about geometrical shapes which can be implemented are [here]. For a summary of detector design considerations which have been followed, see Detector Design

## Getting Started

The software for a Linux machine can be found in this tar file. After you download it, untar it in a directory which is in your default PATH:

tar xfvz esim.tz


Alternatively, if you have an EIC account, you can run the program version installed in the directory /afs/rhic.bnl.gov/eic/PACKAGES/ESIM. Add this directory to your path with (in csh)

setenv PATH /afs/rhic.bnl.gov/eic/PACKAGES/ESIM:$PATH  or (in bash) export PATH=/afs/rhic.bnl.gov/eic/PACKAGES/ESIM:$PATH


After this, you can use the esim executable from any directory.

### Testing

To make sure everything is installed correctly you can run a built-in test, simulating a room with two chairs that have a screw as a sensitive detector. This should help you to understand the basics of detector simulations with ESIM. Your first session may look like this:

mkdir mysim
cd mysim
tar xfvz <somewhere>/esim.tz
setenv PATH .:$PATH  or setenv PATH /afs/rhic.bnl.gov/eic/PACKAGES/ESIM:$PATH
cp -p /afs/rhic.bnl.gov/eic/PACKAGES/ESIM/roomgeo.age .


then

esim.exe -w 1
esim> debug on
esim> make roomgeo
esim> gclose all
esim> gkine 100 5 0 10
esim> switch 2 3
esim> trig


## Running a Simple eRHIC Detector Geometry

A simple eRHIC detector layout can be simulated using file. After downloading it (or, if you have an EIC account, you can copy it from /afs/rhic.bnl.gov/eic/PACKAGES/ESIM), you can run as following:

esim.exe -w 1
make edicgeo.age
dcut edic x 0.1 10 10 0.01 0.01


You should get this layout.

## Generating a Geometry RZ file from ESIM (for use by GEANT4 or ROOT)

To output a geometry RZ file, from an inputfile (for example named myfavoritegeo.age), run the following:

esim.exe -w 1
make myfavoritegeo.age
rz/file 1 myfavoritegeo.rz on


Note: The ESIM we are using is a 32-bit executable. Therefore in order to use the rz file you'll need a 32-bit GEANT installation (for rztog4) or a 32-bit root installation (for g2root).

## Running PYTHIA in ESIM

It is possible to run the PYTHIA event generator (version 6.4.21) directly in ESIM using this tar file. If you have a eRHIC account you can get it from /afs/rhic.bnl.gov/eic/PACKAGES/ESIM area.

After you download and untar it, do "make apythia" in ESIM (without quotes). This command compiles the Pythia code and the interactive interface and loads them into ESIM as a shared library. The steering is done with simple commands, described via an interactive help menu accessed by typing "help pythia" (without quotes). The generated events are stored in the standard Pythia common block HEPEVT and are directly accessible for detector simulations. They can also be save in a file for subsequent input.

An example of a simple session is below:

tar xfvz /afs/rhic.bnl.gov/eic/PACKAGES/ESIM/apythia-6.4.21.tz
esim.exe -w 0
esim> make apythia
esim> help pythia
esim> frame CMS
esim> beam  e- p+
esim> ener 900
esim> msel 1
esim> trig 1
esim> call pylist(1)           - to see the whole parton tree
esim> gprint kine              - to see only the particles going into detector


## Running RAPGAP Events in ESIM

This section is under development.

Events generated by RAPGAP can be replicated in ESIM using the file "esimread.age". Using this example you will see constant magnetic fields for the solenoid and dipoles. Copies of all relevant files can be found in /afs/rhic.bnl.gov/eic/PACKAGES/ESIM/EXAMPLES/

An example of a simple session is below:

esim.exe -w 1
esim> make edicgeo
esim> make mflegeo
esim> debug on
esim> gclose all