#  *********************************************************************
#  * DISCLAIMER                                                        *
#  *                                                                   *
#  * Neither the authors of this software system, nor their employing  *
#  * institutes, nor the agencies providing financial support for this *
#  * work make any representation or warranty, express or implied,     *
#  * regarding this software system or assume any liability for its    *
#  * use.                                                              *
#  *                                                                   *
#  * This code implementation is the intellectual property of the      *
#  * OpenGATE collaboration.                                           *
#  * By copying, distributing or modifying the Program (or any work    *
#  * based on the Program) you indicate your acceptance of this        *
#  * statement, and all its terms.                                     *
#  *********************************************************************

#  *****************************************************************************
# *****  O P T I C A L   I M A G I N G   S Y S T E M   S I M U L A T I O N ***** 
#  *****************************************************************************

GATE Optical Imaging contact: vesna.cuplov@gmail.com (SHFJ-Orsay)

The following macros will simulate a simple OpticalSystem experiment:


== The main macro (the one you run with Gate) is Optical_System.mac 


== A PHANTOM is made of a water box plus a cylindrical insertion of a fluorescent material. 
This material has been defined in the Material.xml (and GateMaterials.db) file with several properties: 
BULK ABSORPTION, MIE scattering(anisotropy and scattering lengths) and FLUORESCENCE (WLS absorption 
and emission spectra).
Defining the fluorophore in GateMaterials.db is mendatory but the given density and element's component number 
are "fake". We use the following description but it doesn't matter in the simulation:
RhB:  d=1.0 g/cm3 ; n=1  <== this can be anything but is mendatory.
        +el: name=Carbon   ; n=1   <== this can be anything but is mendatory.


== The experiment GEOMETRY is described in Geometry.mac
We use an OpticalSystem made of a crystal, that is pixelated (cubicArray). Behind the pixels, we added 
an other volume (part of the crystal) which can be some electronics boards for example. For testing purpose, 
all these volumes are made of Air. Any other material should be defined in Materials.xml with property 
vecors values given in INCREASING ORDER OF ENERGY. (http://hypernews.slac.stanford.edu/HyperNews/geant4/get/opticalphotons/458/1/1.html)
In order to detect optical photons, we need to define the detection surface as a DIELECTRIC-METAL (Surface.xml)
with property vecors values given in INCREASING ORDER OF ENERGY. 

== The digitizer is defined in the main macro: Optical_System.mac
The user defines a digitizer named OpticalSingles. That will be the name of the Optical Singles Tree in the 
output file. 
In this fluorescence experiment, we are interested in fluorescent photons. These photons have an energy smaller that the
excitation photon energy. An energy cut (2eV) is performed at the digitization level. Therefore the result of the ProjectionSet 
module will contain only fluorescent photons. 


== The Optical Photon source is defined in Source.mac
It is assigned a polarization along the x-axis. A photon which is not assigned a polarization at production 
may NOT be Rayleigh scattered. The optical photon energy is set to 2.21eV (which corresponds to a wavelength 
of 561nm).    ==> 1238.7/E[in eV] ~ lambda [in nm].

== The optical imaging simulation gives the following output files: 

- OpticalSimulationOutput.root ROOT tree
A simple root macro is available: [in Root: .x DrawBranches.C]
It produces a postscript file (validation_reference.ps) with all tree branches drawn. 
	
- If you use the Projection.mac in your simulation, you get additionnal files: OpticalSystemProjection.bin and a
header file OpticalSystemProjection.hdr
You can look at the binary file using imagej for example (example: File->Import->Raw and Width=100, Height=100 pixels)

== BIOLUMINESCENCE SIMULATION == 

  Gate < bioluminescence.mac  

  A 2D image of the bioluminescent light detected by the optical system: in ROOT
  root [0] .x MakeBioluminescencePlots.C


== FLUORESCENCE SIMULATION == 

  Gate < fluorescence.mac  

  A 2D image of the fluorescent light detected by the optical system: in ROOT
  root [0] .x MakeFluorescencePlots.C




