Belle II Software  release-06-02-00
ARICHValidate.py
1 #!/usr/bin/env python3
2 
3 
10 
11 """
12 <header>
13 <contact>Luka Santelj</contact>
14 <description>This is a steering file to generate and analyze 10000 events used for ARICH
15 validation plots.
16 </description>
17 <output>../ARICHEvents.root</output>
18 </header>
19 """
20 
21 import basf2 as b2
22 from optparse import OptionParser
23 from simulation import add_simulation
24 from reconstruction import add_mc_reconstruction
25 
26 # Options from command line
27 parser = OptionParser()
28 parser.add_option('-n', '--nevents', dest='nevents', default=10000,
29  help='Number of events to process')
30 parser.add_option('-f', '--file', dest='filename',
31  default='../ARICHEvents.root')
32 parser.add_option('-d', '--debug', dest='debugLevel', default=10)
33 (options, args) = parser.parse_args()
34 nevents = int(options.nevents)
35 filename = options.filename
36 debugLevel = int(options.debugLevel)
37 
38 # suppress messages and warnings during processing DEBUG, INFO, WARNING, ERROR
39 b2.set_log_level(b2.LogLevel.INFO)
40 
41 # Create path
42 main = b2.create_path()
43 
44 # specify number of events to be generated
45 eventinfosetter = b2.register_module('EventInfoSetter')
46 eventinfosetter.param({'evtNumList': [nevents]})
47 main.add_module(eventinfosetter)
48 
49 # Particle gun module
50 particlegun = b2.register_module('ParticleGun')
51 # Setting the random seed for particle generation:
52 b2.set_random_seed(123456)
53 # Setting the list of particle codes (PDG codes) for the generated particles
54 particlegun.param('pdgCodes', [-211, 211, 321, -321])
55 # Setting the number of tracks to be generated per event:
56 particlegun.param('nTracks', 1)
57 # Setting the parameters for the random generation
58 # of particles momenta:
59 particlegun.param('momentumGeneration', 'uniform')
60 particlegun.param('momentumParams', [3.0, 3.5])
61 # Setting the parameters for the random generation
62 # of the particle polar angle:
63 particlegun.param('thetaGeneration', 'uniformCos')
64 particlegun.param('thetaParams', [17.0, 35.0])
65 particlegun.param('vertexGeneration', 'fixed')
66 particlegun.param('xVertexParams', [0.0, 0.0])
67 particlegun.param('yVertexParams', [0.0, 0.0])
68 particlegun.param('zVertexParams', [0.0, 0.0])
69 particlegun.param('independentVertices', False)
70 # Print the parameters of the particle gun
71 b2.print_params(particlegun)
72 main.add_module(particlegun)
73 
74 # Add simulation
75 # choose second line if you want to add background
76 add_simulation(main)
77 # add_simulation(main, components, bkgfiles=glob.glob('/sw/belle2/bkg/ARICH*.root'))
78 
79 # Add reconstruction
80 add_mc_reconstruction(main)
81 
82 # Add module fpr ARICH efficiency analysis
83 arichEfficiency = b2.register_module('ARICHNtuple')
84 arichEfficiency.logging.log_level = b2.LogLevel.DEBUG
85 arichEfficiency.logging.debug_level = debugLevel
86 arichEfficiency.param('outputFile', filename)
87 main.add_module(arichEfficiency)
88 
89 # Show progress of processing
90 progress = b2.register_module('Progress')
91 main.add_module(progress)
92 
93 # Process events
94 b2.process(main)
95 
96 # Print call statistics
97 print(b2.statistics)