The Gaudi Framework  v36r1 (3e2fb5a8)
TupleEx.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
21 """
22 *******************************************************************************
23 * *
24 * Simple example which illustrate the usage of useful *
25 * algorithm base class for N-Tuple manipulations *
26 * *
27 *******************************************************************************
28 """
29 from __future__ import print_function
30 # =============================================================================
31 __author__ = 'Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr'
32 # =============================================================================
33 
34 import math
35 
36 from GaudiPython.Bindings import gbl as cpp
37 
38 Rndm = cpp.Rndm
39 
40 from GaudiPython.GaudiAlgs import TupleAlgo, SUCCESS
41 
42 # =============================================================================
43 # @class TupleEx
44 # Simple algorithm which books&fills three histograms
45 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
46 # @date 2006-11-26
47 
48 
50  """
51  Simple algorithm which implicitely book&fill N-Tuples
52  """
53 
54  # standard constructor
55 
56  def __init__(self, name='TupleEx', **args):
57  """ Constructor """
58  TupleAlgo.__init__(self, name, **args)
59 
60  # the main execution method
61  def execute(self):
62  """
63  The major method 'execute', it is invoked for each event
64  """
65 
66  gauss = Rndm.Numbers(self.randSvc(), Rndm.Gauss(0.0, 1.0))
67 
68  tup = self.nTuple('My trivial N-tuple')
69  for i in range(0, 100):
70  tup.column('a', math.sin(i))
71  tup.column('b', math.cos(i))
72  tup.column('c', math.tan(i))
73  tup.column('g', gauss())
74  tup.write()
75 
76  return SUCCESS
77 
78 
79 # =============================================================================
80 # job configuration
81 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
82 # @date 2006-11-26
83 def configure(gaudi=None):
84  """ Configuration of the job """
85 
86  if not gaudi:
87  from GaudiPython.Bindings import AppMgr
88  gaudi = AppMgr()
89 
90  gaudi.JobOptionsType = 'NONE'
91  gaudi.EvtSel = 'NONE'
92  gaudi.HistogramPersistency = 'ROOT'
93 
94  gaudi.ExtSvc += ["NTupleSvc"]
95 
96  ntSvc = gaudi.service('NTupleSvc')
97  ntSvc.Output = ["MYLUN DATAFILE='TupleEx.root' OPT='NEW' TYP='ROOT'"]
98 
99  gaudi.config()
100 
101  gaudi.DLLs = [
102  'GaudiAlg',
103  'RootHistCnv',
104  ]
105 
106  alg = TupleEx(
107  # configure the property
108  NTupleLUN='MYLUN')
109 
110  gaudi.setAlgorithms([alg])
111 
112  return SUCCESS
113 
114 
115 # =============================================================================
116 # The actual job excution
117 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
118 # @date 2006-11-26
119 if '__main__' == __name__:
120  print(__doc__)
121  from GaudiPython.Bindings import AppMgr
122  gaudi = AppMgr()
123  configure(gaudi)
124  gaudi.run(20)
125 
126 # =============================================================================
127 # The END
128 # =============================================================================
GaudiPython.GaudiAlgs.TupleAlgo
Definition: GaudiAlgs.py:881
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:842
GaudiPython.Bindings
Definition: Bindings.py:1
TupleEx.TupleEx.execute
def execute(self)
Definition: TupleEx.py:61
TupleEx.configure
def configure(gaudi=None)
Definition: TupleEx.py:83
Rndm::Gauss
Parameters for the Gauss random number generation.
Definition: RndmGenerators.h:32
Rndm::Numbers
Random number accessor This small class encapsulates the use of the random number generator.
Definition: RndmGenerators.h:359
HistoUtilsEx.gauss
gauss
Definition: HistoUtilsEx.py:66
TupleEx.TupleEx.__init__
def __init__(self, name='TupleEx', **args)
Definition: TupleEx.py:56
TupleEx.TupleEx
Definition: TupleEx.py:49
GaudiPython.GaudiAlgs
Definition: GaudiAlgs.py:1
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: FunctionalDetails.h:97