-------------------------------------------------------------------
-------------------------------------------------------------------

     =========================================================
 		  Geant4 - Nanobeam example
     =========================================================

                                README file
                          ----------------------

                           CORRESPONDING AUTHOR 

S. Incerti (a, *) et al.
a. Centre d'Etudes Nucleaires de Bordeaux-Gradignan 
(CENBG), IN2P3 / CNRS / Bordeaux 1 University, 33175 Gradignan, France
* e-mail:incerti@cenbg.in2p3.fr

---->1. INTRODUCTION.                                                    
                                                                       
The nanobeam example simulates the beam optics of the nanobeam line installed 
on the AIFIRA electrostatic accelerator facility located at CENBG, 
Bordeaux-Gradignan, France. For more information on this facility, 
please visit :
http://www.cenbg.in2p3.fr/

The code can be used to calculate : 
1) intrinsic aberration coefficients of the nanobeam line
2) beam image from a relasitic primary emittance distribution
3) grid shadow images

Three quadrupole field models can be used :
- a simple square field model
- a 3D mesh field model computed from OPERA3D
- an analytical model based on Enge's model

---->2. GEOMETRY SET-UP.
 
The full magnetic configuration of the nanobeam line is simulated.
This configuration is made of a combination of a doublet and triplet of 
5 Oxford Microbeams Ltd. OM50 quadrupoles. 

More details on the experimental setup and its simulation with Geant4 can 
be found in the following papers:

- A DETAILED RAY-TRACING SIMULATION OF THE HIGH RESOLUTION MICROBEAM AT THE
AIFIRA FACILITY
By F. Andersson, Ph. Barberet, S. Incerti, Ph. Moretto
Published in Nucl.Instrum.Meth.B266:1653-1658, 2008

- MONTE CARLO SIMULATION OF THE CENBG MICROBEAM AND NANOBEAM LINES WITH THE
GEANT4 TOOLKIT
By S. Incerti, Q. Zhang, F. Andersson, Ph. Moretto, G.W. Grime, 
M.J. Merchant, D.T. Nguyen, C. Habchi, T. Pouthier and H. Seznec
Published in Nucl.Instrum.Meth.B260:20-27, 2007

- GEANT4 SIMULATION OF THE NEW CENBG MICRO AND NANO PROBES FACILITY
By S. Incerti, C. Habchi, Ph. Moretto, J. Olivier and H. Seznec
Published in Nucl.Instrum.Meth.B249:738-742, 2006

- A COMPARISON OF RAY-TRACING SOFTWARE FOR THE DESIGN OF QUADRUPOLE MICROBEAM 
SYSTEMS
By S. Incerti et al., 
Published in Nucl.Instrum.Meth.B231:76-85, 2005

---->3  VISUALIZATION

Visualization has not been implemented. 

---->4. HOW TO RUN THE EXAMPLE                                         

1) You must have compiled your Geant4 installation with the FULL version of the
CLHEP library which can handle matrix operations.

2) The code should be compiled cmake and run with :

./nanobeam 

The macro file default.mac is read by default.

Several macro files are provided:

1) for the computation of intrinsic aberration coefficients :
coef-square.mac : using square magnetic field model 
coef-map.mac : using 3D map magnetic field model
coef-enge.mac : using Enge's analytical field model

2) for the simulation of the beam image with a realistic emittance :
image-square.mac : using square magnetic field model (=default.mac)
image-map.mac : using 3D map magnetic field model
image-enge.mac : using Enge's analytical field model

3) for the simulation of grid shadow images
grid-square.mac : using square magnetic field model
grid-map.mac : using 3D map magnetic field model
grid-enge.mac : using Enge's analytical field model

These macros files are stored in the ./macros directory.

To run macros which include *map* in their name, copy the file OM50.grid
into the directory in which you run ./nanobeam.

The code can be run in MT mode, for high statistics image simulation.
Do not use MT for aberration coefficients calculation (32 rays only are shot).
The switch to MT can be made in nanobeam.cc.

---->5. PHYSICS

The example runs with protons with fluctuating energies around 3 MeV.
Standard electromagnetic processes are activated by default (corresponding to the
Physics builder G4EmStandardPhysics), including the G4StepLimiter process. 

---->6. SIMULATION OUTPUT AND RESULT ANALYZIS                                    

All results are stored in the nanobeam.root file and can be displayed with the provided
ROOT macro file plot.C: 
* be sure to have ROOT installed on your machine
* be sure to be in the directory where ROOT output files are generated
* copy plot.C into this directory
* launch ROOT by typing root, then under your ROOT session, type in : .X plot.C 
  to execute the macro file
* or type directly: root plot.X

This macro file shows :
- the beam profile along the nanobeam line (only for the computation of intrinsic 
  coefficients)
- the beam image (Y vs X) on target
- the beam emittance (THETA vs X) and (PHY vs Y) on target
- the grid shadow image (option)

The output ntuples can be written as xml or csv files, by uncommenting the 
appropriate header file in include/Analysis.hh
and by leaving all others commented. 

---------------------------------------------------------------------------

Should you have any enquiry, please do not hesitate to contact: 
incerti@cenbg.in2p3.fr
