ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelBuilderTestConfig.TestAlg Class Reference
Inheritance diagram for TileRawChannelBuilderTestConfig.TestAlg:
Collaboration diagram for TileRawChannelBuilderTestConfig.TestAlg:

Public Member Functions

 __init__ (self, name)
 initialize (self)
 finalize (self)
 execute (self)
 make_digits (self, digits)
 make_digit_coll (self, idHelper, hashFunc, icoll, colldata)
 compare_chans (self, chans, exp_chans)

Static Public Member Functions

 make_vec (data)

Public Attributes

 tool1 = gettool ('tool1')
 tool2 = gettool ('tool2')

Detailed Description

Definition at line 251 of file TileRawChannelBuilderTestConfig.py.

Constructor & Destructor Documentation

◆ __init__()

TileRawChannelBuilderTestConfig.TestAlg.__init__ ( self,
name )

Definition at line 252 of file TileRawChannelBuilderTestConfig.py.

252 def __init__ (self, name):
253 Alg.__init__ (self, name)
254 return
255

Member Function Documentation

◆ compare_chans()

TileRawChannelBuilderTestConfig.TestAlg.compare_chans ( self,
chans,
exp_chans )

Definition at line 363 of file TileRawChannelBuilderTestConfig.py.

363 def compare_chans (self, chans, exp_chans):
364 assert chans.get_type() == 0
365 assert chans.get_unit() == 0
366 assert chans.get_bsflags() == (3<<28)
367
368 exp_chans = exp_chans.copy()
369 idHelper = self.detStore['CaloCell_ID'].tile_idHelper()
370
371 for coll in chans:
372 for c in coll:
373 lchan = [c.amplitude(),
374 c.time(),
375 c.quality(),
376 c.pedestal()]
377
378 cid = c.identify()
379 addr = (idHelper.section(cid),
380 idHelper.side(cid),
381 idHelper.module(cid),
382 idHelper.tower(cid),
383 idHelper.sampling(cid),
384 idHelper.pmt(cid))
385
386 l = exp_chans.get (addr)
387 if not l:
388 print ('xxx unexpected chan', addr, lchan)
389 assert 0
390 continue
391
392 l = l[:]
393
394 if (reldiff (lchan[0], l[0]) > 1e-3 or
395 reldiff (lchan[1], l[1]) > 1e-3 or
396 reldiff (lchan[2], l[2]) > 1e-3 or
397 reldiff (lchan[3], l[3]) > 1e-3):
398 print ('xxx chan mismatch: ', addr, lchan, l)
399 assert 0
400 del exp_chans[addr]
401
402 for extra in exp_chans:
403 print ('xxx unfound chan', extra)
404 assert 0
405 return
406
407
408

◆ execute()

TileRawChannelBuilderTestConfig.TestAlg.execute ( self)

Definition at line 276 of file TileRawChannelBuilderTestConfig.py.

276 def execute (self):
277 ctx = self.getContext()
278 iev = ctx.evt()
279
280 if iev == 3:
281 return StatusCode.Success
282
283 tool = self.tool1
284 exp_chans = exp_chans_0
285
286 if iev == 0:
287 # Event 0: nominal
288 pass
289
290 elif iev == 1:
291 # Event 1: DQstatus bad channels
292 exp_chans = exp_chans_1
293
294 elif iev == 2:
295 # Event 2: noise filter
296 tool = self.tool2
297 exp_chans = exp_chans_2
298
299 else:
300 # Event 3: noise filter + dsp
301 exp_chans = exp_chans_3
302
303 digits = self.make_digits (digits_0)
304
305 if not tool.createContainer(ctx):
306 return StatusCode.Failure
307
308 for coll in digits:
309 if not tool.build (coll, ctx):
310 return StatusCode.Failure
311
312 if not tool.commitContainer(ctx):
313 return StatusCode.Failure
314
315 chans = self.evtStore['TileRawChannelFiltered']
316 self.compare_chans (chans, exp_chans)
317
318 return StatusCode.Success
319
320

◆ finalize()

TileRawChannelBuilderTestConfig.TestAlg.finalize ( self)

Definition at line 271 of file TileRawChannelBuilderTestConfig.py.

271 def finalize (self):
272 # self.check_bad_chan_lines()
273 return StatusCode.Success
274
275

◆ initialize()

TileRawChannelBuilderTestConfig.TestAlg.initialize ( self)

Definition at line 256 of file TileRawChannelBuilderTestConfig.py.

256 def initialize (self):
257 ROOT.ICaloCellMakerTool
258
259 def gettool (name):
260 tool = ROOT.ToolHandle(ROOT.TileRawChannelBuilder)('TileRawChannelBuilderTest/' + name)
261 if not tool.retrieve():
262 assert 0
263 return tool
264
265 self.tool1 = gettool ('tool1')
266 self.tool2 = gettool ('tool2')
267
268 return StatusCode.Success
269
270
void initialize()

◆ make_digit_coll()

TileRawChannelBuilderTestConfig.TestAlg.make_digit_coll ( self,
idHelper,
hashFunc,
icoll,
colldata )

Definition at line 347 of file TileRawChannelBuilderTestConfig.py.

347 def make_digit_coll (self, idHelper, hashFunc, icoll, colldata):
348 coll = ROOT.TileDigitsCollection (hashFunc.identifier(icoll))
349
350 for addr, data in colldata:
351 if isinstance(addr, tuple):
352 adc_id = idHelper.adc_id (*addr)
353 chan = ROOT.TileDigits (adc_id, TestAlg.make_vec (data))
354 else:
355 hwid = ROOT.HWIdentifier (addr)
356 chan = ROOT.TileDigits (hwid, TestAlg.make_vec (data))
357 coll.push_back (chan)
358 ROOT.SetOwnership (chan, False)
359
360 return coll
361
362

◆ make_digits()

TileRawChannelBuilderTestConfig.TestAlg.make_digits ( self,
digits )

Definition at line 330 of file TileRawChannelBuilderTestConfig.py.

330 def make_digits (self, digits):
331 idHelper = self.detStore['CaloCell_ID'].tile_idHelper()
332
333 unit = 0 # TileRawChannelUnit::ADCcounts
334 typ = TileFragHash.Default
335 cont = ROOT.TileDigitsContainer (False, typ, unit)
336 hashFunc = cont.hashFunc()
337
338 for icoll, colldata in digits:
339
340 coll = self.make_digit_coll (idHelper, hashFunc, icoll, colldata)
341 cont.addCollection (coll, ROOT.IdentifierHash(icoll))
342 ROOT.SetOwnership (coll, False)
343
344 return cont
345
346

◆ make_vec()

TileRawChannelBuilderTestConfig.TestAlg.make_vec ( data)
static

Definition at line 322 of file TileRawChannelBuilderTestConfig.py.

322 def make_vec (data):
323 v = getattr(ROOT, 'std::vector<float>')()
324 v.reserve (len (data))
325 for x in data:
326 v.push_back (x)
327 return v
328
329

Member Data Documentation

◆ tool1

TileRawChannelBuilderTestConfig.TestAlg.tool1 = gettool ('tool1')

Definition at line 265 of file TileRawChannelBuilderTestConfig.py.

◆ tool2

TileRawChannelBuilderTestConfig.TestAlg.tool2 = gettool ('tool2')

Definition at line 266 of file TileRawChannelBuilderTestConfig.py.


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