Belle II Software  release-06-00-14
testEntireBKLMChain.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 
11 
12 
19 
20 import basf2
21 import generators as gen
22 import simulation as sim
23 
24 bklm_dataObjects = ['BKLMDigits',
25  'BKLMDigitOutOfRanges',
26  'KLMDigitEventInfos',
27  'BKLMHit1ds',
28  'BKLMHit2ds',
29  'BKLMTracks']
30 use_KKMC = False
31 
32 # Create the main path
33 main = basf2.create_path()
34 
35 # Set EventInfoSetter and add a progress bar
36 main.add_module('EventInfoSetter',
37  expList=0,
38  runList=0,
39  evtNumList=1000)
40 main.add_module('Progress')
41 main.add_module('ProgressBar')
42 
43 if use_KKMC: # Use KKMC to generate generic mu+mu- events
44  gen.add_kkmc_generator(path=main,
45  finalstate='mu-mu+')
46 else: # Use ParticleGun to generate 4GeV mu+ and mu-
47  main.add_module('ParticleGun',
48  nTracks=1,
49  pdgCodes=[13, -13],
50  momentumGeneration='fixed',
51  momentumParams=[4],
52  thetaGeneration='uniform',
53  thetaParams=[37, 130])
54 
55 # Add simulation
56 main.add_module('Gearbox')
57 main.add_module('Geometry',
58  components=['KLM'],
59  useDB=False)
60 sim.add_simulation(path=main,
61  components=['KLM'])
62 
63 # Pack and unpack data
64 main.add_module('KLMPacker')
65 main.add_module('KLMUnpacker',
66  WriteDigitRaws=True)
67 
68 # Add the digit analyzer module (optional)
69 main.add_module('BKLMDigitAnalyzer',
70  outputRootName='bklmHitmap')
71 
72 # Add the reconstruction
73 main.add_module('KLMReconstructor')
74 
75 # Add the self-tracking
76 main.add_module('BKLMTracking',
77  StudyEffiMode=True,
78  outputName='bklmEfficiency.root')
79 
80 # Save the dataobjects in a .root output
81 main.add_module('RootOutput',
82  outputFileName='bklm_dataObjects.root',
83  branchNames=bklm_dataObjects,
84  branchNamesPersistent='FileMetaData')
85 
86 # Process the path
87 basf2.process(main)
88 print(basf2.statistics)