ATLAS Offline Software
Loading...
Searching...
No Matches
ReaderAlg.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3import D3PDMakerCoreComps
4
5from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
6from AthenaPython import PyAthena
7
8from D3PDMakerReader.D3PDMakerReaderConf import D3PD__ReaderAlg
9
10from AthenaCommon.Logging import logging
11from AthenaCommon.AlgSequence import AlgSequence
12topSequence = AlgSequence()
13
14
18class ReaderAlg( D3PD__ReaderAlg ):
19
20 def __init__( self,
21 name,
22 seq = topSequence,
23 tuplename = None,
24 preD3PDAlgSeqName = D3PDMakerFlags.PreD3PDAlgSeqName(), # noqa: B008 (constant string)
25 **kwargs ):
26
27 self.__logger = logging.getLogger( "ReaderAlg" )
28
29 # Work around initialization order issue.
30 seq.__iadd__( D3PDMakerCoreComps.DummyInitAlg( name + 'DummyInit' ),
31 index = 0 )
32
33 # tuple name defaults to the algorithm name.
34 if tuplename is None:
35 tuplename = name
36
37 # Create the algorithm Configurable.
38 D3PD__ReaderAlg.__init__ ( self, name,
39 TupleName = tuplename,
40 **kwargs )
41
42 # Add to the supplied sequence.
43 if seq:
44 # But first, add a sequence for algorithms that should run
45 # before D3PD making, if it's not already there.
46 preseq = AlgSequence( preD3PDAlgSeqName )
47 if not hasattr( seq, preD3PDAlgSeqName ):
48 seq += [ preseq ]
49
50 # We don't want to do filtering in the presequence.
51 preseq.StopOverride = True
52 # Now set up another sequence for filtering.
53 # Unlike the presequence, there should be a unique one of these
54 # per algorithm. We also need to break out an additional
55 # sequence to which users can add, and to wrap the whole
56 # thing in a sequence to prevent a failed filter
57 # decision from stopping other algorithms.
58 # Like this:
59 #
60 # ALG_FilterAlgorithmsWrap (StopOverride = True)
61 # ALG_FilterAlgorithmsHolder
62 # ALG_FilterAlgorithms
63 # ALG
64 # Dummy alg, to reset filter flag
65 suffix = D3PDMakerFlags.FilterAlgSeqSuffix()
66 wrap = AlgSequence( name + suffix + 'Wrap',
67 StopOverride = True )
68 holder = AlgSequence( name + suffix + 'Holder' )
69 self.filterSeq = AlgSequence( name + suffix )
70 holder += self.filterSeq
71 holder += self
72 wrap += holder
73 wrap += PyAthena.Alg( name + 'Dummy' )
74
75 seq += wrap
76
77 # Create a unique collection getter registry tool for this tree.
78 from AthenaCommon.AppMgr import ToolSvc
79 self._registry = \
80 D3PDMakerCoreComps.CollectionGetterRegistryTool (self.name() +
81 '_CollectionGetterRegistry')
82 ToolSvc += self._registry
83
84 return
85
86 def __iadd__( self, configs ):
87 """Add a new IObjFillerTool to a tree."""
88
89 # FIXME: should make sure name is unique within alg.
90 if not isinstance( configs, list ):
91 self.Prefix = configs.Prefix
92 configs = [ configs ]
93 else:
94 self.__logger.warning( "Should only add single D3PDObject-s to algorithm!" )
95 self.Tools += configs
96 super( ReaderAlg, self ).__iadd__( configs )
97
98 # Rescan all children to set the proper collection getter registry.
99 self._setRegistry( self )
100# for c in self.getChildren()[ nchild: ]:
101# D3PDObject.runHooks( c )
102
103 return self
104
105 def _setRegistry( self, conf ):
106 """Scan CONF and all children to set the proper
107 collection getter registry for this tree.
108 """
109
110 if 'CollectionGetterRegistry' in conf.properties():
111 conf.CollectionGetterRegistry = self._registry
112 for c in conf.getAllChildren():
113 self._setRegistry( c )
114
115 return
A class very similar to D3PDMakerCoreComps.MakerAlg, but it creates a configured version of the D3PD....
Definition ReaderAlg.py:18
__iadd__(self, configs)
Definition ReaderAlg.py:86
__init__(self, name, seq=topSequence, tuplename=None, preD3PDAlgSeqName=D3PDMakerFlags.PreD3PDAlgSeqName(), **kwargs)
Definition ReaderAlg.py:25