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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  1 
  2     =========================================================
  3     Geant4 - an Object-Oriented Toolkit for Simulation in HEP
  4     =========================================================
  5 
  6                        Extended Example saxs
  7                        -------------------- 
  8 
  9   The example saxs implements the typical setup of a Small Angle X-ray 
 10   Scattering (SAXS) experiment. It is meant to illustrate the 
 11   usage of molecular interference (MI) of Rayleigh (coherent) scattering
 12   of photons inside the matter, which is implemented in the
 13   G4PenelopeRayleighModelMI model.
 14 
 15   1- GEOMETRY
 16 
 17    The setup consists of a phantom/sample under investigation, slits 
 18    to collimate the photon beam and a shielded detector to collect 
 19    the photons scattered by the phantom (see SAXSDetectorConstruction).  
 20    
 21    The geometry is scalable through the interactive commands defined 
 22    in the SAXSDetectorConstructionMessenger class. All the significant
 23    quantities, such as the setup (scattering) rotation angle, the position 
 24    and size of all the volumes, as well as the phantom material can be
 25    set via macro commands. 
 26    
 27    Two macro files come with this example: saxs.in and saxs_slits.in.
 28    
 29    In the saxs.in macro, the phantom is a cylinder with a diameter and
 30    a height of 10 mm made of a mixture of 80% fat and 20% water. 
 31    In general, if the argument of /det/setPhantomMaterial command is 2, 
 32    as in this case, the material is a biological tissue ("MedMat") 
 33    defined as a mixture of fat, water, collagen and hydroxyapatite. 
 34    The weight fraction of the mixture components can be set through commands 
 35    /det/setComp0, /det/setComp1, /det/setComp2, /det/setComp3, respectively. 
 36    The tissue form factor (including MI) is automatically calculated as a 
 37    weighed sum of the form factors of the basis components.     
 38    In this case, no slits are foreseen and the sensitive detector 
 39    positioned 400 mm downstream of the phantom collects all the photons 
 40    transmitted and scattered by the phantom, which is irradiated 
 41    by a pencil beam with an energy of 20 keV.
 42    
 43    In the saxs_slits.in macro, the phantom is again a cylinder with a
 44    diameter and a height of 10 mm. The phantom is made of a custom
 45    material ("CustomMat") whose density and composition is set through 
 46    /det/setCustomMatDensity and /det/setCustomMatHmassfract,
 47    /det/setCustomMatNmassfract, /det/setCustomMatOmassfract commands, 
 48    respectively. In general, a custom material can be defined by 
 49    specifying the mass fraction of H, C, N, O, Na, P, S, Cl, K, and Ca via
 50    commands analogous to those mentioned above. In this case, the material 
 51    composition corresponds to that of ammonium nitrate (NH4NO3).
 52    For a custom material, the user can provide the path of the file with
 53    the material form factor (with MI) through the /det/SetCustomMatFF 
 54    command. As an example, the file myFF.dat contains the form factor of 
 55    NH4NO3 measured by Harding in 1999. 
 56    In this case the slits upstream and downstream the phantom 
 57    are present. This setup is suitable for both monochromatic and 
 58    polychromatic beams. To speed-up the simulation, a monochromatic 
 59    photon beam was chosen, but a polychromatic beam can be easily defined.    
 60                                  
 61   2- PHYSICS
 62 
 63    In this example, only electromagnetic processes and decays are considered. 
 64    They are defined in a custom physics list that allows the user to
 65    choose among various EM PhysicsList constructors. In particular,
 66    by choosing G4EmPenelopePhysicsMI and setting fUseMIFlag as true, 
 67    it is possible to enable the molecular interference effects. This
 68    is the default configuration.
 69    
 70   3- ACTION INITALIZATION
 71 
 72    SAXSActionInitialization class instantiates and registers to 
 73    Geant4 kernel all user action classes. While in sequential mode 
 74    the action classes are instatiated just once, by invoking the 
 75    method: SAXSActionInitialization::Build(),
 76    in multi-threading mode the same method is invoked for each thread 
 77    worker and so all user action classes are defined thread-local.
 78 
 79    A run action class is instantiated both thread-local and global.
 80    That's why its instance is created also in the method
 81    SAXSActionInitialization::BuildForMaster(), which is 
 82    invoked only in multi-threading mode.
 83 
 84   4- PRIMARY GENERATOR
 85 
 86    The primary generator action class employs the G4GeneralParticleSource (GPS)
 87    generator. The primary beam has to be defined via the G4 built-in 
 88    commands of the G4GeneralParticleSource in a input macro file. 
 89    In particular, a photon beam directed toward the phantom must be defined
 90    to test the MI effects. The X-ray beam can be monochromatic or
 91    polychromatic, parallel or divergent.     
 92   
 93   5- EVENT AND DETECTOR RESPONSE
 94 
 95    An event consists of the generation of a single particle which is 
 96    transported through the phantom and then to the sensitive detector. 
 97    
 98    The interactions of the photons inside the phantom, and in particular,
 99    the scattering events, are scored in a dedicated ntuple through the
