Back to home page

EIC code displayed by LXR

 
 

    


Warning, /geant4/examples/basic/B2/README.md is written in an unsupported language. File is not indexed.

0001 \page ExampleB2 Example B2
0002 
0003 This example simulates a simplified fixed target experiment.
0004 
0005 ## GEOMETRY DEFINITION
0006 
0007    The setup consists of a target followed by six chambers of increasing
0008    transverse size at defined instances from the target. These chambers are
0009    located in a region called the Tracker region.
0010    Their shape are cylinders, constructed as simple cylinders
0011    (in B2a::DetectorConstruction) and as parametrised volumes
0012    (in B2b::DetectorConstruction), see also B2b::ChamberParameterisation class.
0013 
0014    In addition, a global, uniform, and transverse magnetic field can be
0015    applied using G4GlobalMagFieldMessenger, instantiated in
0016    B2a::DetectorConstruction::ConstructSDandField with a non zero field value,
0017    or via interactive commands.
0018    For example:
0019 ```
0020 /globalField/setValue 0.2 0 0 tesla
0021 ```
0022    An instance of the B2::TrackerSD class is created and associated with each
0023    logical chamber volume (in B2a) and with the one G4LogicalVolume associated
0024    with G4PVParameterised (in B2b).
0025 
0026    One can change the materials of the target and the chambers
0027    interactively via the commands defined in B2a::DetectorMessenger
0028    (or B2b::DetectorMessenger). For example:
0029 ```
0030 /B2/det/setTargetMaterial G4_WATER
0031 /B2/det/setChamberMaterial G4_Ar
0032 ```
0033 
0034 ## PHYSICS LIST
0035 
0036    The particle's type and the physic processes which will be available
0037    in this example are set in the FTFP_BERT physics list. This physics list
0038    requires data files for electromagnetic and hadronic processes.
0039    See more on installation of the datasets in
0040    <a href="http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/InstallationGuide/html/ch03s03.html">
0041    Geant4 Installation Guide, Chapter 3.3: Note On Geant4 Datasets </a>.
0042    The following datasets: G4LEDATA, G4LEVELGAMMADATA, G4SAIDXSDATA and
0043    G4ENSDFSTATEDATA are mandatory for this example.
0044 
0045    In addition, the build-in interactive command:
0046 ```
0047 /process/(in)activate processName
0048 ```
0049    allows the user to activate/inactivate the processes one by one.
0050 
0051 ## ACTION INITALIZATION
0052 
0053    A newly introduced class, B2::ActionInitialization,
0054    instantiates and registers to Geant4 kernel all user action classes.
0055 
0056    While in sequential mode the action classes are instatiated just once,
0057    via invoking the method:
0058      B2::ActionInitialization::Build()
0059    in multi-threading mode the same method is invoked for each thread worker
0060    and so all user action classes are defined thread-local.
0061 
0062    A run action class is instantiated both thread-local
0063    and global that's why its instance is created also in the method
0064       B2::ActionInitialization::BuildForMaster()
0065    which is invoked only in multi-threading mode.
0066 
0067 ## PRIMARY GENERATOR
0068 
0069    The primary generator action class employs the G4ParticleGun.
0070    The primary kinematics consists of a single particle which starts close
0071    to the world boundary and hits the target perpendicular to the entrance
0072    face. The type of the particle and its energy can be changed via the
0073    Geant4 built-in commands of the G4ParticleGun class.
0074 
0075 ## RUNS and EVENTS
0076 
0077    A run is a set of events.
0078 
0079    The user has control:
0080       - at Begin and End of each run (class B2::RunAction)
0081       - at Begin and End of each event (class B2::EventAction)
0082       - at Begin and End of each track (class TrackingAction, not used here)
0083       - at End of each step (class SteppingAction, not used here)
0084 
0085    The event number is written to the log file every requested number
0086    of events in B2::EventAction::BeginOfEventAction() and
0087    B2::EventAction::EndOfEventAction().
0088    Moreover, for the first 100 events and every 100 events thereafter
0089    information about the number of stored trajectories in the event
0090    is printed as well as the number of hits stored in the G4VHitsCollection.
0091 
0092    The run number is printed at B2::RunAction::BeginOfRunAction(), where the
0093    G4RunManager is also informed how to SetRandomNumberStore for storing
0094    initial random number seeds per run or per event.
0095 
0096 ## USER LIMITS
0097 
0098    This example also illustrates how to introduce tracking constraints
0099    like maximum step length, minimum kinetic energy etc. via the G4UserLimits
0100    class and associated G4StepLimiter and G4UserSpecialCuts processes.
0101    See B2a::DetectorConstruction (or B2b::DetectorConstruction).
0102 
0103    The maximum step limit in the tracker region can be set by the interactive
0104    command (see B2a::DetectorMessenger, B2b::DetectorMessenger classes).
0105    For example:
0106 
0107 ```
0108 /B2/det/stepMax 1.0 mm
0109 ```
0110 
0111 ## DETECTOR RESPONSE
0112 
0113    A HIT is a step per step record of all the information needed to
0114    simulate and analyse the detector response.
0115 
0116    In this example the Tracker chambers are considered to be the detector.
0117    Therefore, the chambers are declared 'sensitive detectors' (SD) in
0118    the B2a::DetectorConstruction (or B2b::DetectorConstruction) class.
0119    They are associated with an instance of the B2::TrackerSD class.
0120 
0121    Then, a Hit is defined as a set of 4 informations per step, inside
0122    the chambers, namely:
0123      - the track identifier (an integer),
0124      - the chamber number,
0125      - the total energy deposit in this step, and
0126      - the position of the energy deposit.
0127 
0128    A given hit is an instance of the class B2::TrackerHit which is created
0129    during the tracking of a particle, step by step, in the method
0130    B2::TrackerSD::ProcessHits(). This hit is inserted in a HitsCollection.
0131 
0132    The HitsCollection is printed at the end of each event (via the method
0133    B2::TrackerSD::EndOfEvent()), under the control of the command:
0134 ```
0135 /hits/verbose 2
0136 ```
0137 
0138 <hr>
0139 
0140  The following paragraphs are common to all basic examples
0141 
0142 ## VISUALISATION
0143 
0144    The visualization manager is set via the G4VisExecutive class
0145    in the main() function in exampleB2a.cc (or exampleB2b.cc).
0146    The initialisation of the drawing is done via a set of /vis/ commands
0147    in the macro vis.mac. This macro is automatically read from
0148    the main function when the example is used in interactive running mode.
0149 
0150    By default, vis.mac opens the default viewer (/vis/open).
0151    This chooses a graphics system (in order of priority):
0152    - by argument in G4VisExecutive construction.
0153    - by environment variable, G4VIS_DEFAULT_DRIVER.
0154    - by information in ~/.g4session.
0155    - by mode (batch/interactive) and if interactive, by your build flags.
0156 
0157    The user can change the initial viewer
0158    - with environment variable G4VIS_DEFAULT_DRIVER. The format is
0159      ```
0160      <graphics-system> [<window-size-hint>]
0161      ```
0162      Set this, e.g:
0163      - (bash) export G4VIS_DEFAULT_DRIVER=TSG
0164      - (tcsh) setenv G4VIS_DEFAULT_DRIVER OI
0165        - The window-size-hint can optionally be added, e.g:
0166        - (bash) export G4VIS_DEFAULT_DRIVER="RayTracerQt 1000x1000-0+0"
0167    - on the command line, precede the app invocation, e.g:
0168      - ```
0169        G4VIS_DEFAULT_DRIVER=Vtk ./<application-name>
0170        ```
0171    - with ~/.g4session.
0172 
0173    For other suggestions for G4VIS_DEFAULT_DRIVER (see list of registered
0174    graphics systems printed at the start):
0175    - DAWNFILE: to create a .prim file suitable for viewing in DAWN.
0176    - VRML2FILE: to create a .wrl file suitable for viewing in a VRML viewer.
0177    - "TSG_OFFSCREEN 1200x1200": to create an image file with TSG.
0178      - See the tsg_offscreen.mac in examples/basic/B5 for more commands
0179        to change the file format, file name, picture size, etc.
0180 
0181    See "Choosing a graphics viewer" in the Application Guide for details.
0182 
0183    Of course you can change the viewer by editing the /vis/open line in vis.mac.
0184 
0185    Also, after the initial viewer opens, you may open a different viewer by typing
0186    on the command line, e.g:
0187 ```
0188 /vis/open DAWNFILE
0189 ```
0190    or
0191 ```
0192 /vis/open RayTraceQt
0193 ```
0194    (if you are using the Qt GUI).
0195 
0196    The view parameters of the existing viewer are copied.
0197 
0198    The DAWNFILE and similar drivers are always available
0199    (since they require no external libraries), but the OGL driver requires
0200    that the Geant4 libraries have been built with the OpenGL option.
0201 
0202 ## USER INTERFACES
0203 
0204    The user command interface is set via the G4UIExecutive class
0205    in the main() function in exampleB2a.cc
0206 
0207    The selection of the user command interface is then done automatically
0208    according to the Geant4 configuration or it can be done explicitly via
0209    the third argument of the G4UIExecutive constructor (see exampleB2a.cc).
0210 
0211    The gui.mac macros are provided in examples B2, B4 and B5. This macro
0212    is automatically executed if Geant4 is built with any GUI session.
0213    It is also possible to customise the icons menu bar which is
0214    demonstrated in the icons.mac macro in example B5.
0215 
0216 ## HOW TO RUN
0217 
0218    - Execute exampleB2a in the 'interactive mode' with visualization
0219 ```
0220 % exampleB2a
0221 and type in the commands from run1.mac line by line:
0222 Idle> /tracking/verbose 1
0223 Idle> /run/beamOn 1
0224 Idle> ...
0225 Idle> exit
0226 ```
0227       or
0228 ```
0229 Idle> /control/execute run1.mac
0230 ....
0231 Idle> exit
0232 ```
0233 
0234    - Execute exampleB2a in the 'batch' mode from macro files
0235    (without visualization)
0236 ```
0237 % exampleB2a run2.mac
0238 % exampleB2a exampleB2.in > exampleB2.out
0239 ```