Monte Carlo code

From GlueXWiki
Jump to: navigation, search

The goal of this wiki is to give enough information so that someone could install, run, and modify the triplet polarimeter Monte Carlo code.

This is a work in progress

Mami MC code

The Mami MC code is set up to represent the triplet polarimeter expected to be used at Mami


To install and run the Monte Carlo you will need to have installed:

  • ROOT
  • GEANT4 (I have version 4.9.5)

For the GEANT code you will need to modify the analysis.gmk file to include the lines

  • CPPFLAGS +=$(shell root-config --cflags)
  • ROOTLIBS = $(shell root-config --nonew --libs)

where the environment variable ROOTLIBS points to your ROOT libraries

Download and run the MC code

The MC code can be found here (mamiConfig.tar)

  • Extract the files. Type: 'tar xf mamiConfig.tar'
  • Change directory. Type: 'cd mamiConfig'
  • Source the env.csh file (assumes you are using csh as your shell). Type: 'source env.csh'
  • Make the executable. Type: 'make'

Using mamiConfig

There are many parameters that the user can control.

The default settings of the parameters can be found in the file mcDefaults.conf.

The entries in the file mcDefaults.conf are self explanatory.

Here is an example of a mcDefaults.conf file:

outFileName mcOut.root //The output file name

nToGen 1000000 //The number of events to generate

inFileName triplet.e500.root //The input file name

cThickness 35 //Converter thickness in microns

nBeams 3 //Number of beams: 1->triplet, 2->pair, 3->triplet+pair

innerR 1.1 //Inner radius in cm

outerR 3.5 //Outer radius in cm

thetaMax 45 //Max theta in degrees

xOffset 0.0 //Beam x-offset (mm)

yOffset 0.0 //Beam y-offset (mm)

spotRadius 4.2 //Beam spot radius (mm)

magVal 0 //Mag field in gauss

For each parameter in the mcDefaults.conf file there is a command line switch.

The definition of the command line switches can be seen by typeing './mamiConfig -h'

  • Run 1 million triplet events (takes about 1.5 hours). Type: 'mamiConfig -otripletOut.root -b3'
  • Run 1 million pair events (runs faster than triplet). Type: 'mamiConfig -opairOut.root -b2'
  • Obtain macro to find analyzing power. Download macro (fitRingSum.C)
  • Open ROOT session and run the fitRingSum.C macro.
    • You will get the analyzing power from the second parameter of the fit. Also, various rates will be printed to screen

Modifying the code

Small Modifications to the code should not pose too many difficulties.

Here are some of the main parts of the code:

  • Geometry definitions are in src/
  • Primary generator code is located in src/
  • Most histograms are filled in src/

The easiest thing to try and modify would be the choice of converter material.

To change the converter material from beryllium to carbon

  • Use favorite editor to open src/
  • Change
    • logicConverter = new G4LogicalVolume(solidConverter,Beryllium,"converter");
  • To
    • logicConverter = new G4LogicalVolume(solidConverter,Carbon,"converter");