100    SAXSSteppingAction class.
101    
102    The hits of the particles on the sensitive detector positioned 
103    downstream of the phantom (SAXSSensitiveDetectorHit) are recorded
104    in a dedicated ntuple through the SAXSSensitiveDetector class. 
105 
106   6- ANALYSIS:
107 
108    The analysis tools are used to accumulate statistics.
109    ntuple are created in SAXSRunAction::SAXSRunAction() 
110    constructor for the following quantities:
111   
112    Ntuple1 (part) - Particles impinging on the Sensitive Detector (SD):
113    - energy of the particles
114    - position of the hits
115    - momentum of the particles
116    - time of the hits
117    - type of impinging particles
118    - ID number of the impinging particles 
119    - number of scattering events a primary had before hitting the SD
120    - event number of the hits
121    
122   Ntuple2 (scatt) - Interactions of photons inside the phantom:
123   - ID of the process occurred 
124       (0-> transportation, 1->Rayleigh, 2->Compton, 3->Photoelectic)
125   - initial energy of the particles
126   - scattering angle
127 
128    The ntuples are saved in the output file in the Root format.
129 
130    When running in multi-threading mode, the ntuples accumulated 
131    on threads are automatically merged in a single output file.
132    
133    The default output format is root. Two root scripts come with 
134    this example to analyze the output file: scattAnalysis.C and 
135    ADXRD.C. The first can be used to analyze the scatt ntuple, while 
136    the second can be used for part ntuple.
137 
138   7- HOW TO RUN
139   
140     - Execute saxs in the 'interactive mode' with visualization:
141         % ./saxs
142       and type in the commands line by line:  
143         Idle> /control/verbose 2
144         Idle> /tracking/verbose 1
145         Idle> ...
146         Idle> /run/beamOn 10 
147         Idle> ...
148         Idle> exit
149       or it is possible to run a macro file (test.in is a simple macro where the 
150       primary beam is defined through the usual GPS commands):
151         Idle> /control/execute test.in
152         Idle> /run/beamOn 10 
153         ....
154         Idle> exit
155 
156     - Execute saxs in the 'batch' mode from macro files 
157       (without visualization)
158         % ./saxs saxs.in [Ncores]   
159         % ./saxs saxs_slits.in [Ncores]
160       Ncores (optional argument) is the number of threads the user wants to use in
161       MT mode.
162 
163 
164  The following paragraphs are common to all basic examples
165 
166  A- VISUALISATION
167 
168    The visualization manager is set via the G4VisExecutive class
169    in the main() function in saxs.cc.    
170    The initialisation of the drawing is done via a set of /vis/ commands
171    in the macro vis.mac. This macro is automatically read from
172    the main function when the example is used in interactive running mode.
173 
174    By default, vis.mac opens an OpenGL viewer (/vis/open OGL).
175    The user can change the initial viewer by commenting out this line
176    and instead uncommenting one of the other /vis/open statements, such as
177    HepRepFile or DAWNFILE (which produce files that can be viewed with the
178    HepRApp and DAWN viewers, respectively).  Note that one can always
179    open new viewers at any time from the command line.  For example, if
180    you already have a view in, say, an OpenGL window with a name
181    "viewer-0", then
182       /vis/open DAWNFILE
183    then to get the same view
184       /vis/viewer/copyView viewer-0
185    or to get the same view *plus* scene-modifications
186       /vis/viewer/set/all viewer-0
187    then to see the result
188       /vis/viewer/flush
189 
190    The DAWNFILE, HepRepFile drivers are always available
191    (since they require no external libraries), but the OGL driver requires
192    that the Geant4 libraries have been built with the OpenGL option.
193 
194    vis.mac has additional commands that demonstrate additional functionality
195    of the vis system, such as displaying text, axes, scales, date, logo and
196    shows how to change viewpoint and style.
197    To see even more commands use help or ls or browse the available UI commands
198    in the Application Developers Guide.
199 
200    For more information on visualization, including information on how to
201    install and run DAWN, OpenGL and HepRApp, see the visualization tutorials,
202    for example,
203    http://geant4.slac.stanford.edu/Presentations/vis/G4[VIS]Tutorial/G4[VIS]Tutorial.html
204    (where [VIS] can be replaced by DAWN, OpenGL and HepRApp)
205 
206    The tracks are automatically drawn at the end of each event, accumulated
207    for all events and erased at the beginning of the next run.
208 
209  B- USER INTERFACES
210  
211    The user command interface is set via the G4UIExecutive class
212    in the main() function in saxs.cc 
213    The selection of the user command interface is then done automatically 
214    according to the Geant4 configuration or it can be done explicitly via 
215    the third argument of the G4UIExecutive constructor (see exampleB4a.cc). 
216  
217