Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 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 132 of file pTools.py.

133  def bookDataObject( self, n, o ):
134  '''
135  Register a DataObject to the Histo Store
136  '''
137  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 138 of file pTools.py.

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

Definition at line 148 of file pTools.py.

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

Definition at line 161 of file pTools.py.

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

Definition at line 177 of file pTools.py.

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

Definition at line 188 of file pTools.py.

189  def bookTProfile2D( self, n, o ) :
190  '''
191  Register a ROOT TProfile2D to the Histo Store
192  '''
193  obj = self.hvt._ihs.bookProf( n, o.GetTitle(),\
194  o.GetXaxis().GetNbins(),\
195  o.GetXaxis().GetXmin(),\
196  o.GetXaxis().GetXmax(),\
197  o.GetYaxis().GetNbins(),\
198  o.GetYaxis().GetXmin(),\
199  o.GetYaxis().GetXmax() )
200  aida2root(obj).Add(o)
201 
202 # =============================================================================
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  for n in histDict.keys() :
104  o = histDict[ n ]
105  obj = self.hvt.retrieve( n )
106  if obj :
107  try :
108  aida2root(obj).Add(o)
109  except :
110  self.log.warning('FAILED TO ADD : %s'%(str(obj)))
111  errors += 1
112  added += 1
113  else :
114  if o.__class__.__name__ in self.bookingDict.keys() :
115  try :
116  self.bookingDict[o.__class__.__name__](n, o)
117  except :
118  self.log.warning('FAILED TO REGISTER : %s\tto%s'\
119  %(o.__class__.__name__, n))
120  errors += 1
121  else :
122  self.log.warning( 'No booking method for: %s\t%s\t%s'\
123  %(n,type(o),o.__class__.__name__) )
124  errors += 1
125  booked += 1
126  hs = self.hvt.getHistoNames()
127  self.log.info( 'Histo Store Rebuilt : ' )
128  self.log.info( ' Contains %i objects.'%(len(hs)) )
129  self.log.info( ' Errors in Rebuilding : %i'%(errors) )
130  return SUCCESS
131 
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 Nov 28 2012 12:17:39 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004