ATLAS Offline Software
JetInputConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 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 
38 def buildJetInputTruthGEN(parentjetdef, truthmod):
39  """ Build truth constituents as in EVTGEN jobs in the r21 config.
40  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.
41  The source for r21 EVTGEN config was in GeneratorFilters/share/common/GenerateTruthJets.py
42  """
43  truthmod = truthmod or ""
44  from ParticleJetTools.ParticleJetToolsConfig import getCopyTruthJetParticlesGEN
45  return _buildJetAlgForInput("truthpartcopy_"+truthmod,
46  tools = [ getCopyTruthJetParticlesGEN(truthmod, parentjetdef._cflags) ]
47  )
48 
49 
50 def buildLabelledTruth(parentjetdef, truthmod):
51  from ParticleJetTools.ParticleJetToolsConfig import getCopyTruthLabelParticles
52  tool = getCopyTruthLabelParticles(truthmod)
53  return _buildJetAlgForInput("truthlabelcopy_"+truthmod,
54  tools = [ tool ]
55  )
56 
57 def buildPV0TrackSel(parentjetdef, spec):
58  from TrackVertexAssociationTool.TrackVertexAssociationToolConfig import getTTVAToolForReco
59  trkOptions = parentjetdef._contextDic
60  tvaTool = getTTVAToolForReco("trackjetTVAtool",
61  HardScatterLinkDeco = "",
62  WorkingPoint = "Nonprompt_All_MaxWeight",
63  TrackContName = trkOptions['JetTracksQualityCuts']
64  )
65  alg = CompFactory.PV0TrackSelectionAlg("pv0tracksel_trackjet",
66  InputTrackContainer = trkOptions['JetTracksQualityCuts'],
67  VertexContainer = trkOptions['Vertices'],
68  OutputTrackContainer = "PV0"+trkOptions['JetTracks'],
69  TVATool = tvaTool,
70  )
71  return alg
72 
73 
74 def buildPFlowSel(parentjetdef, spec):
75  return CompFactory.JetPFlowSelectionAlg( "pflowselalg",
76  electronIDToExclude = "LHMedium",
77  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
78  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
79  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects",
80  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects"
81  )
82 
83 #This is to be used to seed tau jets which exclude electrons.
84 #Therefore it is an inclusive selection, which means we have
85 #to change the default settings and include all muons.
86 #Then we also exclude charged + neutral FE linked to electrons
87 #passing the relevant egamma PID WP.
88 def buildPFlowSel_tauSeedEleRM(parentjetdef,spec):
89  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_tauSeedEleRM",
90  electronIDToExclude = "LHMedium",
91  ElectronInputContainer="Electrons",
92  excludeNeutralElectronFE=True,
93  muonIDToInclude = "Loose",
94  excludeChargedMuonFE=False,
95  includeChargedMuonFE=True,
96  includeNeutralMuonFE=True,
97  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
98  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
99  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_tauSeedEleRM",
100  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_tauSeedEleRM"
101  )
102 
103 def buildPFlowSel_noElectrons(parentjetdef,spec):
104  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noElectrons",
105  electronIDToExclude = "LHMedium",
106  ElectronInputContainer="Electrons",
107  excludeNeutralElectronFE=True,
108  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
109  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
110  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noElectrons",
111  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noElectrons"
112  )
113 
114 def buildPFlowSel_noMuons(parentjetdef,spec):
115  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noMuons",
116  electronIDToExclude = "LHMedium",
117  muonIDToExclude = "Medium",
118  excludeNeutralMuonFE=True,
119  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
120  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
121  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noMuons",
122  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noMuons"
123  )
124 
125 def buildPFlowSel_noLeptons(parentjetdef,spec):
126  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noLeptons",
127  electronIDToExclude = "LHMedium",
128  ElectronInputContainer="Electrons",
129  excludeNeutralElectronFE=True,
130  muonIDToExclude = "Medium",
131  excludeNeutralMuonFE=True,
132  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
133  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
134  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noLeptons",
135  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noLeptons"
136  )
137 
138 
139 
140 def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf = 0.9, radius = 0.4, suffix = None ):
141  """Function producing an EventShapeAlg to calculate
142  median energy density for pileup correction"""
143 
144  from .JetRecConfig import getPJContName
145  from EventShapeTools.EventDensityConfig import configEventDensityTool, getEventShapeName
146 
147 
148  pjContName = getPJContName(jetOrConstitdef,suffix)
149  nameprefix = inputspec or ""
150  rhotool = configEventDensityTool(
151  f"EventDensity_{nameprefix}Kt4{pjContName}",
152  jetOrConstitdef,
153  InputContainer = pjContName,
154  OutputContainer = getEventShapeName(jetOrConstitdef, nameprefix=nameprefix, suffix=suffix, radius=radius),
155  JetRadius = radius,
156  VoronoiRfact = voronoiRf,
157  )
158 
159  eventshapealg = CompFactory.EventDensityAthAlg(
160  f"EventDensity_{nameprefix}Kt4{pjContName}Alg",
161  EventDensityTool = rhotool )
162 
163  return eventshapealg
164 
python.JetInputConfig.buildLabelledTruth
def buildLabelledTruth(parentjetdef, truthmod)
Definition: JetInputConfig.py:50
python.JetInputConfig.buildPFlowSel_tauSeedEleRM
def buildPFlowSel_tauSeedEleRM(parentjetdef, spec)
Definition: JetInputConfig.py:88
python.JetInputConfig.buildEventShapeAlg
def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf=0.9, radius=0.4, suffix=None)
Definition: JetInputConfig.py:140
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:38
python.JetInputConfig.buildPFlowSel_noMuons
def buildPFlowSel_noMuons(parentjetdef, spec)
Definition: JetInputConfig.py:114
python.JetInputConfig.buildPFlowSel
def buildPFlowSel(parentjetdef, spec)
Definition: JetInputConfig.py:74
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:57
python.JetInputConfig.buildPFlowSel_noLeptons
def buildPFlowSel_noLeptons(parentjetdef, spec)
Definition: JetInputConfig.py:125
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:103
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.getCopyTruthJetParticlesGEN
def getCopyTruthJetParticlesGEN(modspec, cflags)
Definition: ParticleJetToolsConfig.py:89
ParticleJetToolsConfig.getCopyTruthLabelParticles
def getCopyTruthLabelParticles(truthtype)
Definition: ParticleJetToolsConfig.py:43
ParticleJetToolsConfig.getCopyTruthJetParticles
def getCopyTruthJetParticles(modspec, cflags)
Definition: ParticleJetToolsConfig.py:63