MEGSIM: HOWTO GUIDE.

MEGSIM is the still-in-development Monte Carlo Code Written in FORTRAN in a GEANT 3.21 frame.

It's main idea is to be EASY TO USE. In the following a certain familiarity with GEANT is assumed.

The geometry of the various detector should be USABLE but not MODIFIABLE.

In the following I will assume that the simulation package is correctly installed. If this is not the case please see this page .

After a brief explanation there will be the examples so please keep on reading!

The idea of the simulation is that you choose which detector(s) you want to simulate and in your UGEOM routine all you have to do is CALLing the appropriate pre-made subroutine which creates and positions the detector. Such routines are called MEGXXX where XXX is a code for each detector (non standard detectors e.g. the prototypes do not follow this convention).

Some properties of the detectors can be modified throug their own CARDS placed in files called CARXXX.DAT that MUST be accesed through pre-made routine (CALL XXXCAR)

The events are similary generated with CALLs to MEGEVE in GUKINE or can be custom-written.

Few other routines take care of the physics of the processes, e.g. the scintillation of the Xenon.

Summing up the scheme is:

1) INITIALIZATION: Read MEGSIM and USER cards etc... create HISTOGRAMS.....
2) CREATION OF THE GEOMETRY.
3) GENERATION OF THE EVENTS.
4) TRACKING OF THE PARTICLES.

In the following we will try to learn how to test that THE SIMULATION EXISTS and will try a small simulation of the Liquid Xenon Large Prototype.

It is now time that you create your own SIMULATION directory an copy THIS FILE there.
UnTAR it with the command:

tar -xf test.tar

A new directory called TEST should have appeared. Please CD to it and LS.
You should see a thing like this:

HOWTO       carlix.dat  cartof.dat  gufld.F     meguse.inc  uginit.F 
Makefile    carmeg.dat  caruse.dat  gukine.F    test.F      uglast.F 
careve.dat  carspe.dat  draw.kumac  guout.F     testi.F     uhinit.F 
carfie.dat  cartar.dat  geother.F   gustep.F    ugeom.F 

You can se an HOWTO file, the Makefile (we will take care of it later...), *.dat are the cards and *.F are the files we are interested in. All the names should be self explanatory apart test.F and testi.F .

TEST.F is the MAIN file.
TESTI.F is the INTERACTIVE version of the MAIN file (to be used in a PAW-LIKE environment, indispensable for debugging purposes).

Let's take a closer look:

TEST.F

***********************************************************
      PROGRAM TOFTEST                       
***********************************************************
*
*     GEANT main program
*
***********************************************************
*
      IMPLICIT NONE
*      
      INTEGER NGBANK, NHBOOK
      PARAMETER (NGBANK=10000000, NHBOOK=5000000)
      COMMON/GCBANK/GEANT(NGBANK)
      COMMON/PAWC  /PAW(NHBOOK)
*
* *** Initializes dynamic memory for hbook and geant
      CALL GZEBRA( NGBANK)
      CALL HLIMIT(-NHBOOK)
*
* *** Open graphics system
      CALL HPLINT(1)
      CALL IGMETA(10,-111)
*
* *** GEANT initialization
      CALL UGINIT
*
* *** Start events processing
      CALL GRUN
*
* *** End of RUN
      CALL UGLAST
*
      STOP'Normal End'
*
      END

It does pratically nothing apart from calling UGINIT, so let's have a look at it!

UGINIT

************************************************************
      SUBROUTINE UGINIT
************************************************************
*
*     Initialize GEANT program and read data cards
*
************************************************************
*
*
*      IMPLICIT NONE
*
* *** Define the GEANT parameters
      CALL GINIT
*
* *** Own card's definition
*
* *** Read user  cards (called this way only for hedonism)
      CALL USECAR
*
* *** Read GEANT cards (see previous remark)
      CALL GEACAR
* 
* *** Read standard cards 
      CALL LIXCAR
      CALL SPECAR
      CALL TOFCAR
      CALL TARCAR 
