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