ATLAS Offline Software
Loading...
Searching...
No Matches
EventDensityConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2
3import logging
4edLogger = logging.getLogger( "EventDensityConfig" )
5from AthenaConfiguration.ComponentFactory import CompFactory
6
7def getEventShapeName( defOrLabel, nameprefix="", suffix=None, radius=0.4):
8 """ Get the name of the event shape container for a given jet def or jet constit def.
9
10 It's typically like "Kt4EMPFlowEventShape"
11 But there can be many variations :
12 - nameprefix can be "HLT_"
13 - suffix can be EMPFlowPUSB for pu side-band
14
15 We normalize all variations here.
16 """
17
18 from JetRecConfig.JetDefinition import JetDefinition,JetInputConstit
19 tail=''
20 if isinstance(defOrLabel, JetDefinition):
21 label = defOrLabel.inputdef.label
22 if 'NoPtCut' not in defOrLabel.infix and 'LowPt' not in defOrLabel.infix:
23 tail = defOrLabel.infix or ''
24 elif isinstance(defOrLabel, JetInputConstit):
25 label = defOrLabel.label
26 else:
27 label = defOrLabel.replace('_','')
28
29 R = str(int(10*radius))
30 suffix = suffix or ""
31 nameprefix = nameprefix or "" # just in case we are passed None
32
33 return f"{nameprefix}Kt{R}{label}{suffix}{tail}EventShape"
34
35
36def configEventDensityTool( name, jetOrConstitdef, radius=0.4, **options ):
37 """Returns an EventDensityTool configured with input and output names build according to the given jet (or jet constituent) definition.
38
39 jetOrConstitdef can be a JetDefinition, JetInputConstit. The input PseudoJetContainer name and output EventShape name are build
40 using helper functions shared in other parts of the config (jet, trigger, egamma,...)
41
42 It is still possible to override any properties of the tool in the optionnal additionnal arguments.
43 """
44 from JetRecConfig.JetRecConfig import getPJContName
45
46 # Set default and passed properties for the EventDensityTool
47 toolProperties = dict(
48 JetAlgorithm = "Kt",
49 JetRadius = radius,
50 InputContainer = getPJContName( jetOrConstitdef),
51 AbsRapidityMin = 0.0,
52 AbsRapidityMax = 2.0,
53 AreaDefinition = "Voronoi",
54 VoronoiRfact = 0.9,
55 OutputContainer = getEventShapeName( jetOrConstitdef) ,
56 UseFourMomArea = True,
57 )
58 # Override properties with user-supplied options.
59 toolProperties.update( options)
60 # Build the tool :
61 return CompFactory.EventDensityTool(name, **toolProperties)
62
63
65 """ Returns an Athena alg copying EventShape objects with old key/names to objects with new key/names
66 """
67 def buildTool( alg):
68 from AthenaCommon.AppMgr import ToolSvc
69 t= CompFactory.EventShapeCopier( input+alg+"EvtShapeCopier",
70 InputEventShape=input+"EventShape",
71 OutputEventShape=alg+input+"EventShape",
72 EventDensityName = "DensityForJetsR" + alg[-1])
73 ToolSvc +=t
74 return t
75 return CompFactory.EventDensityAlg(input+"EventShapeCopierAlg", EventDensityTool = [ buildTool("Kt4"), buildTool("Kt6") ] )
76
77
78
79
80
81def EventDensityAlg(name, EventDensityTool=None, **args):
82 edLogger.warning("When instantiating %s : call of EventDensityAlg is deprecated", name)
83 edLogger.warning(" please use EventDensityAthAlg (from EventShapeTools.EventShapeToolsConf import EventDensityAthAlg) ")
84 alg = CompFactory.EventDensityAthAlg(name,EventDensityTool=EventDensityTool, **args)
85 return alg
86
getEventShapeName(defOrLabel, nameprefix="", suffix=None, radius=0.4)
EventDensityAlg(name, EventDensityTool=None, **args)
EventDensity Alg for Athena.
configEventDensityTool(name, jetOrConstitdef, radius=0.4, **options)