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
88 jetquarklabel = CompFactory.Analysis.JetQuarkLabel(
90 McEventCollection =
"TruthEvents"
96 truthpartonlabel = CompFactory.Analysis.JetConeLabeling(
98 JetTruthMatchTool = jetquarklabel
100 return truthpartonlabel
104 """Internal unlity to name labels
106 Returns a dictionary to configure labeling tools. Takes one
107 argument which is prefixed to each label.
110 LabelName=f
"{prefix}TruthLabelID",
111 DoubleLabelName=f
"{prefix}ExtendedTruthLabelID",
112 LabelPtName=f
"{prefix}TruthLabelPt",
113 LabelLxyName=f
"{prefix}TruthLabelLxy",
114 LabelDRName=f
"{prefix}TruthLabelDR",
115 LabelPdgIdName=f
"{prefix}TruthLabelPdgId",
116 LabelPositionDPhiName=f
"{prefix}TruthLabelPositionDPhi",
117 LabelPositionDEtaName=f
"{prefix}TruthLabelPositionDEta",
118 LabelBarcodeName=f
"{prefix}TruthLabelBarcode",
119 ChildLxyName=f
"{prefix}TruthLabelChildLxy",
120 ChildPtName=f
"{prefix}TruthLabelChildPt",
121 ChildPdgIdName=f
"{prefix}TruthLabelChildPdgId",
122 ChildPositionDPhiName=f
"{prefix}TruthLabelChildPositionDPhi",
123 ChildPositionDEtaName=f
"{prefix}TruthLabelChildPositionDEta",
128 """Get the standard flavor tagging delta-R labeling tool
130 Uses cone matching to B, C and tau truth particles.
132 return CompFactory.ParticleJetDeltaRLabelTool(
135 BLabelName =
"ConeExclBHadronsFinal",
136 CLabelName =
"ConeExclCHadronsFinal",
137 TauLabelName =
"ConeExclTausFinal",
138 BParticleCollection =
"TruthLabelBHadronsFinal",
139 CParticleCollection =
"TruthLabelCHadronsFinal",
140 TauParticleCollection =
"TruthLabelTausFinal",
144 JetPtMin = jet_pt_min,
149 """returns a ParticleJetDeltaRLabelTool
150 Cone matching for B, C and tau truth for all but track jets.
152 This function is meant to be used as callback from JetRecConfig where
153 it is called as func(jetdef, modspec). Hence the jetdef argument even if not used in this case.
155 jetptmin =
float(modspec)
156 name =
"jetdrlabeler_jetpt{0}GeV".
format(
int(jetptmin/1000))
161 return CompFactory.ParticleJetGhostLabelTool(
164 GhostBName =
"GhostBHadronsFinal",
165 GhostCName =
"GhostCHadronsFinal",
166 GhostTauName =
"GhostTausFinal",
172 """get ghost-based flavor tagging labeling
174 This is a wrapper for JetRecConfig where it's called as
175 func(jetdef, modspec)
182 isTruthJet =
'Truth' in jetdef.fullname()
184 if not isinstance(modspec, str):
185 raise ValueError(
"JetTruthLabelingTool can only be scheduled with str as modspec")
187 truthLabel =
str(modspec)
189 jetTruthLabelTool = CompFactory.JetTruthLabelingTool(
'truthlabeler_{0}'.
format(truthLabel),
190 RecoJetContainer = jetdef.fullname(),
191 IsTruthJetCollection = isTruthJet,
192 TruthLabelName = truthLabel)
194 return jetTruthLabelTool
198 jetPileupLabelTool = CompFactory.JetPileupLabelingTool(
'pileuplabeler',
199 RecoJetContainer = jetdef.fullname(),
200 TruthJetContainer=
"AntiKt4TruthDressedWZJets")
202 return jetPileupLabelTool