ToyMC for Basic Performance Studies


The BGV Toy MC is a standalone python tool. It uses simple detector geometry and pp or pA collisions to study:
  • Multiple scattering (MS) and detector hit resolution
  • Track and vertex fitting

Originally developed by M. Ferro-Luzzi, later extended by P. Hopchev with contributions from M. Witek and H. Dijkstra.

Depends on scipy/matplotlib. One of the two vertex fitting algorithms requires root.

How to run (Feb 2015)

It is recommended to copy the tool and develop it as an independent version. The recipe below is for lxplus

  • Login to lxplus
  • Copy and extract the BGV ToyMC tar archive to a local directory
    • cp /afs/ ./
    • tar -xzvf BGV_ToyMC_v2r3.tar.gz
  • Setup the working environment
    • SetupProject ROOT (ROOT environment is needed by the C++ version of the vertex fitter; if you don't use it, you can skip this step but you need to comment-out "import ROOT" in
    • export PYTHONPATH=/afs/$PYTHONPATH (or the equivalent for tcsh). This allows to use numpy, scipy and matplotlib
  • Run the tool
    • cd BGV_ToyMC_v2r3/workdir/
    • python -i ../

Description of the components

    Main executable script. Defines the job configuration and executes the main algorithm that tracks the particles and calculates MS, detector hits and fits the tracks. The following switches can be used to modify the behavior:
    • boolAcceptanceOnly: calculate acceptance and "fraction of good events"
    • boolAcceptanceMapOnly: calculate acceptance by scanning (modifying) the z-position of the input vertices
    • boolDoVertexFit: After track fitting, call 2 possible vertex fitting routines in cpp and/or python
    • boolCheckDistributions: Draw some distributions
    • boolMakeFigures: Draw other distributions
    • boolDrawEvents: Draw event display(s)
    • boolDrawDetector: Draw detector geometry
    • boolMaterialScan: Draw eta-phi plot of the material seen by the tracks
    • boolVaryWinThick, exitWinTaperAngle: replace the exit window geometry element
    • boolIPFitSingleG: Fit the IP distribution with a single or double gaussian

    Classes and functions providing the functionality of the tool: calculations of geometrical objects and other utility functions

    The input tracks data used in is in the form of a "double list" of charged particles coming from the PV, i.e. list of lists of tracks (one track list per event). This type of data (LLMCP) can be obtained with a few different functions:
    • read_tracks: reads a properly formatted ascii file and returns the LLMCP. Example data file: gausssim_hi_10_7000.dat
    • read_tracks_from_sim: runs a Panoramix job that reads a .sim file and returns a formatted list of tracks. A file name can be specified (boolWriteAsciiFile) to write the input tracks to a new ascii file. See for more details
    • A few functions generating test tracks: e.g. tracks arranged in a circle

  • Folder DetectorGeo
    Contains all detector description files (one layout version = one file)

  • Folder SciPyModules
    Contains a few scipy modules used in Most notably is used to perform Gaussian fits (if you like, change it with your preferred fitting function)

    Functions used in the track acceptance calculations

  • VertexTool.{c,h}
    C++ vertex fitting class by Mariusz Witek. Loaded in as a Macro

    Python vertex fitting and utility functions from Hans Dijkstra and Hugo Ruiz Perez

  • PanoReadTracks
    Run a Panoramix job that loops over the events of a sim file and returns the tracks data in the format used by Optionally can write to an ascii file. Provides track filter functions. Can be run standalone: "python -i ../" after calling "SetupProject Panoramix". Note that the latter will modify $PYTHONPATH, and potentially will mess up scipy/matplotlib

  • Folder tmpPickles1
    Contains python pickle files with the residuals between MC-true and fitted vertices. These pickles can be analyzed with a separate script to get the vertex resolution

Edit | Attach | Watch | Print version | History: r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r1 - 2015-02-14 - PlamenHopchev
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    BGV All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback