Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/extended/exoticphysics/saxs/README.md is written in an unsupported language. File is not indexed.

0001 \page Examplesaxs Example saxs
0002 
0003 \author Gianfranco Paternò - INFN and University Ferrara (Italy) \n
0004  paterno@fe.infn.it
0005 
0006 The example saxs implements the typical setup of a Small Angle X-ray 
0007 Scattering (SAXS) experiment. It is meant to illustrate the 
0008 usage of molecular interference (MI) of Rayleigh (coherent) scattering
0009 of photons inside the matter, which is implemented in the
0010 G4PenelopeRayleighModelMI model.
0011 
0012 
0013 ## Geometry
0014 
0015 The setup consists of a phantom/sample under investigation, slits
0016 to collimate the photon beam and a shielded detector to collect
0017 the photons scattered by the phantom (see SAXSDetectorConstruction).  
0018    
0019 The geometry is scalable through the interactive commands defined 
0020 in the SAXSDetectorConstructionMessenger class. All the significant
0021 quantities, such as the setup (scattering) rotation angle, the position 
0022 and size of all the volumes, as well as the phantom material can be
0023 set via macro commands. 
0024    
0025 Two macro files come with this example: saxs.in and saxs_slits.in.
0026 
0027 -#  In the saxs.in macro, the phantom is a cylinder with a diameter and
0028 a height of 10 mm made of a mixture of 80% fat and 20% water. 
0029 In general, if the argument of <code>/det/setPhantomMaterial</code> command is 2, 
0030 as in this case, the material is a biological tissue ("MedMat") 
0031 defined as a mixture of fat, water, collagen and hydroxyapatite. 
0032 The weight fraction of the mixture components can be set through commands 
0033 ```
0034  /det/setComp0
0035  /det/setComp1
0036  /det/setComp2
0037  /det/setComp3
0038 ```
0039 respectively. 
0040 The tissue form factor (including MI) is automatically calculated as a 
0041 weighed sum of the form factors of the basis components.     
0042 In this case, no slits are foreseen and the sensitive detector 
0043 positioned 400 mm downstream of the phantom collects all the photons 
0044 transmitted and scattered by the phantom, which is irradiated 
0045 by a pencil beam with an energy of 20 keV.
0046    
0047 -# In the saxs_slits.in macro, the phantom is again a cylinder with a
0048 diameter and a height of 10 mm. The phantom is made of a custom
0049 material ("CustomMat") whose density and composition is set through
0050 ```
0051  /det/setCustomMatDensity
0052  /det/setCustomMatHmassfract,
0053  /det/setCustomMatNmassfract
0054  /det/setCustomMatOmassfract
0055 ```
0056 commands. In general, a custom material can be defined by 
0057 specifying the mass fraction of H, C, N, O, Na, P, S, Cl, K, and Ca via
0058 commands analogous to those mentioned above. In this case, the material 
0059 composition corresponds to that of ammonium nitrate
0060 (NH<sub>4</sub>NO<sub>3</sub>).
0061 For a custom material, the user can provide the path of the file with
0062 the material form factor (with MI) through the
0063 ```
0064  /det/SetCustomMatFF
0065 ```
0066 command. As an example, the file myFF.dat contains the form factor of 
0067 NH<sub>4</sub>NO<sub>3</sub> measured by Harding in 1999. 
0068 In this case the slits upstream and downstream the phantom 
0069 are present. This setup is suitable for both monochromatic and 
0070 polychromatic beams. To speed-up the simulation, a monochromatic 
0071 photon beam was chosen, but a polychromatic beam can be easily defined.    
0072 
0073 ## Physics
0074 
0075 In this example, only electromagnetic processes and decays are considered.
0076 
0077 They are defined in a custom physics list that allows the user to
0078 choose among various EM PhysicsList constructors. In particular,
0079 by choosing G4EmPenelopePhysicsMI and setting fUseMIFlag as true, 
0080 it is possible to enable the molecular interference effects. This
0081 is the default configuration.
0082 
0083 ## Action Initialization
0084 
0085 SAXSActionInitialization class instantiates and registers to 
0086 Geant4 kernel all user action classes. While in sequential mode 
0087 the action classes are instatiated just once, by invoking the 
0088 method: SAXSActionInitialization::Build(),
0089 in multi-threading mode the same method is invoked for each thread 
0090 worker and so all user action classes are defined thread-local.
0091 
0092 A run action class is instantiated both thread-local and global.
0093 That's why its instance is created also in the method
0094 SAXSActionInitialization::BuildForMaster(), which is 
0095 invoked only in multi-threading mode.
0096 
0097 ## Primary generator
0098 
0099 The primary generator action class employs the G4GeneralParticleSource (GPS)
0100 generator. The primary beam has to be defined via the G4 built-in 
0101 commands of the G4GeneralParticleSource in a input macro file. 
0102 In particular, a photon beam directed toward the phantom must be defined
0103 to test the MI effects. The X-ray beam can be monochromatic or
0104 polychromatic, parallel or divergent.     
0105 
0106 
0107 ## Event and Detector Response
0108 
0109 An event consists of the generation of a single particle which is 
0110 transported through the phantom and then to the sensitive detector. 
0111    
0112 The interactions of the photons inside the phantom, and in particular,
0113 the scattering events, are scored in a dedicated ntuple through the
0114 SAXSSteppingAction class.
0115    
0116 The hits of the particles on the sensitive detector positioned 
0117 downstream of the phantom (SAXSSensitiveDetectorHit) are recorded
0118 in a dedicated ntuple through the SAXSSensitiveDetector class. 
0119 
0120 ## Analysis
0121 
0122 The analysis tools are used to accumulate statistics.
0123 ntuple are created in SAXSRunAction::SAXSRunAction() 
0124 constructor for the following quantities:
0125   
0126 Ntuple1 (<code>part</code>) - Particles impinging on the Sensitive Detector (SD):
0127 
0128 - energy of the particles
0129 - position of the hits
0130 - momentum of the particles
0131 - time of the hits
0132 - type of impinging particles
0133 - ID number of the impinging particles 
0134 - number of scattering events a primary had before hitting the SD
0135 - event number of the hits
0136    
0137 Ntuple2 (<code>scatt</code>) - Interactions of photons inside the phantom:
0138 
0139 - ID of the process occurred 
0140       (0-> transportation, 1->Rayleigh, 2->Compton, 3->Photoelectic)
0141 - initial energy of the particles
0142 - scattering angle
0143 
0144 The ntuples are saved in the output file in the Root format.
0145 When running in multi-threading mode, the ntuples accumulated 
0146 on threads are automatically merged in a single output file.
0147    
0148 The default output format is root. Two root scripts come with 
0149 this example to analyze the output file: scattAnalysis.C and 
0150 ADXRD.C. The first can be used to analyze the <code>scatt</code> ntuple, while 
0151 the second can be used for <code>part</code> ntuple.
0152 
0153 ## How to run
0154 
0155 Execute <code>saxs</code> in the 'interactive mode' with visualization:
0156 ```
0157   % ./saxs
0158 ```
0159 and type in the commands line by line:
0160 ```
0161   Idle> /control/verbose 2
0162   Idle> /tracking/verbose 1
0163   Idle> ...
0164   Idle> /run/beamOn 10 
0165   Idle> ...
0166   Idle> exit
0167 ```
0168 or it is possible to run a macro file (test.in is a simple macro where the 
0169 primary beam is defined through the usual GPS commands):
0170 ```
0171   Idle> /control/execute test.in
0172   Idle> /run/beamOn 10 
0173   ....
0174   Idle> exit
0175 ```
0176 
0177 Execute saxs in the 'batch' mode from macro files (without visualization)
0178 ```
0179   % ./saxs saxs.in [Ncores]   
0180   % ./saxs saxs_slits.in [Ncores]
0181 ```
0182   <code>Ncores</code> (optional argument) is the number of threads the user wants
0183   to use in MT mode.
0184       
0185 ## Appendix
0186 
0187 The following paragraphs are common to all basic examples
0188 
0189 ## VISUALISATION
0190 
0191    The visualization manager is set via the G4VisExecutive class
0192    in the main() function in exampleB1.cc.
0193    The initialisation of the drawing is done via a set of /vis/ commands
0194    in the macro vis.mac. This macro is automatically read from
0195    the main function when the example is used in interactive running mode.
0196 
0197    By default, vis.mac opens the default viewer (/vis/open).
0198    This chooses a graphics system (in order of priority):
0199    - by argument in G4VisExecutive construction.
0200    - by environment variable, G4VIS_DEFAULT_DRIVER.
0201    - by information in ~/.g4session.
0202    - by mode (batch/interactive) and if interactive, by your build flags.
0203 
0204    The user can change the initial viewer
0205    - with environment variable G4VIS_DEFAULT_DRIVER. The format is
0206      ```
0207      <graphics-system> [<window-size-hint>]
0208      ```
0209      Set this, e.g:
0210      - (bash) export G4VIS_DEFAULT_DRIVER=TSG
0211      - (tcsh) setenv G4VIS_DEFAULT_DRIVER OI
0212        - The window-size-hint can optionally be added, e.g:
0213        - (bash) export G4VIS_DEFAULT_DRIVER="RayTracerQt 1000x1000-0+0"
0214    - on the command line, precede the app invocation, e.g:
0215      - ```
0216        G4VIS_DEFAULT_DRIVER=Vtk ./<application-name>
0217        ```
0218    - with ~/.g4session.
0219 
0220    For other suggestions for G4VIS_DEFAULT_DRIVER (see list of registered
0221    graphics systems printed at the start):
0222    - DAWNFILE: to create a .prim file suitable for viewing in DAWN.
0223    - VRML2FILE: to create a .wrl file suitable for viewing in a VRML viewer.
0224    - "TSG_OFFSCREEN 1200x1200": to create an image file with TSG.
0225      - See the tsg_offscreen.mac in examples/basic/B5 for more commands
0226        to change the file format, file name, picture size, etc.
0227 
0228    See "Choosing a graphics viewer" in the Application Guide for details.
0229 
0230    Of course you can change the viewer by editing the /vis/open line in vis.mac.
0231 
0232    Also, after the initial viewer opens, you may open a different viewer by typing
0233    on the command line, e.g:
0234 ```
0235 /vis/open DAWNFILE
0236 ```
0237    or
0238 ```
0239 /vis/open RayTraceQt
0240 ```
0241    (if you are using the Qt GUI).
0242 
0243    The view parameters of the existing viewer are copied.
0244 
0245    The DAWNFILE and similar drivers are always available
0246    (since they require no external libraries), but the OGL driver requires
0247    that the Geant4 libraries have been built with the OpenGL option.
0248 
0249    The vis.mac macro in example B1 has additional commands
0250    that demonstrate additional functionality of the vis system, such as
0251    displaying text, axes, scales, date, logo and shows how to change
0252    viewpoint and style.  Consider copying these to other examples or
0253    your application.  To see even more commands use help or
0254    ls or browse the available UI commands in the Application
0255    Developers Guide, "Controlling Visualization from Commands".
0256 
0257 ### User Interfaces
0258  
0259 The user command interface is set via the G4UIExecutive class
0260 in the main() function in saxs.cc.
0261 
0262 The selection of the user command interface is then done automatically
0263 according to the Geant4 configuration or it can be done explicitly via
0264 the third argument of the G4UIExecutive constructor (see exampleB4a.cc).