Warning, /geant4/examples/advanced/composite_calorimeter/README is written in an unsupported language. File is not indexed.
0001 -------------------------------------------------------------------
0002 -------------------------------------------------------------------
0003
0004 =========================================================
0005 Geant4 - Composite calorimeter example
0006 =========================================================
0007
0008 README
0009 ---------------------
0010
0011 CompositeCalorimeter is an example of a test-beam simulation used
0012 by the CMS Collaboration to validate Geant4 against real data taken
0013 (in 1996) in a CMS Hadron calorimeter test-beam.
0014 The name "Composite" for this example emphasizes that, although the
0015 test-beam had the goal of studying the hadronic calorimeter response,
0016 part of the data was taken with the presence of the electromagnetic
0017 crystal calorimeter in front of the hadronic calorimeter, to better
0018 reproduce the situation as in the real CMS experiment.
0019 The geometry of the simulation has been setup in such a way to allow
0020 very easily, at run time (therefore without need of changing any code;
0021 see below for the details) the inclusion or exclusion of the
0022 electromagnetic calorimeter part.
0023 Although some important aspects, for a detailed comparison between
0024 test-beam data and simulation, like beam profile, noise, and digitization,
0025 have been omitted here (to avoid too many technical details),
0026 nevertheless, this example is able to reproduce the main features of
0027 most of the relevant observables as measured in the real test-beam.
0028 The output of this example consists of a set of histograms
0029 and one ntuple which are stored on a ROOT file (default).
0030 In our opinion, the most original "lesson" which is offered by this
0031 advanced example for the Geant4 user is to show how the Geometry and
0032 the Sensitive/Hit part of the simulation is treated in a big experiment.
0033 Although the details of how this is done vary from experiment to
0034 experiment (it is worth, for instance, to compare with the Atlas-based
0035 advanced example lAr_calorimeter), the main driving needs and goals
0036 are quite general: to have consistency, but avoiding duplications
0037 and couplings as much as possibile, between Simulation, Reconstruction,
0038 and Visualization. Notice that the solution offered in this example
0039 by CMS could appear "overdone" for the sake of simulating only a
0040 relatively simple test-beam setup; but it should be kept in mind
0041 that the same approach is used also for the full CMS detector
0042 simulation, as well as for any subdetector.
0043
0044
0045 1. Setting up the environment variables
0046 ---------------------------------------
0047
0048 The user should first setup, as "usual", the Geant4 environmental
0049 variables (e.g. the script produced by cmake)
0050 Then the specific setup for this example should be run:
0051
0052 > source envExample.csh in the case of C-shell
0053 or
0054 > . envExample.sh in the case of bash-shell
0055
0056 The analysis part is based on the native g4analysis tools. As default
0057 the output is a ROOT file. This can be changed to XML by changing the G4AnalysisManager default file type in CCalRunAction::BeginOfRunAction().
0058
0059
0060 2. Sample run
0061 -------------
0062
0063 Once the environmental variables are setup, you can get the executable
0064 CompositeCalorimeter
0065 by configuring with cmake and then running the compiler.
0066 Then, you can execute it using the Geant4 macro command input file test.g4mac
0067 as follows:
0068
0069 > ./CompositeCalorimeter test.g4mac
0070
0071 which simulate a few events, each being a 100 GeV pi- incident on the
0072 electromagnetic crystal calorimeter followed by the hadronic calorimeter,
0073 without magnetic field.
0074 The output is the ROOT file "ccal.root" .
0075 See part "8. Analysis / Histogramming" below for more details on the
0076 content of that file.
0077 If you run instead:
0078
0079 > ./CompositeCalorimeter
0080
0081 after having setup the Geant4 visualization variables and the PATH,
0082 you can visualize the geometry of the apparatus, and also see some
0083 events. Similarly, you can get a very simple graphical user interface
0084 that allows to select the particle type, its energy, and the number
0085 of events (between a limited number of possibilities).
0086 For more details, see part "9. Visualization / GUI".
0087
0088
0089 3. Detector description
0090 -----------------------
0091
0092 Let's start with a brief description of the test-beam setup.
0093
0094 There are two possible configurations:
0095 i) HCAL only, that is only the hadronic calorimeter is present;
0096 ii) ECAL+HCAL, that is the electromagnetic calorimeter (ECAL)
0097 is placed in front of the hadronic calorimeter.
0098 ECAL is made of 23 cm long PbWO4 crystals (corresponding to about
0099 25.8 radiation lengths, and 1.1 interaction lengths); for the
0100 test beam a 7 x 7 = 49 matrix of crystals is used.
0101 HCAL is a sampling calorimeter, with plastic scintillator as sensitive
0102 part and copper as absorber. 28 scintillator plates were used with
0103 absorber of varying thickness in between, and also varying thickness
0104 and type of scintillator. More precisely:
0105 --- layer 1: 2 cm of Copper
0106 --- layer 2 to 7: 4 cm of Copper
0107 --- layer 8 to 21: 6 cm of Copper
0108 --- layer 22 to 27: 8 cm of Copper
0109 For the scintillators: 2 mm passive Plastic; 4 mm active Plastic;
0110 1 mm passive Plastic.
0111 The total length of HCAL consists of 152 cm of Copper plus 189 mm of Plastic.
0112 The dimension orthogonal to the beam direction is 64 cm x 64 cm.
0113 The ECAL and HCAL considered here are prototypes for the Central and
0114 Endcap calorimeters of the CMS detector (which covers the rapidity
0115 region |eta| < 3.0 ; CMS has also a Forward calorimeter, which covers
0116 the region 3.0 < |eta| < 5.0, but this part was not considered in
0117 this test-beam setup). Notice, however, that there are more layers
0118 (28 instead of 19 in the Barrel or 18 in the Endcap) of HCAL in the
0119 test-beam setup than in the real CMS detector, in order to study
0120 energy containment. Therefore, the ECAL+HCAL in the test-beam amounts
0121 to more than 11 radiation lengths as for the real CMS detector (the
0122 19 layers of the Barrel have each 6 cm of absorber, whereas the
0123 18 layers of the Endcap have each 6.6 cm of absorber, so that the
0124 number of interaction lengths are rougly the same).
0125 Five values of the magnetic field (parallel to the face of the scintillators)
0126 have been considered in the test-beam: 0.0 , 0.375 , 0.75 , 1.50 , 3.0 Tesla.
0127
0128 In order to set the magnetic field, you have to edit the file
0129 dataglobal/fmap.tb96
0130 and change the first number (which appears in the third line of
0131 that file, on the first column; the unit being Tesla):
0132 #. Field map
0133 *DO FLDM
0134 0.0 9 652.0
0135 for example, if you want a magnetic field of 3.0 Tesla the last
0136 line must be set as follows (the magnetic field unity is kilo Gauss).
0137 30.0 9 652.0
0138
0139 In order to deactivate either the ECAL or the HCAL, it is enough
0140 to comment out the corresponding line in the file g4testbeamhcal96.conf,
0141 using "#" as the comment character. For instance, to have only the HCAL
0142 without ECAL:
0143 "HcalTB96" "tbhcal96" 1
0144 #"CrystalMatrixModule" "tbhcal96xtal" 1
0145
0146
0147 In this test-beam setup, at the back of ECAL, there is also some
0148 material for support and readout, which has been considered in the
0149 simulation. For the HCAL, only the fibres are close to the test-beam,
0150 and because they have the same composition as the scintillators
0151 they are adequately represented in the simulation; the remaining
0152 of the readout, including the photomultipliers, are in readout boxes
0153 far away from the HCAL, and hence are not present in the simulation.
0154
0155 Let's summarizes now the geometry description of the simulation.
0156 As said in the introduction, this part is the most original and
0157 important of this example, but it is quite complex and can be fully
0158 appreciated only in the context of the CMS software framework, in
0159 particular in the relation between Simulation, Reconstruction, and
0160 Visualization. Therefore we limit ourself to only few considerations,
0161 pointing to the internal CMS documentation for more details.
0162
0163 --- In order to share the same geometrical and physical information
0164 about CMS between Simulation, Reconstruction, and Visualization,
0165 avoiding inconsistencies, duplications, and unnecessary dependecies,
0166 all these information is store, once for all, in common databases
0167 (typically in XML format), instead of putting them inside C++ classes,
0168 as usually done in simpler detector descriptions (in most of the
0169 the Geant4 examples, novice or advanced, the geometry information
0170 is kept inside the concrete class which inherits from
0171 G4VUserDetectorConstruction). For simplicity, in this example,
0172 these "databases" are nothing more than ASCII files:
0173
0174 datageom/ : tbhcal96.geom, tbhcal96hcal.geom, tbhcal96xtal.geom
0175 store the information about the experimental Hall,
0176 the HCAL, and the ECAL, respectively.
0177
0178 dataconf/ : g4testbeamhcal96.conf, testbeamhcal96.conf
0179 store the information about which configuration
0180 (HCAL only, or ECAL+HACL) is considered, in the
0181 Simulation and Reconstruction, respectively.
0182
0183 dataglobal/ : fmap.tb96, material.cms, rotation.cms
0184 The first one is the magnetic field map (how the
0185 intensity of the magnetic field, in the direction
0186 orthogonal to the beam direction, varies along
0187 the beam axis). The second one, material.cms,
0188 keeps the full collection of all materials used in
0189 the CMS detector (not only in the calorimeters,
0190 although we are simulating only them in this example!).
0191 The third one, rotation.cms, collects a set of useful
0192 rotation parameters (angles).
0193
0194 datavis/ : tbhcal96.vis, tbhcal96hcal.vis, tbhcal96xtal.vis
0195 visualization information for, respectively, the
0196 experimental Hall, HCAL, and ECAL.
0197
0198 --- In order to allow an high degree of flexibility, at the geometry
0199 level the user can choose which subsystem of the detector setup
0200 should be simulated and can activate or deactivate the sensitive
0201 parts, subsystem by subsystem. This can be done at run time,
0202 by modifying one of the above database information, without need
0203 of putting the hands on the code, recompiling, etc.
0204
0205 --- There are two "parallel geometry factories": one described by "core"
0206 classes, which are independent from the Simulation (and therefore
0207 can be used, for instance, by the Reconstruction); and one which
0208 is specific of the Simulation. In the latter case (Geant4 side of
0209 the geometry model), all the geometry factories are derived from the
0210 base class CCalG4Albe. Furthermore, using double inheritance, each
0211 of them derives also from the counterpart in the "core" hierarchy.
0212 The design of the CCalG4Able class helps a modular approach and easy
0213 interchanging at the level of subdetectors, allowing a straightforward
0214 transition from the simulation of the entire CMS detector to that of
0215 just a part of it, or to a test-beam geometry, as indeed in this example.
0216 Of course this modular, flexible, and general approach does not come
0217 for free: the price to pay here is its complexity, which would be
0218 otherwise unjustified if we limited ourself to the pure simulation
0219 of a relatively simple test-beam setup.
0220
0221 --- See "10. Classes Overview" below for a schematic summary of the
0222 various classes involved in the Geometry description of this example.
0223
0224
0225 4. Physics processes
0226 --------------------
0227
0228 The factory physics list is used, therefore the choice of the physics list
0229 is steered by the environmental variable PHYSLIST.
0230 (Note: if this environmental variable is not set, the default physics list
0231 which is used is FTFP_BERT).
0232
0233
0234 5. Particle Generator
0235 ---------------------
0236
0237 The 1996 test-beam has been taken with the following particles:
0238 --- 225 GeV muons (for calibration)
0239 --- 10 to 300 GeV pions
0240 --- 10 to 300 GeV electrons
0241 therefore the standard Geant4 Particle Gun has been used as primary
0242 generator. Notice that, for the sake of keeping the example not too
0243 complicated, the proper simulation of the beam profile and
0244 beam contamination have been neglected.
0245
0246
0247 6. Hits
0248 -------
0249
0250 In CMS there are two groups of hits: Tracker-like and Calorimeter-like.
0251 Only the latter one appears in this example.
0252 For the same reasons, as seen for the Geometry, of consistency without
0253 duplication of information and unnecessary coupling between Simulation,
0254 Reconstruction, and Visualization, the simulation calorimeter hit class,
0255 CCalG4Hit, doubly inherits from the common Geant4 abstract class for
0256 all hits, G4VHit, and from the "core" (i.e. simulation independent)
0257 CMS calorimeter hit class, CCalHit.
0258 A new Hit object is created
0259 - for each new particle entering the calorimeter;
0260 - for each detector unit (i.e cristal or fiber or scintillator layer);
0261 - for each nanosecond of the shower development;
0262 The information stored in each CCalHit object is the following:
0263 - Entry : local coordinates of the entrance point of the particle
0264 in the unit where the shower starts;
0265 - the TrackID : Identification number of the incident particle;
0266 - the IncidentEnergy : kinetic energy of that incident particle;
0267 - the UnitID : the identification number of the detector unit
0268 (crystal, or fiber, or scintillator layer);
0269 - the TimeSlice : the time interval, in nanoseconds, in which the
0270 hit has been created;
0271 - the EnergyDeposit : the energy deposit in this hit.
0272 Notice that all hit objects created for a given shower have the same
0273 values for the first three pieces of information.
0274
0275
0276 No Noise and Digitization
0277 --------------------------
0278
0279 In order to keep the complexity of this example to a reasonable
0280 level, both noise and digitization effects have not been included.
0281
0282
0283 7. User Actions
0284 ----------------
0285
0286 In this example. there have been used the following User Actions:
0287
0288 --- G4UserRunAction (the derived, concrete class is CCalRunAction):
0289 it is used to invoke the Analysis object at the beginning of
0290 the Run, to instantiate it and passing it the Run number, and
0291 at the end of the Run, to inform it that the Run is finished
0292 and therefore the histograms, ntuples, etc. must be closed.
0293
0294 --- G4UserEventAction (the derived, concrete class is CCalEndOfEventAction):
0295 it is used to examine, at the end of the Event, all collected
0296 (calorimeter) hits, extract the various observables which are
0297 interesting (to the goal of understanding things like: the effect
0298 of magnetic field on scintiallator; choice of the absorber
0299 thickness by optimizing resolution versus containment; impact of
0300 the absorber depth in the energy caontainment; electromagnetic
0301 calorimeter contribution in the electron - pion separation; etc.)
0302 and finally call the analysis object to store such selected
0303 information on histograms and/or in the ntuple.
0304 The name of the class "CCalEndOfEventAction" is motivated by the
0305 fact that at the beginning of the Event nothing is done.
0306
0307 --- G4UserSteppingAction (the derived, concrete class is CCalSteppingAction):
0308 it is used to extract some "unphysical" information (that is not
0309 experimentally measurable, although interesting for a better
0310 understanding of the shower development), namely the lateral profile
0311 and the deposit as a function of the time (see "8.Analysis/Histogramming
0312 for more details"), which is available only from simulation, and then,
0313 at the end of Event, the analysis object is invoked to store such
0314 information on histograms.
0315 Please notice that the stepping action is not used to create hits.
0316
0317 --- G4UserStackingAction (the derived, concrete class is CCalStackingAction):
0318 it is used to ensure that the same track ID of the particle
0319 originating a shower appears in all hits (calorimeter hit objects
0320 of class CCalHit) of the shower, in any calorimeter part.
0321
0322
0323 8. Analysis / Histogramming
0324 ----------------------------
0325
0326 The analysis part of CompositeCalorimeter is kept in class CCalAnalysis,
0327 and is based on the g4tool interfaces.
0328 Both the histograms and the ntuple are saved at the end of the run in the
0329 ROOT file "ccal.root" (default: this can be changed to XML or to other
0330 formats supported by the g4analysis tools).
0331 Please note that in a multiple run session, the last run always overrides
0332 the output file.
0333 What the histograms and the variables of the ntuple represent is
0334 explained below:
0335
0336 Histograms h100 - h127 : energy deposit (in GeV) in the sensitive part
0337 (plastic scintillator layer) of one Hadronic
0338 calorimeter module (there are 28 modules, numbered
0339 from 0 to 27, and the corresponding histogram has
0340 ID = 100 + number of module).
0341 Ntuple variables hcal0 - hcal27 : provide the same information.
0342
0343 Histograms h200 - h248 : energy deposit (in GeV) in one crystal
0344 electromagnetic towers (there are a matrix of
0345 7 x 7 = 49 towers, numbered from 0 to 48, and
0346 the corresponding histogram has
0347 ID = 200 + number of tower).
0348 Ntuple variables ecal0 - ecal48 : provide the same information.
0349
0350 Histograms h300 - h339 : total energy deposit (in GeV) in any
0351 electromagnetic crystal tower or hadronic module
0352 (either in a sensitive or insensitive layer)
0353 in one of the 40 nanosecond time slices: in other
0354 words, histogram 300+I , where I = 0 - 39,
0355 contains the total deposit energy between
0356 I and I+1 nanoseconds after the "collision".
0357 (Notice that the time window considered,
0358 40 nanoseconds, is larger than the LHC
0359 bunch-crossing of 25 nanoseconds.)
0360
0361 Histograms h400 - h469 : energy profile (in GeV), summed over all layers
0362 sensitive (plastic scintillator) and insensitive
0363 (copper absorber), as a function of the radial
0364 distance (in centimeter) from the beam axis
0365 ( ID histo = 400 + radial distance in cm ).
0366
0367 Histogram h4000 : total energy deposit (in GeV) in the sensitive parts
0368 of either the electromagnetic or hadronic calorimeters.
0369 Ntuple variable edep provides the same information.
0370
0371 Other ntuple variables are the following:
0372 --- elab : energy (in GeV) of the incident particle.
0373 --- xpos, ypos, zpos : position (in mm) from where the projectile
0374 has been shot.
0375 --- edec, edhc : total energy deposit (in GeV) in the sensitive
0376 parts of, respectively, the electromagnetic
0377 and hadronic calorimeters. Notice that their
0378 sum edec+edhc coincides with edep
0379
0380 Notice that lateral profile (400-469) and time-slice (300-339)
0381 histograms show purely Monte Carlo quantities, which cannot be
0382 experimentally measured.
0383 Please be careful that the range of the histograms has been chosen
0384 in such a way to contain most of the entries, but only few histograms
0385 fill a large fraction of that range, whereas the remaining majority
0386 fill only the first few bins (corresponding to lower energy), and,
0387 therefore, when plotted they look almost empty, but they are not,
0388 and the results are sensible. We suggest to plot the ntuple's variables,
0389 rather than the histograms, when the same information is available
0390 from the ntuple.
0391
0392
0393 9. Visualization / GUI
0394 -----------------------
0395
0396 If you setup one of the following Geant4 environmental variables:
0397 G4VIS_USE_DAWN
0398 G4VIS_USE_VRML
0399 G4VIS_USE_OPENGLX
0400 which correspond to the use of DAWN, VRML, and OPENGLX, respectively,
0401 as visualization engine of Geant4, and set properly the corresponding
0402 PATH as well, it is then possible to visualize the detector and also
0403 some events.
0404 To do so, you have to run
0405 > ./CompositeCalorimeter
0406 without input file: you then see the detector; after that,
0407 you can select the particle gun and its energy, in the
0408 case you want something different from the the default
0409 (which is a 100 GeV pi-), for example:
0410 Idle> /gun/particle e-
0411 Idle> /gun/energy 200 GeV
0412 and then run some events, for example:
0413 Idle> /run/beamOn 3
0414
0415 The tracks that are shown include both charged and neutral particles
0416 of any momentum: if you want instead only charged, or only neutral,
0417 then you have simply to edit src/CCalEndOfEventAction.cc
0418 at the end of the method EndOfEventAction and uncomment the line
0419 where the condition on the charge is made (it should then be
0420 straighforward to eventual add some other conditions, for example
0421 if you want to see only those particles that satisfy certain
0422 kinematic conditions).
0423
0424 Rather than to specify "by hand" the type of particle gun,
0425 its energy, and the number of events, it is possible to have
0426 a very simple GUI (graphical user interface) from which to make
0427 such choices, between a limited set of possibilities, via menus.
0428 Such GUI is based on Motif XmCommand widget, but it would be
0429 straightforward, eventually, to make the necessary changes
0430 in order to use a different one.
0431 The only thing you need to do to get the GUI is to setup
0432 the following Geant4 environmental variables:
0433 G4UI_BUILD_XM_SESSION=1
0434 G4UI_USE_XM=1
0435 Then, if you run the executable without specifying a macro file
0436 (like test.g4mac):
0437 > $G4WORKDIR/bin/$G4SYSTEM/CompositeCalorimeter
0438 a window automatically pops out, with the menus where you
0439 can make your selection of particle type, energy, and number
0440 of events to be run.
0441
0442
0443 10. Classes Overview
0444 ---------------------
0445
0446 This is a schematic overview of the classes defined in this example:
0447
0448 CCalPrimaryGeneratorAction
0449 CCalPrimaryGeneratorMessenger
0450 User action for primaries generator.
0451
0452 CCalDetectorConstruction
0453 CCalAMaterial
0454 CCalDataSet
0455 CCalDetector
0456 CCalEcal
0457 CCalEcalOrganization
0458 CCalG4Able
0459 CCalG4Ecal
0460 CCalG4Hall
0461 CCalG4Hcal
0462 CCalGeometryConfiguration
0463 CCalHall
0464 CCalHcal
0465 CCalHcalOrganization
0466 CCalMagneticField
0467 CCalMaterial
0468 CCalMaterialFactory
0469 CCalRotationMatrixFactory
0470 CCalVOrganization
0471 CCalVisManager
0472 CCalVisualisable
0473 CCaloOrganization
0474 CCalutils
0475 Geometry and material definitions for the detector.
0476 Notice in particular that:
0477 CCalHall, CCalEcal, CCalHcal derive from CCalDetector;
0478 CCalG4Hall, CCalG4Ecal, CCalG4Hcal derive from the above
0479 corresponding classes and from CCalG4Able;
0480 CCalEcalOrganization, CCalHcalOrganization derive from
0481 CCalVOrganization : each sensitive cell has an unique
0482 number for detector organization (this is a software
0483 ID not an hardware/electronic one).
0484
0485 CCalHit
0486 CCalG4Hit
0487 CCalG4HitCollection
0488 CCalSDList
0489 CCalSensAssign
0490 CCalSensitiveConfiguration
0491 CCalSensitiveDetectors
0492 CCaloSD
0493 Hit and Sensitive Detectors.
0494 Notice in particular that:
0495 CCalG4Hit derives from G4VHit and CCalHit;
0496 CCaloSD derives from G4VSensitiveDetector.
0497
0498 CCalActionInitializer
0499 User-action initialization.
0500
0501 CCalAnalysis
0502 Analysis manager class.
0503
0504 CCalRunAction
0505 User run action class.
0506
0507 CCalEndOfEventAction
0508 User event action class.
0509
0510 CCalStackingAction
0511 User Stacking action class.
0512
0513 CCalSteppingAction
0514 User Stepping action class.
0515