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
29 __author__ =
'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
36 Rndm = GaudiPython.gbl.Rndm
38 SUCCESS = GaudiPython.SUCCESS
40 Numbers.__call__ = Numbers.shoot
48 """ Simple algorithm which manipulates with counters """
52 GaudiAlgo.__init__(self, name)
55 """ The major method 'execute', it is invoked for each event """
57 executed = self.counter(
'executed')
66 g1 = self.counter(
'gauss')
67 g2 = self.counter(
'g2')
73 gp = self.counter(
'Gpos')
76 gn = self.counter(
'Gneg')
79 stat1 = self.counter(
'NG')
80 stat2 = self.counter(
'G')
81 for i
in range(0, int(poisson())):
85 stat3 = self.counter(
'eff')
89 executed = self.counter(
'executed')
90 prnt = int(executed.flag())
92 six.print_(
" Event number %s " % prnt, flush=
True)
93 bc = self.counter(
'eff')
94 line =
"(%.12g += %.12g)%s" % (bc.eff() * 100, bc.effErr() * 100,
97 ' 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__)