| The Gaudi Framework v32r1 (f65d50dc)

Public Member Functions | Public Attributes | Private Attributes | List of all members
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 50 of file pTools.py.

## Constructor & Destructor Documentation

## ◆ __init__()

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

Definition at line 51 of file pTools.py.

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
69

## Member Function Documentation

## ◆ bookDataObject()

def GaudiMP.pTools.HistoAgent.bookDataObject | ( |  | self,
|  |  | n,
|  |  | o
| ) |  |

    Register a DataObject to the Histo Store

Definition at line 137 of file pTools.py.

137 def bookDataObject(self, n, o):
138 '''
139 Register a DataObject to the Histo Store
140 '''
141 self._gmpc.hvt.registerObject(n, o)
142

## ◆ bookTH1D()

def GaudiMP.pTools.HistoAgent.bookTH1D | ( |  | self,
|  |  | n,
|  |  | o
| ) |  |

    Register a ROOT 1D THisto to the Histo Store

Definition at line 143 of file pTools.py.

143 def bookTH1D(self, n, o):
144 '''
145 Register a ROOT 1D THisto to the Histo Store
146 '''
147 obj = self.hvt._ihs.book(n, o.GetTitle(),
148 o.GetXaxis().GetNbins(),
149 o.GetXaxis().GetXmin(),
150 o.GetXaxis().GetXmax())
151 aida2root(obj).Add(o)
152
GaudiMP.pTools.aida2root
aida2root
Definition: pTools.py:45

## ◆ bookTH2D()

def GaudiMP.pTools.HistoAgent.bookTH2D | ( |  | self,
|  |  | n,
|  |  | o
| ) |  |

    Register a ROOT 2D THisto to the Histo Store

Definition at line 153 of file pTools.py.

153 def bookTH2D(self, n, o):
154 '''
155 Register a ROOT 2D THisto to the Histo Store
156 '''
157 obj = self.hvt._ihs.book(n, o.GetTitle(),
158 o.GetXaxis().GetNbins(),
159 o.GetXaxis().GetXmin(),
160 o.GetXaxis().GetXmax(),
161 o.GetYaxis().GetNbins(),
162 o.GetYaxis().GetXmin(),
163 o.GetYaxis().GetXmax())
164 aida2root(obj).Add(o)
165
GaudiMP.pTools.aida2root
aida2root
Definition: pTools.py:45

## ◆ bookTH3D()

def GaudiMP.pTools.HistoAgent.bookTH3D | ( |  | self,
|  |  | n,
|  |  | o
| ) |  |

    Register a ROOT 3D THisto to the Histo Store

Definition at line 166 of file pTools.py.

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

## ◆ bookTProfile()

def GaudiMP.pTools.HistoAgent.bookTProfile | ( |  | self,
|  |  | n,
|  |  | o
| ) |  |

    Register a ROOT TProfile to the Histo Store

Definition at line 182 of file pTools.py.

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

## ◆ bookTProfile2D()

def GaudiMP.pTools.HistoAgent.bookTProfile2D | ( |  | self,
|  |  | n,
|  |  | o
| ) |  |

    Register a ROOT TProfile2D to the Histo Store

Definition at line 192 of file pTools.py.

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

## ◆ 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 90 of file pTools.py.

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
103 registered = 0
104 booked = 0
105
106 for n in histDict.keys():
107 o = histDict[n]
108 obj = self.hvt.retrieve(n)
109
110 if obj:
111 try:
112 aida2root(obj).Add(o)
113 except:
114 self.log.warning('FAILED TO ADD : %s' % (str(obj)))
115 errors += 1
116 added += 1
117 else:
118
119 if o.__class__.__name__ in self.bookingDict.keys():
120 try:
121 self.bookingDict[o.__class__.__name__](n, o)
122 except:
123 self.log.warning('FAILED TO REGISTER : %s\tto%s' %
124 (o.__class__.__name__, n))
125 errors += 1
126 else:
127 self.log.warning('No booking method for: %s\t%s\t%s' %
128 (n, type(o), o.__class__.__name__))
129 errors += 1
130 booked += 1
131 hs = self.hvt.getHistoNames()
132 self.log.info('Histo Store Rebuilt : ')
133 self.log.info(' Contains %i objects.' % (len(hs)))
134 self.log.info(' Errors in Rebuilding : %i' % (errors))
135 return SUCCESS
136
gaudirun.type
type
Definition: gaudirun.py:142
GaudiMP.pTools.aida2root
aida2root
Definition: pTools.py:45

## ◆ Receive()

def GaudiMP.pTools.HistoAgent.Receive | ( |  | self | ) |

Definition at line 75 of file pTools.py.

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:
83 break
84 else:
85 self.register(tup)
86 self._gmpc.sEvent.set()
87 self.log.info('Writer received all histo bundles and set sync event')
88 return SUCCESS
89
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:332

## ◆ register()

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

Definition at line 70 of file pTools.py.

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

## Member Data Documentation

## ◆ _gmpc

GaudiMP.pTools.HistoAgent._gmpc
| private

Definition at line 52 of file pTools.py.

## ◆ bookingDict

GaudiMP.pTools.HistoAgent.bookingDict

Definition at line 60 of file pTools.py.

## ◆ histos

GaudiMP.pTools.HistoAgent.histos

Definition at line 54 of file pTools.py.

## ◆ hvt

GaudiMP.pTools.HistoAgent.hvt

Definition at line 53 of file pTools.py.

## ◆ log

GaudiMP.pTools.HistoAgent.log

Definition at line 56 of file pTools.py.

## ◆ qin

GaudiMP.pTools.HistoAgent.qin

Definition at line 55 of file pTools.py.

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

- GaudiMP/python/GaudiMP/pTools.py