The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
GaudiMP.pTools.HistoAgent Class Reference

Public Member Functions

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

Public Attributes

 hvt = self._gmpc.hvt
list histos = []
 qin = self._gmpc.hq
 log = self._gmpc.log
dict bookingDict = {}

Protected Attributes

 _gmpc = gmpComponent

Detailed Description

Definition at line 61 of file pTools.py.

Constructor & Destructor Documentation

◆ __init__()

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()

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

Definition at line 148 of file pTools.py.

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

◆ bookTH1D()

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

Definition at line 154 of file pTools.py.

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

◆ bookTH2D()

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

Definition at line 167 of file pTools.py.

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

◆ bookTH3D()

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

Definition at line 183 of file pTools.py.

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

◆ bookTProfile()

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

Definition at line 202 of file pTools.py.

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

◆ bookTProfile2D()

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

Definition at line 216 of file pTools.py.

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

◆ RebuildHistoStore()

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(f"FAILED TO ADD : {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 f"FAILED TO REGISTER : {o.__class__.__name__}\tto{n}"
134 )
135 errors += 1
136 else:
137 self.log.warning(
138 f"No booking method for: {n}\t{type(o)}\t{o.__class__.__name__}"
139 )
140 errors += 1
141 booked += 1
142 hs = self.hvt.getHistoNames()
143 self.log.info("Histo Store Rebuilt : ")
144 self.log.info(f" Contains {len(hs)} objects.")
145 self.log.info(f" Errors in Rebuilding : {errors}")
146 return SUCCESS
147

◆ Receive()

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()

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 = gmpComponent
protected

Definition at line 63 of file pTools.py.

◆ bookingDict

dict GaudiMP.pTools.HistoAgent.bookingDict = {}

Definition at line 71 of file pTools.py.

◆ histos

list GaudiMP.pTools.HistoAgent.histos = []

Definition at line 65 of file pTools.py.

◆ hvt

GaudiMP.pTools.HistoAgent.hvt = self._gmpc.hvt

Definition at line 64 of file pTools.py.

◆ log

GaudiMP.pTools.HistoAgent.log = self._gmpc.log

Definition at line 67 of file pTools.py.

◆ qin

GaudiMP.pTools.HistoAgent.qin = self._gmpc.hq

Definition at line 66 of file pTools.py.


The documentation for this class was generated from the following file: