ATLAS Offline Software
Loading...
Searching...
No Matches
AtlRunQuerySelectorEvents.py
Go to the documentation of this file.
1# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
4from time import time
5import sys
6
7from CoolRunQuery.utils.AtlRunQueryIOV import IOVRange
8from CoolRunQuery.utils.AtlRunQueryTimer import timer
9from CoolRunQuery.utils.AtlRunQueryUtils import coolDbConn, GetRanges
10
11from .AtlRunQuerySelectorBase import RunLBBasedCondition
12
14 def __init__(self, name, events=None):
15 self.events = events
16 super(EventSelector,self).__init__(name=name,
17 dbfolderkey='oracle::SFO-based',
18 channelKeys = [(0,'#Events','EFEvents')])
19 if events:
20 self.cutRange = GetRanges(events)
21
22
23
24 def __str__(self):
26 return "SELOUT Checking if number of events matches %s" % self.events
27 else:
28 return "Retrieving event numbers"
29
30 def select(self, runlist):
31
32 # some preparation: compile the show patterns
33 start = time()
34
35 print (self, end='')
36 sys.stdout.flush()
37 newrunlist = []
38 connection = coolDbConn.GetSFODBConnection()
39 cursor = connection.cursor()
40 cursor.arraysize = 1000
41
42 runnrlist = [r.runNr for r in runlist]
43
44 from CoolRunQuery.AtlRunQuerySFO import GetSFO_NphysicseventsAll
45 with timer("GetSFO_NphysicseventsAll", disabled=True):
46 events = GetSFO_NphysicseventsAll( cursor, runnrlist ) # { runnr: nPhysEvents }
47
48 for run in runlist:
49
50 iov = IOVRange(runStart=run.runNr, lbStart=1, runEnd=run.runNr+1, lbEnd=0)
51
52 for k in self.ResultKey():
53 if run.runNr not in events:
54 # the OVERLAP_EVENTS information is not yet available in the SFO (before Nov 15, 2009)
55 # use the inclusive number instead
56 run.addResult(k, "n.a.", iov, reject=False)
57 run.showDataIncomplete=True
58 continue
59
60 nev = events[run.runNr]
61
62 if self.ApplySelection(k) and not self.passes(nev,k):
63 run.addResult(k, self.prettyValue(nev,k), iov, reject=True)
64 continue
65
66 run.addResult(k, self.prettyValue(nev,k), iov)
67
68 rej = self.rejectRun(run)
69
70 if not rej:
71 newrunlist += [run.runNr]
72
73 runlist = [r for r in runlist if r.runNr in newrunlist]
74
75 duration = time() - start
76 if self.applySelection:
77 print (" ==> %i runs found (%.2f sec)" % (len(runlist),duration))
78 else:
79 print (" ==> Done (%g sec)" % duration)
80 return runlist
81
82 def passes(self,values,key):
83 try:
84 val = int(values)
85 except ValueError: # if n.a.
86 self.selDataMissing = True
87 return True
88 for cr in self.cutRange:
89 if val>=cr[0] and val<=cr[1]:
90 return True
91 return False
92
93
95 def __init__(self, name, events=None):
96 self.events = events
97 self.showAllevents = False
98 super(AllEventsSelector,self).__init__(name=name,
99 dbfolderkey='COOLONL_TDAQ::/TDAQ/RunCtrl/EventCounters',
100 channelKeys = [(0,'#Events (incl. calib.)','EFEvents'),
101 (0,'#Events (streamed)','RecordedEvents'),
102 (0,'#L2A','L2Events')])
103 if events:
104 self.cutRange = GetRanges(events)
105
106 def __str__(self):
108 return "SELOUT Checking if number of events matches %s" % self.events
109 else:
110 return "Retrieving event numbers"
111
112 def passes(self,values,key):
113 try:
114 val = int(values)
115 except ValueError: # if n.a.
116 self.selDataMissing = True
117 return True
118 for cr in self.cutRange:
119 if val>=cr[0] and val<=cr[1]:
120 return True
121 return False
122
124 def __init__(self, name, events=None):
125 self.events = events
126 self.showL1events = False
127 super(L1EventsSelector,self).__init__(name=name,
128 dbfolderkey='COOLONL_TRIGGER::/TRIGGER/LVL1/CTPCORELBDATA',
129 channelKeys = [(0,'#L1A','GlobalL1AcceptCounter')])
131 self.showL1events = True
132 super(L1EventsSelector,self).setShowOutput()
133
134 def __str__(self):
136 return "SELOUT Checking if number of L1A events matches %s" % self.events
137 else:
138 return "Retrieving L1A numbers"
139
140 def passes(self,values,key):
141 return True
142
Validity Range object.
Definition IOVRange.h:30