11 from AthenaCommon
import Logging
12 jrtlog = Logging.logging.getLogger(
'ParticleJetToolsConfig')
14 from AthenaConfiguration.ComponentFactory
import CompFactory
17 from JetRecConfig.JetRecConfig
import isAnalysisRelease
18 except ModuleNotFoundError:
25 truthclassif = CompFactory.MCTruthClassifier(
26 "JetMCTruthClassifier"
29 truthclassif.xAODTruthLinkVector=
""
32 if "AtlasProject" in os.environ.keys():
33 if os.environ[
"AtlasProject"]
in [
"Athena",
"AthDerivation"]:
34 truthclassif.ParticleCaloExtensionTool=
""
39 "Partons":{
"ToolType":CompFactory.CopyTruthPartons,
"ptmin":5000},
40 "BosonTop":{
"ToolType":CompFactory.CopyBosonTopLabelTruthParticles,
"ptmin":100000},
41 "FlavourLabel":{
"ToolType":CompFactory.CopyFlavorLabelTruthParticles,
"ptmin":5000},
45 if truthtype ==
"Partons":
46 truthcategory =
"Partons"
47 elif truthtype
in [
"WBosons",
"ZBosons",
"HBosons",
"TQuarksFinal"]:
48 truthcategory =
"BosonTop"
49 toolProperties[
'ParticleType'] = truthtype
51 truthcategory =
"FlavourLabel"
52 toolProperties[
'ParticleType'] = truthtype
54 tooltype = truthpartoptions[truthcategory][
"ToolType"]
55 toolProperties.update( PtMin = truthpartoptions[truthcategory][
"ptmin"],
56 OutputName =
"TruthLabel"+truthtype)
57 ctp = tooltype(
"truthpartcopy_"+truthtype,
66 truthpartcopy = CompFactory.CopyTruthJetParticles(
67 "truthpartcopy"+modspec,
68 OutputName=
"JetInputTruthParticles"+modspec,
69 MCTruthClassifier=truthclassif)
71 truthpartcopy.IncludePromptLeptons=
False
72 truthpartcopy.IncludePromptPhotons=
False
73 truthpartcopy.IncludeMuons=
True
74 truthpartcopy.IncludeNeutrinos=
True
75 if modspec==
"DressedWZ":
76 truthpartcopy.IncludePromptLeptons=
False
77 truthpartcopy.IncludePromptPhotons=
True
78 truthpartcopy.IncludeMuons=
True
79 truthpartcopy.IncludeNeutrinos=
True
80 truthpartcopy.DressingDecorationNames=[
'TruthParticles.dressedPhoton_e',
'TruthParticles.dressedPhoton_mu']
82 truthpartcopy.ExtraInputs = {(
'xAOD::TruthParticleContainer' ,
'StoreGateSvc+TruthParticles.dressedPhoton_e' ),
83 (
'xAOD::TruthParticleContainer' ,
'StoreGateSvc+TruthParticles.dressedPhoton_mu' )}
84 if modspec==
"Charged":
85 truthpartcopy.ChargedParticlesOnly=
True
90 """Internal unlity to name labels
92 Returns a dictionary to configure labeling tools. Takes one
93 argument which is prefixed to each label.
96 LabelName=f
"{prefix}TruthLabelID",
97 DoubleLabelName=f
"{prefix}ExtendedTruthLabelID",
98 LabelPtName=f
"{prefix}TruthLabelPt",
99 LabelLxyName=f
"{prefix}TruthLabelLxy",
100 LabelDRName=f
"{prefix}TruthLabelDR",
101 LabelPdgIdName=f
"{prefix}TruthLabelPdgId",
102 LabelPositionDPhiName=f
"{prefix}TruthLabelPositionDPhi",
103 LabelPositionDEtaName=f
"{prefix}TruthLabelPositionDEta",
104 LabelBarcodeName=f
"{prefix}TruthLabelBarcode",
105 ChildLxyName=f
"{prefix}TruthLabelChildLxy",
106 ChildPtName=f
"{prefix}TruthLabelChildPt",
107 ChildPdgIdName=f
"{prefix}TruthLabelChildPdgId",
108 ChildPositionDPhiName=f
"{prefix}TruthLabelChildPositionDPhi",
109 ChildPositionDEtaName=f
"{prefix}TruthLabelChildPositionDEta",
114 """Get the standard flavor tagging delta-R labeling tool
116 Uses cone matching to B, C and tau truth particles.
118 prefix_to_name =
"HadronConeExcl"
119 if collection !=
"Final":
120 prefix_to_name += collection
123 return CompFactory.ParticleJetDeltaRLabelTool(
126 BLabelName =
"ConeExclBHadrons"+collection,
127 CLabelName =
"ConeExclCHadrons"+collection,
128 TauLabelName =
"ConeExclTausFinal",
129 BParticleCollection =
"TruthLabelBHadrons"+collection,
130 CParticleCollection =
"TruthLabelCHadrons"+collection,
131 TauParticleCollection =
"TruthLabelTausFinal",
135 JetPtMin = jet_pt_min,
140 output_label = "QuarkChargeTruthLabelID",
141 hadron_label = "HadronGhostInitialTruthLabelPdgId",
142 parton_label = "PartonExtendedTruthLabelID"):
143 """Get the flavor tagging labeling tool to store the quark charge of a jet
144 It is necessary to have saved before an hadron label and a parton label, otherwise the code will break
147 import ParticleJetTools.quarkChargeMap
as qcMap
148 charge_map = qcMap.hadrons_dict
150 return CompFactory.JetQuarkChargeLabelingTool(
152 HadronDecorationName = hadron_label,
153 PartonDecorationName = parton_label,
154 HadronChargeMap = charge_map,
155 OutputName = output_label,
159 """returns a ParticleJetDeltaRLabelTool
160 Cone matching for B, C and tau truth for all but track jets.
162 This function is meant to be used as callback from JetRecConfig where
163 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.
165 jetptmin =
float(modspec)
166 name =
"jetdrlabeler_jetpt{0}GeV".
format(
int(jetptmin/1000))
171 """returns a JetQuarkChargeLabelingTool
173 This function is meant to be used as callback from JetRecConfig where
174 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used.
179 outputLabel,hadronLabel,partonLabel = modspec.split(
",")
181 name = f
"jetquarkcharge_{outputLabel}_{hadronLabel}_{partonLabel}"
185 """returns a ParticleJetDeltaRLabelTool
186 Cone matching for B, C and tau truth for all but track jets.
188 This function is meant to be used as callback from JetRecConfig where
189 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.
191 jetptmin =
float(modspec)
192 name =
"jetdrlabeler_jetpt{0}GeV".
format(
int(jetptmin/1000))
198 prefix_to_name =
"HadronGhost"
199 if collection !=
"Final":
200 prefix_to_name += collection
202 return CompFactory.ParticleJetGhostLabelTool(
205 GhostBName =
"GhostBHadrons"+collection,
206 GhostCName =
"GhostCHadrons"+collection,
207 GhostTauName =
"GhostTausFinal",
212 """get ghost-based flavor tagging labeling
214 This is a wrapper for JetRecConfig where it's called as
215 func(jetdef, modspec)
220 """get ghost-based flavor tagging labeling
222 This is a wrapper for JetRecConfig where it's called as
223 func(jetdef, modspec)
230 isTruthJet =
'Truth' in jetdef.fullname()
232 if not isinstance(modspec, str):
233 raise ValueError(
"JetTruthLabelingTool can only be scheduled with str as modspec")
235 truthLabel =
str(modspec)
237 jetTruthLabelTool = CompFactory.JetTruthLabelingTool(
'truthlabeler_{0}'.
format(truthLabel),
238 RecoJetContainer = jetdef.fullname(),
239 IsTruthJetCollection = isTruthJet,
240 TruthLabelName = truthLabel)
242 return jetTruthLabelTool
245 return [
"input:AntiKt10TruthDressedWZSoftDropBeta100Zcut10Jets"]
if modspec ==
"R10WZTruthLabel_R22v1" and jetdef._cflags.Input.isMC
else []
249 jetPileupLabelTool = CompFactory.JetPileupLabelingTool(
'pileuplabeler',
250 RecoJetContainer = jetdef.fullname(),
251 TruthJetContainer=
"AntiKt4TruthDressedWZJets")
253 return jetPileupLabelTool