예제 #1
0
    def test4Methods(self):
        """Test various methods of CfgItemList"""
        i = CfgItemList('MyItems')
        self.failUnless(i.name() == 'MyItems')

        i.add({'Klass': ['key1', 'key2']})
        self.failUnless(i() == ['Klass#key1', 'Klass#key2'])

        i.add({'Klass': ['key1', 'key3']})
        self.failUnless(i() == ['Klass#key1', 'Klass#key2', 'Klass#key3'])

        props = i.getProperties()
        self.failUnless(props.has_key('Klass'))
        self.failUnless(len(props['Klass']) == len(['key1', 'key2', 'key3']))
        self.failUnless('key1' in props['Klass'])
        self.failUnless('key2' in props['Klass'])
        self.failUnless('key3' in props['Klass'])

        self.failUnless(len(i.allChildren()) == 0)

        self.failUnless(i.has_item('Klass#key1'))
        self.failUnless(i.has_item('Klass#key*'))
        self.failUnless(not i.has_item('Klass#Key1'))
        self.failUnless(not i.has_item('Klass#Key*'))

        i.clear()
        self.failUnless(len(i()) == 0)

        i.add({'Klass': ['key1', 'key2']})
        self.failUnless(len(i()) == 2)
        i.remove('Klass')
        self.failUnless(len(i()) == 2)
        i.remove('Klass#key1')
        self.failUnless(len(i()) == 2)
        i.removeAll()
        self.failUnless(len(i()) == 2)

        i.removeItem('Klass')
        self.failUnless(len(i()) == 2)
        i.removeItem('Klass#key1')
        self.failUnless(len(i()) == 1)

        _keys = ['key1', 'key2', 'key3']
        i.add({'Klass': _keys})
        self.failUnless(len(i()) == 3)
        i.removeAllItems('Klass#key2')
        self.failUnless(len(i()) == 2)

        ## test we don't modify input dict
        d = {'Klassy': ['key1', 'key2', 'key3']}
        orig_d = d.copy()
        i.add(d)
        self.failUnless(d == orig_d)

        d = {'Klassy': 'key4'}
        orig_d = d.copy()
        i.add(d)
        self.failUnless(d == orig_d)

        ## test extraction of the item list of a given Container type
        _keys = ["Klassy#%s" % k for k in 'key1', 'key2', 'key3', 'key4']
        self.failUnless(i("Klassy") == _keys)
        self.failUnless(i.list("Klassy") == _keys)
        self.failUnless(i(key="Klassy") == _keys)
        self.failUnless(i.list(key="Klassy") == _keys)

        ## test dict()
        _keys = ['key1', 'key2', 'key3', 'key4']
        self.failUnless(i.dict()['Klass'] == ['key1', 'key3'])
        self.failUnless(i.dict()['Klassy'] == _keys)
        _dict = {
            'Klass': ['key1', 'key3'],
            'Klassy': ['key1', 'key2', 'key3', 'key4']
        }
        self.failUnless(i.dict() == _dict)
# MC Truth for PileUp
AOD_ItemList += ["PileUpEventInfo#*"]

#obsolete AOD_ItemList+=[ "DetStatusMap#DetectorStatus" ]

if AODFlags.Trigger:
    include("TriggerRelease/TriggerOutputItemListAOD_jobOptions.py")

# now merge the explicit AOD list to the one coming from ObjKeyStore
# (more and more will be taken from ObjKeyStore)
from AthenaCommon.KeyStore import CfgItemList, CfgKeyStore
theCKS = CfgKeyStore("KeyStore")
CILMergeAOD = CfgItemList("AODMerge", allowWildCard=True)
CILMergeAOD.add(AOD_ItemList)
CILMergeAOD.add(theCKS.streamAOD())

#now prune the itemlist from the object which are soft linked

# this doe not work CILMergeAOD.remove("DataVector<INavigable4Momentum>")
#this does
for k in CILMergeAOD('DataVector<INavigable4Momentum>'):
    CILMergeAOD.removeItem(k)

# The only items declared in StreamESD are those written here.
# Note the use of "=" instead of "+=" is deliberate
#StreamESD.ItemList = fullESDList()

AOD_ItemList = CILMergeAOD()

#print "ESD Output list is :",StreamESD.ItemList
예제 #3
0
    pass

