ATLAS Offline Software
JetInputConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 """
3 # JetInputConfig: A helper module providing function to setup algorithms
4 # in charge of preparing input sources to jets (ex: EventDensity algo, track
5 # or truth selection,...)
6 #
7 # Author: P-A Delsart #
8 """
9 from AthenaConfiguration.ComponentFactory import CompFactory
10 
11 # we can't add the imports here, because some modules may not be available
12 # in all releases (Ex: AthGeneration, AnalysisBase...) so we delay the imports
13 # inside the functions
14 
15 def _buildJetAlgForInput(suffix, tools ):
16  jetalg = CompFactory.JetAlgorithm("jetalg_"+suffix,
17  Tools = tools,
18  )
19  return jetalg
20 
21 def buildJetTrackUsedInFitDeco( parentjetdef, inputspec ):
22  from InDetUsedInFitTrackDecoratorTool.UsedInVertexFitTrackDecoratorConfig import (
23  getUsedInVertexFitTrackDecoratorAlg)
24  trkProperties = parentjetdef._contextDic
25 
26  return getUsedInVertexFitTrackDecoratorAlg(trackCont=trkProperties["Tracks"],
27  vtxCont= trkProperties["Vertices"])
28 
29 
30 def buildJetInputTruth(parentjetdef, truthmod):
31  truthmod = truthmod or ""
32  from ParticleJetTools.ParticleJetToolsConfig import getCopyTruthJetParticles
33  return _buildJetAlgForInput("truthpartcopy_"+truthmod,
34  tools = [ getCopyTruthJetParticles(truthmod, parentjetdef._cflags) ]
35  )
36 
37 def buildJetInputTruthGEN(parentjetdef, truthmod):
38  """ Build truth constituents as in EVTGEN jobs in the r21 config.
39  IMPORTANT : this is expected to be temporary, only to reproduce the EVTGEN r21 config with the new config. The definitions should be harmonized with reco-level at some point and this function removed.
40  The source for r21 EVTGEN config was in GeneratorFilters/share/common/GenerateTruthJets.py
41  """
42  truthmod = truthmod or ""
43 
44  # recopy config from GeneratorFilters/share/common/GenerateTruthJets.py
45  truthClassifier = CompFactory.MCTruthClassifier("JetMCTruthClassifier")
46 
47  if truthmod == "":
48  truthpartcopy = CompFactory.CopyTruthJetParticles("truthpartcopy",
49  OutputName="JetInputTruthParticlesGEN",
50  MCTruthClassifier=truthClassifier)
51  elif truthmod=="NoWZ":
52 
53  truthpartcopy = CompFactory.CopyTruthJetParticles("truthpartcopywz",
54  OutputName="JetInputTruthParticlesGENNoWZ",
55  MCTruthClassifier=truthClassifier,
56  IncludePromptLeptons=False)
57 
58  return _buildJetAlgForInput("truthpartcopy_"+truthmod,
59  tools = [ truthpartcopy ]
60  )
61 
62 def buildLabelledTruth(parentjetdef, truthmod):
63  from ParticleJetTools.ParticleJetToolsConfig import getCopyTruthLabelParticles
64  tool = getCopyTruthLabelParticles(truthmod)
65  return _buildJetAlgForInput("truthlabelcopy_"+truthmod,
66  tools = [ tool ]
67  )
68 
69 def buildPV0TrackSel(parentjetdef, spec):
70  from TrackVertexAssociationTool.TrackVertexAssociationToolConfig import getTTVAToolForReco
71  trkOptions = parentjetdef._contextDic
72  tvaTool = getTTVAToolForReco("trackjetTVAtool",
73  HardScatterLinkDeco = "",
74  WorkingPoint = "Nonprompt_All_MaxWeight",
75  TrackContName = trkOptions['JetTracksQualityCuts']
76  )
77  alg = CompFactory.PV0TrackSelectionAlg("pv0tracksel_trackjet",
78  InputTrackContainer = trkOptions['JetTracksQualityCuts'],
79  VertexContainer = trkOptions['Vertices'],
80  OutputTrackContainer = "PV0"+trkOptions['JetTracks'],
81  TVATool = tvaTool,
82  )
83  return alg
84 
85 
86 def buildPFlowSel(parentjetdef, spec):
87  return CompFactory.JetPFlowSelectionAlg( "pflowselalg",
88  electronIDToExclude = "LHMedium",
89  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
90  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
91  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects",
92  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects"
93  )
94 
95 #This is to be used to seed tau jets which exclude electrons.
96 #Therefore it is an inclusive selection, which means we have
97 #to change the default settings and include all muons.
98 #Then we also exclude charged + neutral FE linked to electrons
99 #passing the relevant egamma PID WP.
100 def buildPFlowSel_tauSeedEleRM(parentjetdef,spec):
101  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_tauSeedEleRM",
102  electronIDToExclude = "LHMedium",
103  ElectronInputContainer="Electrons",
104  excludeNeutralElectronFE=True,
105  muonIDToInclude = "Loose",
106  excludeChargedMuonFE=False,
107  includeChargedMuonFE=True,
108  includeNeutralMuonFE=True,
109  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
110  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
111  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_tauSeedEleRM",
112  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_tauSeedEleRM"
113  )
114 
115 def buildPFlowSel_noElectrons(parentjetdef,spec):
116  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noElectrons",
117  electronIDToExclude = "LHMedium",
118  ElectronInputContainer="Electrons",
119  excludeNeutralElectronFE=True,
120  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
121  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
122  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noElectrons",
123  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noElectrons"
124  )
125 
126 def buildPFlowSel_noMuons(parentjetdef,spec):
127  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noMuons",
128  electronIDToExclude = "LHMedium",
129  muonIDToExclude = "Medium",
130  excludeNeutralMuonFE=True,
131  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
132  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
133  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noMuons",
134  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noMuons"
135  )
136 
137 def buildPFlowSel_noLeptons(parentjetdef,spec):
138  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noLeptons",
139  electronIDToExclude = "LHMedium",
140  ElectronInputContainer="Electrons",
141  excludeNeutralElectronFE=True,
142  muonIDToExclude = "Medium",
143  excludeNeutralMuonFE=True,
144  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
145  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
146  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noLeptons",
147  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noLeptons"
148  )
149 
150 
151 
152 def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf = 0.9, radius = 0.4, suffix = None ):
153  """Function producing an EventShapeAlg to calculate
154  median energy density for pileup correction"""
155 
156  from .JetRecConfig import getPJContName
157  from EventShapeTools.EventDensityConfig import configEventDensityTool, getEventShapeName
158 
159 
160  pjContName = getPJContName(jetOrConstitdef,suffix)
161  nameprefix = inputspec or ""
162  rhotool = configEventDensityTool(
163  f"EventDensity_{nameprefix}Kt4{pjContName}",
164  jetOrConstitdef,
165  InputContainer = pjContName,
166  OutputContainer = getEventShapeName(jetOrConstitdef, nameprefix=nameprefix, suffix=suffix, radius=radius),
167  JetRadius = radius,
168  VoronoiRfact = voronoiRf,
169  )
170 
171  eventshapealg = CompFactory.EventDensityAthAlg(
172  f"EventDensity_{nameprefix}Kt4{pjContName}Alg",
173  EventDensityTool = rhotool )
174 
175  return eventshapealg
176 
python.JetInputConfig.buildLabelledTruth
def buildLabelledTruth(parentjetdef, truthmod)
Definition: JetInputConfig.py:62
python.JetInputConfig.buildPFlowSel_tauSeedEleRM
def buildPFlowSel_tauSeedEleRM(parentjetdef, spec)
Definition: JetInputConfig.py:100
python.JetInputConfig.buildEventShapeAlg
def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf=0.9, radius=0.4, suffix=None)
Definition: JetInputConfig.py:152
python.JetInputConfig._buildJetAlgForInput
def _buildJetAlgForInput(suffix, tools)
Definition: JetInputConfig.py:15
EventDensityConfig.configEventDensityTool
def configEventDensityTool(name, jetOrConstitdef, radius=0.4, **options)
Definition: EventDensityConfig.py:36
python.JetInputConfig.buildJetInputTruthGEN
def buildJetInputTruthGEN(parentjetdef, truthmod)
Definition: JetInputConfig.py:37
python.JetInputConfig.buildPFlowSel_noMuons
def buildPFlowSel_noMuons(parentjetdef, spec)
Definition: JetInputConfig.py:126
python.JetInputConfig.buildPFlowSel
def buildPFlowSel(parentjetdef, spec)
Definition: JetInputConfig.py:86
python.JetInputConfig.buildJetTrackUsedInFitDeco
def buildJetTrackUsedInFitDeco(parentjetdef, inputspec)
Definition: JetInputConfig.py:21
EventDensityConfig.getEventShapeName
def getEventShapeName(defOrLabel, nameprefix="", suffix=None, radius=0.4)
Definition: EventDensityConfig.py:7
python.JetInputConfig.buildPV0TrackSel
def buildPV0TrackSel(parentjetdef, spec)
Definition: JetInputConfig.py:69
python.JetInputConfig.buildPFlowSel_noLeptons
def buildPFlowSel_noLeptons(parentjetdef, spec)
Definition: JetInputConfig.py:137
python.JetInputConfig.buildJetInputTruth
def buildJetInputTruth(parentjetdef, truthmod)
Definition: JetInputConfig.py:30
UsedInVertexFitTrackDecoratorConfig.getUsedInVertexFitTrackDecoratorAlg
def getUsedInVertexFitTrackDecoratorAlg(trackCont="InDetTrackParticles", vtxCont="PrimaryVertices", vertexDeco="TTVA_AMVFVertices_forReco", weightDeco="TTVA_AMVFWeights_forReco")
Definition: UsedInVertexFitTrackDecoratorConfig.py:16
python.JetInputConfig.buildPFlowSel_noElectrons
def buildPFlowSel_noElectrons(parentjetdef, spec)
Definition: JetInputConfig.py:115
python.JetRecConfig.getPJContName
def getPJContName(jetOrConstitdef, suffix=None, parent_jetdef=None)
Definition: JetRecConfig.py:341
TrackVertexAssociationToolConfig.getTTVAToolForReco
def getTTVAToolForReco(name="TTVATool", **kwargs)
Definition: TrackVertexAssociationToolConfig.py:6
ParticleJetToolsConfig.getCopyTruthLabelParticles
def getCopyTruthLabelParticles(truthtype)
Definition: ParticleJetToolsConfig.py:43
ParticleJetToolsConfig.getCopyTruthJetParticles
def getCopyTruthJetParticles(modspec, cflags)
Definition: ParticleJetToolsConfig.py:63