Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Attributes | List of all members
GaudiMP.pTools.HistoAgent Class Reference

Public Member Functions

def __init__
 
def register
 
def Receive
 
def RebuildHistoStore
 
def bookDataObject
 
def bookTH1D
 
def bookTH2D
 
def bookTH3D
 
def bookTProfile
 
def bookTProfile2D
 

Public Attributes

 hvt
 
 histos
 
 qin
 
 log
 
 bookingDict
 

Private Attributes

 _gmpc
 

Detailed Description

Definition at line 49 of file pTools.py.

Constructor & Destructor Documentation

def GaudiMP.pTools.HistoAgent.__init__ (   self,
  gmpComponent 
)

Definition at line 50 of file pTools.py.

50 
51  def __init__( self, gmpComponent ) :
52  self._gmpc = gmpComponent
53  self.hvt = self._gmpc.hvt
54  self.histos = []
55  self.qin = self._gmpc.hq
56  self.log = self._gmpc.log
57 
58  # There are many methods for booking Histogram Objects to Histo store
59  # here they are collected in a dictionary, with key = a relevant name
60  self.bookingDict = {}
61  self.bookingDict['DataObject'] = self.bookDataObject
62  self.bookingDict['NTuple::Directory'] = self.bookDataObject
63  self.bookingDict['NTuple::File'] = self.bookDataObject
64  self.bookingDict['TH1D'] = self.bookTH1D
65  self.bookingDict['TH2D'] = self.bookTH2D
66  self.bookingDict['TH3D'] = self.bookTH3D
67  self.bookingDict['TProfile'] = self.bookTProfile
68  self.bookingDict['TProfile2D'] = self.bookTProfile2D

Member Function Documentation

def GaudiMP.pTools.HistoAgent.bookDataObject (   self,
  n,
  o 
)
Register a DataObject to the Histo Store

Definition at line 135 of file pTools.py.

136  def bookDataObject( self, n, o ):
137  '''
138  Register a DataObject to the Histo Store
139  '''
140  self._gmpc.hvt.registerObject( n, o )
def GaudiMP.pTools.HistoAgent.bookTH1D (   self,
  n,
  o 
)
Register a ROOT 1D THisto to the Histo Store

Definition at line 141 of file pTools.py.

142  def bookTH1D( self, n, o ) :
143  '''
144  Register a ROOT 1D THisto to the Histo Store
145  '''
146  obj = self.hvt._ihs.book( n, o.GetTitle(),\
147  o.GetXaxis().GetNbins(),\
148  o.GetXaxis().GetXmin(),\
149  o.GetXaxis().GetXmax() )
150  aida2root(obj).Add(o)
def GaudiMP.pTools.HistoAgent.bookTH2D (   self,
  n,
  o 
)
Register a ROOT 2D THisto to the Histo Store

Definition at line 151 of file pTools.py.

152  def bookTH2D( self, n, o ) :
153  '''
154  Register a ROOT 2D THisto to the Histo Store
155  '''
156  obj = self.hvt._ihs.book( n, o.GetTitle(),\
157  o.GetXaxis().GetNbins(),\
158  o.GetXaxis().GetXmin(),\
159  o.GetXaxis().GetXmax(),\
160  o.GetYaxis().GetNbins(),\
161  o.GetYaxis().GetXmin(),\
162  o.GetYaxis().GetXmax() )
163  aida2root(obj).Add(o)
def GaudiMP.pTools.HistoAgent.bookTH3D (   self,
  n,
  o 
)
Register a ROOT 3D THisto to the Histo Store

Definition at line 164 of file pTools.py.

165  def bookTH3D( self, n, o ) :
166  '''
167  Register a ROOT 3D THisto to the Histo Store
168  '''
169  obj = self.hvt._ihs.book( n, o.GetTitle(),\
170  o.GetXaxis().GetXbins(),\
171  o.GetXaxis().GetXmin(),\
172  o.GetXaxis().GetXmax(),\
173  o.GetYaxis().GetXbins(),\
174  o.GetYaxis().GetXmin(),\
175  o.GetYaxis().GetXmax(),\
176  o.GetZaxis().GetXbins(),\
177  o.GetZaxis().GetXmin(),\
178  o.GetZaxis().GetXmax() )
179  aida2root(obj).Add(o)
def GaudiMP.pTools.HistoAgent.bookTProfile (   self,
  n,
  o 
)
Register a ROOT TProfile to the Histo Store

Definition at line 180 of file pTools.py.

