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] [ 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 ]

Name Size       Last modified (GMT) Description
Back Parent directory       2024-12-05 15:16:16
Folder include/       2024-12-05 15:16:16
Folder src/       2024-12-05 15:16:16
File CMakeLists.txt 1678 bytes       2024-12-05 15:16:16
File GNUmakefile 391 bytes       2024-12-05 15:16:16
File History 16773 bytes       2024-12-05 15:16:16
File README 13854 bytes       2024-12-05 15:16:16
C++ file exampleB5.cc 3991 bytes       2024-12-05 15:16:16
File exampleB5.in 1337 bytes       2024-12-05 15:16:16
File exampleB5.out 67863 bytes       2024-12-05 15:16:16
File gui.mac 1773 bytes       2024-12-05 15:16:16
File icons.mac 925 bytes       2024-12-05 15:16:16
File init_vis.mac 375 bytes       2024-12-05 15:16:16
File plotter.mac 9839 bytes       2024-12-05 15:16:16
File run.png 14508 bytes       2024-12-05 15:16:16
File run1.mac 659 bytes       2024-12-05 15:16:16
File run2.mac 947 bytes       2024-12-05 15:16:16
File tsg_offscreen.mac 4002 bytes       2024-12-05 15:16:16
File vis.mac 1983 bytes       2024-12-05 15:16:16

  1 
  2     =========================================================
  3     Geant4 - an Object-Oriented Toolkit for Simulation in HEP
  4     =========================================================
  5 
  6                        Extended Example B5
  7                        --------------------
  8 
  9   Example B5 implements a double-arm spectrometer with wire chambers,
 10   hodoscopes and calorimeters.  Event simulation and collection are
 11   enabled, as well as event display and analysis.
 12 
 13 
 14   1- GEOMETRY
 15 
 16    The spectrometer consists of two detector arms
 17    (see B5::DetectorConstruction).  One arm provides
 18    position and timing information of the incident particle while the
 19    other collects position, timing and energy information of the particle
 20    after it has been deflected by a magnetic field centered at the
 21    spectrometer pivot point.
 22 
 23      - First arm:  box filled with air, also containing:
 24 
 25          1 hodoscope (15 vertical strips of plastic scintillator)
 26          1 drift chamber (5 horizontal argon gas layers with a
 27                           "virtual wire" at the center of each layer)
 28 
 29      - Second arm:  box filled with air, also containing:
 30 
 31          1 hodoscope (25 vertical strips of plastic scintillator)
 32          1 drift chamber (5 horizontal argon gas layers with a
 33                           "virtual wire" at the center of each layer)
 34          1 electromagnetic calorimeter:
 35                a box sub-divided along x,y and z
 36                axes into cells of CsI
 37          1 hadronic calorimeter:
 38                a box sub-divided along x,y, and z axes
 39                into cells of lead, with a layer of
 40                plastic scintillator placed at the center
 41                of each cell
 42 
 43       - Magnetic field region: air-filled cylinder which contains
 44                               the field (see B5::MagneticField)
 45 
 46            The maximum step limit in the magnetic field region is also set
 47            via the G4UserLimits class in a similar way as in Example B2.
 48 
 49    The rotation angle of the second arm and the magnetic field value
 50    can be set via the interactive command defined using the G4GenericMessenger
 51    class.
 52 
 53   2- PHYSICS
 54 
 55    This example uses the reference hadronic physics list, FTFP_BERT,
 56    and also adds the G4StepLimiter process.
 57 
 58 
 59   3- ACTION INITALIZATION
 60 
 61    B5::ActionInitialization class
 62    instantiates and registers to Geant4 kernel all user action classes.
 63 
 64    While in sequential mode the action classes are instatiated just once,
 65    via invoking the method:
 66       B5::ActionInitialization::Build()
 67    in multi-threading mode the same method is invoked for each thread worker
 68    and so all user action classes are defined thread-local.
 69 
 70    A run action class is instantiated both thread-local
 71    and global that's why its instance is created also in the method
 72       B5::ActionInitialization::BuildForMaster()
 73    which is invoked only in multi-threading mode.
 74 
 75   4- PRIMARY GENERATOR
 76 
 77    The primary generator action class employs the G4ParticleGun.
 78    The primary kinematics consists of a single particle which is
 79    is sent in the direction of the first spectrometer arm.
 80 
 81    The type of the particle and its several properties can be changed
 82    via the  G4 built-in commands of  the G4ParticleGun class or
 83    this example command defined using the G4GenericMessenger class.
 84 
 85 
 86   5- EVENT
 87 
 88    An event consists of the generation of a single particle which is
 89    transported through the first spectrometer arm.  Here, a scintillator
 90    hodoscope records the reference time of the particle before it passes
 91    through a drift chamber where the particle position is measured.
 92    Momentum analysis is performed as the particle passes through a magnetic
 93    field at the spectrometer pivot and then into the second spectrometer
 94    arm.  In the second arm, the particle passes through another hodoscope
 95    and drift chamber before interacting in the electromagnetic calorimeter.
 96    Here it is likely that particles will induce electromagnetic showers.
 97    The shower energy is recorded in a three-dimensional array of CsI
 98    crystals.  Secondary particles from the shower, as well as primary
 99    particles which do not interact in the CsI crystals, pass into the
100    hadronic calorimeter.  Here, the remaining energy is collected in a
101    three-dimensional array of scintillator-lead sandwiches.
102 
103    Several aspects of the event may be changed interactively by the user:
104      - angle of the second spectrometer arm
105      - strength of magnetic field
106      - initial particle type
107      - initial momentum and angle
108      - momentum and angle spreads
109      - type of initial particle may be randomized
110 
111    The initial particle type can be changed using the G4ParticleGun command:
112      /gun/particle particleName
113 
114    The UI commands specific to this example are available in /B5 command
115    directory:
116      /B5/detector/armAngle angle unit
117      /B5/field/value field unit
118      /B5/generator/momentum  value unit
119      /B5/generator/sigmaMomentum value unit
120      /B5/generator/sigmaAngle value unit
121      /B5/generator/randomizePrimary [true|false]
122 
123    They are implemented in
124      B5::DetectorConstruction::DefineCommands(),
125      B5::MagneticField::DefineCommands() and
126      B5::PrimaryGeneratorAction::DefineCommands() methods
127    using G4GenericMessenger class.
128 
129    In first execution of BeginOfEventAction()
130    the hits collections identifiers are saved in data members of the class
131    and used in EndOfEventAction() for accessing
132    the hists collections and filling the accounted information in defined
133    histograms and ntuples and printing its summary in a log file.
134    The frequency of printing can be tuned with the built-in command
135      /run/printProgress  frequency
136 
137   6- DETECTOR RESPONSE:
138 
139      All the information required to simulate and analyze an event is
140      recorded in hits.  This information is recorded in the following
141      sensitive detectors:
142 
143        - hodoscope:
144            particle time
145            strip ID, position and rotation
146              (see B5::HodoscopeSD, B5::HodoscopeHit classes)
147 
148        - drift chamber:
149            particle time
150            particle position
151            layer ID
152              (see B5::DriftChamberSD, B5::DriftChamberHit classes)
153 
154        - electromagnetic calorimeter:
155            energy deposited in cell
156            cell ID, position and rotation
157              (see B5::EMCalorimeterSD, B5::EMCalorimeterHit classes)
158 
159        - hadronic calorimeter:
160            energy deposited in cell
161            cell column ID and row ID, position and rotation
162              (see B5::HadCalorimeterSD, B5::HadCalorimeterHit classes)
163 
164      The hit classes include methods GetAttDefs and CreateAttValues to define
165      and then fill extra "HepRep-style" Attributes that the visualization system
166      can use to present extra information about the hits.
167      For example, if you pick a B5::HadCalorimeterHit in OpenGL or a HepRep viewer,
168      you will be shown the hit's "Hit Type", "Column ID", "Row ID",
169      "Energy Deposited" and "Position".
170      These attributes are essentially arbitrary extra pieces of information
171      (integers, doubles or strings) that are carried through the visualization.
172      Each attribute is defined once in G4AttDef object and then is filled for
173      each hit in a G4AttValue object.
174      These attributes can also be used by commands to filter which hits are drawn:
175      /vis/filtering/hits/drawByAttribute
176      Detector Geometry and trajectories also carry HepRep-style attributes,
177      but these are filled automatically in the base classes.
178      HepRep is further described at: http://www.slac.stanford.edu/~perl/heprep/
179 
180   7- ANALYSIS:
181 
182    The analysis tools are used to accumulate statistics.
183    Histograms and an ntuple are created in B5::RunAction::RunAction()
184    constructor for the following quantities:
185 
186    1D histograms:
187    - Number of hits in Chamber 1
188    - Number of hits in Chamber 2
189 
190    2D histograms:
191    - Drift Chamber 1 X vs Y positions
192    - Drift Chamber 2 X vs Y positions
193 
194    Ntuple:
195    - Number of hits in Chamber 1
196    - Number of hits in Chamber 2
197    - Total energy deposit in EM calorimeter
198    - Total energy deposit in Hadronic calorimeter
199    - Time of flight in Hodoscope 1
200    - Time of flight in Hodoscope 2
201    - Vector of energy deposits in EM calorimeter cells
202    - Vector of energy deposits in Hadronic calorimeter cells
203 
204    The histograms and ntuple are saved in two output files in a default
205    (Root) file format.
206 
207    Another file format (for example xml) can be selected either by
208    changing the generic analysis manager default file type:
209      analysisManager->SetDefaultFileType("xml");
210    or by providing the file names with the extension:
211      analysisManager->SetFileName("B5.xml");
212      analysisManager->SetNtupleFileName(0, "B4ntuple.xml");
213 
214    When running in multi-threading mode, the histograms and ntuple accumulated
215    on threads are automatically merged in a single output file.
216 
217   8- PLOTTING:
218 
219   This example comes with a commented plotter.mac that shows how to use the
220   plotting coming with some of the visualization drivers (for example the
221   ToolsSG ones) to see the histograms. In it you will see how to activate
222   the vis driver (create a "scene handler"), create a viewer, create a scene
223   containing a plotter model object, create plotting "regions" (here 2x2
224   regions) and attach the histograms to each region. When done, each
225   run beamOn should display at end the content of the histograms.
226 
227   In the second part of plotter.mac, is shown various ways to customize the
228   regions, for example changing the bins color, the axis labels fonts, etc...
229   This could be done by using default embedded styles, defining styles with commands,
230   or setting up directly parameters of the various parts of a plot by using a
231   dedicated command.
232 
233   By default the fonts used are the Hershey vectorial ones that do not need
234   an extra package, but you can use some freetype fonts if building with the
235   cmake flag -DGEANT4_USE_FREETYPE=ON. Two embedded ttf fonts comes with the
236   ToolsSG plotting: roboto_bold (some open source kind of the Microsoft arialbd)
237   and lato_regular (close to an helvetica). You can use your own .ttf files by
238   using the TOOLS_FONT_PATH environment variable to specify the directory where
239   they could be found.
240 
241  The following paragraphs are common to all basic examples
242 
243  A- VISUALISATION
244 
245    The visualization manager is set via the G4VisExecutive class
246    in the main() function in exampleB5.cc.
247    The initialisation of the drawing is done via a set of /vis/ commands
248    in the macro vis.mac. This macro is automatically read from
249    the main function when the example is used in interactive running mode.
250 
251    By default, vis.mac opens an OpenGL viewer (/vis/open OGL).
252    The user can change the initial viewer by commenting out this line
253    and instead uncommenting one of the other /vis/open statements, such as
254    HepRepFile or DAWNFILE (which produce files that can be viewed with the
255    HepRApp and DAWN viewers, respectively).  Note that one can always
256    open new viewers at any time from the command line.  For example, if
257    you already have a view in, say, an OpenGL window with a name
258    "viewer-0", then
259       /vis/open DAWNFILE
260    then to get the same view
261       /vis/viewer/copyView viewer-0
262    or to get the same view *plus* scene-modifications
263       /vis/viewer/set/all viewer-0
264    then to see the result
265       /vis/viewer/flush
266 
267    The DAWNFILE, HepRepFile drivers are always available
268    (since they require no external libraries), but the OGL driver requires
269    that the Geant4 libraries have been built with the OpenGL option.
270 
271    vis.mac has additional commands that demonstrate additional functionality
272    of the vis system, such as displaying text, axes, scales, date, logo and
273    shows how to change viewpoint and style.
274    To see even more commands use help or ls or browse the available UI commands
275    in the Application Developers Guide.
276 
277    Since 11.1, the TSG visualization driver can also produce the "offscrean"
278    file output in png, jpeg, gl2ps formats without drawing on the screen.
279    It can be controlled via UI commands provided in '/vis/tsg' which are
280    demonstrated in the tsg_offscreen.mac macro in example B5.
281 
282    For more information on visualization, including information on how to
283    install and run DAWN, OpenGL and HepRApp, see the visualization tutorials,
284    for example,
285    http://geant4.slac.stanford.edu/Presentations/vis/G4[VIS]Tutorial/G4[VIS]Tutorial.html
286    (where [VIS] can be replaced by DAWN, OpenGL and HepRApp)
287 
288    The tracks are automatically drawn at the end of each event, accumulated
289    for all events and erased at the beginning of the next run.
290 
291  B- USER INTERFACES
292 
293    The user command interface is set via the G4UIExecutive class
294    in the main() function in exampleB5.cc
295 
296    The selection of the user command interface is then done automatically
297    according to the Geant4 configuration or it can be done explicitly via
298    the third argument of the G4UIExecutive constructor (see exampleB4a.cc).
299 
300    The gui.mac macros are provided in examples B2, B4 and B5. This macro
301    is automatically executed if Geant4 is built with any GUI session.
302    It is also possible to customise the icons menu bar which is
303    demonstrated in the icons.mac macro in example B5.
304 
305  C- HOW TO RUN
306 
307     - Execute exampleB5 in the 'interactive mode' with visualization:
308         % ./exampleB5
309       and type in the commands from run1.mac line by line:
310         Idle> /control/verbose 2
311         Idle> /tracking/verbose 1
312         Idle> /run/beamOn 10
313         Idle> ...
314         Idle> exit
315       or
316         Idle> /control/execute run1.mac
317         ....
318         Idle> exit
319 
320     - Execute exampleB5  in the 'batch' mode from macro files
321       (without visualization)
322         % ./exampleB5 run2.mac
323         % ./exampleB5 exampleB5.in > exampleB5.out
324 
325