Example #1
0
    class TestAlgSequenceWithAlgs(unittest.TestCase):

        ## Function setting up the sequence to be tested
        def setUp(self):
            self.seq = AlgSequence('TestSequence')
            self.seq += AnaAlgorithmConfig('AlgType1/Algorithm1')
            self.seq += AnaAlgorithmConfig('AlgType2/Algorithm2')
            return

        ## Test basic features of the algorithm sequence
        def test_sequenceBasics(self):
            self.assertEqual(self.seq.name(), 'TestSequence')
            self.assertEqual(len(self.seq), 2)
            return

        ## Test index lookup operations on the algorithm sequence
        def test_indexLookup(self):
            self.assertEqual(self.seq[0].name(), 'Algorithm1')
            self.assertEqual(self.seq[1].name(), 'Algorithm2')
            with self.assertRaises(IndexError):
                self.seq[2]
                pass
            return

        ## Test 'by name' lookup operations on the algorithm sequence
        def test_nameLookup(self):
            self.assertEqual(self.seq.Algorithm1.type(), 'AlgType1')
            self.assertEqual(self.seq.Algorithm2.type(), 'AlgType2')
            with self.assertRaises(AttributeError):
                self.seq.Algorithm3.type()
                pass
            return

        ## Test the ability to iterate over the algorithms in the sequence
        def test_iteration(self):
            algNames = [alg.name() for alg in self.seq]
            self.assertEqual(algNames, ['Algorithm1', 'Algorithm2'])
            return

        ## Test the insertion of one algorithm
        def test_insertAlg(self):
            self.seq.insert(1, AnaAlgorithmConfig('AlgType3/Algorithm3'))
            self.assertEqual(len(self.seq), 3)
            self.assertEqual(self.seq[0].name(), 'Algorithm1')
            self.assertEqual(self.seq[1].name(), 'Algorithm3')
            self.assertEqual(self.seq[2].name(), 'Algorithm2')
            return

        ## Test the deletion of an algorithm
        def test_deleteAlg(self):
            del self.seq.Algorithm1
            self.assertEqual(len(self.seq), 1)
            self.assertEqual(self.seq[0].name(), 'Algorithm2')
            return

        pass
# filter policy (ie: here we accept event numbers 1,4,5,6)
seq.alg.filter_policy = 'accept'  # 'reject'

# we could have use a lambda function selecting 'even' event numbers
# NOTE: you can't use both 'evt_list' and 'filter_fct'
# NOTE: the signature of the lambda function *has* to be 'run,evt'
seq.alg.filter_fct = lambda run, evt: evt % 2 == 0

## write out a few ntuples
svcMgr += CfgMgr.DecisionSvc()
import AthenaRootComps.WriteAthenaRoot as arcw
out = arcw.createNtupleOutputStream("StreamD3PD",
                                    "d3pd.root",
                                    "egamma",
                                    asAlg=True)
out.ForceRead = True
# force reading and accessing all input keys
out.ForceRead = True
# copy the whole input tree layout
out.ItemList = ["*"]
# honor the event selection
out.AcceptAlgs = [seq.name()]

# we now add an event counter in the usual TopAlg sequence to see
# the result of the filtering above
job += CfgMgr.AthEventCounter('counter', OutputLevel=Lvl.INFO)

svcMgr.MessageSvc.OutputLevel = Lvl.ERROR
theApp.EvtMax = 5
### EOF ###
Example #3
0
l1ViewAlgorithms.StopOverride = False
makeViewSequence = AthSequencer("makeViewSequence")
makeViewSequence.ModeOR = False
makeViewSequence.Sequential = True
makeViewSequence.StopOverride = False

# Event-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence

job = AlgSequence()

# Make views
makeViewSequence += CfgMgr.AthViews__ViewSubgraphAlg("make_alg")
makeViewSequence.make_alg.ViewBaseName = "view"
makeViewSequence.make_alg.ViewNumber = 10
makeViewSequence.make_alg.ViewNodeName = l1ViewAlgorithms.name()
makeViewSequence.make_alg.Scheduler = AlgScheduler.getScheduler()

# View algorithms
ViewTest = CfgMgr.AthViews__ViewTestAlg("view_test")
l1ViewAlgorithms += ViewTest
#
l1ViewAlgorithms += CfgMgr.AthViews__ViewSubgraphAlg("nest_alg")
l1ViewAlgorithms.nest_alg.ViewBaseName = "viewView"
l1ViewAlgorithms.nest_alg.ViewNumber = 10
l1ViewAlgorithms.nest_alg.ViewNodeName = l2ViewAlgorithms.name()
l1ViewAlgorithms.nest_alg.Scheduler = AlgScheduler.getScheduler()
#
ViewViewTest = CfgMgr.AthViews__ViewTestAlg("viewView_test")
l2ViewAlgorithms += ViewViewTest
Example #4
0
viewSequence = AthSequencer( "viewSequence" )
viewSequence.ModeOR = False
viewSequence.Sequential = True
viewSequence.StopOverride = False

# Event-level algorithm sequence
from AthenaCommon.AlgSequence import AlgSequence
job = AlgSequence()

# Make views
view_make_1 = CfgMgr.AthViews__ViewSubgraphAlg("view_make_1")
view_make_1.ViewBaseName = "view_1"
view_make_1.ViewStart = "view_data_1"
view_make_1.ViewNumber = totalViews
view_make_1.AllViews = "view_collection_1"
view_make_1.ViewNodeName = view_1.name()
view_make_1.Scheduler = AlgScheduler.getScheduler()
viewSequence += view_make_1

# View 1 algorithm
view_verify_1 = CfgMgr.AthViews__ViewDataVerifier("view_verify_1")
view_verify_1.DataObjects = [ ('int','view_data_1') ]
view_1 += view_verify_1

# Add the view node to the job
viewSequence += view_1

# Make child views
view_make_2 = CfgMgr.AthViews__ViewSubgraphAlg("view_make_2")
view_make_2.ViewBaseName = "view_2"
view_make_2.ViewStart = "view_data_2"