ATLAS Offline Software
ReadAthenaPool.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 
7 """
8  This is a module for reading event objects in AthenaPool.
9  It loads the conversion service shared lib, and the EventInfo converter.
10 
11  When using Explicit Collection, a query can be applied to the collection attributes
12  through the EventSelector for preselecting events. Note only attributes are (run,event) for now.
13  For example:
14 
15  EventSelector.query = 'event > 10 && event < 100';
16 
17  will select events that have event number in the specified range.
18 """
19 
21  """ Helper method to configure Athena to read back POOL files """
22 
23  from AthenaCommon.Logging import logging
24  msg = logging.getLogger( 'configureReadAthenaPool' )
25  msg.debug( "Configuring Athena for reading POOL files..." )
26 
27  from AthenaCommon import CfgMgr
28  from AthenaCommon.AppMgr import ServiceMgr as svcMgr
29  from AthenaCommon.AppMgr import theApp
30 
31  # Load the basic services
32  import AthenaPoolCnvSvc.AthenaPool # noqa: F401
33 
34  # Switch on TTreeCache for CollectionTree
35  svcMgr.AthenaPoolCnvSvc.InputPoolAttributes += [ "DatabaseName = '*'; ContainerName = 'CollectionTree'; TREE_CACHE = '-1'" ]
36 
37  # Load ProxyProviderSvc
38  if not hasattr (svcMgr, 'ProxyProviderSvc'):
39  svcMgr += CfgMgr.ProxyProviderSvc()
40 
41  # Add in MetaDataSvc
42  if not hasattr (svcMgr, 'MetaDataSvc'):
43  svcMgr += CfgMgr.MetaDataSvc ("MetaDataSvc")
44  svcMgr.ProxyProviderSvc.ProviderNames += [ "MetaDataSvc" ]
45 
46  # Add in MetaData Stores
47  if not hasattr (svcMgr, 'InputMetaDataStore'):
48  svcMgr += CfgMgr.StoreGateSvc ("InputMetaDataStore")
49  if not hasattr (svcMgr, 'MetaDataStore'):
50  svcMgr += CfgMgr.StoreGateSvc ("MetaDataStore")
51 
52  # Enable IOVDbSvc to read MetaData
53  svcMgr.MetaDataSvc.MetaDataContainer = "MetaDataHdr"
54  svcMgr.MetaDataSvc.MetaDataTools += [ "IOVDbMetaDataTool" ]
55  if not hasattr (svcMgr.ToolSvc, 'IOVDbMetaDataTool'):
56  svcMgr.ToolSvc += CfgMgr.IOVDbMetaDataTool()
57 
58  # Add in EventSelector
59  svcMgr += CfgMgr.EventSelectorAthenaPool ("EventSelector")
60  #default InputCollections to FilesInput value of AthenaCommonFlags
61  from AthenaCommon.AthenaCommonFlags import jobproperties as jps
62  svcMgr.EventSelector.InputCollections = jps.AthenaCommonFlags.FilesInput()
63 
64  _n = svcMgr.EventSelector.getFullJobOptName()
65  theApp.EvtSel = _n
66  del _n
67 
68  # For Analysis release use lower heartbeat
69  import os
70  if "AthAnalysisBase" in os.environ.get('CMTEXTRATAGS',""):
71  # From Will Buttinger to suppress the event loop heartbeat as it is somewhat I/O hungry for
72  # no real gain in analysis scenarii
73  if not hasattr(svcMgr, theApp.EventLoop):
74  svcMgr += getattr(CfgMgr, theApp.EventLoop)()
75  evtloop = getattr(svcMgr, theApp.EventLoop)
76  try:
77  evtloop.EventPrintoutInterval = 10000
78  except Exception:
79  msg.info('failed suppressing event loop heartbeat. performances might be sub-par... sorry.')
80  pass
81 
82  # Add in AthenaPoolAddressProviderSvc
83  if not hasattr (svcMgr, 'AthenaPoolAddressProviderSvc'):
84  svcMgr += CfgMgr.AthenaPoolAddressProviderSvc ("AthenaPoolAddressProviderSvc")
85  svcMgr.ProxyProviderSvc.ProviderNames += [ "AthenaPoolAddressProviderSvc" ]
86 
87  # Set up DataVector/DataProxyStorage backwards compatibility.
88  #from DataModelAthenaPool import DataModelCompatSvc
89  svcMgr += CfgMgr.DataModelCompatSvc()
90 
91  # Always want AddressRemappingSvc, since that's responsible for suppressing
92  # the read of objects that are produced by a WriteHandle.
93  from SGComps.AddressRemappingSvc import getAddressRemappingSvc
95 
96  msg.debug( "Configuring Athena for reading POOL files... [DONE]" )
97  return
98 
99 
101 
102 
103 del _configureReadAthenaPool
AddressRemappingSvc.getAddressRemappingSvc
def getAddressRemappingSvc()
Definition: AddressRemappingSvc.py:12
python.ReadAthenaPool._configureReadAthenaPool
def _configureReadAthenaPool()
Definition: ReadAthenaPool.py:20