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