The Gaudi Framework  v36r6 (b1ee9983)
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 152 of file pTools.py.

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

◆ bookTH1D()

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

Definition at line 158 of file pTools.py.

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

◆ bookTH2D()

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

Definition at line 171 of file pTools.py.

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

◆ bookTH3D()

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

Definition at line 187 of file pTools.py.

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

◆ bookTProfile()

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

Definition at line 206 of file pTools.py.

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

◆ bookTProfile2D()

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

Definition at line 220 of file pTools.py.

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

◆ 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  registered = 0
115  booked = 0
116 
117  for n in histDict.keys():
118  o = histDict[n]
119  obj = self.hvt.retrieve(n)
120 
121  if obj:
122  try:
123  aida2root(obj).Add(o)
124  except:
125  self.log.warning("FAILED TO ADD : %s" % (str(obj)))
126  errors += 1
127  added += 1
128  else:
129 
130  if o.__class__.__name__ in self.bookingDict.keys():
131  try:
132  self.bookingDict[o.__class__.__name__](n, o)
133  except:
134  self.log.warning(
135  "FAILED TO REGISTER : %s\tto%s"
136  % (o.__class__.__name__, n)
137  )
138  errors += 1
139  else:
140  self.log.warning(
141  "No booking method for: %s\t%s\t%s"
142  % (n, type(o), o.__class__.__name__)
143  )
144  errors += 1
145  booked += 1
146  hs = self.hvt.getHistoNames()
147  self.log.info("Histo Store Rebuilt : ")
148  self.log.info(" Contains %i objects." % (len(hs)))
149  self.log.info(" Errors in Rebuilding : %i" % (errors))
150  return SUCCESS
151 

◆ 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:
GaudiMP.pTools.aida2root
aida2root
Definition: pTools.py:56
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:444
gaudirun.type
type
Definition: gaudirun.py:160
StringKeyEx.keys
list keys
Definition: StringKeyEx.py:67