Belle II Software development
beast_gun.py
1#!/usr/bin/env python
2
3
10
11# -------------------------------------------------------------------------------------
12# Example steering file for beast2 simulation
13# Builds beast2 geometry and uses particle gun module to shoot particles
14# Uncomment the lines related to the display module to show the detector geometry
15# Simulation output hits are stored into "beast_test.root"
16# -------------------------------------------------------------------------------------
17
18import basf2 as b2
19
20# set parameters
21main = b2.create_path()
22
23# Event info setter
24eventinfosetter = b2.register_module('EventInfoSetter')
25# set number of events
26eventinfosetter.param('evtNumList', [200])
27main.add_module(eventinfosetter)
28
29# Uncomment if you include your study/analysis module into the path
30# Study modules (in your detector folder) are HistoModules, they produce histograms,
31# and HistoManager module takes care to store them in the output root file
32#
33# histo = register_module('HistoManager')
34# histo.param('histoFileName', 'histograms.root') # File to save histograms
35# main.add_module(histo)
36
37# Gearbox - reads parameters from the xml files
38gearbox = b2.register_module('Gearbox')
39gearbox.param('fileName', 'geometry/Beast2_phase2.xml')
40main.add_module(gearbox)
41
42# Geant geometry
43geometry = b2.register_module('Geometry')
44# select detectors to be built (IR structures+VXD+Beast2)
45geometry.param('components', ["STR", "BeamPipe", "Cryostat",
46 "HeavyMetalShield", "PXD", "SVD", "MICROTPC", "PINDIODE",
47 "BEAMABORT", "HE3TUBE", "CLAWS", "FANGS", "PLUME", "QCSMONITOR",
48 "MagneticField3dQuadBeamline"])
49main.add_module(geometry)
50
51# Overlap checker / if you make g4 geometry changes please check
52# that there are no overlaps
53# main.add_module("OverlapChecker")
54# Save overlaps to file to be able to view them with b2display
55# main.add_module("RootOutput", outputFileName="Overlaps.root")
56
57
58# particle gun module, shoot particles into your detector
59particlegun = b2.register_module('ParticleGun')
60particlegun.param('pdgCodes', [11]) # electron
61particlegun.param('nTracks', 1)
62particlegun.param('momentumGeneration', 'uniform')
63particlegun.param('momentumParams', [1, 1.01]) # 1 GeV
64particlegun.param('thetaGeneration', 'uniformCos')
65particlegun.param('thetaParams', [0, 360]) # theta angle
66particlegun.param('phiGeneration', 'uniform')
67particlegun.param('phiParams', [0, 360]) # phi angle
68particlegun.param('vertexGeneration', 'fixed')
69particlegun.param('xVertexParams', [0])
70particlegun.param('yVertexParams', [0])
71particlegun.param('zVertexParams', [0])
72particlegun.param('independentVertices', False)
73main.add_module(particlegun)
74
75# Geant simulation
76fullsim = b2.register_module('FullSim')
77fullsim.param('PhysicsList', 'FTFP_BERT_HP')
78fullsim.param('UICommandsAtIdle', ['/process/inactivate nKiller'])
79fullsim.param('StoreAllSecondaries', True)
80fullsim.param('SecondariesEnergyCut', 0.000001) # [MeV] need for CDC EB neutron flux
81main.add_module(fullsim)
82
83# Add additional modules, like digitization and study/analysis
84# for example He3Digitizer
85# dataobjects created in these modules are also put into the datastore
86# and finally saved into the output root file (he3 digits in this case)
87#
88# he3digi = register_module('He3Digitizer')
89# main.add_module(he3digi)
90#
91# if you add study/analysis module uncomment also HistoManager lines
92#
93# he3study = register_module('He3tubeStudy')
94# main.add_module(he3study)
95
96# Show progress of processing
97progress = b2.register_module('Progress')
98main.add_module(progress)
99
100# uncomment below to add the event display module
101# display = register_module('Display')
102# display.param('fullGeometry', True)
103# main.add_module(display)
104
105# store output hits into root file (these is collection of hits, not histograms)
106# by default all content of datastore is stored
107output = b2.register_module('RootOutput')
108output.param('outputFileName', "beast_test.root")
109# if you want to store only branches of interest (hits in your detector, etc.) use
110# output.param('branchNames', ['PlumeSimHits'])
111main.add_module(output)
112
113
114# Process events
115b2.process(main)
116
117# Print call statistics
118print(b2.statistics)