Belle II Software  release-08-01-10
TestNoiseCalibration.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 """Test implementation of pure CsI digitization and waveform fit
13 
14 Input:
15  No file is required
16 
17 Output:
18  Mdst file
19 
20 Usage:
21  $ basf2 TestNoiseCalibration.py -- --outputFileName <name>
22  --elecNoise <float> --photoStatResolution <float>
23  [--beamBkgPath <path_to_files>]
24 """
25 
26 import glob
27 import argparse
28 import basf2 as b2
29 from simulation import add_simulation
30 from reconstruction import add_reconstruction
31 from mdst import add_mdst_output
32 
33 
34 def argparser():
35 
36  parser = argparse.ArgumentParser()
37 
38  parser.add_argument('--outputFileName',
39  required=True,
40  help='Output file name')
41 
42  parser.add_argument('--elecNoise',
43  type=float,
44  required=True,
45  help='Electronics noise energy equivalent in MeV')
46 
47  parser.add_argument('--photoStatResolution',
48  type=float,
49  required=True,
50  help='Sigma for 1 MeV energy deposit')
51 
52  parser.add_argument('--beamBkgPath',
53  help='If you want to add beam background, pass this'
54  'option with path to beam background files.')
55  return parser
56 
57 
58 args = argparser().parse_args()
59 
60 b2.set_log_level(b2.LogLevel.ERROR)
61 
62 # Create path. Register necessary modules to this path.
63 mainPath = b2.create_path()
64 
65 # Register and add 'EventInfoSetter' module and settings
66 eventInfoSetter = b2.register_module('EventInfoSetter')
67 eventInfoSetter.param({'evtNumList': [10],
68  'runList': [1],
69  'expList': [0]})
70 mainPath.add_module(eventInfoSetter)
71 
72 if args.beamBkgPath:
73  # Add beam background
74  bgFiles = glob.glob(args.beamBkgPath + '/*.root')
75  # Add simulation
76  add_simulation(mainPath, bkgfiles=bgFiles, components='ECL')
77 else:
78  add_simulation(mainPath, components='ECL')
79 
80 # Add reconstruction
81 add_reconstruction(mainPath)
82 
83 # Register and add 'ECLDigitizerPureCsI' module and settings
84 eclDigitizerPureCsI = b2.register_module('ECLDigitizerPureCsI')
85 eclDigitizerPureCsI.param('Calibration', 1)
86 eclDigitizerPureCsI.param('elecNoise', args.elecNoise)
87 eclDigitizerPureCsI.param('photostatresolution',
88  args.photoStatResolution)
89 eclDigitizerPureCsI.param('sigmaTrigger', 0)
90 eclDigitizerPureCsI.param('LastRing', 12)
91 mainPath.add_module(eclDigitizerPureCsI)
92 
93 # Register and add 'EclCovMatrixNtuple' module and settings
94 eclCovMatrixNtuple = b2.register_module('EclCovMatrixNtuple')
95 eclCovMatrixNtuple.param('dspArrayName', 'ECLDspsPureCsI')
96 eclCovMatrixNtuple.param('digiArrayName', 'ECLDigitsPureCsI')
97 eclCovMatrixNtuple.param('outputFileName',
98  args.outputFileName)
99 mainPath.add_module(eclCovMatrixNtuple)
100 
101 add_mdst_output(mainPath, additionalBranches=['ECLDspsPureCsI'])
102 
103 # Process the events and print call statistics
104 mainPath.add_module('Progress')
105 b2.process(mainPath)
106 print(b2.statistics)