Belle II Software development
cdcdedx_calibration_utils.py
1
8
9import basf2
10from reconstruction import prepare_cdst_analysis
11import modularAnalysis as mA
12
13
14# radiative electron selection
15def make_electron_collection(path_electron):
16 # Add a TriggerSkim module to apply a specific trigger line
17 trg_bhabhaskim = path_electron.add_module(
18 "TriggerSkim",
19 triggerLines=["software_trigger_cut&skim&accept_bhabha_cdc"])
20 trg_bhabhaskim.if_value("==0", basf2.Path(), basf2.AfterConditionPath.END)
21
22 prepare_cdst_analysis(path=path_electron)
23
24 # Add the CDCDedxCorrection module to correct dE/dx (no saturation)
25 path_electron.add_module(
26 'CDCDedxCorrection',
27 relativeCorrections=False, # Disable relative corrections
28 scaleCor=True,
29 runGain=True, # Enable run gain corrections
30 timeGain=True, # Enable injection time gain corrections
31 cosineCor=True, # Enable cosine corrections
32 wireGain=True, # Enable wire gain corrections
33 twoDCell=True, # Enable 2D cell corrections
34 oneDCell=True) # Enable 1D cell corrections
35
36 # Fill the particle list
37 mA.fillParticleList('e+:calib', ' ', path=path_electron)
38 return ['e+:calib']
39
40# ------------------------------------------------------------------------------------------------------------------
41
42# radiative muon selection
43
44
45def make_muon_collection(path_muon):
46
47 prepare_cdst_analysis(path=path_muon)
48
49 # Add the CDCDedxCorrection module to correct dE/dx (no saturation)
50 path_muon.add_module(
51 'CDCDedxCorrection',
52 relativeCorrections=False, # Disable relative corrections
53 scaleCor=True,
54 runGain=True, # Enable run gain corrections
55 timeGain=True, # Enable injection time gain corrections
56 cosineCor=True, # Enable cosine corrections
57 wireGain=True, # Enable wire gain corrections
58 twoDCell=True, # Enable 2D cell corrections
59 oneDCell=True) # Enable 1D cell corrections
60
61 # Creating a particle list with basic cuts
62 goodTrack = 'abs(dr) < 0.5 and abs(dz) < 0.5 and nCDCHits > 0'
63 goodTrack += ' and clusterE < 0.40 and clusterEoP < 0.40 and inCDCAcceptance==1'
64 goodTrack += ' and [[isPIDAvailableFrom(KLM) == 0 and clusterE < 0.25] or isPIDAvailableFrom(KLM) == 1]'
65
66 # Create a particle list for muons that satisfy the selection criteria
67 mA.fillParticleList('mu+:calib', goodTrack, path=path_muon)
68
69 # Define cuts for the track pair (mu+ and mu-)
70 track_cuts = ''
71 track_cuts += 'daughterProductOf(charge) < 0'
72 track_cuts += ' and daughterLowest(clusterE) <= 0.25'
73
74 # One of the muons is valid in KLM
75 track_cuts += ' and [daughter(0,isPIDAvailableFrom(KLM)) == 1 or daughter(1,isPIDAvailableFrom(KLM)) == 1]'
76
77 # Reconstruct the decay 'vpho -> mu+ mu-'
78 mA.reconstructDecay('vpho:mumu -> mu+:calib mu-:calib', track_cuts, path=path_muon)
79
80 # Apply event-level cuts to ensure there are exactly two cleaned tracks
81 event_cuts = '[nCleanedTracks('+goodTrack+') == 2]'
82 mA.applyEventCuts(event_cuts, path=path_muon)
83 radmumulist = ['vpho:mumu']
84
85 # Apply SkimFilter
86 skimfilter = basf2.register_module('SkimFilter')
87 skimfilter.param('particleLists', radmumulist)
88 path_muon.add_module(skimfilter)
89
90 filter_path = basf2.create_path()
91 skimfilter.if_value('=1', filter_path, basf2.AfterConditionPath.CONTINUE)
92
93 # Define additional cuts for the muon pair
94 cutonPairs = ''
95 mA.cutAndCopyList('mu+:cal', 'mu+:calib', cutonPairs, path=filter_path)
96
97 # Apply event-level cuts for the copied muons
98 event_cutscopy = '[nCleanedTracks('+goodTrack+') == 2]'
99 mA.applyEventCuts(event_cutscopy, path=filter_path)
100
101 return ['mu+:cal']
102
103# ------------------------------------------------------------------------------------------------------------------
104
105# proton selection
106
107
108def make_proton_collection(path_hadrons):
109
110 # Trigger Skim Module to apply the specified trigger lines
111 trg_skim = path_hadrons.add_module("TriggerSkim", triggerLines=["software_trigger_cut&skim&accept_lambda"])
112 trg_skim.if_value("==0", basf2.Path(), basf2.AfterConditionPath.END)
113
114 prepare_cdst_analysis(path=path_hadrons)
115
116 # Add the CDCDedxCorrection module to correct dE/dx (no saturation)
117 path_hadrons.add_module(
118 'CDCDedxCorrection',
119 relativeCorrections=False, # Disable relative corrections
120 scaleCor=True,
121 runGain=True, # Enable run gain corrections
122 timeGain=True, # Enable injection time gain corrections
123 cosineCor=True, # Enable cosine corrections
124 wireGain=True, # Enable wire gain corrections
125 twoDCell=True, # Enable 2D cell corrections
126 oneDCell=True) # Enable 1D cell corrections
127
128 # Define a selection criteria for good proton tracks
129 goodProtonTrack = 'dr< 0.50 and abs(dz)<0.50'
130 mA.fillParticleList("p+:calib", goodProtonTrack, path=path_hadrons)
131 return "p+:calib"
132
133# ------------------------------------------------------------------------------------------------------------------
134
135# pion kaon selection
136
137
138def make_pion_kaon_collection(path_hadrons):
139
140 # Add the TriggerSkim module to the path with specified trigger lines
141 trg_skim = path_hadrons.add_module(
142 "TriggerSkim",
143 triggerLines=[
144 "software_trigger_cut&skim&accept_dstar_1",
145 "software_trigger_cut&skim&accept_dstar_3"])
146
147 trg_skim.if_value("==0", basf2.Path(), basf2.AfterConditionPath.END)
148
149 prepare_cdst_analysis(path=path_hadrons)
150
151 # Add the CDCDedxCorrection module to correct dE/dx (no saturation)
152 path_hadrons.add_module(
153 'CDCDedxCorrection',
154 relativeCorrections=False, # Disable relative corrections
155 scaleCor=True,
156 runGain=True, # Enable run gain corrections
157 timeGain=True, # Enable injection time gain corrections
158 cosineCor=True, # Enable cosine corrections
159 wireGain=True, # Enable wire gain corrections
160 twoDCell=True, # Enable 2D cell corrections
161 oneDCell=True) # Enable 1D cell corrections
162
163 # Define cleaning criteria for the Kaon particle list
164 clean_K = 'dr < 1.00 and abs(dz) < 1.0 and inCDCAcceptance==1 '
165 clean_K += ' and [[cosTheta<-0.45 or cosTheta >= 0.80] or [[cosTheta>=-0.45 and cosTheta <= 0.80 and pt <= 0.50]'
166 clean_K += ' or [cosTheta>=-0.45 and cosTheta <= 0.80 and pt > 0.50 and pidProbabilityExpert(321, TOP) > 0.015 ]]]'
167
168 # Fill the cleaned Kaon list
169 mA.fillParticleList("K+:calib", clean_K, path=path_hadrons)
170
171 # Define cleaning criteria for the Pion particle list
172 clean_Pi = 'dr < 1.0 and abs(dz) < 1.0 and inCDCAcceptance==1 '
173 clean_Pi += ' and [[cosTheta<-0.45 or cosTheta > 0.80] or [[cosTheta>=-0.45 and cosTheta <= 0.80 and pt <= 0.50] '
174 clean_Pi += ' or [cosTheta>=-0.45 and cosTheta <= 0.80 and pt > 0.50 and pidProbabilityExpert(321, TOP) < 0.60 ]]]'
175
176 # Fill the cleaned Pion list
177 mA.fillParticleList("pi+:calib", clean_Pi, path=path_hadrons)
178
179 # -----------------------------------------------------------
180 # Reconstruction for the D0 -> K- pi+ decay
181 clean_Dz1 = 'abs(dM) < 0.020' # Mass difference of D0
182 clean_Dz1 += ' and [daughter(0,nCDCHits) > 30 or daughter(1, nCDCHits) > 30] '
183
184 mA.reconstructDecay('D0:cal1 -> K-:calib pi+:calib', clean_Dz1, path=path_hadrons)
185
186 # Reconstruction for the D0 -> K- pi+ pi+ pi- decay
187 clean_Dz2 = 'abs(dM) < 0.020' # Mass difference of D0
188 clean_Dz2 += ' and [daughter(0,nCDCHits) > 25 or daughter(1, nCDCHits) > 25 or daughter(2, nCDCHits) > 25 '
189 clean_Dz2 += ' or daughter(3, nCDCHits) > 25] '
190 mA.reconstructDecay('D0:cal2 -> K-:calib pi+:calib pi+:calib pi-:calib', clean_Dz2, path=path_hadrons)
191
192 # ------------------------------------------------------------
193 # Define cleaning for slow pions
194 clean_sPi = 'dr < 1.00 and abs(dz) < 1.00 and p < 1.5 and nCDCHits > 10 and inCDCAcceptance==1'
195 mA.fillParticleList("pi+:slow", clean_sPi, path=path_hadrons) # Fill the slow pion list
196
197 # ------------------------------------------------------------
198 # Reconstruct the first D*+ -> D0 [-> K- pi+] and slow pion decay
199 # tights are 0.0017 and 0.015
200 clean_Ds = 'useCMSFrame(p) > 1.5 and abs(formula(massDifference(0) - 0.14542)) < 0.00070 '
201 clean_Ds += ' and abs(dM) < 0.020' # Mass difference of D*
202 mA.reconstructDecay('D*+:cal1 -> D0:cal1 pi+:slow', clean_Ds, path=path_hadrons)
203
204 # Apply SkimFilter for the first D*+ decay
205 list_Ds1 = ['D*+:cal1']
206 skimf_Ds1 = basf2.register_module('SkimFilter')
207 skimf_Ds1.param('particleLists', list_Ds1)
208 path_hadrons.add_module(skimf_Ds1)
209 fpath_Ds1 = basf2.create_path()
210 skimf_Ds1.if_value('=1', fpath_Ds1, basf2.AfterConditionPath.CONTINUE)
211
212 # Reconstruct the second D*+ [-> D0 [-> K- pi+ pi+ pi- ] slow pion] decay and apply SkimFilter
213 mA.reconstructDecay('D*+:cal2 -> D0:cal2 pi+:slow', clean_Ds, path=path_hadrons)
214
215 list_Ds2 = ['D*+:cal2']
216 skimf_Ds2 = basf2.register_module('SkimFilter')
217 skimf_Ds2.param('particleLists', list_Ds2)
218 path_hadrons.add_module(skimf_Ds2)
219 fpath_Ds2 = basf2.create_path()
220 skimf_Ds2.if_value('=1', fpath_Ds2, basf2.AfterConditionPath.CONTINUE)
221
222 # ------------------------------------------------------------
223 # Add extra information to daughter particles for first D*+ decay
224 mA.variablesToDaughterExtraInfo('D*+:cal1', 'D*+ -> [D0 -> ^K- ^pi+ ] ^pi+', {'dM': 'l_Ds1dM'}, path=fpath_Ds1)
225 mA.variablesToDaughterExtraInfo('D*+:cal1', 'D*+ -> [D0 -> ^K- ^pi+ ] ^pi+', {'useCMSFrame(p)': 'l_Ds1p'}, path=fpath_Ds1)
226 mA.variablesToDaughterExtraInfo('D*+:cal1', 'D*+ -> [D0 -> ^K- ^pi+ ] ^pi+',
227 {'massDifference(0)': 'l_Ds1mDiff'}, path=fpath_Ds1)
228 mA.variablesToDaughterExtraInfo('D*+:cal1', 'D*+ -> [D0 -> ^K- ^pi+ ] ^pi+', {'daughter(0,dM)': 'l_Ds1_DzdM'}, path=fpath_Ds1)
229 mA.variablesToDaughterExtraInfo('D*+:cal1',
230 'D*+ -> [D0 -> ^K- ^pi+ ] ^pi+',
231 {'daughter(0,daughter(0,nCDCHits))': 'l_Ds1_Dz_Khits'},
232 path=fpath_Ds1)
233 mA.variablesToDaughterExtraInfo('D*+:cal1',
234 'D*+ -> [D0 -> ^K- ^pi+ ] ^pi+',
235 {'daughter(0,daughter(1,nCDCHits))': 'l_Ds1_Dz_Pihits'},
236 path=fpath_Ds1)
237
238 # Define the cut conditions for first D*+ mass difference, momentum, and decay parameters
239 cutonD1var = "abs(extraInfo(l_Ds1dM)) < 0.02" # D* mass difference
240 cutonD1var += " and extraInfo(l_Ds1p) > 1.5 " # D* momentum
241 cutonD1var += " and abs(formula(extraInfo(l_Ds1mDiff) - 0.14542)) < 0.0010" # \DeltaM
242 cutonD1var += " and abs(extraInfo(l_Ds1_DzdM)) < 0.02" # D0 mass difference
243 cutonD1var += " and [extraInfo(l_Ds1_Dz_Khits) > 30 or extraInfo(l_Ds1_Dz_Pihits) > 30]"
244
245 # Apply cuts and copy the filtered particles to new lists
246 mA.cutAndCopyList('K+:dst1', 'K+:calib', cutonD1var, path=fpath_Ds1)
247 mA.cutAndCopyList('pi+:dst1', 'pi+:calib', cutonD1var, path=fpath_Ds1)
248
249 # ------------------------------------------------------------
250 # Add extra information to daughter particles for second D*+ decay
251 mA.variablesToDaughterExtraInfo('D*+:cal2', 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+', {'dM': 'l_Ds2dM'}, path=fpath_Ds2)
252 mA.variablesToDaughterExtraInfo('D*+:cal2',
253 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+',
254 {'useCMSFrame(p)': 'l_Ds2p'},
255 path=fpath_Ds2)
256 mA.variablesToDaughterExtraInfo('D*+:cal2',
257 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+',
258 {'massDifference(0)': 'l_Ds2mDiff'},
259 path=fpath_Ds2)
260 mA.variablesToDaughterExtraInfo('D*+:cal2',
261 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+',
262 {'daughter(0,dM)': 'l_Ds2_DzdM'},
263 path=fpath_Ds2)
264 mA.variablesToDaughterExtraInfo('D*+:cal2',
265 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+',
266 {'daughter(0,daughter(0,nCDCHits))': 'l_Ds2_Dz_Khits'},
267 path=fpath_Ds2)
268 mA.variablesToDaughterExtraInfo('D*+:cal2',
269 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+',
270 {'daughter(0,daughter(1,nCDCHits))': 'l_Ds2_Dz_Pi1hits'},
271 path=fpath_Ds2)
272 mA.variablesToDaughterExtraInfo('D*+:cal2',
273 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+',
274 {'daughter(0,daughter(2,nCDCHits))': 'l_Ds2_Dz_Pi2hits'},
275 path=fpath_Ds2)
276 mA.variablesToDaughterExtraInfo('D*+:cal2',
277 'D*+ -> [D0 -> ^K- ^pi+ ^pi+ ^pi-] ^pi+',
278 {'daughter(0,daughter(3,nCDCHits))': 'l_Ds2_Dz_Pi3hits'},
279 path=fpath_Ds2)
280
281 # Define the cut conditions for second D*+ mass difference, momentum, and decay parameters
282 cutonD2var = "abs(extraInfo(l_Ds2dM)) < 0.02" # D* mass difference
283 cutonD2var += " and extraInfo(l_Ds2p) > 2.0" # D* momentum
284 cutonD2var += " and abs(formula(extraInfo(l_Ds2mDiff) - 0.14542)) < 0.0010" # \DeltaM
285 cutonD2var += " and abs(extraInfo(l_Ds2_DzdM)) < 0.02" # D0 mass difference
286 cutonD2var += " and [extraInfo(l_Ds2_Dz_Khits) > 25 or extraInfo(l_Ds2_Dz_Pi1hits) > 25 "
287 cutonD2var += " or extraInfo(l_Ds2_Dz_Pi2hits) > 25 or extraInfo(l_Ds2_Dz_Pi3hits) > 25]"
288
289 # Apply cuts and copy the filtered particles to new lists
290 mA.cutAndCopyList('K+:dst2', 'K+:calib', cutonD2var, path=fpath_Ds2)
291 mA.cutAndCopyList('pi+:dst2', 'pi+:calib', cutonD2var, path=fpath_Ds2)
292
293 pion_kaon_list = ['pi+:dst1', 'pi+:dst2', 'K+:dst1', 'K+:dst2']
294
295 return pion_kaon_list