Some notes on MCFAST

August 24, 1998

The Five things you really need to know

Where are the include files?

Go to the example area and look at the file GNUmakefile. There you will find lines of the form:
INC1 = $(MCFINC)/inc/event
INC2 = $(MCFINC)/inc/geom
where MCFINC is defined as $MCFAST_DIR/inc. Check these areas to find the include files.

The two files mentioned above are found in:
$STDHEP_DIR/src/inc/stdhep.inc
$MCFAST_DIR/inc/event/offline_track.inc

A general discussion on finding source files and include files, and a description of some usefully searching utilities, is given in "Find: The Mysteries Explained".

A Rough Outline of MCFAST

This outline ignores any simulation of calorimetry; that information is in preparation. Also notice that the control of vertexing is left up to the user.
  1. Do job initialization. This includes a call to usr_init.F.
  2. Read in the next event from the evgen output file. This fills the common stdhep.inc with the generator information.
  3. Trace every track through the detector and create a list of hits on each track. This fills internal common blocks which are not normally interesting to the user. At present there is no simulation of errors in pattern recognition and, therefore, the list of hits on a track is perfect. Well, almost perfect; there is a simulation of efficiency.
  4. Run the trigger simulation. In the example this is a dummy.
  5. Call usr_analysis.F. The tracking reconstruction is done inside usr_analysis by the call to trk_offline.
  6. trk_offline: When a track has been successfully fitted, its track parameters and covarinace matrix are loaded into the common offline_track.inc.
  7. When the command usr_kalman T has been given, the preceding description is exactly correct. When that command has not been given, the kalman filter only computes the covariance matrix, not the track parameters. The track parameters are then computed by smearing the generated values using the covariance matrix computed in the previous step.
  8. A corollary of the previous point is the the chisq varaible in the offline track common is only defined if use_kalman T has been set. Otherwise it is undefined.
  9. At this point, we are back in usr_analysis.F, the simulation is complete and the user can do his or her physics analysis using the information in offline_track.inc. Make sure that your your analysis code comes after the call to trk_offline!
  10. Get the next event.
  11. At the end of the job, the histograms are written out automagically.

A Rather Abbreviated Calling Tree

Track representations.

WARNING:
STDHEP reports distances in mm but the MCFAST commons report distances in cm! They agree on GeV/c for quantities with dimensions of momentum. Also, check quantities before you use them since some have never been filled - for example the chi2 of the track fit is only filled if you have specified "use_kalman T" in the command file.

MCFAST knows about three representations of tracks.

Utility Routines

The directory $MCFAST_DIR/simulator/util/src contains many utility routines to do such things as transform among the three track representations, project tracks to cylinders, change the local orgin to some new point, and so on. There are also routines do compute such things as angles and pseudo-rapidty from a 3-momentum and routines to compute errors on various quantities, given the covariance matrix of a track. Many of these routines are exercised in the MCFast Advanced Examples.

Fitters

There is a postscript document which describes the use of the vertex-constraint and mass-constraint fitters. Some of these routines are exercised in the MCFast Advanced Examples.

Miscellaneous

  1. When MCFast is run with decays in-flight turned on, it sometimes complains about negative mass particles, usually pi0's. This is due to precision problems in the hadronic event generators and the problems are rare enough to be ignored. See the evgen_notes . When the problem occurs, the offending particle is simply treated as stable and the program continues.
  2. What are all of the DFLOAT things? MCFAST was written to be switchable between real*4 and real*8. This is implemented by defining the string DFLOAT to be either "double precision" or "real". This is done in $MCFAST_DIR/inc/event/const.inc and it is currently set to double precision. In all of the MCFAST code, all of the floating point variables are typed using DFLOAT. In a preprocessing step, before compilation, the variable DFLOAT is expanded and the resulting file is sent to the compiler ( the prepreprocessor is invoked on files with an extension .F, but not on files with an extension of .f ). Users are encouraged to also use this method. However the example files may still have a few examples of hard coded typing.

    Warning: When DFLOAT is expanded to "DOUBLE PRECISION" it can shift the end of a long line past column 72. This causes the fortran compiler to truncate variable names and to produce unpredictable results. If one is compiling with -u ( or implicit none ), then this will normally be caught by the compiler.

  3. One of the new features of MCFAST version v4_0 is a full treatment of multiple scattering for hit generation. This is enabled by issuing the command:
    trace_integrated T
    In the future this will be come the default. At present the default mode of operation has trace_integrated F, in which there is no multiple scattering for hit generation if the detector contains both forward and central elements. In all cases the tracks found in the offline track common do include the mulitple scattering.
  4. When filling histograms with calls to hf1, hf2, hfill, etc remember that these take single precision numbers. Therefore an explicit type conversion is needed when passing many MCFast variables into hbook.

    If you prefer, MCFast contains a double precision interface to hbook, dhf1, dhf2 etc. However I recommend not paying the overhead of the additional subroutine call.

  5. The MCFast random number generator is seeded using the command ranseed from withing the .cmd file. A value of 0 means that it is seeded from the time of day. Other values are used as the seed; the seed is 2 words long. If qq is used within mcfast, it is seeded separately from the MCFast random number generator; it is seeded from the time of day when the first call to qq takes place. In the next release of mcfast it will be possible to easily link in user supplied random number generators.
  6. Some of the example makefiles are distributed with the compile and link options set to make the fastest executable possible. During code development I strongly recommend modifying your makefiles adding the compile options -g -u -C and the link option -g. These do the following:
    -g - build symbol tables for the debugger
    -u - give compile time warnings of undeclared variables
    -C - enable run time bounds checking
  7. The variable ISTHEP in the include file "stdhep.inc" tells whether or not a particle has been decayed. If isthep(i).eq.1, then particle i has not been been decayed. A number other than 1 indicates that the particle has either decayed or interacted. Occaisionally, particles such as pi0's and K0S's are found to be stable when MCFast has finished! These cases fall into two categories: 1) if the particle is the daughter of some long lived particle and the decay vertex is outside of the volume of the detector. 2) if the trace list or the stdhep list have filled up then the remaining unstable particles cannot be decayed.

[fermi at work] [simulation home]
Rob Kutschke kutschke@fnal.gov