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