ATLAS Offline Software
Functions
python.CutFlowHelpers Namespace Reference

Functions

def GetCurrentStreamName (msg)
 
def GetCurrentSkimmingCycle (msg)
 
def CreateCutFlowSvc (seq=None, addMetaDataToAllOutputFiles=True)
 
def CreateBookkeeperTool (name="BookkeeperTool")
 
def CreateBookkeeperDumperTool (name='BookkeeperDumperTool')
 

Function Documentation

◆ CreateBookkeeperDumperTool()

def python.CutFlowHelpers.CreateBookkeeperDumperTool (   name = 'BookkeeperDumperTool')

Definition at line 140 of file CutFlowHelpers.py.

140 def CreateBookkeeperDumperTool(name='BookkeeperDumperTool'):
141  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
142 
143  # Make sure MetaDataSvc is ready
144  if not hasattr(svcMgr, 'MetaDataSvc'):
145  from AthenaServices.AthenaServicesConf import MetaDataSvc
146  svcMgr += MetaDataSvc('MetaDataSvc')
147 
148  # Add BookkeeperDumperTool
149  from EventBookkeeperTools.EventBookkeeperToolsConf import BookkeeperDumperTool
150  tool = BookkeeperDumperTool(name)
151  svcMgr.ToolSvc += tool
152 
153  # Add tool to MetaDataSvc
154  svcMgr.MetaDataSvc.MetaDataTools += [tool]

◆ CreateBookkeeperTool()

def python.CutFlowHelpers.CreateBookkeeperTool (   name = "BookkeeperTool")

Definition at line 117 of file CutFlowHelpers.py.

117 def CreateBookkeeperTool( name="BookkeeperTool" ):
118 
119  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
120 
121  # Make sure MetaDataSvc is ready
122  if not hasattr(svcMgr,'MetaDataSvc'):
123  from AthenaServices.AthenaServicesConf import MetaDataSvc
124  svcMgr += MetaDataSvc( "MetaDataSvc" )
125 
126  # Add BookkeeperTools
127  from EventBookkeeperTools.EventBookkeeperToolsConf import BookkeeperTool
128 
129  # Standard event bookkeepers
130  cutflowtool = BookkeeperTool(name,
131  InputCollName=name,
132  OutputCollName = name)
133  svcMgr.ToolSvc += cutflowtool
134 
135  # Add tool to MetaDataSvc
136  #svcMgr.MetaDataSvc.MetaDataTools += [cutflowtool]
137 
138  return
139 

◆ CreateCutFlowSvc()

def python.CutFlowHelpers.CreateCutFlowSvc (   seq = None,
  addMetaDataToAllOutputFiles = True 
)
Helper to create the CutFlowSvc, extract the needed information from
the input file, and also schedule all the needed stuff.

Definition at line 30 of file CutFlowHelpers.py.

