Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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  electronID = "LHMedium",
89  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
90  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
91  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects",
92  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects"
93  )
94 
95 def buildPFlowSel_noElectrons(parentjetdef,spec):
96  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noElectrons",
97  electronID = "LHMedium",
98  ElectronInputContainer="Electrons",
99  removeNeutralElectronFE=True,
100  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
101  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
102  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noElectrons",
103  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noElectrons"
104  )
105 
106 def buildPFlowSel_noMuons(parentjetdef,spec):
107  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noMuons",
108  electronID = "LHMedium",
109  muonID = "Medium",
110  removeNeutralMuonFE=True,
111  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
112  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
113  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noMuons",
114  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noMuons"
115  )
116 
117 def buildPFlowSel_noLeptons(parentjetdef,spec):
118  return CompFactory.JetPFlowSelectionAlg( "pflowselalg_noLeptons",
119  electronID = "LHMedium",
120  ElectronInputContainer="Electrons",
121  removeNeutralElectronFE=True,
122  muonID = "Medium",
123  removeNeutralMuonFE=True,
124  ChargedPFlowInputContainer = "JetETMissChargedParticleFlowObjects",
125  NeutralPFlowInputContainer = "JetETMissNeutralParticleFlowObjects",
126  ChargedPFlowOutputContainer = "GlobalChargedParticleFlowObjects_noLeptons",
127  NeutralPFlowOutputContainer = "GlobalNeutralParticleFlowObjects_noLeptons"
128  )
129 
130 
131 
132 def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf = 0.9, radius = 0.4, suffix = None ):
133  """Function producing an EventShapeAlg to calculate
134  median energy density for pileup correction"""
135 
136  from .JetRecConfig import getPJContName
137  from EventShapeTools.EventDensityConfig import configEventDensityTool, getEventShapeName
138 
139 
140  pjContName = getPJContName(jetOrConstitdef,suffix)
141  nameprefix = inputspec or ""
142  rhotool = configEventDensityTool(
143  f"EventDensity_{nameprefix}Kt4{pjContName}",
144  jetOrConstitdef,
145  InputContainer = pjContName,
146  OutputContainer = getEventShapeName(jetOrConstitdef, nameprefix=nameprefix, suffix=suffix, radius=radius),
147  JetRadius = radius,
148  VoronoiRfact = voronoiRf,
149  )
150 
151  eventshapealg = CompFactory.EventDensityAthAlg(
152  f"EventDensity_{nameprefix}Kt4{pjContName}Alg",
153  EventDensityTool = rhotool )
154 
155  return eventshapealg
156 
python.JetInputConfig.buildLabelledTruth
def buildLabelledTruth(parentjetdef, truthmod)
Definition: JetInputConfig.py:62
python.JetInputConfig.buildEventShapeAlg
def buildEventShapeAlg(jetOrConstitdef, inputspec, voronoiRf=0.9, radius=0.4, suffix=None)
Definition: JetInputConfig.py:132
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:106
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:117
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:95
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