Belle II Software development
EclPureCsIExample.py
1#!/usr/bin/env python3
2
3
10
11"""Pure CsI simulation for the ECL
12
13Input:
14 No file is required
15
16Output:
17 Mdst file named 'Ecl_Pure.mdst.root'
18
19Usage:
20 $ basf2 EclPureCsIExample.py [-- --withBkg]
21"""
22
23import os
24import glob
25import argparse
26import basf2 as b2
27from simulation import add_simulation
28from reconstruction import add_reconstruction
29
30
31def argparser():
32
33 parser = argparse.ArgumentParser()
34
35 parser.add_argument('--withBkg',
36 action='store_true',
37 default=False,
38 help='Add beam background'
39 'Default is False i.e. no beam background.')
40 return parser
41
42
43args = argparser().parse_args()
44
45# Create path. Register necessary modules to this path.
46mainPath = b2.create_path()
47
48# Register and add 'EventInfoSetter' module and settings
49eventInfoSetter = b2.register_module('EventInfoSetter')
50eventInfoSetter.param({'evtNumList': [1000],
51 'runList': [1],
52 'expList': [0]})
53mainPath.add_module(eventInfoSetter)
54
55# Random number for generation
56b2.set_random_seed(123456)
57
58# Register and add 'ParticleGun' generator module and settings
59particleGun = b2.register_module('ParticleGun')
60param_particleGun = {
61 'pdgCodes': [22], # 22: photon
62 'nTracks': 1,
63 'momentumGeneration': 'fixed',
64 'momentumParams': [.1],
65 'thetaGeneration': 'uniform',
66 'thetaParams': [13., 150.],
67 'phiGeneration': 'uniform',
68 'phiParams': [0., 360.],
69 'vertexGeneration': 'uniform',
70 'xVertexParams': [0., 0.],
71 'yVertexParams': [0., 0.],
72 'zVertexParams': [0., 0.],
73}
74particleGun.param(param_particleGun)
75mainPath.add_module(particleGun)
76
77if args.withBkg:
78 # Add beam background overlay files
79 bgFiles = glob.glob(os.environ['BELLE2_BACKGROUND_DIR'] + '*.root')
80 # Add simulation
81 add_simulation(mainPath, bkgfiles=bgFiles)
82else:
83 # Simulation
84 add_simulation(mainPath)
85
86# Reconstruction
87add_reconstruction(mainPath)
88
89# Register and add 'ECLDigitizerPureCsI' module and settings
90eclDigitizerPureCsI = b2.register_module('ECLDigitizerPureCsI')
91eclDigitizerPureCsI.param('adcTickFactor', 8)
92eclDigitizerPureCsI.param('sigmaTrigger', 0.)
93eclDigitizerPureCsI.param('elecNoise', 1.3)
94eclDigitizerPureCsI.param('photostatresolution', 0.4)
95eclDigitizerPureCsI.param('sigmaTrigger', 0)
96eclDigitizerPureCsI.param('LastRing', 12)
97eclDigitizerPureCsI.param('NoCovMatrix', 1)
98eclDigitizerPureCsI.param('Background', 0)
99mainPath.add_module(eclDigitizerPureCsI)
100
101# Register and add 'ECLDigitCalibratorPureCsI' module
102eclDigitCalibratorPureCsI = b2.register_module('ECLDigitCalibratorPureCsI')
103# It is IMPORTANT to set 'simulatePure' to 1 for pure CsI simulation.
104eclDigitCalibratorPureCsI.param('simulatePure', 1)
105mainPath.add_module(eclDigitCalibratorPureCsI)
106
107# Register and add 'ECLCRFinderPureCsI' module
108eclCRFinderPureCsI = b2.register_module('ECLCRFinderPureCsI')
109mainPath.add_module(eclCRFinderPureCsI)
110
111# Register and add 'ECLLocalMaximumFinderPureCsI' module
112eclLocalMaximumFinderPureCsI = b2.register_module('ECLLocalMaximumFinderPureCsI')
113mainPath.add_module(eclLocalMaximumFinderPureCsI)
114
115# Register and add 'ECLSplitterN1PureCsI' module
116eclSplitterN1PureCsI = b2.register_module('ECLSplitterN1PureCsI')
117mainPath.add_module(eclSplitterN1PureCsI)
118
119# Register and add 'ECLSplitterN2PureCsI' module
120eclSplitterN2PureCsI = b2.register_module('ECLSplitterN2PureCsI')
121mainPath.add_module(eclSplitterN2PureCsI)
122
123# Register and add 'ECLShowerCorrectorPureCsI' module
124eclShowerCorrectorPureCsI = b2.register_module('ECLShowerCorrectorPureCsI')
125mainPath.add_module(eclShowerCorrectorPureCsI)
126
127# Register and add 'ECLShowerCalibratorPureCsI' module
128eclShowerCalibratorPureCsI = b2.register_module('ECLShowerCalibratorPureCsI')
129mainPath.add_module(eclShowerCalibratorPureCsI)
130
131# Register and add 'ECLShowerShapePureCsI' module
132eclShowerShapePureCsI = b2.register_module('ECLShowerShapePureCsI')
133mainPath.add_module(eclShowerShapePureCsI)
134
135# Register and add 'ECLCovarianceMatrixPureCsI' module
136eclCovarianceMatrixPureCsI = b2.register_module('ECLCovarianceMatrixPureCsI')
137mainPath.add_module(eclCovarianceMatrixPureCsI)
138
139# Register and add 'ECLFinalizerPureCsI' module
140eclFinalizerPureCsI = b2.register_module('ECLFinalizerPureCsI')
141mainPath.add_module(eclFinalizerPureCsI)
142
143# Register and add 'MCMatcherECLClustersPureCsI' module
144mcMatcherECLClustersPureCsI = b2.register_module('MCMatcherECLClustersPureCsI')
145mainPath.add_module(mcMatcherECLClustersPureCsI)
146
147# Register and add 'ECLDataAnalysis' module
148eclDataAnalysis = b2.register_module('ECLDataAnalysis')
149eclDataAnalysis.param('writeToRoot', 1)
150eclDataAnalysis.param('rootFileName', 'Ecl_Pure_CsI_Example.root')
151eclDataAnalysis.param('doSimulation', 0)
152eclDataAnalysis.param('doTracking', 1)
153eclDataAnalysis.param('doPureCsIStudy', 1)
154mainPath.add_module(eclDataAnalysis)
155
156# Register and add 'RootOutput' module
157outputFile = b2.register_module('RootOutput')
158outputFile.param('outputFileName', 'Ecl_Pure.mdst.root')
159mainPath.add_module(outputFile)
160
161# Process the events and print call statistics
162mainPath.add_module('Progress')
163b2.process(mainPath)
164print(b2.statistics)