ATLAS Offline Software
ReadAthenaxAODHybrid.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 # @file AthenaRootComps/python/ReadAthenaxAODHybrid.py
4 # @purpose make the Athena framework read a set of xAOD files to emulate the
5 # usual TEvent event loop ... BUT READ METADATA WITH POOL!
6 # @author Will Buttinger and Johannes Elmsheuser
7 #
8 
9 
10 def _configure():
11  """Install the Athena-based xAOD event selector and correctly configure
12  a few other services.
13  """
14  from AthenaCommon import CfgMgr
15  from AthenaCommon.AppMgr import theApp
16  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
17  from AthenaCommon.Logging import logging
18  from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
19  from AthenaCommon.Constants import ERROR
20 
21 
22  msg = logging.getLogger( 'ReadAthenaxAODHybrid' )
23  msg.debug("Configuring Athena for reading xAOD files (via TEvent, with POOL for Metadata)...")
24 
25 
26  #check if we already have a selector set up
27  if hasattr(svcMgr, 'EventSelector'):
28  err = "svcMgr already configured with another EventSelector: [%s]"%\
29  svcMgr.EventSelector.getFullJobOptName()
30  msg.error( err )
31  raise RuntimeError( err )
32 
33 
34 
35  #Setup our EventSelector
36  svcMgr += CfgMgr.Athena__xAODEventSelector( "EventSelector" )
37 
38  #for historical reasons, we now add configurables of a bunch of services
39  if not hasattr(svcMgr, 'THistSvc'): svcMgr += CfgMgr.THistSvc()
40  if not hasattr (svcMgr, 'ProxyProviderSvc'): svcMgr += CfgMgr.ProxyProviderSvc()
41  if not hasattr (svcMgr, 'InputMetaDataStore'): svcMgr += CfgMgr.StoreGateSvc("InputMetaDataStore")
42  if not hasattr (svcMgr, 'Athena::xAODCnvSvc'): svcMgr += CfgMgr.Athena__xAODCnvSvc()
43  if not hasattr(svcMgr, 'EventPersistencySvc'): svcMgr += CfgMgr.EvtPersistencySvc( "EventPersistencySvc" )
44  if not hasattr (svcMgr, 'MetaDataSvc'): svcMgr += CfgMgr.MetaDataSvc ("MetaDataSvc")
45  if not hasattr(svcMgr, 'PoolSvc'): svcMgr += CfgMgr.PoolSvc()
46 
47  #Here we set various properties of things
48  theApp.ExtSvc += [ svcMgr.EventSelector.getFullName() ]
49  theApp.EvtSel = "EventSelector"
50  svcMgr.MetaDataSvc.MetaDataContainer = "MetaDataHdr" #this really should be the default for this property :-(
51  svcMgr.ProxyProviderSvc.ProviderNames += [ "MetaDataSvc" ]
52  svcMgr.PoolSvc.OutputLevel = ERROR
53  svcMgr.EventSelector.ReadMetaDataWithPool=True
54  #default the input collections to the FilesInput from AthenaCommonFlags
55  #this is so that the eventselector picks up input files in grid jobs
56  svcMgr.EventSelector.InputCollections = athenaCommonFlags.FilesInput()
57 
58 
59  # suppress the event loop heartbeat as it is somewhat I/O hungry for
60  # no real gain in n-tuple reading/writing scenarii
61  if not hasattr(svcMgr, theApp.EventLoop): svcMgr += getattr(CfgMgr, theApp.EventLoop)()
62  evtloop = getattr(svcMgr, theApp.EventLoop)
63  try:
64  evtloop.EventPrintoutInterval = 10000
65  except Exception:
66  msg.info('disabling event loop heartbeat... [failed]')
67  msg.info('performances might be sub-par... sorry.')
68  pass
69 
70 
71  msg.debug("Configuring Athena for reading ROOT files (via TEvent, with POOL for Metadata)... [OK]")
72  return
73 
74 # execute at module import
75 _configure()
76 
77 # clean-up namespace
78 del _configure
python.ReadAthenaxAODHybrid._configure
def _configure()
Definition: ReadAthenaxAODHybrid.py:10
Constants
some useful constants -------------------------------------------------—