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