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