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