20 name_suffix=''):
21
22
23 if source is not None:
24 warnings.warn(
25 "'source' option is deprecated, use 'sources'",
26 FutureWarning,
27 stacklevel=2
28 )
29 if sources:
30 raise ValueError(
31 "Can't use 'sources' and 'source' at the same time"
32 )
33 sources = [source]
34
35 if not sources:
36 sources = [target]
37
38 if source_name is None:
39 source_name = 'Or'.join(sources)
40
41 dr_str = f'deltaRTo{source_name}'
42 deta_str = f'deltaEtaTo{source_name}'
43 dphi_str = f'deltaPhiTo{source_name}'
44 dpt_str = f'deltaPtTo{source_name}'
45 match_str = f'matchedTo{source_name}'
46 n_match_str = f'numberOfMatchesTo{source_name}'
47
48 def to(f):
49 return f + f'From{source_name}' if add_suffix_with_source else f
50
51 ca = ComponentAccumulator()
52 ca.addEventAlgo(
53 CompFactory.ftag.JetMatcherAlg(
54 f'{source_name}To{target}CopyAlg{name_suffix}',
55 targetJet=target,
56 sourceJets=sources,
57 floatsToCopy={f: to(f) for f in floats_to_copy},
58 intsToCopy={i: to(i) for i in ints_to_copy},
59 charsToCopy={c: to(c) for c in chars_to_copy},
60 iparticlesToCopy={p: to(p) for p in iparticles_to_copy},
61 dR=dr_str,
62 dEta=deta_str,
63 dPhi=dphi_str,
64 dPt=dpt_str,
65 isMatched=match_str,
66 nMatch=n_match_str,
67 ptPriorityWithDeltaR=pt_priority_with_delta_r,
68 sourceMinimumPt=source_minimum_pt,
69 particleLink=(particle_link_name or ""),
70 )
71 )
72 return ca