181  def bookTProfile( self, n, o ) :
182  '''
183  Register a ROOT TProfile to the Histo Store
184  '''
185  obj = self.hvt._ihs.bookProf( n, o.GetTitle(),\
186  o.GetXaxis().GetNbins(),\
187  o.GetXaxis().GetXmin(),\
188  o.GetXaxis().GetXmax(),\
189  o.GetOption() )
190  aida2root(obj).Add(o)
def GaudiMP.pTools.HistoAgent.bookTProfile2D (   self,
  n,
  o 
)
Register a ROOT TProfile2D to the Histo Store

Definition at line 191 of file pTools.py.

192  def bookTProfile2D( self, n, o ) :
193  '''
194  Register a ROOT TProfile2D to the Histo Store
195  '''
196  obj = self.hvt._ihs.bookProf( n, o.GetTitle(),\
197  o.GetXaxis().GetNbins(),\
198  o.GetXaxis().GetXmin(),\
199  o.GetXaxis().GetXmax(),\
200  o.GetYaxis().GetNbins(),\
201  o.GetYaxis().GetXmin(),\
202  o.GetYaxis().GetXmax() )
203  aida2root(obj).Add(o)
204 
205 # =============================================================================
def GaudiMP.pTools.HistoAgent.RebuildHistoStore (   self)
Rebuild the Histogram Store from the histos received by Receive()
If we have a histo which is not in the store,
book and fill it according to self.bookingDict
If we have a histo with a matching histo in the store,
add the two histos, remembering that aida2root must be used on
the Stored histo for compatibility.

Definition at line 89 of file pTools.py.

89 
90  def RebuildHistoStore( self ) :
91  '''
92  Rebuild the Histogram Store from the histos received by Receive()
93  If we have a histo which is not in the store,
94  book and fill it according to self.bookingDict
95  If we have a histo with a matching histo in the store,
96  add the two histos, remembering that aida2root must be used on
97  the Stored histo for compatibility.
98  '''
99  errors = 0
100  for tup in self.histos :
101  workerID, histDict = tup
102  added = 0 ; registered = 0; booked = 0
103 
104  for n in histDict.keys() :
105  o = histDict[ n ]
106  obj = self.hvt.retrieve( n )
107 
108  if obj :
109  try :
110  aida2root(obj).Add(o)
111  except :
112  self.log.warning('FAILED TO ADD : %s'%(str(obj)))
113  errors += 1
114  added += 1
115  else :
116 
117  if o.__class__.__name__ in self.bookingDict.keys() :
118  try :
119  self.bookingDict[o.__class__.__name__](n, o)
120  except :
121  self.log.warning('FAILED TO REGISTER : %s\tto%s'\
122  %(o.__class__.__name__, n))
123  errors += 1
124  else :
125  self.log.warning( 'No booking method for: %s\t%s\t%s'\
126  %(n,type(o),o.__class__.__name__) )
127  errors += 1
128  booked += 1
129  hs = self.hvt.getHistoNames()
130  self.log.info( 'Histo Store Rebuilt : ' )
131  self.log.info( ' Contains %i objects.'%(len(hs)) )
132  self.log.info( ' Errors in Rebuilding : %i'%(errors) )
133  return SUCCESS
134 
def GaudiMP.pTools.HistoAgent.Receive (   self)

Definition at line 74 of file pTools.py.

74 
75  def Receive( self ) :
76  hstatus = self._gmpc.nWorkers+1 # +1 for the Reader!
77  while True :
78  tup = self.qin.get()
79  if tup == 'HISTOS_SENT' :
80  self.log.debug('received HISTOS_SENT message')
81  hstatus -= 1
82  if not hstatus : break
83  else :
84  self.register( tup )
85  self._gmpc.sEvent.set()
86  self.log.info('Writer received all histo bundles and set sync event')
87  return SUCCESS
88 
def GaudiMP.pTools.HistoAgent.register (   self,
  tup 
)

Definition at line 69 of file pTools.py.

69 
70  def register( self, tup ) :
71  # add a tuple of (worker-id, histoDict) to self.histos
72  assert tup.__class__.__name__ == 'tuple'
73  self.histos.append( tup )

Member Data Documentation

GaudiMP.pTools.HistoAgent._gmpc
private

Definition at line 51 of file pTools.py.

GaudiMP.pTools.HistoAgent.bookingDict

Definition at line 59 of file pTools.py.

GaudiMP.pTools.HistoAgent.histos

Definition at line 53 of file pTools.py.

GaudiMP.pTools.HistoAgent.hvt

Definition at line 52 of file pTools.py.

GaudiMP.pTools.HistoAgent.log

Definition at line 55 of file pTools.py.

GaudiMP.pTools.HistoAgent.qin

Definition at line 54 of file pTools.py.


The documentation for this class was generated from the following file:
Generated at Wed Jan 30 2013 17:13:51 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004