ATLAS Offline Software
Loading...
Searching...
No Matches
python.trigbs_prescaleL1 Namespace Reference

Functions

 loadPrescales (config)
 modify_general (**kwargs)

Variables

 prescales = None
 log = logging.getLogger('trigbs_prescaleL1.py')
dict kwargs
 ost = eformat.ostream()
 new_event = modify_general(**kwargs)

Detailed Description

Module for applying L1 prescales to the input data

Used as a "-Z" plugin to athenaHLT:
athenaHLT -Z TrigByteStreamTools.trigbs_prescaleL1 ...

Function Documentation

◆ loadPrescales()

python.trigbs_prescaleL1.loadPrescales ( config)
Load L1 prescales from DB

Definition at line 27 of file trigbs_prescaleL1.py.

27def loadPrescales(config):
28 """Load L1 prescales from DB"""
29
30 database = config['db-server']
31 l1psk = int(config['db-extra']['lvl1key'])
32
33 log.info('Applying L1 prescale set %s from %s', l1psk, database)
34 from TrigConfigSvc.TrigConfigSvcUtils import getL1Prescales
35 name, prescales = getL1Prescales(database,l1psk)
36 log.debug('Prescales: %s', str(prescales))
37 return prescales
38
39

◆ modify_general()

python.trigbs_prescaleL1.modify_general ( ** kwargs)
Prescale L1 items in CTP fragment used by HLT

Definition at line 40 of file trigbs_prescaleL1.py.

40def modify_general(**kwargs):
41 """Prescale L1 items in CTP fragment used by HLT"""
42 global prescales
43
44 if prescales is None:
45 prescales = loadPrescales(kwargs['configuration'])
46
47 event = kwargs["event"]
48
49 # Set seed based on event time stamp to make it reproducible
50 seed = '%s%s' % (event.bc_time_seconds(),event.bc_time_nanoseconds())
51 random.seed(zlib.crc32(seed))
52
53 new_event=eformat.write.FullEventFragment()
54 new_event.copy_header(event)
55 for rob in event:
56 if rob.source_id()!=eformat.helper.SourceIdentifier(eformat.helper.SubDetector.TDAQ_CTP,1):
57 new_event.append_unchecked(rob)
58 else:
59 data = [d for d in rob.rod_data()]
60 v = CTPfragment.ctpFormatVersion(rob)
61 TBPpos = CTPfragment._versioned(CTPdataformat,'TBPpos',v)
62 TBPwords = CTPfragment._versioned(CTPdataformat,'TBPwords',v)
63 TAVpos = CTPfragment._versioned(CTPdataformat,'TAVpos',v)
64
65 L1TBP = CTPfragment.decodeTriggerBits(data[TBPpos:TBPpos+TBPwords])
66 log.debug('L1TBP: %s', L1TBP)
67 newL1TAV = []
68 for ctp in L1TBP:
69 if prescales[ctp]<=0:
70 continue
71 if random.uniform(0,prescales[ctp])>1:
72 continue
73 newL1TAV.append(ctp)
74
75 log.debug('New L1TAV: %s', newL1TAV)
76 newL1TAVBits = CTPfragment.encodeTriggerBits(newL1TAV,TBPwords)
77 for i,value in enumerate(newL1TAVBits):
78 data[TAVpos+i] = value
79
80 # Write new CTP ROB
81 newrob = eformat.write.ROBFragment(rob)
82 newrob.rod_data(data)
83 new_event.append(newrob)
84 # Update event header
85 l1bits = [b for b in event.lvl1_trigger_info()]
86 new_event.lvl1_trigger_info(l1bits[0:TBPwords]+data[TAVpos:TAVpos+TBPwords]*2)
87
88 return new_event.readonly()
89
90
91

Variable Documentation

◆ kwargs

dict python.trigbs_prescaleL1.kwargs
Initial value:
1= {'configuration' : {'db-server':'TRIGGERDB_RUN1',
2 'db-extra' : {'lvl1key' : 300}}}

Definition at line 98 of file trigbs_prescaleL1.py.

◆ log

python.trigbs_prescaleL1.log = logging.getLogger('trigbs_prescaleL1.py')

Definition at line 24 of file trigbs_prescaleL1.py.

◆ new_event

python.trigbs_prescaleL1.new_event = modify_general(**kwargs)

Definition at line 107 of file trigbs_prescaleL1.py.

◆ ost

python.trigbs_prescaleL1.ost = eformat.ostream()

Definition at line 104 of file trigbs_prescaleL1.py.

◆ prescales

python.trigbs_prescaleL1.prescales = None

Definition at line 23 of file trigbs_prescaleL1.py.