Skip to content

Repository files navigation

***************************************
*Geting and building the code (lxplus)*
***************************************

This is the procedure for compiling and running Geant4 spacal code on lxplus machines with 64-bit SLC6.

1) All the necessary libraries and compiler versions are already installed on lxplus machines running 64-bit SLC6, 
thus after logging on, like this:

> ssh lxplus6.cern.ch
 
you just need to source the following scripts and to set the following variables to setup an appropriate environment:

> export SCRAM_ARCH=x86_64-slc6-gcc46
> source /afs/cern.ch/sw/lcg/contrib/gcc/4.6/x86_64-slc6/setup.sh
> source /afs/cern.ch/sw/lcg/external/geant4/9.6.p03/x86_64-slc6-gcc46-opt/CMake-setup.sh
> export CXX=`which g++`; export CC=`which gcc`

You can also put those commands in a script and launch the script on startup (i.e. calling it in .bashrc)


2) make a dir where you want to put the code, say G4_spacal

> mkdir G4_spacal
> cd G4_spacal

3)get the code 

>svn checkout http://spacal.googlecode.com/svn/trunk/ spacalCode

this will download the code and place it in a dir *spacalCode* 

4) make a build directory

> mkdir build
> cd build
> mkdir spacalCode
> cd spacalCode

5) build using cmake

> cmake -DGeant4_DIR=/afs/cern.ch/sw/lcg/external/geant4/9.6.p03/x86_64-slc6-gcc46-opt/lib64/Geant4-9.6.3 ../../spacalCode
CMake will now run to configure the build and generate Makefiles
-----
Note1: If you do not want to type this long path,  in your .bashrc  set a variable, say g4Dir:

export g4Dir="/afs/cern.ch/sw/lcg/external/geant4/9.6.p03/x86_64-slc6-gcc46-opt/lib64/Geant4-9.6.3"

than you can run cmake as:
> cmake -DGeant4_DIR=$g4Dir /path_to/your_source_code/
-----

6) When cmake finishes we can now build by simply running make:

> make 
or if your machine has more than 1 core processor

>make -jN

where N is the number of core processors

7) now you are ready to run

> ./SPc -m beam_circ.mac


This will run the macro beam_circ.mac. 



**********
*Geometry*
**********
The way the geometry is constructed is object
oriented way to construct geometry. It seperates the concept of how a volume
is built from where it is placed. Each major volume in the geometry is defined
as a class derived from G4PVPlacement. Right now there are 2 classes: Calorimeter volume anf PMT volume.
To place one of these volumes, simply create an instance of it with the appropriate
rotation, translation, and mother volumes.

- A tungsten block with a number of holes filled with the quartz tubes filled with a liquid scintillator.
- The number of holes is automatically calculated from the value of pitch.
- A small gap between the tubes and tungsten block 

- At the front of the calo block a thin Al mirror is placed

- In front of the mirror there is a tungsten preshower (thickness 1X0).

- The PMTs are coded as well. Dimensions and placement of PMTs have 
	to be adjusted for different pitches so they do not cross the quartz tubes. 

- Magnetic field of 3.8 T (0,0, 3.8T). 

***********************************
*Modifying the geometry at runtime*
***********************************
You can modify the geometry definition at runtime. This
is accomplished through DetectorMessenger, a derived class of G4UImessenger.
After changing geometry using commands from DetectorMessenger the /SPc/detector/update command must be issued to reconstruct the geometry
with the new values. Right now there are 12 things you can change at the runtime. Here are the commands 
you can use in your macros:
		----------------
/SPc/detector/defaults  #create default geometry; does not take argument
/SPc/detector/update    #update geometry; does not take argument; compulsory command if you make any change

