22 *******************************************************************************
24 * Simple example which illustrate the usage of useful *
25 * algorithm base class for N-Tuple manipulations *
27 *******************************************************************************
29 from __future__
import print_function
31 __author__ =
'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
37 SUCCESS = GaudiPython.SUCCESS
40 Rndm = GaudiPython.gbl.Rndm
54 Primitive function which transform arbitrary sequence into
55 GaudiPython.Vector ( std::vector<double> )
57 result = GaudiPython.gbl.GaudiPython.Vector()
58 if hasattr(sequence,
'__len__'):
59 result.reserve(len(sequence))
60 elif hasattr(sequence,
'size'):
61 result.reserve(sequence.size())
64 result.push_back(item)
77 Simple algorithm which implicitely book&fill N-Tuples
84 The major method 'execute', it is invoked for each event
98 tuple1 = self.nTuple(1,
"Trivial Row-Wise Tuple", 42)
101 tuple1.column(
'gauss',
gauss())
102 tuple1.column(
'flat', flat())
103 tuple1.column(
'expo', expo())
104 tuple1.column(
'breit', breit())
107 tuple1.column(
'poiss1', int(poisson()))
108 tuple1.column(
'binom1', int(binom()))
111 tuple1.column_ll(
'poiss2', int(poisson()))
112 tuple1.column_ll(
'binom2', int(binom()))
115 tuple1.column_ull(
'poiss3', int(poisson()))
116 tuple1.column_ull(
'binom3', int(binom()))
119 tuple1.column(
'poiss4', int(poisson()), 0, 14)
120 tuple1.column(
'binom4', int(binom()), 0, 14)
123 tuple1.column(
"poisb", poisson() > 1.0)
131 tuple2 = self.nTuple(2,
"Trivial Column-Wise Tuple")
134 tuple2.column(
'gauss',
gauss())
135 tuple2.column(
'flat', flat())
136 tuple2.column(
'expo', expo())
137 tuple2.column(
'breit', breit())
140 tuple2.column(
'poiss', int(poisson()))
141 tuple2.column(
'binom', int(binom()))
143 tuple2.column(
'poiss', int(poisson()), 0, 14)
144 tuple2.column(
'binom', int(binom()), 0, 14)
147 tuple2.column(
"poisb", poisson() > 1.0)
155 tuple3 = self.nTuple(3,
"Fixed-size arrays/vectors")
157 tuple3.array(
'arflat',
vct([flat()
for i
in range(0, 50)]))
158 tuple3.array(
'arexpo',
vct([expo()
for i
in range(0, 62)]))
161 tuple3.array(
'argau2',
vct(t))
173 """ Configuration of the job """
178 gaudi.JobOptionsType =
'NONE'
179 gaudi.EvtSel =
'NONE'
180 gaudi.HistogramPersistency =
'ROOT'
182 gaudi.ExtSvc += [
"NTupleSvc"]
184 ntSvc = gaudi.service(
'NTupleSvc')
185 ntSvc.Output = [
"MYLUN DATAFILE='TupleEx1.root' OPT='NEW' TYP='ROOT'"]
195 gaudi.setAlgorithms([alg])
198 alg.NTupleLUN =
'MYLUN'
207 if '__main__' == __name__: