ATLAS Offline Software
EventDensityConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
2 
3 import logging
4 edLogger = logging.getLogger( "EventDensityConfig" )
5 from AthenaConfiguration.ComponentFactory import CompFactory
6 
7 def 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 
36 def 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 
81 def 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 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
EventDensityConfig.configEventShapeCopierAlg
def configEventShapeCopierAlg(input)
Definition: EventDensityConfig.py:64
EventDensityConfig.configEventDensityTool
def configEventDensityTool(name, jetOrConstitdef, radius=0.4, **options)
Definition: EventDensityConfig.py:36
EventDensityConfig.getEventShapeName
def getEventShapeName(defOrLabel, nameprefix="", suffix=None, radius=0.4)
Definition: EventDensityConfig.py:7
python.JetRecConfig.getPJContName
def getPJContName(jetOrConstitdef, suffix=None, parent_jetdef=None)
Definition: JetRecConfig.py:342
str
Definition: BTagTrackIpAccessor.cxx:11
EventDensityConfig.EventDensityAlg
def EventDensityAlg(name, EventDensityTool=None, **args)
EventDensity Alg for Athena.
Definition: EventDensityConfig.py:81