ATLAS Offline Software
Loading...
Searching...
No Matches
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 # Add in AthenaPoolAddressProviderSvc
69 if not hasattr (svcMgr, 'AthenaPoolAddressProviderSvc'):
70 svcMgr += CfgMgr.AthenaPoolAddressProviderSvc ("AthenaPoolAddressProviderSvc")
71 svcMgr.ProxyProviderSvc.ProviderNames += [ "AthenaPoolAddressProviderSvc" ]
72
73 # Always want AddressRemappingSvc, since that's responsible for suppressing
74 # the read of objects that are produced by a WriteHandle.
75 from SGComps.AddressRemappingSvc import getAddressRemappingSvc
76 getAddressRemappingSvc()
77
78 msg.debug( "Configuring Athena for reading POOL files... [DONE]" )
79 return
80
81
83
84
85del _configureReadAthenaPool