Belle II Software development
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
15validation plots.
16</description>
17<output>../ARICHEvents.root</output>
18</header>
19"""
20
21import basf2 as b2
22from optparse import OptionParser
23from simulation import add_simulation
24from svd import add_svd_reconstruction
25from pxd import add_pxd_reconstruction
26
27# Options from command line
28parser = OptionParser()
29parser.add_option('-n', '--nevents', dest='nevents', default=10000,
30 help='Number of events to process')
31parser.add_option('-f', '--file', dest='filename',
32 default='../ARICHEvents.root')
33parser.add_option('-d', '--debug', dest='debugLevel', default=10)
34(options, args) = parser.parse_args()
35nevents = int(options.nevents)
36filename = options.filename
37debugLevel = int(options.debugLevel)
38
39# suppress messages and warnings during processing DEBUG, INFO, WARNING, ERROR
40b2.set_log_level(b2.LogLevel.INFO)
41
42# Create path
43main = b2.create_path()
44
45# specify number of events to be generated
46eventinfosetter = b2.register_module('EventInfoSetter')
47eventinfosetter.param({'evtNumList': [nevents]})
48main.add_module(eventinfosetter)
49
50# Particle gun module
51particlegun = b2.register_module('ParticleGun')
52# Setting the random seed for particle generation:
53b2.set_random_seed(123456)
54# Setting the list of particle codes (PDG codes) for the generated particles
55particlegun.param('pdgCodes', [-211, 211, 321, -321])
56# Setting the number of tracks to be generated per event:
57particlegun.param('nTracks', 1)
58# Setting the parameters for the random generation
59# of particles momenta:
60particlegun.param('momentumGeneration', 'uniform')
61particlegun.param('momentumParams', [3.0, 3.5])
62# Setting the parameters for the random generation
63# of the particle polar angle:
64particlegun.param('thetaGeneration', 'uniformCos')
65particlegun.param('thetaParams', [17.0, 35.0])
66particlegun.param('vertexGeneration', 'fixed')
67particlegun.param('xVertexParams', [0.0, 0.0])
68particlegun.param('yVertexParams', [0.0, 0.0])
69particlegun.param('zVertexParams', [0.0, 0.0])
70particlegun.param('independentVertices', False)
71main.add_module(particlegun)
72
73# Add simulation
74# choose second line if you want to add background
75add_simulation(main)
76# add_simulation(main, components, bkgfiles=glob.glob('/sw/belle2/bkg/ARICH*.root'))
77
78# Add reconstruction
79add_pxd_reconstruction(main)
80add_svd_reconstruction(main)
81main.add_module('SetupGenfitExtrapolation')
82main.add_module('TrackFinderMCTruthRecoTracks', RecoTracksStoreArrayName='RecoTracks',
83 UseSecondCDCHits=False, UsePXDHits=True, UseSVDHits=True, UseCDCHits=True)
84main.add_module('TrackCreator', recoTrackColName='RecoTracks', pdgCodes=[211, 321, 2212])
85main.add_module('TrackToMCParticleRelator')
86main.add_module('Ext')
87main.add_module('ARICHFillHits')
88main.add_module('ARICHReconstructor', storePhotons=1)
89
90# Add module fpr ARICH efficiency analysis
91arichEfficiency = b2.register_module('ARICHNtuple')
92arichEfficiency.logging.log_level = b2.LogLevel.DEBUG
93arichEfficiency.logging.debug_level = debugLevel
94arichEfficiency.param('outputFile', filename)
95main.add_module(arichEfficiency)
96
97# Show progress of processing
98progress = b2.register_module('Progress')
99main.add_module(progress)
100
101# Process events
102b2.process(main)
103
104# Print call statistics
105print(b2.statistics)