13import modularAnalysis
as ma
19 Interfacing for the Charm Flavor Tagger.
21 This function requires a reconstructed D meson signal particle list
with a built RestOfEvent.
23 :param particle_list: string, particle list of the reconstructed signal D meson
24 :param uniqueIdentifier: string, database identifier
for the method
25 :param path: basf2 path obj
30 roe_path = basf2.create_path()
31 dead_end_path = basf2.create_path()
34 extension = particle_list.replace(
':',
'_to_')
35 roe_particle_list_cut =
'isInRestOfEvent == 1 and dr < 1 and abs(dz) < 3'
36 roe_particle_list =
'pi+:cft' +
'_' + extension
39 ma.signalSideParticleFilter(particle_list,
'', roe_path, dead_end_path)
42 ma.fillParticleList(roe_particle_list, roe_particle_list_cut, path=roe_path)
45 rank_variable =
'opang_shift'
46 va.variables.addAlias(rank_variable, f
"abs(formula(angleToClosestInList({particle_list}) - 3.14159265359/2))")
47 va.variables.addAlias(
"eta",
"formula(-1*log(tan(formula(theta/2))))")
48 va.variables.addAlias(
"phi_sig",
"particleRelatedToCurrentROE(phi)")
49 va.variables.addAlias(
"eta_sig",
"particleRelatedToCurrentROE(eta)")
50 va.variables.addAlias(
"deltaPhi_temp",
"abs(formula(phi-phi_sig))")
51 va.variables.addAlias(
53 "conditionalVariableSelector(deltaPhi_temp>3.14159265359,formula(deltaPhi_temp-2*3.14159265359),deltaPhi_temp)")
54 va.variables.addAlias(
"deltaR",
"formula(((deltaPhi)**2+(eta-eta_sig)**2)**0.5)")
55 va.variables.addAlias(
"PID_diff",
"formula(pionID-kaonID)")
58 var_list = [
'mRecoil',
'PID_diff',
'deltaR']
59 cft_particle_dict = {
'pi+:pos_charge': [
'charge > 0 and p < infinity',
'p'],
60 'pi+:neg_charge': [
'charge < 0 and p < infinity',
'n']}
62 for listName, config
in cft_particle_dict.items():
63 ma.cutAndCopyList(listName, roe_particle_list, config[0], writeOut=
True, path=roe_path)
64 ma.rankByHighest(listName, rank_variable, numBest=3, path=roe_path)
68 for i_num
in range(1, 3 + 1):
69 roe_dict[f
'eventCached(getVariableByRank({listName}, {rank_variable}, {var}, {i_num}))'] = (
70 f
'pi_{i_num}_{suffix}_{var}')
71 va.variables.addAlias(f
'pi_{i_num}_{suffix}_{var}', f
'extraInfo(pi_{i_num}_{suffix}_{var})')
73 ma.variableToSignalSideExtraInfo(listName, roe_dict, path=roe_path)
76 expert_module = basf2.register_module(
'MVAExpert')
77 expert_module.param(
'listNames', [particle_list])
78 expert_module.param(
'identifier', uniqueIdentifier)
80 expert_module.param(
'extraInfoName',
'CFT_out')
82 roe_path.add_module(expert_module)
85 va.variables.addAlias(
87 'conditionalVariableSelector(isNAN(pi_1_p_deltaR) and isNAN(pi_1_n_deltaR),0.5,formula(1-extraInfo(CFT_out)))')
88 va.variables.addAlias(
'CFT_qr',
'formula(2*CFT_prob-1)')
90 path.for_each(
'RestOfEvent',
'RestOfEvents', roe_path)