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