14 *******************************************************************************
16 * Simple example which illustrates the usage of the useful base class *
17 * GaudiAlgo (python version of C++ GaudiAlgorithm) for "easy" manipulations *
20 * The example is equivalent to C++ example 'CounterEx', see *
21 * GaudiExamples/src/CounterEx/*.cpp and *
22 * GaudiExamples/options/CounterEx.opts *
24 *******************************************************************************
26 from __future__
import print_function
31 __author__ =
"Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr"
38 Rndm = GaudiPython.gbl.Rndm
40 SUCCESS = GaudiPython.SUCCESS
42 Numbers.__call__ = Numbers.shoot
50 """Simple algorithm which manipulates with counters"""
54 GaudiAlgo.__init__(self, name)
57 """The major method 'execute', it is invoked for each event"""
59 executed = self.counter(
"executed")
68 g1 = self.counter(
"gauss")
69 g2 = self.counter(
"g2")
75 gp = self.counter(
"Gpos")
78 gn = self.counter(
"Gneg")
81 stat1 = self.counter(
"NG")
82 stat2 = self.counter(
"G")
83 for i
in range(0, int(poisson())):
87 stat3 = self.counter(
"eff")
91 executed = self.counter(
"executed")
92 prnt = int(executed.flag())
94 six.print_(
" Event number %s " % prnt, flush=
True)
95 bc = self.counter(
"eff")
96 line =
"(%.12g += %.12g)%s" % (bc.eff() * 100, bc.effErr() * 100,
"%")
97 six.print_(
' Efficiency (binomial counter "eff"): %s' % line, flush=
True)
106 """Configuration of the job"""
111 gaudi.JobOptionsType =
"NONE"
112 gaudi.EvtSel =
"NONE"
117 gaudi.setAlgorithms([alg])
118 gaudi.ExtSvc += [
"Gaudi::Monitoring::MessageSvcSink"]
126 if "__main__" == __name__:
127 print(__doc__ + __author__)