The Gaudi Framework  v36r11 (bdb84f5f)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TupleEx2.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 import GaudiPython
38 
39 Rndm = GaudiPython.gbl.Rndm
40 Math = GaudiPython.gbl.ROOT.Math
41 SUCCESS = GaudiPython.SUCCESS
42 
43 from GaudiPython.GaudiAlgs import TupleAlgo
44 
45 # =============================================================================
46 # @class TupleEx2
47 # Simple algorithm for advanced N-Tuple columns
48 #
49 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
50 # @date 2006-11-26
51 
52 
54  """
55  Simple algorithm for advanced N-Tuple columns
56  """
57 
58  # standard constructor
59  def __init__(self, name="TupleEx2"):
60  """Constructor"""
61  TupleAlgo.__init__(self, name)
62 
63  # the main execution method
64  def execute(self):
65  """The major method 'execute', it is invoked for each event"""
66 
67  gauss = Rndm.Numbers(self.randSvc(), Rndm.Gauss(0.0, 1.0))
68  flat = Rndm.Numbers(self.randSvc(), Rndm.Flat(-10, 10))
69  breit = Rndm.Numbers(self.randSvc(), Rndm.BreitWigner(0.0, 1.0))
70 
71  # N-tuple with 4D-vectors
72  tup = self.nTuple("Vectors-4D", "N-tuple with 4D-vectors")
73  for i in range(0, 100):
74 
75  lv1 = Math.PxPyPzEVector()
76 
77  lv1.SetPx(gauss())
78  lv1.SetPy(gauss())
79  lv1.SetPz(gauss())
80  lv1.SetE(gauss())
81 
82  tup.column("lv1", lv1)
83 
84  tup.write()
85 
86  # N-tuple with 3D-vectors
87  tup = self.nTuple("Vectors-3D", "N-tuple with 3D-vectors")
88  for i in range(0, 100):
89 
90  v1 = Math.XYZVector()
91  v1.SetX(gauss())
92  v1.SetY(gauss())
93  v1.SetZ(gauss())
94 
95  tup.column("v1", v1)
96 
97  tup.write()
98 
99  # N-tuple with 3D-points
100  tup = self.nTuple("Points-3D", "N-tuple with 3D-points")
101  for i in range(0, 100):
102 
103  p1 = Math.XYZPoint()
104  p1.SetX(gauss())
105  p1.SetY(gauss())
106  p1.SetZ(gauss())
107 
108  tup.column("p1", p1)
109 
110  tup.write()
111 
112  return SUCCESS
113 
114 
115 # =============================================================================
116 # job configuration
117 #
118 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
119 # @date 2006-11-26
120 
121 
122 def configure(gaudi=None):
123  """
124  Configuration of the job
125  """
126 
127  if not gaudi:
128  gaudi = GaudiPython.AppMgr()
129 
130  gaudi.JobOptionsType = "NONE"
131  gaudi.EvtSel = "NONE"
132  gaudi.HistogramPersistency = "ROOT"
133 
134  gaudi.ExtSvc += ["NTupleSvc"]
135 
136  ntSvc = gaudi.service("NTupleSvc")
137  ntSvc.Output = ["MYLUN DATAFILE='TupleEx2.root' OPT='NEW' TYP='ROOT'"]
138 
139  gaudi.config()
140 
141  gaudi.DLLs = [
142  "GaudiAlg",
143  "RootHistCnv",
144  ]
145 
146  alg = TupleEx2()
147  gaudi.setAlgorithms([alg])
148 
149  # configure the properties
150  alg.NTupleLUN = "MYLUN"
151 
152  return SUCCESS
153 
154 
155 # =============================================================================
156 # The actual job execution
157 #
158 # @author Vanya BELYAEV ibelyaev@physics.syr.edu
159 # @date 2006-11-26
160 if "__main__" == __name__:
161  print(__doc__)
163  configure(gaudi)
164  gaudi.run(20)
165 
166 # =============================================================================
167 # The END
168 # =============================================================================
GaudiPython.GaudiAlgs.TupleAlgo
Definition: GaudiAlgs.py:882
GaudiPython.Bindings.AppMgr
Definition: Bindings.py:872
Rndm::Flat
Parameters for the flat random number generation within boundaries [minimum, maximum].
Definition: RndmGenerators.h:253
TupleEx2.TupleEx2.__init__
def __init__(self, name="TupleEx2")
Definition: TupleEx2.py:59
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
Rndm::BreitWigner
Parameters for the BreitWigner distributed random number generation.
Definition: RndmGenerators.h:94
HistoUtilsEx.gauss
gauss
Definition: HistoUtilsEx.py:66
TupleEx2.configure
def configure(gaudi=None)
Definition: TupleEx2.py:122
TupleEx2.TupleEx2
Definition: TupleEx2.py:53
TupleEx2.TupleEx2.execute
def execute(self)
Definition: TupleEx2.py:64
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