*
* *** Data structure initialisation
      CALL GZINIT
*
* *** Particle table initialization
      CALL GPART
*
* *** Standard Materials Initialization
      CALL GMATE
*
* *** Initialize graphics
      CALL GDINIT
*
* *** Geometry and material description
      CALL UGEOM
*
* *** Energy loss and cross-sections initializations
      CALL GPHYSI
*
* *** Print banks
      CALL GPRINT('MATE',0)
      CALL GPRINT('TMED',0)
      CALL GPRINT('VOLU',0)     
*
* *** Booking histograms
*
      CALL UHINIT
      END

As you can see it's all standard stuff apart from the RED part which takes care of reading the cards of the detectors.

We decided to use the Liquid Xenon Calorimeter, the TIMING COUNTER and the SPECTROMETER, so we CALL the opportune routines. The routines you can call in this way are:

SUBROUTINE EVECAR   ! Event Generation Cards 
SUBROUTINE FIECAR   ! Magnetic Field Control Card 
SUBROUTINE LIXCAR   ! Calorimeter Card 
SUBROUTINE SPECAR   ! Spectrmeter Card 
SUBROUTINE TARCAR   ! Target Card 
SUBROUTINE TOFCAR   ! Timing Counter Card 

The call at UGEOM takes care of BUILDING THE EXPERIMENT....

UGEOM

**********************************************************
      SUBROUTINE UGEOM
**********************************************************
*
*     Define experimental setup
* 
**********************************************************
*
      IMPLICIT NONE
*
* Define user geometry set up
*
* *** List of the volumes to use.
*
* *** MEGFRA must **always** be called:  it  defines the MARS
*     and has the right size to contain all the other volumes
      CALL MEGFRA
*
* *** Liquid Xenon Calorimeter
      CALL MEGLIX
*
* *** Spectrometer 
      CALL MEGSPE
*
* *** Target: N.B. You can call the target even **without** MEGSPE
      CALL MEGTAR
*
* *** Coil (and eventually endcaps...)
      CALL MEGCOI
*
* *** Timing counter
      CALL MEGTOF
*
* *** Close geometry banks
      CALL GGCLOS
      END

There are other two objects: the LARGE PROTOTYPE and a BIGGER version of the large prototype (or, if you want, a LIXE not curved...). Those two things can be built with:

CALL LIXPRO
CALL BIGPRO

Let's try to compile

If you are on a Pisa PC (PCCHOOZ*.PI.INFN.IT ) and you see the disk DATA1/ you can try to compile the test program. Just type

make int

to build the interactive version.

If everything went OK, you can now type:

./testi

and see a "familiar" paw window. Now type

dtree

to see the logical tree of the volumes defined. Left-click on the labels to see each volume specification (remember to move this second window!) and right-click on the main window to exit. There is a test KUMAC (draw.kumac). Try to execute it!

exe draw

Simple simulation of the Large Prototype.

To simulate, e.g., the existence of the Large Prototype one needs only to do the following calls:
In    UGINIT.F     ----> CALL LIXCAR (To choose the axistence of Raylaigh scattering and/or absorption) 
In    UGEOM.F      ----> CALL MEGFRA (Always) 
                         CALL LIXPRO (To create the Large Prototype) 

To simulate the behavior of the prototype two things are needed:

  1. Generation of the event
  2. Tracking of the scintillation photons into the Xenon to the PMTs
The two steps are accomplished by spcific instructions in GUKINE.F and GUSTEP.F

A very simple programme simulating the large prototype can be found HERE. Un-tar it as before. Then CD to the newly-created directory lp/ and create there a symblic link to your GEANT include directory.

ln -s /cern/pro/geant/include/ ./geant321

(You need to do this because of the various #include in GUSTEP.F). Now compile and try the macro draw_event.kumac!

The Structure of the detector can be found HERE


MEG Home Page
G. Signorelli, Jan 11th, 2001