/SPc/detector/dice5 true 			# dice4 or dice5; boolean; 0 (false) is default
/SPc/detector/pitch 2.0 mm		# size of the pitch; takes double with unit
/SPc/detector/holeR 0.7 mm		# R of the holes; takes double with unit
/SPc/detector/capillR 0.5 mm	# R of the quartz capillaries; takes double with unit
/SPc/detector/coreR 0.1 mm		# R of the scintill core; takes double with unit
/SPc/detector/calo true		 		# create a calorimeter; boolean; 1 (true) is default
/SPc/detector/psw true				# create a preshower; boolean; 1 (true) is default
/SPc/detector/mirror true			# create an Al mirror; boolean; 1 (true) is default
/SPc/detector/magfield true		# switch on/of the magnetic field (3.8 T along z); boolean; 0 (false) is default
/SPc/detector/pmts true			# create PMTs; boolean; 0 (false) is default
/SPc/detector/nbPmts 2			# number of pmts along x and y axis; integer; 5 is default
/SPc/detector/pswNbX0 3			# thickness of the preshower; double; in units of radiation length
		----------------

************************
*PMT sensitive detector*
************************
The PMT sensitive detector cannot be triggered like a normal sensitive detector
because the sensitive volume does not allow photons to pass through it. Rather,
it detects them in the OpBoundary process based on an efficiency set on the
skin of the volume.

*********************************
*Scintillator sensitive detector*
*********************************
This one we need to measure energy deposited in the scintillator


**********************
*Modular Physics List*
**********************
Using a modular physics list is an easy way to organise the physics list into
categories for easier maintenance. Here I used GeneralPhysics, EMPhysics and OpticalPhysics. 

******
*Beam*
******
I use GPS source. In the code you can choose between 3deg tilted beam and a parallel to the z axes of calo block. Look at PrimaryGeneratorAction.cc 
Change energy of incident electrons using:

# it is important to give the energy in GeV because of the calculation of X0; In the code I have
# defined that X0 is calculated  as the value of z position (in mm) when the incindent particle
# is left with less that 1/e * incindentEnergy (in GeV!!!)

/gps/energy theEnergyOfIncindentPElectron GeV 	

To calculate X0, you have to isue the command:

/SPc/cutOff theEnergyOfIncindentPElectron GeV 


************************
*Histograms and ntuples*
************************

Look at HistoManager, SPcEventAction and SPcSteppingAction classes. There are a number of things calculated during the runtime and they are 
written in a few ntuples. To chose the name of the output root file and what is going to be written in it, in your macro add something as following:

#
/SPc/histo/name test1
/SPc/histo/event true
/SPc/histo/pp true
/SPc/histo/lost false
#

Here the output root file will be test1.root, the event ntuple will be written, pp (primary particle) ntuple will be written, but information about 
particles exiting the calo block (lost) will not.

******
*Run*
*****

I have added an option to choose the run number. In your macro add a line:

/SPc/setRun someInt

It comes handy when you have to submit a number of jobs to run on condor.

*****************
*Optical Photons*
*****************

If you are looking at the things such as energy deposition in tungsten, X0 or Moliere, tracking optical photons increases the running time immensely 
(for 1 MeV deposited in the scintillator 11500 optical photons is produced). In this case the best is to kill the optical photons as soon as they are 
produced. You will still have information how many of them has been produced per event. By default, the optical photons are not tracked.

To switch on the tracking of the scintillation photons, in your macro, add the following command:

/SPc/trackScintill true # false is default


***************************************
*Optical Photons at optical boundaries*
***************************************

If you want to extract information about processes at the optical boundaries in your macro add the command;

/SPc/boundaryProc true # false is default 


Do not forget to add the command for tracking optical photons:

/SPc/trackScintill true  

If you want to look at the number of Scintill. photons arriving at the end of calo block 
you also have to remove the pmts from the geometry:

/SPc/detector/pmts false		

**********************************************
*Measuring energy deposited in the calo-block*
**********************************************

Switch off tracking of the optical photons (to spead up the simulation).
Use Geant's comand based scoring:
	- in your macro create a scoring mesh (can be a cilinder or a box). 
	- a cilinder is good for Moliere's radius
	- see comm_scoring.mac macro for more details 

About

Automatically exported from code.google.com/p/spacal

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages