Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v36r16 (ea80daf8)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TupleEx.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
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 # =============================================================================
32 __author__ = "Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr"
33 # =============================================================================
34 
35 import math
36 
37 from GaudiPython.Bindings import gbl as cpp
38 
39 Rndm = cpp.Rndm
40 
41 from GaudiPython.GaudiAlgs import SUCCESS, TupleAlgo
42 
43 # =============================================================================
44 # @class TupleEx
45 # Simple algorithm which books&fills three histograms
46 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
47 # @date 2006-11-26
48 
49 
51  """
52  Simple algorithm which implicitely book&fill N-Tuples
53  """
54 
55  # standard constructor
56 
57  def __init__(self, name="TupleEx", **args):
58  """Constructor"""
59  TupleAlgo.__init__(self, name, **args)
60 
61  # the main execution method
62  def execute(self):
63  """
64  The major method 'execute', it is invoked for each event
65  """
66 
67  gauss = Rndm.Numbers(self.randSvc(), Rndm.Gauss(0.0, 1.0))
68 
69  tup = self.nTuple("My trivial N-tuple")
70  for i in range(0, 100):
71  tup.column("a", math.sin(i))
72  tup.column("b", math.cos(i))
73  tup.column("c", math.tan(i))
74  tup.column("g", gauss())
75  tup.write()
76 
77  return SUCCESS
78 
79 
80 # =============================================================================
81 # job configuration
82 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
83 # @date 2006-11-26
84 def configure(gaudi=None):
85  """Configuration of the job"""
86 
87  if not gaudi:
88  from GaudiPython.Bindings import AppMgr
89 
90  gaudi = AppMgr()
91 
92  gaudi.JobOptionsType = "NONE"
93  gaudi.EvtSel = "NONE"
94  gaudi.HistogramPersistency = "ROOT"
95 
96  gaudi.ExtSvc += ["NTupleSvc"]
97 
98  ntSvc = gaudi.service("NTupleSvc")
99  ntSvc.Output = ["MYLUN DATAFILE='TupleEx_py.root' OPT='NEW' TYP='ROOT'"]
100 
101  gaudi.config()
102 
103  gaudi.DLLs = [
104  "GaudiAlg",
105  "RootHistCnv",
106  ]
107 
108  alg = TupleEx(
109  # configure the property
110  NTupleLUN="MYLUN"
111  )
112 
113  gaudi.setAlgorithms([alg])
114 
115  return SUCCESS
116 
117 
118 # =============================================================================
119 # The actual job excution
120 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
121 # @date 2006-11-26
122 if "__main__" == __name__:
123  print(__doc__)
124  from GaudiPython.Bindings import AppMgr
125 
126  gaudi = AppMgr()
127  configure(gaudi)
128  gaudi.run(20)
129 
130 # =============================================================================
131 # The END
132 # =============================================================================
GaudiPython.GaudiAlgs.TupleAlgo
Definition: GaudiAlgs.py:882
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:869
GaudiPython.Bindings
Definition: Bindings.py:1
TupleEx.TupleEx.execute
def execute(self)
Definition: TupleEx.py:62
TupleEx.configure
def configure(gaudi=None)
Definition: TupleEx.py:84
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:57
TupleEx.TupleEx
Definition: TupleEx.py:50
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:102