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