The Gaudi Framework  v30r3 (a5ef0a68)
BasicViewTest.py
Go to the documentation of this file.
1 #!/usr/bin/env gaudirun.py
2 
3 '''
4 A test for basic functionality of sub-event scheduling.
5 Algorithms A2 and A3 should run twice per event, in sub-event contexts.
6 
7 The ViewTester is an algorithm specifically designed to create sub-event
8 contexts, pass them to the scheduler, and report on the current context.
9 
10 Four instances of ViewTester are used as follows:
11  - Algorithm A1 creates two sub-event contexts
12  - Algorithms A2 and A3 run within the sub-event contexts
13  - Algorithm A4 runs in the whole event context, after the sub-events
14 
15 '''
16 from Gaudi.Configuration import *
17 from Configurables import (HiveWhiteBoard, HiveSlimEventLoopMgr,
18  AvalancheSchedulerSvc, AlgResourcePool,
19  CPUCruncher, GaudiSequencer, Test__ViewTester)
20 
21 # metaconfig -------------------------------------------------------------------
22 # It's confortable to collect the relevant parameters at the top of the optionfile
23 evtslots = 1
24 evtMax = 10
25 cardinality = 1
26 threads = 1
27 viewsPerEvt = 2
28 # -------------------------------------------------------------------------------
29 
30 # The configuration of the whiteboard ------------------------------------------
31 # It is useful to call it EventDataSvc to replace the usual data service with
32 # the whiteboard transparently.
33 
34 whiteboard = HiveWhiteBoard("EventDataSvc", EventSlots=evtslots)
35 
36 # -------------------------------------------------------------------------------
37 
38 # Event Loop Manager -----------------------------------------------------------
39 # It's called slim since it has less functionalities overall than the good-old
40 # event loop manager. Here we just set its outputlevel to DEBUG.
41 
42 slimeventloopmgr = HiveSlimEventLoopMgr(
43  SchedulerName="AvalancheSchedulerSvc", OutputLevel=INFO)
44 
45 # -------------------------------------------------------------------------------
46 
47 # ForwardScheduler -------------------------------------------------------------
48 # We just decide how many algorithms in flight we want to have and how many
49 # threads in the pool. The default value is -1, which is for TBB equivalent
50 # to take over the whole machine.
51 
52 scheduler = AvalancheSchedulerSvc(ThreadPoolSize=threads, OutputLevel=INFO)
53 
54 # -------------------------------------------------------------------------------
55 
56 # Algo Resource Pool -----------------------------------------------------------
57 # Nothing special here, we just set the debug level.
58 AlgResourcePool(OutputLevel=INFO)
59 
60 # -------------------------------------------------------------------------------
61 
62 # Set up of the crunchers, daily business --------------------------------------
63 
64 a1 = Test__ViewTester("A1")
65 a1.baseViewName = 'view'
66 a1.viewNumber = viewsPerEvt
67 a1.viewNodeName = 'viewNode'
68 
69 a2 = Test__ViewTester("A2")
70 a2.viewNodeName = ''
71 
72 a3 = Test__ViewTester("A3")
73 a3.viewNodeName = ''
74 
75 a4 = Test__ViewTester("A4")
76 a4.viewNodeName = ''
77 
78 for algo in [a1, a2, a3, a4]:
79  algo.Cardinality = cardinality
80  algo.OutputLevel = INFO
81 
82 viewNode = GaudiSequencer("viewNode",
83  Members=[a2, a3],
84  Sequential=False,
85  OutputLevel=INFO)
86 
87 createViewSeq = GaudiSequencer("createViewSeq",
88  Members=[a1, viewNode, a4],
89  Sequential=True,
90  OutputLevel=INFO)
91 
92 # Application Manager ----------------------------------------------------------
93 # We put everything together and change the type of message service
94 
95 ApplicationMgr(EvtMax=evtMax,
96  EvtSel='NONE',
97  ExtSvc=[whiteboard],
98  EventLoop=slimeventloopmgr,
99  TopAlg=[createViewSeq],
100  MessageSvcType="InertMessageSvc")
101 
102 # -------------------------------------------------------------------------------
Sequencer for executing several algorithms, stopping when one is faulty.
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Data service base class.
The Application Manager class.