Belle II Software development
KLMMuidLikelihoodVariables.py
1#!/usr/bin/env python
2
3
10
11
26
27import basf2
28import generators as gen
29import simulation as sim
30import reconstruction as rec
31import modularAnalysis as ma
32
33# Load the klm libraries
34# Fundamental for using the KLMMuidLikelihood variables!
35from ROOT import gSystem
36gSystem.Load('libklm.so')
37
38# Create the main path
39main = basf2.create_path()
40
41
44
45# Set EventInfoSetter and add a progress bar
46main.add_module('EventInfoSetter',
47 expList=0,
48 runList=1,
49 evtNumList=100)
50main.add_module('Progress')
51main.add_module('ProgressBar')
52
53use_KKMC = True
54if use_KKMC: # Use KKMC to generate generic mu+mu- events
55 gen.add_kkmc_generator(finalstate='mu+mu-',
56 path=main)
57else: # Use ParticleGun to generate 4GeV mu+ and mu-
58 main.add_module('ParticleGun',
59 nTracks=1,
60 pdgCodes=[13, -13],
61 momentumGeneration='fixed',
62 momentumParams=[4],
63 thetaGeneration='uniformCos',
64 thetaParams=[20, 47])
65
66# Add simulation and reconstruction
67# Note that we skip the trigger simulation in this example
68sim.add_simulation(path=main)
69rec.add_reconstruction(path=main)
70
71
74
75# Reconstruct muon-candidates in the event with ECL-based cuts
76ma.fillParticleList(
77 'mu+:basic',
78 'nCDCHits > 20 and abs(dz) < 2.0 and abs(dr) < 0.5 and 0.15 < clusterE < 0.4 and formula(clusterE/p) < 0.4',
79 path=main)
80
81# Select better muon-candidates requiring at least one hit after layer 3 of KLM
82# Note that we are using a Muid variable
83ma.cutAndCopyList('mu+:muid',
84 'mu+:basic',
85 'muidHitLayer > 3',
86 path=main)
87
88# Saving variables to a flat ntuple
89listOfVariables = ['p',
90 'charge',
91 'theta',
92 'phi',
93 'muonID',
94 'pionID',
95 # Here we select some Muid variables
96 'muidMuonProbability',
97 'muidPionProbability',
98 'muidMuonLogLikelihood',
99 'muidPionLogLikelihood',
100 'muidOutcomeExtTrack',
101 'muidHitLayer',
102 'muidExtLayer',
103 'muidHitLayerPattern',
104 'muidExtLayerPattern',
105 # Here we select some KLMCluster variables
106 'klmClusterIsBKLM',
107 'klmClusterInnermostLayer',
108 'klmClusterLayers']
109ma.variablesToNtuple('mu+:muid',
110 listOfVariables,
111 filename='MuidVariables.root',
112 treename='muons',
113 path=main)
114
115# Process the path
116basf2.process(main)
117print(basf2.statistics)