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
32 __author__ =
"Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr"
39 SUCCESS = GaudiPython.SUCCESS
42 Rndm = GaudiPython.gbl.Rndm
56 Primitive function which transform arbitrary sequence into
57 GaudiPython.Vector ( std::vector<double> )
59 result = GaudiPython.gbl.GaudiPython.Vector()
60 if hasattr(sequence,
"__len__"):
61 result.reserve(len(sequence))
62 elif hasattr(sequence,
"size"):
63 result.reserve(sequence.size())
66 result.push_back(item)
79 Simple algorithm which implicitely book&fill N-Tuples
86 The major method 'execute', it is invoked for each event
100 tuple1 = self.nTuple(1,
"Trivial Row-Wise Tuple", 42)
103 tuple1.column(
"gauss",
gauss())
104 tuple1.column(
"flat", flat())
105 tuple1.column(
"expo", expo())
106 tuple1.column(
"breit", breit())
109 tuple1.column(
"poiss1", int(poisson()))
110 tuple1.column(
"binom1", int(binom()))
113 tuple1.column_ll(
"poiss2", int(poisson()))
114 tuple1.column_ll(
"binom2", int(binom()))
117 tuple1.column_ull(
"poiss3", int(poisson()))
118 tuple1.column_ull(
"binom3", int(binom()))
121 tuple1.column(
"poiss4", int(poisson()), 0, 14)
122 tuple1.column(
"binom4", int(binom()), 0, 14)
125 tuple1.column(
"poisb", poisson() > 1.0)
133 tuple2 = self.nTuple(2,
"Trivial Column-Wise Tuple")
136 tuple2.column(
"gauss",
gauss())
137 tuple2.column(
"flat", flat())
138 tuple2.column(
"expo", expo())
139 tuple2.column(
"breit", breit())
142 tuple2.column(
"poiss", int(poisson()))
143 tuple2.column(
"binom", int(binom()))
145 tuple2.column(
"poiss", int(poisson()), 0, 14)
146 tuple2.column(
"binom", int(binom()), 0, 14)
149 tuple2.column(
"poisb", poisson() > 1.0)
157 tuple3 = self.nTuple(3,
"Fixed-size arrays/vectors")
159 tuple3.array(
"arflat",
vct([flat()
for i
in range(0, 50)]))
160 tuple3.array(
"arexpo",
vct([expo()
for i
in range(0, 62)]))
163 tuple3.array(
"argau2",
vct(t))
175 """Configuration of the job"""
180 gaudi.JobOptionsType =
"NONE"
181 gaudi.EvtSel =
"NONE"
182 gaudi.HistogramPersistency =
"ROOT"
184 gaudi.ExtSvc += [
"NTupleSvc"]
186 ntSvc = gaudi.service(
"NTupleSvc")
187 ntSvc.Output = [
"MYLUN DATAFILE='TupleEx1.root' OPT='NEW' TYP='ROOT'"]
197 gaudi.setAlgorithms([alg])
200 alg.NTupleLUN =
"MYLUN"
209 if "__main__" == __name__: