ATLAS Offline Software
Functions | Variables
python.trigbs_prescaleL1 Namespace Reference

Functions

def loadPrescales (config)
 
def modify_general (**kwargs)
 

Variables

 prescales
 
 log
 
 kwargs
 
 ost
 
 new_event
 

Function Documentation

◆ loadPrescales()

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

Definition at line 27 of file trigbs_prescaleL1.py.

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

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

Definition at line 40 of file trigbs_prescaleL1.py.

40 def 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

python.trigbs_prescaleL1.kwargs

Definition at line 98 of file trigbs_prescaleL1.py.

◆ log

python.trigbs_prescaleL1.log

Definition at line 24 of file trigbs_prescaleL1.py.

◆ new_event

python.trigbs_prescaleL1.new_event

Definition at line 107 of file trigbs_prescaleL1.py.

◆ ost

python.trigbs_prescaleL1.ost

Definition at line 104 of file trigbs_prescaleL1.py.

◆ prescales

python.trigbs_prescaleL1.prescales

Definition at line 23 of file trigbs_prescaleL1.py.

CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.trigbs_prescaleL1.loadPrescales
def loadPrescales(config)
Definition: trigbs_prescaleL1.py:27
python.trigbs_prescaleL1.modify_general
def modify_general(**kwargs)
Definition: trigbs_prescaleL1.py:40
python.utils.AtlRunQueryTriggerUtils.getL1Prescales
def getL1Prescales(l1prescalekey, run_number)
Definition: AtlRunQueryTriggerUtils.py:562
str
Definition: BTagTrackIpAccessor.cxx:11