The Gaudi Framework  master (594c33fa)
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)
 

Public Attributes

 hvt
 
 histos
 
 qin
 
 log
 
 bookingDict
 

Private Attributes

 _gmpc
 

Detailed Description

Definition at line 61 of file pTools.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 62 of file pTools.py.

62  def __init__(self, gmpComponent):
63  self._gmpc = gmpComponent
64  self.hvt = self._gmpc.hvt
65  self.histos = []
66  self.qin = self._gmpc.hq
67  self.log = self._gmpc.log
68 
69  # There are many methods for booking Histogram Objects to Histo store
70  # here they are collected in a dictionary, with key = a relevant name
71  self.bookingDict = {}
72  self.bookingDict["DataObject"] = self.bookDataObject
73  self.bookingDict["NTuple::Directory"] = self.bookDataObject
74  self.bookingDict["NTuple::File"] = self.bookDataObject
75  self.bookingDict["TH1D"] = self.bookTH1D
76  self.bookingDict["TH2D"] = self.bookTH2D
77  self.bookingDict["TH3D"] = self.bookTH3D
78  self.bookingDict["TProfile"] = self.bookTProfile
79  self.bookingDict["TProfile2D"] = self.bookTProfile2D
80 

Member Function Documentation

◆ bookDataObject()

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

Definition at line 150 of file pTools.py.

150  def bookDataObject(self, n, o):
151  """
152  Register a DataObject to the Histo Store
153  """
154  self._gmpc.hvt.registerObject(n, o)
155 

◆ bookTH1D()

def GaudiMP.pTools.HistoAgent.bookTH1D (   self,
  n,
  o 
)
Register a ROOT 1D THisto to the Histo Store

Definition at line 156 of file pTools.py.

156  def bookTH1D(self, n, o):
157  """
158  Register a ROOT 1D THisto to the Histo Store
159  """
160  obj = self.hvt._ihs.book(
161  n,
162  o.GetTitle(),
163  o.GetXaxis().GetNbins(),
164  o.GetXaxis().GetXmin(),
165  o.GetXaxis().GetXmax(),
166  )
167  aida2root(obj).Add(o)
168 

◆ bookTH2D()

def GaudiMP.pTools.HistoAgent.bookTH2D (   self,
  n,
  o 
)
Register a ROOT 2D THisto to the Histo Store

Definition at line 169 of file pTools.py.

169  def bookTH2D(self, n, o):
170  """
171  Register a ROOT 2D THisto to the Histo Store
172  """
173  obj = self.hvt._ihs.book(
174  n,
175  o.GetTitle(),
176  o.GetXaxis().GetNbins(),
177  o.GetXaxis().GetXmin(),
178  o.GetXaxis().GetXmax(),
179  o.GetYaxis().GetNbins(),
180  o.GetYaxis().GetXmin(),
181  o.GetYaxis().GetXmax(),
182  )
183  aida2root(obj).Add(o)
184 

◆ bookTH3D()

def GaudiMP.pTools.HistoAgent.bookTH3D (   self,
  n,
  o 
)
Register a ROOT 3D THisto to the Histo Store

Definition at line 185 of file pTools.py.

185  def bookTH3D(self, n, o):
186  """
187  Register a ROOT 3D THisto to the Histo Store
188  """
189  obj = self.hvt._ihs.book(
190  n,
191  o.GetTitle(),
192  o.GetXaxis().GetXbins(),
193  o.GetXaxis().GetXmin(),
194  o.GetXaxis().GetXmax(),
195  o.GetYaxis().GetXbins(),
196  o.GetYaxis().GetXmin(),
197  o.GetYaxis().GetXmax(),
198  o.GetZaxis().GetXbins(),
199  o.GetZaxis().GetXmin(),
200  o.GetZaxis().GetXmax(),
201  )
202  aida2root(obj).Add(o)
203 

◆ bookTProfile()

def GaudiMP.pTools.HistoAgent.bookTProfile (   self,
  n,
  o 
)
Register a ROOT TProfile to the Histo Store

Definition at line 204 of file pTools.py.

204  def bookTProfile(self, n, o):
205  """
206  Register a ROOT TProfile to the Histo Store
207  """
208  obj = self.hvt._ihs.bookProf(
209  n,
210  o.GetTitle(),
211  o.GetXaxis().GetNbins(),
212  o.GetXaxis().GetXmin(),
213  o.GetXaxis().GetXmax(),
214  o.GetOption(),
215  )
216  aida2root(obj).Add(o)
217 

◆ bookTProfile2D()

def GaudiMP.pTools.HistoAgent.bookTProfile2D (   self,
  n,
  o 
)
Register a ROOT TProfile2D to the Histo Store

Definition at line 218 of file pTools.py.

218  def bookTProfile2D(self, n, o):
219  """
220  Register a ROOT TProfile2D to the Histo Store
221  """
222  obj = self.hvt._ihs.bookProf(
223  n,
224  o.GetTitle(),
225  o.GetXaxis().GetNbins(),
226  o.GetXaxis().GetXmin(),
227  o.GetXaxis().GetXmax(),
228  o.GetYaxis().GetNbins(),
229  o.GetYaxis().GetXmin(),
230  o.GetYaxis().GetXmax(),
231  )
232  aida2root(obj).Add(o)
233 
234 
235 # =============================================================================
236 
237 

◆ RebuildHistoStore()

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 101 of file pTools.py.

101  def RebuildHistoStore(self):
102  """
103  Rebuild the Histogram Store from the histos received by Receive()
104  If we have a histo which is not in the store,
105  book and fill it according to self.bookingDict
106  If we have a histo with a matching histo in the store,
107  add the two histos, remembering that aida2root must be used on
108  the Stored histo for compatibility.
109  """
110  errors = 0
111  for tup in self.histos:
112  workerID, histDict = tup
113  added = 0
114  booked = 0
115 
116  for n in histDict.keys():
117  o = histDict[n]
118  obj = self.hvt.retrieve(n)
119 
120  if obj:
121  try:
122  aida2root(obj).Add(o)
123  except Exception:
124  self.log.warning("FAILED TO ADD : %s" % (str(obj)))
125  errors += 1
126  added += 1
127  else:
128  if o.__class__.__name__ in self.bookingDict.keys():
129  try:
130  self.bookingDict[o.__class__.__name__](n, o)
131  except Exception:
132  self.log.warning(
133  "FAILED TO REGISTER : %s\tto%s"
134  % (o.__class__.__name__, n)
135  )
136  errors += 1
137  else:
138  self.log.warning(
139  "No booking method for: %s\t%s\t%s"
140  % (n, type(o), o.__class__.__name__)
141  )
142  errors += 1
143  booked += 1
144  hs = self.hvt.getHistoNames()
145  self.log.info("Histo Store Rebuilt : ")
146  self.log.info(" Contains %i objects." % (len(hs)))
147  self.log.info(" Errors in Rebuilding : %i" % (errors))
148  return SUCCESS
149 

◆ Receive()

def GaudiMP.pTools.HistoAgent.Receive (   self)

Definition at line 86 of file pTools.py.

86  def Receive(self):
87  hstatus = self._gmpc.nWorkers + 1 # +1 for the Reader!
88  while True:
89  tup = self.qin.get()
90  if tup == "HISTOS_SENT":
91  self.log.debug("received HISTOS_SENT message")
92  hstatus -= 1
93  if not hstatus:
94  break
95  else:
96  self.register(tup)
97  self._gmpc.sEvent.set()
98  self.log.info("Writer received all histo bundles and set sync event")
99  return SUCCESS
100 

◆ register()

def GaudiMP.pTools.HistoAgent.register (   self,
  tup 
)

Definition at line 81 of file pTools.py.

81  def register(self, tup):
82  # add a tuple of (worker-id, histoDict) to self.histos
83  assert tup.__class__.__name__ == "tuple"
84  self.histos.append(tup)
85 

Member Data Documentation

◆ _gmpc

GaudiMP.pTools.HistoAgent._gmpc
private

Definition at line 63 of file pTools.py.

◆ bookingDict

GaudiMP.pTools.HistoAgent.bookingDict

Definition at line 71 of file pTools.py.

◆ histos

GaudiMP.pTools.HistoAgent.histos

Definition at line 65 of file pTools.py.

◆ hvt

GaudiMP.pTools.HistoAgent.hvt

Definition at line 64 of file pTools.py.

◆ log

GaudiMP.pTools.HistoAgent.log

Definition at line 67 of file pTools.py.

◆ qin

GaudiMP.pTools.HistoAgent.qin

Definition at line 66 of file pTools.py.


The documentation for this class was generated from the following file:
GaudiPartProp.decorators.get
get
decorate the vector of properties
Definition: decorators.py:283
GaudiMP.pTools.aida2root
aida2root
Definition: pTools.py:56
gaudirun.type
type
Definition: gaudirun.py:160
StringKeyEx.keys
keys
Definition: StringKeyEx.py:64