The Monte Carlo simulations can be found in the folder mcEff. There are three different simulations:


The origin of coordinates is in the detector surface. The initial position of the particle in the source in cylindrical coordinates (ρ, φ, z) is generated randomly. If the thickness of the source is b, its radius is r and the distance between detectors is d, the particle coordinates in the source (ρsrc, φsrc, zsrc) are:

ρsrc ∈ [0, r]
φsrc ∈ [0, 2π]
zsrc = b + d

where b is generated randomly, since the particle can come from any deep. In cartesian coordinates:

xsrc = ρsrc cos(φsrc)
ysrc = ρsrc sin(φsrc)

Next, the direction of the particle is generated. Only the particles inside the proper solid angle Ω will hit the detector.

θ ∈ [0, π]
φ ∈ [0, 2π]

Which in the code translates to:

 * Photon coordinates at source
 * The origin is in the detector
zSrc   = ( (double)rand()/RAND_MAX ) * b + d;
rSrc   = ( (double)rand()/RAND_MAX ) * r;
phiSrc = ( (double)rand()/RAND_MAX ) * 360 * pi/180.0;
xSrc   = rSrc * cos(phiSrc);
ySrc   = rSrc * sin(phiSrc);

 * Photon exit direction (theta, phi)
theta = ( (double)rand()/RAND_MAX ) *  90 * pi/180.0;
phi   = ( (double)rand()/RAND_MAX ) * 360 * pi/180.0;

Now that we have the initial position and exit direction of the particle from the source, we calculate at which position it arrives to the detector. First we calculate the projection D of the particle's trajectory over the detector surface:

D = zsrc tan(θ)

Defined like this, D will have the correct sign automatically. Now, from the projection D and the azimuthal angle φ, we can calculate the ρ coordinate in the detector:

xdet = xsrc + D cos(φ)
ydet = ysrc + D sin(φ)
ρdet = √ xdet2 + ydet2

The position of the particle in the surface of the detector is given by (ρdet, φ, 0). If R is the radius of the detector, the condition that a particle arrived at the detector is then ρdet < R. In our code:

 * Photon coordinates at detector
 * D is the module of the vector projected in the detector
D    = zSrc * tan(theta);
xDet = xSrc + D * cos(phi);
yDet = ySrc + D * sin(phi);
rDet = sqrt( xDet*xDet + yDet*yDet );

if (rDet < R)

The efficiency is then calculated as the ratio between the number of particles that reached the detector and the number of particles generated by the source.

gammaEff = (double)Nin / N;


For this calculation, the geometry of Appendix B in the lab-guide is used. The scintillator detectors are placed facing each other and separated a certain distance d.

Scintillators set-up

The thickness of the detectors is not taken into account. The simulation acts as if the particle source were in the lower surface of the upper scintillator.

The rest is very similar to the previous section. The (x, y) coordinates of the initial position of the particle in the upper detector are generated randomly, and then the projection over the lower detector is calculated as in the previous example and as explained in Appendix B of the lab-guide.


To simulate an isotropic angular distribution, we can use the same code of the previous section, if we just change the line:

cosine  = pow( (double)rand() / RAND_MAX, 1/4.0 );

for the line:

cosine  = 1 - 2 * ( (double)rand() / RAND_MAX );