Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
from DDSim.DD4hepSimulation import DD4hepSimulation
from g4units import mm, GeV, MeV
SIM = DD4hepSimulation()
## The compact XML file, or multiple compact files, if the last one is the closer.
SIM.compactFile = []
## Lorentz boost for the crossing angle, in radian!
SIM.crossingAngleBoost = 0.0
SIM.enableDetailedShowerMode = False
SIM.enableG4GPS = False
SIM.enableG4Gun = False
SIM.enableGun = False
## InputFiles for simulation .stdhep, .slcio, .HEPEvt, .hepevt, .pairs, .hepmc, .hepmc.gz, .hepmc.xz, .hepmc.bz2, .hepmc3, .hepmc3.gz, .hepmc3.xz, .hepmc3.bz2, .hepmc3.tree.root files are supported
SIM.inputFiles = []
## Macro file to execute for runType 'run' or 'vis'
SIM.macroFile = ""
## number of events to simulate, used in batch mode
SIM.numberOfEvents = 0
## Outputfile from the simulation: .slcio, edm4hep.root and .root output files are supported
SIM.outputFile = "dummyOutput.slcio"
## Physics list to use in simulation
SIM.physicsList = None
## Verbosity use integers from 1(most) to 7(least) verbose
## or strings: VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL, ALWAYS
SIM.printLevel = 3
## The type of action to do in this invocation
## batch: just simulate some events, needs numberOfEvents, and input file or gun
## vis: enable visualisation, run the macroFile if it is set
## qt: enable visualisation in Qt shell, run the macroFile if it is set
## run: run the macroFile and exit
## shell: enable interactive session
SIM.runType = "batch"
## Skip first N events when reading a file
SIM.skipNEvents = 0
## Steering file to change default behaviour
SIM.steeringFile = None
## FourVector of translation for the Smearing of the Vertex position: x y z t
SIM.vertexOffset = [0.0, 0.0, 0.0, 0.0]
## FourVector of the Sigma for the Smearing of the Vertex position: x y z t
SIM.vertexSigma = [0.0, 0.0, 0.0, 0.0]
################################################################################
## Helper holding sensitive detector actions.
##
## The default tracker and calorimeter actions can be set with
##
## >>> SIM = DD4hepSimulation()
## >>> SIM.action.tracker=('Geant4TrackerWeightedAction', {'HitPositionCombination': 2, 'CollectSingleDeposits': False})
## >>> SIM.action.calo = "Geant4CalorimeterAction"
##
## The default sensitive actions for calorimeters and trackers are applied based on the sensitive type.
## The list of sensitive types can be changed with
##
## >>> SIM = DD4hepSimulation()
## >>> SIM.action.trackerSDTypes = ['tracker', 'myTrackerSensType']
## >>> SIM.calor.calorimeterSDTypes = ['calorimeter', 'myCaloSensType']
##
## For specific subdetectors specific sensitive detectors can be set based on patterns in the name of the subdetector.
##
## >>> SIM = DD4hepSimulation()
## >>> SIM.action.mapActions['tpc'] = "TPCSDAction"
##
## and additional parameters for the sensitive detectors can be set when the map is given a tuple
##
## >>> SIM = DD4hepSimulation()
## >>> SIM.action.mapActions['ecal'] =( "CaloPreShowerSDAction", {"FirstLayerNumber": 1} )
##
##
## Additional actions can be set as well with the following syntax variations:
##
## >>> SIM = DD4hepSimulation()
## # single action by name only:
## >>> SIM.action.run = "Geant4TestRunAction"
## # multiple actions with comma-separated names:
## >>> SIM.action.event = "Geant4TestEventAction/Action0,Geant4TestEventAction/Action1"
## # single action by tuple of name and parameter dict:
## >>> SIM.action.track = ( "Geant4TestTrackAction", {"Property_int": 10} )
## # single action by dict of name and parameter dict:
## >>> SIM.action.step = { "name": "Geant4TestStepAction", "parameter": {"Property_int": 10} }
## # multiple actions by list of dict of name and parameter dict:
## >>> SIM.action.stack = [ { "name": "Geant4TestStackAction", "parameter": {"Property_int": 10} } ]
##
## On the command line or in python, these actions can be specified as JSON strings:
## $ ddsim --action.stack '{ "name": "Geant4TestStackAction", "parameter": { "Property_int": 10 } }'
## or
## >>> SIM.action.stack = '''
## {
## "name": "Geant4TestStackAction",
## "parameter": {
## "Property_int": 10,
## "Property_double": "1.0*mm"
## }
## }
## '''
##
##
################################################################################
## set the default calorimeter action
SIM.action.calo = "Geant4ScintillatorCalorimeterAction"
## List of patterns matching sensitive detectors of type Calorimeter.
SIM.action.calorimeterSDTypes = ['calorimeter']
## Create a map of patterns and actions to be applied to sensitive detectors.
##
## Example: if the name of the detector matches 'tpc' the TPCSDAction is used.
##
## SIM.action.mapActions['tpc'] = "TPCSDAction"
##
SIM.action.mapActions = {}
## set the default tracker action
SIM.action.tracker = ('Geant4TrackerWeightedAction', {'HitPositionCombination': 2, 'CollectSingleDeposits': False})
## List of patterns matching sensitive detectors of type Tracker.
SIM.action.trackerSDTypes = ['tracker']
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
## single action by name only
SIM.action.run = "Geant4TestRunAction/RunAction1"
## multiple actions with comma-separated names:
SIM.action.event = "Geant4TestEventAction/EventAction0,Geant4TestEventAction/EventAction1"
## single action by tuple of name and parameter dict:
SIM.action.track = ( "Geant4TestTrackAction/TrackAction1", {"Property_int": 10} )
## single action by dict of name and parameter dict:
SIM.action.step = { "name": "Geant4TestStepAction/StepAction1", "parameter": {"Property_int": 10} }
## multiple actions by list of dict of name and parameter dict:
SIM.action.stack = [ { "name": "Geant4TestStackAction/StackAction1", "parameter": {"Property_int": 10} } ]
## On the command line or in python, these actions can be specified as JSON strings:
SIM.action.stack = '''
{
"name": "Geant4TestStackAction/StackActionJSON1",
"parameter": {
"Property_int": 10,
"Property_double": "1.0*mm"
}
}
'''
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
################################################################################
## Configuration for the magnetic field (stepper)
################################################################################
SIM.field.delta_chord = 0.25
SIM.field.delta_intersection = 0.001
SIM.field.delta_one_step = 0.01
SIM.field.eps_max = 0.001
SIM.field.eps_min = 5e-05
SIM.field.equation = "Mag_UsualEqRhs"
SIM.field.largest_step = 10000.0
SIM.field.min_chord_step = 0.01
SIM.field.stepper = "ClassicalRK4"
################################################################################
## Configuration for sensitive detector filters
##
## Set the default filter for 'tracker'
## >>> SIM.filter.tracker = "edep1kev"
## Use no filter for 'calorimeter' by default
## >>> SIM.filter.calo = ""
##
## Assign a filter to a sensitive detector via pattern matching
## >>> SIM.filter.mapDetFilter['FTD'] = "edep1kev"
##
## Or more than one filter:
## >>> SIM.filter.mapDetFilter['FTD'] = ["edep1kev", "geantino"]
##
## Don't use the default filter or anything else:
## >>> SIM.filter.mapDetFilter['TPC'] = None ## or "" or []
##
## Create a custom filter. The dictionary is used to instantiate the filter later on
## >>> SIM.filter.filters['edep3kev'] = dict(name="EnergyDepositMinimumCut/3keV", parameter={"Cut": 3.0*keV} )
##
##
################################################################################
##
## default filter for calorimeter sensitive detectors;
## this is applied if no other filter is used for a calorimeter
##
SIM.filter.calo = "edep0"
## list of filter objects: map between name and parameter dictionary
SIM.filter.filters = {'geantino': {'name': 'GeantinoRejectFilter/GeantinoRejector', 'parameter': {}}, 'edep1kev': {'name': 'EnergyDepositMinimumCut', 'parameter': {'Cut': 0.001}}, 'edep0': {'name': 'EnergyDepositMinimumCut/Cut0', 'parameter': {'Cut': 0.0}}}
## a map between patterns and filter objects, using patterns to attach filters to sensitive detector
SIM.filter.mapDetFilter = {}
## default filter for tracking sensitive detectors; this is applied if no other filter is used for a tracker
SIM.filter.tracker = "edep1kev"
################################################################################
## Configuration for the Detector Construction.
################################################################################
SIM.geometry.dumpGDML = ""
SIM.geometry.dumpHierarchy = 0
## Print Debug information about Elements
SIM.geometry.enableDebugElements = False
## Print Debug information about Materials
SIM.geometry.enableDebugMaterials = False
## Print Debug information about Placements
SIM.geometry.enableDebugPlacements = False
## Print Debug information about Reflections
SIM.geometry.enableDebugReflections = False
## Print Debug information about Regions
SIM.geometry.enableDebugRegions = False
## Print Debug information about Shapes
SIM.geometry.enableDebugShapes = False
## Print Debug information about Surfaces
SIM.geometry.enableDebugSurfaces = False
## Print Debug information about Volumes
SIM.geometry.enableDebugVolumes = False
## Print information about placements
SIM.geometry.enablePrintPlacements = False
## Print information about Sensitives
SIM.geometry.enablePrintSensitives = False
################################################################################
## Configuration for the GuineaPig InputFiles
################################################################################
## Set the number of pair particles to simulate per event.
## Only used if inputFile ends with ".pairs"
## If "-1" all particles will be simulated in a single event
##
SIM.guineapig.particlesPerEvent = "-1"
################################################################################
## Configuration for the DDG4 ParticleGun
################################################################################
## direction of the particle gun, 3 vector
SIM.gun.direction = (0, 0, 1)
## choose the distribution of the random direction for theta
##
## Options for random distributions:
##
## 'uniform' is the default distribution, flat in theta
## 'cos(theta)' is flat in cos(theta)
## 'eta', or 'pseudorapidity' is flat in pseudorapity
## 'ffbar' is distributed according to 1+cos^2(theta)
##
## Setting a distribution will set isotrop = True
##
SIM.gun.distribution = None
## Total energy (including mass) for the particle gun.
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
##
## If not None, it will overwrite the setting of momentumMin and momentumMax
SIM.gun.energy = None
## Maximal pseudorapidity for random distibution (overrides thetaMin)
SIM.gun.etaMax = None
## Minimal pseudorapidity for random distibution (overrides thetaMax)
SIM.gun.etaMin = None
## isotropic distribution for the particle gun
##
## use the options phiMin, phiMax, thetaMin, and thetaMax to limit the range of randomly distributed directions
## if one of these options is not None the random distribution will be set to True and cannot be turned off!
##
SIM.gun.isotrop = False
## Maximal momentum when using distribution (default = 0.0)
SIM.gun.momentumMax = 10000.0
## Minimal momentum when using distribution (default = 0.0)
SIM.gun.momentumMin = 0.0
SIM.gun.multiplicity = 1
SIM.gun.particle = "mu-"
## Maximal azimuthal angle for random distribution
SIM.gun.phiMax = None
## Minimal azimuthal angle for random distribution
SIM.gun.phiMin = None
## position of the particle gun, 3 vector
SIM.gun.position = (0.0, 0.0, 0.0)
## Maximal polar angle for random distribution
SIM.gun.thetaMax = None
## Minimal polar angle for random distribution
SIM.gun.thetaMin = None
################################################################################
## Configuration for the hepmc3 InputFiles
################################################################################
## Set the name of the attribute contraining color flow information index 0.
SIM.hepmc3.Flow1 = "flow1"
## Set the name of the attribute contraining color flow information index 1.
SIM.hepmc3.Flow2 = "flow2"
## Set to false if the input should be opened with the hepmc2 ascii reader.
##
## If ``True`` a '.hepmc' file will be opened with the HEPMC3 Reader Factory.
##
## Defaults to true if DD4hep was build with HEPMC3 support.
##
SIM.hepmc3.useHepMC3 = False
################################################################################
## Configuration for Input Files.
################################################################################
## Set one or more functions to configure input steps.
##
## The functions must take a ``DD4hepSimulation`` object as their only argument and return the created generatorAction
## ``gen`` (for example).
##
## For example one can add this to the ddsim steering file:
##
## def exampleUserPlugin(dd4hepSimulation):
## '''Example code for user created plugin.
##
## :param DD4hepSimulation dd4hepSimulation: The DD4hepSimulation instance, so all parameters can be accessed
## :return: GeneratorAction
## '''
## from DDG4 import GeneratorAction, Kernel
## # Geant4InputAction is the type of plugin, Cry1 just an identifier
## gen = GeneratorAction(Kernel(), 'Geant4InputAction/Cry1' , True)
## # CRYEventReader is the actual plugin, steeringFile its constructor parameter
## gen.Input = 'CRYEventReader|' + 'steeringFile'
## # we can give a dictionary of Parameters that has to be interpreted by the setParameters function of the plugin
## gen.Parameters = {'DataFilePath': '/path/to/files/data'}
## gen.enableUI()
## return gen
##
## SIM.inputConfig.userInputPlugin = exampleUserPlugin
##
## Repeat function definition and assignment to add multiple input steps
##
##
SIM.inputConfig.userInputPlugin = []
################################################################################
## Configuration for the generator-level InputFiles
################################################################################
## Set the name of the collection containing the MCParticle input.
## Default is "MCParticle".
##
SIM.lcio.mcParticleCollectionName = "MCParticle"
################################################################################
## Configuration for the LCIO output file settings
################################################################################
## The event number offset to write in slcio output file. E.g setting it to 42 will start counting events from 42 instead of 0
SIM.meta.eventNumberOffset = 0
## Event parameters to write in every event. Use C/F/I ids to specify parameter type. E.g parameterName/F=0.42 to set a float parameter
SIM.meta.eventParameters = []
## The run number offset to write in slcio output file. E.g setting it to 42 will start counting runs from 42 instead of 0
SIM.meta.runNumberOffset = 0
################################################################################
## Configuration for the output levels of DDG4 components
################################################################################
## Output level for geometry.
SIM.output.geometry = 2
## Output level for input sources
SIM.output.inputStage = 3
## Output level for Geant4 kernel
SIM.output.kernel = 3
## Output level for ParticleHandler
SIM.output.part = 3
## Output level for Random Number Generator setup
SIM.output.random = 6
################################################################################
## Configuration for Output Files.
################################################################################
## Set a function to configure the outputFile.
##
## The function must take a ``DD4hepSimulation`` object as its only argument and return ``None``.
##
## For example one can add this to the ddsim steering file:
##
## def exampleUserPlugin(dd4hepSimulation):
## '''Example code for user created plugin.
##
## :param DD4hepSimulation dd4hepSimulation: The DD4hepSimulation instance, so all parameters can be accessed
## :return: None
## '''
## from DDG4 import EventAction, Kernel
## dd = dd4hepSimulation # just shorter variable name
## evt_root = EventAction(Kernel(), 'Geant4Output2ROOT/' + dd.outputFile, True)
## evt_root.HandleMCTruth = True or False
## evt_root.Control = True
## if not dd.outputFile.endswith(dd.outputConfig.myExtension):
## output = dd.outputFile + dd.outputConfig.myExtension
## evt_root.Output = output
## evt_root.enableUI()
## Kernel().eventAction().add(evt_root)
## return None
##
## SIM.outputConfig.userOutputPlugin = exampleUserPlugin
## # arbitrary options can be created and set via the steering file or command line
## SIM.outputConfig.myExtension = '.csv'
##
SIM.outputConfig.userOutputPlugin = None
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
################################################################################
## Configuration for the Particle Handler/ MCTruth treatment
################################################################################
## Enable lots of printout on simulated hits and MC-truth information
SIM.part.enableDetailedHitsAndParticleInfo = False
## Keep all created particles
SIM.part.keepAllParticles = False
## Minimal distance between particle vertex and endpoint of parent after
## which the vertexIsNotEndpointOfParent flag is set
##
SIM.part.minDistToParentVertex = 2.2e-14
## MinimalKineticEnergy to store particles created in the tracking region
SIM.part.minimalKineticEnergy = 1.0
## Printout at End of Tracking
SIM.part.printEndTracking = False
## Printout at Start of Tracking
SIM.part.printStartTracking = False
## List of processes to save, on command line give as whitespace separated string in quotation marks
SIM.part.saveProcesses = ['Decay']
## Optionally enable an extended Particle Handler
SIM.part.userParticleHandler = "Geant4TCUserParticleHandler"
################################################################################
## Configuration for the PhysicsList
################################################################################
## If true, add decay processes for all particles.
##
## Only enable when creating a physics list not based on an existing Geant4 list!
##
SIM.physics.decays = False
## The name of the Geant4 Physics list.
SIM.physics.list = "FTFP_BERT"
## location of particle.tbl file containing extra particles and their lifetime information
##
## For example in $DD4HEP/examples/DDG4/examples/particle.tbl
##
SIM.physics.pdgfile = None
## The global geant4 rangecut for secondary production
##
## Default is 0.7 mm as is the case in geant4 10
##
## To disable this plugin and be absolutely sure to use the Geant4 default range cut use "None"
##
## Set printlevel to DEBUG to see a printout of all range cuts,
## but this only works if range cut is not "None"
##
SIM.physics.rangecut = 0.7
## Set of PDG IDs that will not be passed from the input record to Geant4.
##
## Quarks, gluons and W's Z's etc should not be treated by Geant4
##
SIM.physics.rejectPDGs = {1, 2, 3, 4, 5, 6, 3201, 3203, 4101, 4103, 21, 23, 24, 5401, 25, 2203, 5403, 3101, 3103, 4403, 2101, 5301, 2103, 5303, 4301, 1103, 4303, 5201, 5203, 3303, 4201, 4203, 5101, 5103, 5503}
## Set of PDG IDs for particles that should not be passed to Geant4 if their properTime is 0.
##
## The properTime of 0 indicates a documentation to add FSR to a lepton for example.
##
SIM.physics.zeroTimePDGs = {17, 11, 13, 15}
def setupCerenkovScint(kernel):
from DDG4 import PhysicsList
seq = kernel.physicsList()
scint = PhysicsList(kernel, 'Geant4ScintillationPhysics/ScintillationPhys')
scint.VerboseLevel = 0
scint.TrackSecondariesFirst = True
scint.enableUI()
seq.adopt(scint)
cerenkov = PhysicsList(kernel, 'Geant4CerenkovPhysics/CerenkovPhys')
cerenkov.VerboseLevel = 0
cerenkov.MaxNumPhotonsPerStep = 10
cerenkov.MaxBetaChangePerStep = 10.0
cerenkov.TrackSecondariesFirst = True
cerenkov.enableUI()
seq.adopt(cerenkov)
ph = PhysicsList(kernel, 'Geant4OpticalPhotonPhysics/OpticalGammaPhys')
ph.addParticleConstructor('G4OpticalPhoton')
ph.VerboseLevel = 0
ph.enableUI()
seq.adopt(ph)
return None
SIM.physics.setupUserPhysics(setupCerenkovScint)
################################################################################
## Properties for the random number generator
################################################################################
## If True, calculate random seed for each event basedon eventID and runID
## Allows reproducibility even whenSkippingEvents
SIM.random.enableEventSeed = False
SIM.random.file = None
SIM.random.luxury = 1
SIM.random.replace_gRandom = True
SIM.random.seed = None
SIM.random.type = None