GaudiMP.pTools.HistoAgent Class Reference

Public Member Functions

def __init__ (self, gmpComponent)
 
def register (self, tup)
 
def Receive (self)
 
def RebuildHistoStore (self)
 
def bookDataObject (self, n, o)
 
def bookTH1D (self, n, o)
 
def bookTH2D (self, n, o)
 
def bookTH3D (self, n, o)
 
def bookTProfile (self, n, o)
 
def bookTProfile2D (self, n, o)
 
def __init__ (self, gmpComponent)
 
def register (self, tup)
 
def Receive (self)
 
def RebuildHistoStore (self)
 
def bookDataObject (self, n, o)
 
def bookTH1D (self, n, o)
 
def bookTH2D (self, n, o)
 
def bookTH3D (self, n, o)
 
def bookTProfile (self, n, o)
 
def bookTProfile2D (self, n, o)
 

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  def __init__( self, gmpComponent ) :
51  self._gmpc = gmpComponent
52  self.hvt = self._gmpc.hvt
53  self.histos = []
54  self.qin = self._gmpc.hq
55  self.log = self._gmpc.log
56 
57  # There are many methods for booking Histogram Objects to Histo store
58  # here they are collected in a dictionary, with key = a relevant name
59  self.bookingDict = {}
60  self.bookingDict['DataObject'] = self.bookDataObject
61  self.bookingDict['NTuple::Directory'] = self.bookDataObject
62  self.bookingDict['NTuple::File'] = self.bookDataObject
63  self.bookingDict['TH1D'] = self.bookTH1D
64  self.bookingDict['TH2D'] = self.bookTH2D
65  self.bookingDict['TH3D'] = self.bookTH3D
66  self.bookingDict['TProfile'] = self.bookTProfile
67  self.bookingDict['TProfile2D'] = self.bookTProfile2D
68 
def bookTH2D(self, n, o)
Definition: pTools.py:151
def bookTH1D(self, n, o)
Definition: pTools.py:141
def __init__(self, gmpComponent)
Definition: pTools.py:50
def bookTH3D(self, n, o)
Definition: pTools.py:164
def bookTProfile(self, n, o)
Definition: pTools.py:180
def bookDataObject(self, n, o)
Definition: pTools.py:135
def bookTProfile2D(self, n, o)
Definition: pTools.py:191
def GaudiMP.pTools.HistoAgent.__init__ (   self,
  gmpComponent 
)

Definition at line 50 of file pTools.py.

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

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.

135  def bookDataObject( self, n, o ):
136  '''
137  Register a DataObject to the Histo Store
138  '''
139  self._gmpc.hvt.registerObject( n, o )
140 
def bookDataObject(self, n, o)
Definition: pTools.py:135
def GaudiMP.pTools.HistoAgent.bookDataObject (   self,
  n,
  o 
)
Register a DataObject to the Histo Store

Definition at line 135 of file pTools.py.

135  def bookDataObject( self, n, o ):
136  '''
137  Register a DataObject to the Histo Store
138  '''
139  self._gmpc.hvt.registerObject( n, o )
140 
def bookDataObject(self, n, o)
Definition: pTools.py:135
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.

141  def bookTH1D( self, n, o ) :
142  '''
143  Register a ROOT 1D THisto to the Histo Store
144  '''
145  obj = self.hvt._ihs.book( n, o.GetTitle(),\
146  o.GetXaxis().GetNbins(),\
147  o.GetXaxis().GetXmin(),\
148  o.GetXaxis().GetXmax() )
149  aida2root(obj).Add(o)
150 
def bookTH1D(self, n, o)
Definition: pTools.py:141
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.

141  def bookTH1D( self, n, o ) :
142  '''
143  Register a ROOT 1D THisto to the Histo Store
144  '''
145  obj = self.hvt._ihs.book( n, o.GetTitle(),\
146  o.GetXaxis().GetNbins(),\
147  o.GetXaxis().GetXmin(),\
148  o.GetXaxis().GetXmax() )
149  aida2root(obj).Add(o)
150 
def bookTH1D(self, n, o)
Definition: pTools.py:141
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.

151  def bookTH2D( self, n, o ) :
152  '''
153  Register a ROOT 2D THisto to the Histo Store
154  '''
155  obj = self.hvt._ihs.book( n, o.GetTitle(),\
156  o.GetXaxis().GetNbins(),\
157  o.GetXaxis().GetXmin(),\
158  o.GetXaxis().GetXmax(),\
159  o.GetYaxis().GetNbins(),\
160  o.GetYaxis().GetXmin(),\
161  o.GetYaxis().GetXmax() )
162  aida2root(obj).Add(o)
163 
def bookTH2D(self, n, o)
Definition: pTools.py:151
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.

151  def bookTH2D( self, n, o ) :
152  '''
153  Register a ROOT 2D THisto to the Histo Store
154  '''
155  obj = self.hvt._ihs.book( n, o.GetTitle(),\
156  o.GetXaxis().GetNbins(),\
157  o.GetXaxis().GetXmin(),\
158  o.GetXaxis().GetXmax(),\
159  o.GetYaxis().GetNbins(),\
160  o.GetYaxis().GetXmin(),\
161  o.GetYaxis().GetXmax() )
162  aida2root(obj).Add(o)
163 
def bookTH2D(self, n, o)
Definition: pTools.py:151
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.

164  def bookTH3D( self, n, o ) :
165  '''
166  Register a ROOT 3D THisto to the Histo Store
167  '''
168  obj = self.hvt._ihs.book( n, o.GetTitle(),\
169  o.GetXaxis().GetXbins(),\
170  o.GetXaxis().GetXmin(),\
171  o.GetXaxis().GetXmax(),\
172  o.GetYaxis().GetXbins(),\
173  o.GetYaxis().GetXmin(),\
174  o.GetYaxis().GetXmax(),\
175  o.GetZaxis().GetXbins(),\
176  o.GetZaxis().GetXmin(),\
177  o.GetZaxis().GetXmax() )
178  aida2root(obj).Add(o)
179 
def bookTH3D(self, n, o)
Definition: pTools.py:164
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.

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

