50 modClusColls={}):
51 tool = None
52 doModClus = (modConstKey!="" and not doPFlow)
53 if doModClus:
54 modLCClus = modClusColls['LC{0}Clusters'.format(modConstKey)]
55 modEMClus = modClusColls['EM{0}Clusters'.format(modConstKey)]
56
57
58 if config.objType == 'Ele':
59 tool = CompFactory.getComp("met::METElectronAssociator")('MET_ElectronAssociator_'+suffix,TCMatchMethod=1)
60 if config.objType == 'LRTEle':
61 tool = CompFactory.getComp("met::METElectronAssociator")('MET_LRTElectronAssociator_'+suffix,TCMatchMethod=1)
62 if config.objType == 'Gamma':
63 tool = CompFactory.getComp("met::METPhotonAssociator")('MET_PhotonAssociator_'+suffix,TCMatchMethod=1)
64 if config.objType == 'Tau':
65 tool = CompFactory.getComp("met::METTauAssociator")('MET_TauAssociator_'+suffix)
66 if config.objType == 'LCJet':
67 tool = CompFactory.getComp("met::METJetAssocTool")('MET_LCJetAssocTool_'+suffix)
68 if config.objType == 'EMJet':
69 tool = CompFactory.getComp("met::METJetAssocTool")('MET_EMJetAssocTool_'+suffix)
70 if config.objType == 'PFlowJet':
71 tool = CompFactory.getComp("met::METJetAssocTool")('MET_PFlowJetAssocTool_'+suffix)
72 if config.objType == 'HadronicRecoil':
73 tool = CompFactory.getComp("met::METJetAssocTool")('MET_PFlowJetAssocTool_HR_'+suffix)
74 if config.objType == 'CustomJet':
75 tool = CompFactory.getComp("met::METJetAssocTool")('MET_CustomJetAssocTool_'+suffix)
76 if config.objType == 'Muon':
77 tool = CompFactory.getComp("met::METMuonAssociator")('MET_MuonAssociator_'+suffix)
78 if config.objType == 'MuonLRT':
79 tool = CompFactory.getComp("met::METMuonAssociator")('MET_MuonLRTAssociator_'+suffix)
80 if config.objType == 'Soft':
81 tool = CompFactory.getComp("met::METSoftAssociator")('MET_SoftAssociator_'+suffix)
82 tool.DecorateSoftConst = True
83 if doModClus:
84 tool.LCModClusterKey = modLCClus
85 tool.EMModClusterKey = modEMClus
86 if config.objType == 'Truth':
87 tool = CompFactory.getComp("met::METTruthAssociator")('MET_TruthAssociator_'+suffix)
88 tool.RecoJetKey = config.inputKey
89 if doPFlow:
90 tool.PFlow = True
91 if doRecoil:
92 tool.FlowElementCollection = modConstKey if modConstKey!="" else defaultInputKey["PFlowObjHR"]
93 else:
94 tool.FlowElementCollection = modConstKey if modConstKey!="" else defaultInputKey["PFlowObj"]
95 else:
96 tool.UseModifiedClus = doModClus
97 if doRecoil and (config.objType == 'Muon' or config.objType == 'Ele'):
98 tool.HRecoil = True
99 tool.UseFELinks = False if config.objType == 'MuonLRT' or config.objType == 'LRTEle' else useFELinks
100
101 if config.inputKey == '' and defaultInputKey[config.objType] != '':
102 config.inputKey = defaultInputKey[config.objType]
103
104 if hasattr(tool, 'InputCollection'):
105 tool.InputCollection = config.inputKey
106 if config.objType in ['Ele', 'LRTEle', 'Gamma', 'Tau', 'Muon', 'MuonLRT']:
107 tool.UEcorrPtDecorKey = "{inputKey}.UEcorr_Pt".format(inputKey=config.inputKey)
108 if config.inputKey == '':
109 metlog.error("Unable to correctly set {}.InputCollection as config.inputKey is empty! config.objType = {}".format(tool.name, config.ObjType))
110 if config.objType in ['Gamma']:
111 tool.photonNeutralPFOReadDecorKey = "{}.neutralpfoLinks".format(config.inputKey)
112 tool.photonChargedPFOReadDecorKey = "{}.chargedpfoLinks".format(config.inputKey)
113 tool.photonNeutralFEReadDecorKey = "{}.neutralGlobalFELinks".format(config.inputKey)
114 tool.photonChargedFEReadDecorKey = "{}.chargedGlobalFELinks".format(config.inputKey)
115 if config.objType in ['Ele', 'LRTEle']:
116 tool.electronNeutralPFOReadDecorKey = "{}.neutralpfoLinks".format(config.inputKey)
117 tool.electronChargedPFOReadDecorKey = "{}.chargedpfoLinks".format(config.inputKey)
118 tool.electronNeutralFEReadDecorKey = "{}.neutralGlobalFELinks".format(config.inputKey)
119 tool.electronChargedFEReadDecorKey = "{}.chargedGlobalFELinks".format(config.inputKey)
120
121 if doModClus:
122 tool.ClusColl = modLCClus
123 if 'EMTopo' in suffix: tool.ClusColl = modEMClus
124 tool.TrkColl = defaultInputKey['Tracks']
125 tool.UseTracks = configFlags.MET.UseTracks
126 tool.TrackSelectorTool = trkseltool
127 tool.TrackIsolationTool = trkisotool
128 tool.CaloIsolationTool = caloisotool
129
130 return tool
131