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.DressingDecorationName=
'dressedPhoton'
82 truthpartcopy.ExtraInputs = {(
'xAOD::TruthParticleContainer' ,
'StoreGateSvc+TruthParticles.dressedPhoton' )}
83 if modspec==
"Charged":
84 truthpartcopy.ChargedParticlesOnly=
True
89 """Internal unlity to name labels
91 Returns a dictionary to configure labeling tools. Takes one
92 argument which is prefixed to each label.
95 LabelName=f
"{prefix}TruthLabelID",
96 DoubleLabelName=f
"{prefix}ExtendedTruthLabelID",
97 LabelPtName=f
"{prefix}TruthLabelPt",
98 LabelLxyName=f
"{prefix}TruthLabelLxy",
99 LabelDRName=f
"{prefix}TruthLabelDR",
100 LabelPdgIdName=f
"{prefix}TruthLabelPdgId",
101 LabelPositionDPhiName=f
"{prefix}TruthLabelPositionDPhi",
102 LabelPositionDEtaName=f
"{prefix}TruthLabelPositionDEta",
103 LabelBarcodeName=f
"{prefix}TruthLabelBarcode",
104 ChildLxyName=f
"{prefix}TruthLabelChildLxy",
105 ChildPtName=f
"{prefix}TruthLabelChildPt",
106 ChildPdgIdName=f
"{prefix}TruthLabelChildPdgId",
107 ChildPositionDPhiName=f
"{prefix}TruthLabelChildPositionDPhi",
108 ChildPositionDEtaName=f
"{prefix}TruthLabelChildPositionDEta",
113 """Get the standard flavor tagging delta-R labeling tool
115 Uses cone matching to B, C and tau truth particles.
117 return CompFactory.ParticleJetDeltaRLabelTool(
120 BLabelName =
"ConeExclBHadronsFinal",
121 CLabelName =
"ConeExclCHadronsFinal",
122 TauLabelName =
"ConeExclTausFinal",
123 BParticleCollection =
"TruthLabelBHadronsFinal",
124 CParticleCollection =
"TruthLabelCHadronsFinal",
125 TauParticleCollection =
"TruthLabelTausFinal",
129 JetPtMin = jet_pt_min,
134 """returns a ParticleJetDeltaRLabelTool
135 Cone matching for B, C and tau truth for all but track jets.
137 This function is meant to be used as callback from JetRecConfig where
138 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.
140 jetptmin =
float(modspec)
141 name =
"jetdrlabeler_jetpt{0}GeV".
format(
int(jetptmin/1000))
146 return CompFactory.ParticleJetGhostLabelTool(
149 GhostBName =
"GhostBHadronsFinal",
150 GhostCName =
"GhostCHadronsFinal",
151 GhostTauName =
"GhostTausFinal",
157 """get ghost-based flavor tagging labeling
159 This is a wrapper for JetRecConfig where it's called as
160 func(jetdef, modspec)
167 isTruthJet =
'Truth' in jetdef.fullname()
169 if not isinstance(modspec, str):
170 raise ValueError(
"JetTruthLabelingTool can only be scheduled with str as modspec")
172 truthLabel =
str(modspec)
174 jetTruthLabelTool = CompFactory.JetTruthLabelingTool(
'truthlabeler_{0}'.
format(truthLabel),
175 RecoJetContainer = jetdef.fullname(),
176 IsTruthJetCollection = isTruthJet,
177 TruthLabelName = truthLabel)
179 return jetTruthLabelTool
182 return [
"input:AntiKt10TruthDressedWZSoftDropBeta100Zcut10Jets"]
if modspec ==
"R10WZTruthLabel_R22v1" and jetdef._cflags.Input.isMC
else []
186 jetPileupLabelTool = CompFactory.JetPileupLabelingTool(
'pileuplabeler',
187 RecoJetContainer = jetdef.fullname(),
188 TruthJetContainer=
"AntiKt4TruthDressedWZJets")
190 return jetPileupLabelTool