30 def CreateCutFlowSvc( seq=None, addMetaDataToAllOutputFiles=True ):
31  """
32  Helper to create the CutFlowSvc, extract the needed information from
33  the input file, and also schedule all the needed stuff.
34  """
35  # Create a message logger
36  from AthenaCommon.Logging import logging
37  msg = logging.getLogger( "CreateCutFlowSvc" )
38 
39  # Get the service manager
40  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
41 
42  # Determine current input stream name
43  inputStreamName = GetCurrentStreamName( msg=msg )
44  msg.debug("CreateCutFlowSvc: Have inputStreamName = %s", inputStreamName)
45 
46  skimmingCycle = GetCurrentSkimmingCycle( msg=msg )
47  msg.debug("CreateCutFlowSvc: Have skimmingCycle = %s", skimmingCycle)
48 
49  # Create the CutFlowSvc instance
50  import AthenaCommon.CfgMgr as CfgMgr
51  if not hasattr(svcMgr,"CutFlowSvc"):
52  cutFlowSvc = CfgMgr.CutFlowSvc()
53  svcMgr += cutFlowSvc
54  else:
55  cutFlowSvc = svcMgr.CutFlowSvc
56  cutFlowSvc.Configured = True
57  cutFlowSvc.InputStream = inputStreamName
58  cutFlowSvc.SkimmingCycle = skimmingCycle
59 
60  # Make sure MetaDataSvc is ready
61  if not hasattr(svcMgr,'MetaDataSvc'):
62  from AthenaServices.AthenaServicesConf import MetaDataSvc
63  svcMgr += MetaDataSvc( "MetaDataSvc" )
64 
65  # Add BookkeeperTools
66  from EventBookkeeperTools.EventBookkeeperToolsConf import BookkeeperTool
67 
68  # Standard event bookkeepers
69  output_name = "CutBookkeepers"
70  cutflowtool = BookkeeperTool("BookkeeperTool",
71  InputCollName = output_name,
72  OutputCollName= output_name)
73  svcMgr.ToolSvc += cutflowtool
74 
75  # Add tool to MetaDataSvc
76  svcMgr.MetaDataSvc.MetaDataTools += [cutflowtool]
77 
78  # Check if we have a sequence given
79  if not seq :
80  # Fetch the AthAlgSeq, i.e., one of the existing master sequences where one should attach all algorithms
81  seq = CfgMgr.AthSequencer("AthAlgSeq")
82  pass
83 
84  # First of all, schedule AllExecutedEventsCounterAlg
85  if not hasattr(seq,"AllExecutedEvents"):
86  if not seq.isLocked():
87  # Need to schedule it after the xAODMaker::EventInfoCnvAlg such that xAOD::EventInfo is present
88  index = 0
89  if hasattr( seq, "xAODMaker::EventInfoCnvAlg" ):
90  for alg in seq:
91  index += 1
92  if alg.getName() == "xAODMaker::EventInfoCnvAlg": break
93  pass
94  pass
95  msg.debug("Adding AllExecutedEventsCounterAlg with name AllExecutedEvents to sequence with name %s at position %i", seq.getName(), index)
96  seq.insert( index, CfgMgr.AllExecutedEventsCounterAlg("AllExecutedEvents") )
97  pass
98  else :
99  msg.info("Could NOT add AllExecutedEventsCounterAlg with name AllExecutedEvents to locked sequence with name %s", seq.getName())
100  pass
101  pass
102 
103  # If wanted, add the meta-data to all output files
104  if addMetaDataToAllOutputFiles:
105  msg.debug("Adding CutBookkeepers the the output meta data of all output streams")
106  from OutputStreamAthenaPool.MultipleStreamManager import MSMgr
107  # Explicitely add file metadata from input and from transient store,
108  # but only the ones that we always create.
109  MSMgr.AddMetaDataItemToAllStreams( "xAOD::CutBookkeeperContainer#"+output_name+"*" )
110  MSMgr.AddMetaDataItemToAllStreams( "xAOD::CutBookkeeperAuxContainer#"+output_name+"*Aux.*" )
111  MSMgr.AddMetaDataItemToAllStreams( "xAOD::CutBookkeeperContainer#Incomplete"+output_name+"*" )
112  MSMgr.AddMetaDataItemToAllStreams( "xAOD::CutBookkeeperAuxContainer#Incomplete"+output_name+"*Aux.*" )
113  pass
114 
115  return
116 

◆ GetCurrentSkimmingCycle()

def python.CutFlowHelpers.GetCurrentSkimmingCycle (   msg)

Definition at line 18 of file CutFlowHelpers.py.

18 def GetCurrentSkimmingCycle( msg ):
19  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
20  try:
21  input_files = svcMgr.EventSelector.InputCollections
22  except AttributeError:
23  from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
24  input_files = athenaCommonFlags.FilesInput()
25 
26  from AthenaConfiguration.AutoConfigFlags import GetFileMD
27  return GetFileMD(input_files).get('currentCutCycle', -1) + 1
28 
29 

◆ GetCurrentStreamName()

def python.CutFlowHelpers.GetCurrentStreamName (   msg)
Helper to decide where to get the input stream name from.

Definition at line 4 of file CutFlowHelpers.py.

4 def GetCurrentStreamName( msg ):
5  """ Helper to decide where to get the input stream name from."""
6  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
7  try:
8  input_files = svcMgr.EventSelector.InputCollections
9  except AttributeError:
10  from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
11  input_files = athenaCommonFlags.FilesInput()
12 
13  from AthenaConfiguration.AutoConfigFlags import GetFileMD
14  processingTags = GetFileMD(input_files).get("processingTags", [])
15  return processingTags[-1] if processingTags else 'N/A'
16 
17 
python.CutFlowHelpers.CreateCutFlowSvc
def CreateCutFlowSvc(seq=None, addMetaDataToAllOutputFiles=True)
Definition: CutFlowHelpers.py:30
python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True)
Definition: AutoConfigFlags.py:51
python.CutFlowHelpers.GetCurrentStreamName
def GetCurrentStreamName(msg)
Definition: CutFlowHelpers.py:4
BookkeeperDumperTool
Definition: BookkeeperDumperTool.h:29
MetaDataSvc
Manages the content of the metadata stores.
Definition: MetaDataSvc.h:95
python.CutFlowHelpers.CreateBookkeeperTool
def CreateBookkeeperTool(name="BookkeeperTool")
Definition: CutFlowHelpers.py:117
python.CutFlowHelpers.CreateBookkeeperDumperTool
def CreateBookkeeperDumperTool(name='BookkeeperDumperTool')
Definition: CutFlowHelpers.py:140
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
BookkeeperTool
Definition: BookkeeperTool.h:44
python.CutFlowHelpers.GetCurrentSkimmingCycle
def GetCurrentSkimmingCycle(msg)
Definition: CutFlowHelpers.py:18