The Gaudi Framework  master (37c0b60a)
ProduceConsume.py
Go to the documentation of this file.
1 
14 from Configurables import EvtStoreSvc
15 from Configurables import Gaudi__Monitoring__MessageSvcSink as MessageSvcSink
16 from Configurables import Gaudi__TestSuite__ContextConsumer as ContextConsumer
17 from Configurables import Gaudi__TestSuite__ContextIntConsumer as ContextIntConsumer
18 from Configurables import Gaudi__TestSuite__CountingConsumer as CountingConsumer
19 from Configurables import Gaudi__TestSuite__FloatDataConsumer as FloatDataConsumer
20 from Configurables import Gaudi__TestSuite__FrExpTransformer as FrExpTransformer
21 from Configurables import Gaudi__TestSuite__IntDataConsumer as IntDataConsumer
22 from Configurables import Gaudi__TestSuite__IntDataProducer as IntDataProducer
23 from Configurables import (
24  Gaudi__TestSuite__IntIntToFloatFloatData as IntIntToFloatFloatData,
25 )
26 from Configurables import Gaudi__TestSuite__IntToFloatData as IntToFloatData
27 from Configurables import Gaudi__TestSuite__IntVectorsMerger as IntVectorsMerger
28 from Configurables import (
29  Gaudi__TestSuite__IntVectorsMergingConsumer as IntVectorsMergingConsumer,
30 )
31 from Configurables import Gaudi__TestSuite__IntVectorsToInts as IntVectorsToInts
32 from Configurables import (
33  Gaudi__TestSuite__IntVectorsToIntVector as IntVectorsToIntVector,
34 )
35 from Configurables import Gaudi__TestSuite__LdExpTransformer as LdExpTransformer
36 from Configurables import Gaudi__TestSuite__MyConsumerTool as MyConsumerTool
37 from Configurables import Gaudi__TestSuite__MyExampleTool as MyExampleTool
38 from Configurables import Gaudi__TestSuite__OpaqueProducer as OpaqueProducer
39 from Configurables import Gaudi__TestSuite__OptFrExpTransformer as OptFrExpTransformer
40 from Configurables import Gaudi__TestSuite__OptLdExpTransformer as OptLdExpTransformer
41 from Configurables import Gaudi__TestSuite__SDataProducer as SDataProducer
42 from Configurables import Gaudi__TestSuite__ShrdPtrConsumer as ShrdPtrConsumer
43 from Configurables import Gaudi__TestSuite__ShrdPtrProducer as ShrdPtrProducer
44 from Configurables import Gaudi__TestSuite__SRangesToIntVector as SRangesToIntVector
45 from Configurables import (
46  Gaudi__TestSuite__OptionalSRangesMerger as OptionalSRangesMerger,
47 )
48 from Configurables import Gaudi__TestSuite__ToolConsumer as ToolConsumer
49 from Configurables import Gaudi__TestSuite__TwoDMerger as TwoDMerger
50 from Configurables import Gaudi__TestSuite__VectorDataProducer as VectorDataProducer
51 from Configurables import Gaudi__TestSuite__VectorDoubleProducer as VectorDoubleProducer
52 from Gaudi.Configuration import *
53 from GaudiKernel.DataHandle import DataHandle
54 
55 # Application setup
57 app.ExtSvc = [EvtStoreSvc("EventDataSvc"), MessageSvcSink()]
58 
59 types = []
60 
61 # this printout is useful to check that the type information is passed to python correctly
62 print("---\n# List of input and output types by class")
63 for configurable in sorted(
64  [
65  ToolConsumer,
66  IntDataProducer,
67  VectorDataProducer,
68  FloatDataConsumer,
69  IntDataConsumer,
70  IntToFloatData,
71  IntIntToFloatFloatData,
72  IntVectorsToIntVector,
73  ContextConsumer,
74  ContextIntConsumer,
75  VectorDoubleProducer,
76  FrExpTransformer,
77  LdExpTransformer,
78  OptFrExpTransformer,
79  OptLdExpTransformer,
80  CountingConsumer,
81  ShrdPtrProducer,
82  ShrdPtrConsumer,
83  ],
84  key=lambda c: c.getType(),
85 ):
86  print('"{}":'.format(configurable.getType()))
87  props = configurable.getDefaultProperties()
88  for propname, prop in sorted(props.items()):
89  if isinstance(prop, DataHandle):
90  types.append(prop.type())
91  print(' {}: "{}"'.format(propname, prop.type()))
92 print("---")
93 
94 # - Algorithms
95 
96 OtherIntDataProducer = IntDataProducer("OtherIntDataProducer")
97 OtherIntDataProducer.OutputLocation = "/Event/MyOtherInt"
98 VectorDataProducer1 = VectorDataProducer(
99  "VectorDataProducer1", OutputLocation="/Event/IntVector1"
100 )
101 VectorDataProducer2 = VectorDataProducer(
102  "VectorDataProducer2", OutputLocation="/Event/IntVector2"
103 )
104 SDataProducer1 = SDataProducer("SDataProducer1", OutputLocation="/Event/S1", j=3)
105 SDataProducer2 = SDataProducer("SDataProducer2", OutputLocation="/Event/S2", j=10)
106 app.TopAlg = [
107  IntDataProducer("IntDataProducer"),
108  OtherIntDataProducer,
109  IntDataConsumer("IntDataConsumer"),
110  ToolConsumer("MyToolConsumer", MyTool=MyExampleTool(Message="Hello World!!!")),
111  ToolConsumer(
112  "MyBoundToolConsumer", MyTool=MyConsumerTool(MyInt="/Event/MyOtherInt")
113  ),
114  IntToFloatData("IntToFloatData"),
115  IntIntToFloatFloatData("IntIntToFloatFloatData"),
116  FloatDataConsumer("FloatDataConsumer"),
117  ContextConsumer("ContextConsumer"),
118  ContextIntConsumer("ContextIntConsumer"),
119  VectorDoubleProducer("VectorDoubleProducer"),
120  VectorDataProducer1,
121  VectorDataProducer2,
122  IntVectorsToIntVector(
123  "IntVectorsToIntVector",
124  InputLocations=[
125  str(VectorDataProducer1.OutputLocation),
126  str(VectorDataProducer2.OutputLocation),
127  ],
128  ),
129  FrExpTransformer("FrExpTransformer"),
130  LdExpTransformer("LdExpTransfomer"),
131  OptFrExpTransformer("OptFrExpTransformer"),
132  OptLdExpTransformer("OptLdExpTransformer"),
133  CountingConsumer("CountingConsumer"),
134  SDataProducer1,
135  SDataProducer2,
136  SRangesToIntVector(
137  "SRangesToIntVector",
138  InputRanges=[
139  str(SDataProducer1.OutputLocation),
140  str(SDataProducer2.OutputLocation),
141  ],
142  ),
143  OptionalSRangesMerger(
144  "OptionalSRangesMerger",
145  InputRanges=[
146  str(SDataProducer1.OutputLocation),
147  str(SDataProducer2.OutputLocation),
148  ],
149  ),
150  OptionalSRangesMerger(
151  "OptionalSRangesMerger_EmptyInput",
152  InputRanges=[
153  "/Event/NonExistent",
154  ],
155  ),
156  IntVectorsMerger(
157  "IntVectorsMerger",
158  InputLocations=[
159  str(VectorDataProducer1.OutputLocation),
160  str(VectorDataProducer2.OutputLocation),
161  ],
162  ),
163  IntVectorsMergingConsumer(
164  "IntVectorsMergingConsumer",
165  InputLocations=[
166  str(VectorDataProducer1.OutputLocation),
167  str(VectorDataProducer2.OutputLocation),
168  ],
169  ),
170  TwoDMerger(
171  "TwoDMerger",
172  InputInts=[
173  str(VectorDataProducer1.OutputLocation),
174  str(VectorDataProducer2.OutputLocation),
175  ],
176  InputDoubles=[
177  str(OptLdExpTransformer("OptLdExpTransformer").OutputDoubles),
178  ],
179  OutputInts="/Event/SummedInts",
180  OutputDoubles="/Event/SummedDoubles",
181  ),
182  OpaqueProducer("OpaqueProducer"),
183  ShrdPtrProducer("SharedPtrProducer"),
184  ShrdPtrConsumer("SharedPtrConsumer"),
185  VectorDataProducer(
186  "IntProducer0", Data=[0, 2, 4], OutputLocation="/Event/EventInts"
187  ),
188  VectorDataProducer(
189  "IntProducer1", Data=[1, 3, 5, 7], OutputLocation="/Event/OddInt"
190  ),
191  VectorDataProducer(
192  "IntProducer2", Data=[1, 1, 2, 3, 5, 8, 13], OutputLocation="/Event/Fib7"
193  ),
194  IntVectorsToInts(
195  "IntVectorsToInts",
196  Mapping=[[0, 0], [0, 1], [0, 2], [1, 1], [1, 2]],
197  InputLocations=["/Event/EventInts", "/Event/OddInt", "/Event/Fib7"],
198  OutputLocations=["/Event/EvenOddFib", "/Event/OddFib"],
199  ),
200  ContextIntConsumer("EvenOddFibConsumer", InputLocation="/Event/EvenOddFib"),
201  ContextIntConsumer("OddFibConsumer", InputLocation="/Event/OddFib"),
202 ]
203 # - Events
204 app.EvtMax = 2
205 app.EvtSel = "NONE"
206 app.HistogramPersistency = "NONE"
GaudiKernel.DataHandle
Definition: DataHandle.py:1
Gaudi.Configuration
Definition: Configuration.py:1
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
ApplicationMgr
Definition: ApplicationMgr.h:57