Definition at line 180 of file pTools.py.

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

Definition at line 180 of file pTools.py.

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

Definition at line 191 of file pTools.py.

191  def bookTProfile2D( self, n, o ) :
192  '''
193  Register a ROOT TProfile2D to the Histo Store
194  '''
195  obj = self.hvt._ihs.bookProf( n, o.GetTitle(),\
196  o.GetXaxis().GetNbins(),\
197  o.GetXaxis().GetXmin(),\
198  o.GetXaxis().GetXmax(),\
199  o.GetYaxis().GetNbins(),\
200  o.GetYaxis().GetXmin(),\
201  o.GetYaxis().GetXmax() )
202  aida2root(obj).Add(o)
203 
204 # =============================================================================
205 
def bookTProfile2D(self, n, o)
Definition: pTools.py:191
def GaudiMP.pTools.HistoAgent.bookTProfile2D (   self,
  n,
  o 
)
Register a ROOT TProfile2D to the Histo Store

Definition at line 191 of file pTools.py.

191  def bookTProfile2D( self, n, o ) :
192  '''
193  Register a ROOT TProfile2D to the Histo Store
194  '''
195  obj = self.hvt._ihs.bookProf( n, o.GetTitle(),\
196  o.GetXaxis().GetNbins(),\
197  o.GetXaxis().GetXmin(),\
198  o.GetXaxis().GetXmax(),\
199  o.GetYaxis().GetNbins(),\
200  o.GetYaxis().GetXmin(),\
201  o.GetYaxis().GetXmax() )
202  aida2root(obj).Add(o)
203 
204 # =============================================================================
205 
def bookTProfile2D(self, n, o)
Definition: pTools.py:191
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  def RebuildHistoStore( self ) :
90  '''
91  Rebuild the Histogram Store from the histos received by Receive()
92  If we have a histo which is not in the store,
93  book and fill it according to self.bookingDict
94  If we have a histo with a matching histo in the store,
95  add the two histos, remembering that aida2root must be used on
96  the Stored histo for compatibility.
97  '''
98  errors = 0
99  for tup in self.histos :
100  workerID, histDict = tup
101  added = 0 ; registered = 0; booked = 0
102 
103  for n in histDict.keys() :
104  o = histDict[ n ]
105  obj = self.hvt.retrieve( n )
106 
107  if obj :
108  try :
109  aida2root(obj).Add(o)
110  except :
111  self.log.warning('FAILED TO ADD : %s'%(str(obj)))
112  errors += 1
113  added += 1
114  else :
115 
116  if o.__class__.__name__ in self.bookingDict.keys() :
117  try :
118  self.bookingDict[o.__class__.__name__](n, o)
119  except :
120  self.log.warning('FAILED TO REGISTER : %s\tto%s'\
121  %(o.__class__.__name__, n))
122  errors += 1
123  else :
124  self.log.warning( 'No booking method for: %s\t%s\t%s'\
125  %(n,type(o),o.__class__.__name__) )
126  errors += 1
127  booked += 1
128  hs = self.hvt.getHistoNames()
129  self.log.info( 'Histo Store Rebuilt : ' )
130  self.log.info( ' Contains %i objects.'%(len(hs)) )
131  self.log.info( ' Errors in Rebuilding : %i'%(errors) )
132  return SUCCESS
133 
134 
def RebuildHistoStore(self)
Definition: pTools.py:89
string type
Definition: gaudirun.py:151
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  def RebuildHistoStore( self ) :
90  '''
91  Rebuild the Histogram Store from the histos received by Receive()
92  If we have a histo which is not in the store,
93  book and fill it according to self.bookingDict
94  If we have a histo with a matching histo in the store,
95  add the two histos, remembering that aida2root must be used on
96  the Stored histo for compatibility.
97  '''
98  errors = 0
99  for tup in self.histos :
100  workerID, histDict = tup
101  added = 0 ; registered = 0; booked = 0
102 
103  for n in histDict.keys() :
104  o = histDict[ n ]
105  obj = self.hvt.retrieve( n )
106 
107  if obj :
108  try :
109  aida2root(obj).Add(o)
110  except :
111  self.log.warning('FAILED TO ADD : %s'%(str(obj)))
112  errors += 1
113  added += 1
114  else :
115 
116  if o.__class__.__name__ in self.bookingDict.keys() :
117  try :
118  self.bookingDict[o.__class__.__name__](n, o)
119  except :
120  self.log.warning('FAILED TO REGISTER : %s\tto%s'\
121  %(o.__class__.__name__, n))
122  errors += 1
123  else :
124  self.log.warning( 'No booking method for: %s\t%s\t%s'\
125  %(n,type(o),o.__class__.__name__) )
126  errors += 1
127  booked += 1
128  hs = self.hvt.getHistoNames()
129  self.log.info( 'Histo Store Rebuilt : ' )
130  self.log.info( ' Contains %i objects.'%(len(hs)) )
131  self.log.info( ' Errors in Rebuilding : %i'%(errors) )
132  return SUCCESS
133 
134 
def RebuildHistoStore(self)
Definition: pTools.py:89
string type
Definition: gaudirun.py:151
def GaudiMP.pTools.HistoAgent.Receive (   self)

Definition at line 74 of file pTools.py.

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

Definition at line 74 of file pTools.py.

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

Definition at line 69 of file pTools.py.

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

Definition at line 69 of file pTools.py.

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

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: