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