ATLAS Offline Software
Functions | Variables
ExtractEBRunDetails Namespace Reference

Functions

def readTimestampsOfLb (runNumber, lbStart=-1, lbEnd=-1)
 
def readDeadtimeFromIS (startOfRun, endOfRun, server="https://atlasop.cern.ch")
 
def getPhysicsDeadtimePerLB (startOfRun, endOfRun, lbRangesDict, itemName="L1_TAU8--enabled", server="https://atlasop.cern.ch")
 
def createDeadtimeNode (xmlRoot, totalDeadtime)
 
def createFiltersNodes (xmlRoot, chainsDict)
 
def createLumiBlockNodes (xmlRoot, runNumber, lbStart, lbEnd, deadTimeData)
 
def createLbNode (xmlRoot, lbId, lumi, mu, nEvents, avgDeadtime)
 
def createBunchGroupNodes (xmlRoot, key, db)
 
def createBgNode (xmlRoot, bgId, name, length)
 

Variables

 log
 
 parser
 
 type
 
 int
 
 default
 
 help
 
 str
 
 nargs
 
 args
 
 flags
 
 runNumber
 
 lumiblocks
 
 bsfile
 
 event
 
 configKeys
 
 root
 
 xml
 
 lbRanges
 
 startOfRun
 
 endOfRun
 
 lumiValNode
 
 bgNode
 
 deadTimeData
 
 lumiNode
 
 filename
 
 xml_str
 
 indent
 

Function Documentation

◆ createBgNode()

def ExtractEBRunDetails.createBgNode (   xmlRoot,
  bgId,
  name,
  length 
)

Definition at line 200 of file ExtractEBRunDetails.py.

200 def createBgNode(xmlRoot, bgId, name, length):
201  bgNode = xmlRoot.createElement('bunchgroup')
202  bgNode.setAttribute('id', str(bgId))
203  bgNode.setAttribute('name', name)
204  bgNode.appendChild(xmlRoot.createTextNode(str(length)))
205 
206  return bgNode
207 
208 

◆ createBunchGroupNodes()

def ExtractEBRunDetails.createBunchGroupNodes (   xmlRoot,
  key,
  db 
)

Definition at line 181 of file ExtractEBRunDetails.py.

181 def createBunchGroupNodes(xmlRoot, key, db):
182  from TrigConfIO.L1TriggerConfigAccess import BunchGroupSetAccess
183  bgset = BunchGroupSetAccess(dbalias = db, bgskey = key)
184 
185  bgNodeList = xmlRoot.createElement('bunchgroups')
186  for bunchgroup in bgset["bunchGroups"]:
187  bgLength = 0
188  for entry in bgset["bunchGroups"][bunchgroup]["bcids"]:
189  bgLength += entry["length"]
190 
191  bgNode = createBgNode(xmlRoot, bgset["bunchGroups"][bunchgroup]["id"], bgset["bunchGroups"][bunchgroup]["name"], bgLength)
192  bgNodeList.appendChild(bgNode)
193 
194  log.debug("Bunchgroup {0} length: {1}".format(bgset["bunchGroups"][bunchgroup]["name"], bgLength))
195 
196  return bgNodeList
197 
198 
199 # Create a node for a single bunchgroup entry

◆ createDeadtimeNode()

def ExtractEBRunDetails.createDeadtimeNode (   xmlRoot,
  totalDeadtime 
)

Definition at line 110 of file ExtractEBRunDetails.py.

110 def createDeadtimeNode(xmlRoot, totalDeadtime):
111  lumiValNode = xmlRoot.createElement('lumivalues')
112 
113  deadtimeNode = xmlRoot.createElement('deadtime')
114  deadtimeNode.appendChild(xmlRoot.createTextNode(str(round(totalDeadtime, 3))))
115 
116  lumiValNode.appendChild(deadtimeNode)
117 
118  return lumiValNode
119 
120 
121 # Parse constructed chains and their seeds dictionary into xml tree

◆ createFiltersNodes()

def ExtractEBRunDetails.createFiltersNodes (   xmlRoot,
  chainsDict 
)

Definition at line 122 of file ExtractEBRunDetails.py.

122 def createFiltersNodes(xmlRoot, chainsDict):
123  filters = xmlRoot.createElement('filters')
124  for chain in chainsDict:
125  f = xmlRoot.createElement('filter')
126  fname = xmlRoot.createElement('filter_name')
127  fname.appendChild(xmlRoot.createTextNode(chain))
128  f.appendChild(fname)
129 
130  for item in chainsDict[chain]:
131  itemNode = xmlRoot.createElement('lv1_filter')
132  itemNode.appendChild(xmlRoot.createTextNode(item))
133  f.appendChild(itemNode)
134 
135  filters.appendChild(f)
136 
137  return filters
138 
139 # Save lumiblock details for each lumi block lumi, pileup, nevents from COOL database

◆ createLbNode()

def ExtractEBRunDetails.createLbNode (   xmlRoot,
  lbId,
  lumi,
  mu,
  nEvents,
  avgDeadtime 
)

Definition at line 169 of file ExtractEBRunDetails.py.

169 def createLbNode(xmlRoot, lbId, lumi, mu, nEvents, avgDeadtime):
170  l = xmlRoot.createElement('lb')
171  l.setAttribute('id', str(lbId))
172  l.setAttribute('lumi', str(round(lumi, 3 if lumi > 1 else 6)))
173  l.setAttribute('mu', str(round(mu, 3 if mu > 1 else 6)))
174  l.setAttribute('deadtime', str(round(avgDeadtime, 3)))
175  l.appendChild(xmlRoot.createTextNode(str(nEvents)))
176 
177  return l
178 
179 
180 # Save bunchgroup set details

◆ createLumiBlockNodes()

def ExtractEBRunDetails.createLumiBlockNodes (   xmlRoot,
  runNumber,
  lbStart,
  lbEnd,
  deadTimeData 
)

Definition at line 140 of file ExtractEBRunDetails.py.

140 def createLumiBlockNodes(xmlRoot, runNumber, lbStart, lbEnd, deadTimeData):
141  from PyCool import cool
142  from TrigConfStorage.TriggerCoolUtil import TriggerCoolUtil
143  db = TriggerCoolUtil.GetConnection('CONDBR2')
144  folder = db.getFolder("/TRIGGER/LUMI/OnlPrefLumi")
145  folderIterator = folder.browseObjects(RunLumi(runNumber, lbStart), RunLumi(runNumber, lbEnd), cool.ChannelSelection())
146 
147  # Read number of events for each lumiblock
148  from CoolRunQuery.AtlRunQuerySFO import GetSFO_NeventsAll
149  from CoolRunQuery.utils.AtlRunQueryUtils import coolDbConn
150  cursor = coolDbConn.GetSFODBConnection().cursor()
151  nEventsPerLB = dict(GetSFO_NeventsAll(cursor, [runNumber])[runNumber]['physics_EnhancedBias'])
152 
153  lbNodeList = xmlRoot.createElement('lb_list')
154 
155  i=lbStart
156  while folderIterator.goToNext():
157  payload=folderIterator.currentRef().payload()
158  nEvents = nEventsPerLB[i] if i in nEventsPerLB else 0
159  lbNode = createLbNode(xmlRoot, i, payload["LBAvInstLumi"], payload["LBAvEvtsPerBX"], nEvents, deadTimeData[i])
160  lbNodeList.appendChild(lbNode)
161  log.debug("Lumiblock {0} lumi {1} pileup {2} events {3}".format(i, payload["LBAvInstLumi"], payload["LBAvEvtsPerBX"], nEvents))
162 
163  i+=1
164 
165  return lbNodeList
166 
167 
168 # Create a node for a single lumiblock entry

◆ getPhysicsDeadtimePerLB()

def ExtractEBRunDetails.getPhysicsDeadtimePerLB (   startOfRun,
  endOfRun,
  lbRangesDict,
  itemName = "L1_TAU8--enabled",
  server = "https://atlasop.cern.ch" 
)

Definition at line 77 of file ExtractEBRunDetails.py.

77 def getPhysicsDeadtimePerLB(startOfRun, endOfRun, lbRangesDict, itemName="L1_TAU8--enabled", server="https://atlasop.cern.ch"): try:
78  import libpbeastpy
79  pbeast = libpbeastpy.ServerProxy(server)
80  physicsDT = pbeast.get_data('ATLAS', 'L1_Rate', 'DT', 'ISS_TRP.' + itemName, False, startOfRun, endOfRun, 0, True)[0].data['ISS_TRP.' + itemName]
81 
82  entryCounter = 1
83  deadtimePerLb = {}
84  for lbRange in lbRangesDict:
85  avgDt = 0
86  counter = 0
87  while physicsDT[entryCounter].ts > lbRangesDict[lbRange]["start"] and physicsDT[entryCounter].ts < lbRangesDict[lbRange]["end"]:
88  if type(physicsDT[entryCounter].value) is not float: # None type
89  entryCounter += 1
90  continue
91  avgDt += physicsDT[entryCounter].value
92  counter += 1
93  entryCounter += 1
94 
95  deadtimePerLb[lbRange] = avgDt/counter if counter > 0 else 1.
96 
97  return deadtimePerLb
98 
99  except ImportError:
100  log.error("The pbeast python library was not found! Remember to setup tdaq release")
101  return {}
102  except RuntimeError:
103  log.error("Error when reading from Pbeast! Remember to export pbeast server sso: export PBEAST_SERVER_SSO_SETUP_TYPE=AutoUpdateKerberos")
104  return {}
105 
106 
107 # Create xml node storing luminosity values
108 # Currently only deadtime was imported compared to Run 2, because only this value is used in further analysis
109 

◆ readDeadtimeFromIS()

def ExtractEBRunDetails.readDeadtimeFromIS (   startOfRun,
  endOfRun,
  server = "https://atlasop.cern.ch" 
)

Definition at line 50 of file ExtractEBRunDetails.py.

50 def readDeadtimeFromIS(startOfRun, endOfRun, server="https://atlasop.cern.ch"):
51  try:
52  import libpbeastpy
53  pbeast = libpbeastpy.ServerProxy(server)
54  deadTimeData = pbeast.get_data(
55  'ATLAS', 'CtpBusyInfo', 'ctpcore_objects/CtpcoreBusyInfoObject/fraction',
56  'L1CT.CTP.Instantaneous.BusyFractions/ctpcore_objects\\[9\\]',
57  True, startOfRun, endOfRun)[0].data['L1CT.CTP.Instantaneous.BusyFractions/ctpcore_objects[9]']
58 
59  totalDeadtime = 0
60  for entry in deadTimeData:
61  totalDeadtime += entry.value
62 
63  avgDeadtime = totalDeadtime/len(deadTimeData)
64 
65  log.debug("Average deadtime per event during this EB run was {0}".format(avgDeadtime))
66  return avgDeadtime
67 
68  except ImportError:
69  log.error("The pbeast python library was not found! Remember to setup tdaq release")
70  return -1
71  except RuntimeError:
72  log.error("Error when reading from Pbeast! Remember to export pbeast server sso: export PBEAST_SERVER_SSO_SETUP_TYPE=AutoUpdateKerberos")
73  return -1
74 
75 
76 # Read average physics deadtime for item from TRP per lumiblock

◆ readTimestampsOfLb()

def ExtractEBRunDetails.readTimestampsOfLb (   runNumber,
  lbStart = -1,
  lbEnd = -1 
)
Returns start and end of the run read from COOL database


Definition at line 16 of file ExtractEBRunDetails.py.

16 def readTimestampsOfLb(runNumber, lbStart=-1, lbEnd=-1):
17  '''
18  Returns start and end of the run read from COOL database
19  '''
20  from TrigConfStorage.TriggerCoolUtil import TriggerCoolUtil
21  dbconn = TriggerCoolUtil.GetConnection("CONDBR2")
22 
23  # based on TriggerCoolUtil.getRunStartTime
24  f = dbconn.getFolder( "/TRIGGER/LUMI/LBLB" )
25 
26  since = RunLumi(runNumber, lbStart) if lbStart >= 0 else (runNumber<<32)
27  until = RunLumi(runNumber, lbEnd) if lbEnd >= 0 else ((runNumber+1)<<32)-1
28 
29  from PyCool import cool
30  objs = f.browseObjects(since, until, cool.ChannelSelection(0) )
31 
32  lbCounter = lbStart
33  timestampDict = OrderedDict()
34  while objs.goToNext():
35  objCurrRef = objs.currentRef()
36  timestampDict[lbCounter] = {"start": int(objCurrRef.payload()["StartTime"]/1000), "end": int(objCurrRef.payload()["EndTime"]/1000)}
37  lbCounter+=1
38 
39  startTime = timestampDict[lbStart]["start"]
40  endTime = timestampDict[lbEnd]["end"]
41 
42  from time import ctime
43  log.info("Read start and end of run {0} from COOL: {1} - {2}".format(runNumber, ctime(startTime/1E6).replace(' ','_'), ctime(endTime/1E6).replace(' ','_')))
44  log.debug("Timestamps: {0} - {1} ".format(startTime, endTime))
45 
46  return timestampDict
47 
48 
49 # Read the published deadtime value from IS based on start and stop of the run timestamps

Variable Documentation

◆ args

ExtractEBRunDetails.args

Definition at line 216 of file ExtractEBRunDetails.py.

◆ bgNode

ExtractEBRunDetails.bgNode

Definition at line 250 of file ExtractEBRunDetails.py.

◆ bsfile

ExtractEBRunDetails.bsfile

Definition at line 228 of file ExtractEBRunDetails.py.

◆ configKeys

ExtractEBRunDetails.configKeys

Definition at line 235 of file ExtractEBRunDetails.py.

◆ deadTimeData

ExtractEBRunDetails.deadTimeData

Definition at line 254 of file ExtractEBRunDetails.py.

◆ default

ExtractEBRunDetails.default

Definition at line 212 of file ExtractEBRunDetails.py.

◆ endOfRun

ExtractEBRunDetails.endOfRun

Definition at line 245 of file ExtractEBRunDetails.py.

◆ event

ExtractEBRunDetails.event

Definition at line 229 of file ExtractEBRunDetails.py.

◆ filename

ExtractEBRunDetails.filename

Definition at line 259 of file ExtractEBRunDetails.py.

◆ flags

ExtractEBRunDetails.flags

Definition at line 219 of file ExtractEBRunDetails.py.

◆ help

ExtractEBRunDetails.help

Definition at line 212 of file ExtractEBRunDetails.py.

◆ indent

ExtractEBRunDetails.indent

Definition at line 261 of file ExtractEBRunDetails.py.

◆ int

ExtractEBRunDetails.int

Definition at line 212 of file ExtractEBRunDetails.py.

◆ lbRanges

ExtractEBRunDetails.lbRanges

Definition at line 244 of file ExtractEBRunDetails.py.

◆ log

ExtractEBRunDetails.log

Definition at line 12 of file ExtractEBRunDetails.py.

◆ lumiblocks

ExtractEBRunDetails.lumiblocks

Definition at line 225 of file ExtractEBRunDetails.py.

◆ lumiNode

ExtractEBRunDetails.lumiNode

Definition at line 255 of file ExtractEBRunDetails.py.

◆ lumiValNode

ExtractEBRunDetails.lumiValNode

Definition at line 246 of file ExtractEBRunDetails.py.

◆ nargs

ExtractEBRunDetails.nargs

Definition at line 215 of file ExtractEBRunDetails.py.

◆ parser

ExtractEBRunDetails.parser

Definition at line 211 of file ExtractEBRunDetails.py.

◆ root

ExtractEBRunDetails.root

Definition at line 238 of file ExtractEBRunDetails.py.

◆ runNumber

ExtractEBRunDetails.runNumber

Definition at line 224 of file ExtractEBRunDetails.py.

◆ startOfRun

ExtractEBRunDetails.startOfRun

Definition at line 245 of file ExtractEBRunDetails.py.

◆ str

ExtractEBRunDetails.str

Definition at line 213 of file ExtractEBRunDetails.py.

◆ type

ExtractEBRunDetails.type

Definition at line 212 of file ExtractEBRunDetails.py.

◆ xml

ExtractEBRunDetails.xml

Definition at line 239 of file ExtractEBRunDetails.py.

◆ xml_str

ExtractEBRunDetails.xml_str

Definition at line 261 of file ExtractEBRunDetails.py.

replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
vtune_athena.format
format
Definition: vtune_athena.py:14
ExtractEBRunDetails.createBgNode
def createBgNode(xmlRoot, bgId, name, length)
Definition: ExtractEBRunDetails.py:200
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
ExtractEBRunDetails.readDeadtimeFromIS
def readDeadtimeFromIS(startOfRun, endOfRun, server="https://atlasop.cern.ch")
Definition: ExtractEBRunDetails.py:50
ExtractEBRunDetails.createLbNode
def createLbNode(xmlRoot, lbId, lumi, mu, nEvents, avgDeadtime)
Definition: ExtractEBRunDetails.py:169
ExtractEBRunDetails.int
int
Definition: ExtractEBRunDetails.py:212
python.sugar.runlumi.RunLumi
RunLumi
Definition: runlumi.py:131
ExtractEBRunDetails.createDeadtimeNode
def createDeadtimeNode(xmlRoot, totalDeadtime)
Definition: ExtractEBRunDetails.py:110
ExtractEBRunDetails.readTimestampsOfLb
def readTimestampsOfLb(runNumber, lbStart=-1, lbEnd=-1)
Definition: ExtractEBRunDetails.py:16
ExtractEBRunDetails.createLumiBlockNodes
def createLumiBlockNodes(xmlRoot, runNumber, lbStart, lbEnd, deadTimeData)
Definition: ExtractEBRunDetails.py:140
ExtractEBRunDetails.getPhysicsDeadtimePerLB
def getPhysicsDeadtimePerLB(startOfRun, endOfRun, lbRangesDict, itemName="L1_TAU8--enabled", server="https://atlasop.cern.ch")
Definition: ExtractEBRunDetails.py:77
ExtractEBRunDetails.createFiltersNodes
def createFiltersNodes(xmlRoot, chainsDict)
Definition: ExtractEBRunDetails.py:122
PixelModuleFeMask_create_db.payload
string payload
Definition: PixelModuleFeMask_create_db.py:69
python.AtlRunQuerySFO.GetSFO_NeventsAll
def GetSFO_NeventsAll(cursor, runlist)
Definition: AtlRunQuerySFO.py:176
query_example.cursor
cursor
Definition: query_example.py:21
ExtractEBRunDetails.createBunchGroupNodes
def createBunchGroupNodes(xmlRoot, key, db)
Definition: ExtractEBRunDetails.py:181
str
Definition: BTagTrackIpAccessor.cxx:11
ExtractEBRunDetails.type
type
Definition: ExtractEBRunDetails.py:212