# now merge the explicit ESD list to the one coming from ObjKeyStore
# (more and more will be taken from ObjKeyStore)
from AthenaCommon.KeyStore import CfgItemList, CfgKeyStore
theCKS = CfgKeyStore("KeyStore")
CILMergeESD = CfgItemList("ESDMerge", allowWildCard=True)
CILMergeESD.add(fullESDList())
CILMergeESD.add(theCKS.streamESD())

#now prune the itemlist from the object which are soft linked

# this doe not work CILMergeESD.remove("DataVector<INavigable4Momentum>")
#this does
for k in CILMergeESD('DataVector<INavigable4Momentum>'):
    CILMergeESD.removeItem(k)

# The only items declared in StreamESD are those written here.
# Note the use of "=" instead of "+=" is deliberate
#DR moved to RecExCommon_topOptions.py
#StreamESD.ItemList = CILMergeESD()

#merge back the complete list in objkeystore
#(note that oks and theCKS are two interfaces on the same underlying object)
# need to remove the wild card object like EventInfo etc...
CILMergeESDNoWild = CfgItemList("ESDMergeNoWild", allowWildCard=False)
for item in CILMergeESD():
    if not item.endswith("#*"):
        CILMergeESDNoWild.add(item)

objKeyStore.addManyTypesStreamESD(CILMergeESDNoWild())
예제 #4
0
    def test4Methods( self ):
        """Test various methods of CfgItemList"""
        i = CfgItemList( 'MyItems' )
        self.failUnless( i.name() == 'MyItems' )

        i.add( { 'Klass' : ['key1', 'key2'] } )
        self.failUnless( i() == [ 'Klass#key1', 'Klass#key2' ] )

        i.add( { 'Klass' : ['key1', 'key3' ] } )
        self.failUnless( i() == [ 'Klass#key1', 'Klass#key2', 'Klass#key3' ] )

        props = i.getProperties()
        self.failUnless( props.has_key( 'Klass' ) )
        self.failUnless( len(props['Klass']) == len(['key1','key2','key3']) )
        self.failUnless( 'key1' in props['Klass'] )
        self.failUnless( 'key2' in props['Klass'] )
        self.failUnless( 'key3' in props['Klass'] )

        self.failUnless( len(i.allChildren()) == 0 )

        self.failUnless(     i.has_item( 'Klass#key1' ) )
        self.failUnless(     i.has_item( 'Klass#key*' ) )
        self.failUnless( not i.has_item( 'Klass#Key1' ) )
        self.failUnless( not i.has_item( 'Klass#Key*' ) )

        i.clear()
        self.failUnless( len(i()) == 0 )
        
        i.add( { 'Klass' : ['key1', 'key2'] } )
        self.failUnless( len(i()) == 2 )
        i.remove( 'Klass' )
        self.failUnless( len(i()) == 2 )
        i.remove( 'Klass#key1' )
        self.failUnless( len(i()) == 2 )
        i.removeAll()
        self.failUnless( len(i()) == 2 )

        i.removeItem( 'Klass' )
        self.failUnless( len(i()) == 2 )
        i.removeItem( 'Klass#key1' )
        self.failUnless( len(i()) == 1 )

        _keys = ['key1', 'key2', 'key3']
        i.add( { 'Klass' : _keys } )
        self.failUnless( len(i()) == 3 )
        i.removeAllItems( 'Klass#key2' )
        self.failUnless( len(i()) == 2 )

        ## test we don't modify input dict
        d = {  'Klassy' : ['key1', 'key2', 'key3'] }
        orig_d = d.copy()
        i.add( d )
        self.failUnless( d == orig_d )

        d = {  'Klassy' : 'key4' }
        orig_d = d.copy()
        i.add( d )
        self.failUnless( d == orig_d )

        ## test extraction of the item list of a given Container type
        _keys = [ "Klassy#%s" % k for k in 'key1', 'key2', 'key3', 'key4' ]
        self.failUnless(      i(       "Klassy" ) == _keys )
        self.failUnless( i.list(       "Klassy" ) == _keys )
        self.failUnless(      i( key = "Klassy" ) == _keys )
        self.failUnless( i.list( key = "Klassy" ) == _keys )

        ## test dict()
        _keys = [ 'key1', 'key2', 'key3', 'key4' ]
        self.failUnless( i.dict()['Klass' ] == ['key1', 'key3'] )
        self.failUnless( i.dict()['Klassy'] == _keys )
        _dict = { 'Klass' : ['key1', 'key3'],
                  'Klassy': ['key1', 'key2', 'key3', 'key4']}
        self.failUnless( i.dict() == _dict )