ATLAS Offline Software
Loading...
Searching...
No Matches
python.LumiGRLParser.LumiGRLParser Class Reference
Collaboration diagram for python.LumiGRLParser.LumiGRLParser:

Public Member Functions

 __init__ (self, grlfile=None)
 parseFile (self, filename)
 selectRange (self)
 lumiBlockList (self, runnum)

Public Attributes

 tree = None
 lumiRangeName = None
 lumiRange = None
list runList = []
list iovList = []
 iovDict = dict()

Detailed Description

Definition at line 10 of file LumiGRLParser.py.

Constructor & Destructor Documentation

◆ __init__()

python.LumiGRLParser.LumiGRLParser.__init__ ( self,
grlfile = None )

Definition at line 12 of file LumiGRLParser.py.

12 def __init__(self, grlfile=None):
13
14 # Holds the element tree for the parsed XML file
15 self.tree = None
16
17 # Name of NamedLumiRange to consider (None works if only one NamedLumiRange is present)
18 self.lumiRangeName = None
19 self.lumiRange = None
20
21 # List of (integer) run numbers
22 self.runList = []
23
24 # List of COOL IOV ranges (start, end)
25 # run << 32 & LB
26 self.iovList = []
27
28 # Dictionary keyed by runnum containing a list of IOV ranges
29 self.iovDict = dict()
30
31 if grlfile is not None:
32 self.parseFile(grlfile)
33
34

Member Function Documentation

◆ lumiBlockList()

python.LumiGRLParser.LumiGRLParser.lumiBlockList ( self,
runnum )

Definition at line 127 of file LumiGRLParser.py.

127 def lumiBlockList(self, runnum):
128
129 lbList = []
130 for iov in self.iovDict.get(runnum, []):
131 lbList.extend(range(iov[0], iov[1]))
132
133 return lbList
134
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ parseFile()

python.LumiGRLParser.LumiGRLParser.parseFile ( self,
filename )

Definition at line 35 of file LumiGRLParser.py.

35 def parseFile(self, filename):
36
37 self.tree = ET.parse(filename)
38
39 self.runList = []
40 self.iovList = []
41 self.iovDict = dict()
42
43 # Return list of runs in GRL
44 if not self.selectRange():
45 print('LumiGRLParser.parseFile(%s) - Error selecting valid range!' % filename)
46 return
47
48 # Now, go through this range and find run numbers
49 for lbc in self.lumiRange.findall('LumiBlockCollection'):
50 runnum = int(lbc.findtext('Run', '-1'))
51 if runnum < 0:
52 print("LumiGRLParser.parseFile(%s) - Couldn't find Run in valid LumiBlockCollection!" % filename)
53 continue
54
55 self.runList.append(runnum)
56 self.iovDict[runnum] = []
57
58 for lbr in lbc.findall('LBRange'):
59 lbstart = int(lbr.get('Start', '-1'))
60 lbend = int(lbr.get('End', '-1'))
61
62 if lbstart < 0 or lbend < 0:
63 print("LumiGRLParser.parseFile(%s) - Couldn't find LBRange attributes for run %d!" % (filename, runnum))
64 continue
65
66 # Must add one to make IOVRange exclusive at end
67 lbend += 1
68 self.iovDict[runnum].append((lbstart, lbend))
69
70 iovstart = (runnum<<32)+lbstart
71 iovend = (runnum<<32)+lbend
72 self.iovList.append((iovstart, iovend))
73
74 # Finally sort these
75 self.runList.sort()
76 self.iovList.sort()
77
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.
void print(char *figname, TCanvas *c1)

◆ selectRange()

python.LumiGRLParser.LumiGRLParser.selectRange ( self)

Definition at line 78 of file LumiGRLParser.py.

78 def selectRange(self):
79
80 self.lumiRange = None
81
82 if self.tree is None:
83 print('LumiGRLParser.selectRange() - no tree found!')
84 return False
85
86 lumiRangeList = self.tree.findall('NamedLumiRange')
87 if len(lumiRangeList) == 1:
88
89 if self.lumiRangeName is not None:
90 name = lumiRangeList[0].findtext('Name', '')
91
92 if name != self.lumiRangeName:
93 print("LumiGRLParser.selectRange() - Can't find %s in GRL, only %s!" % (self.lumiRangeName, name))
94 return False
95
96 self.lumiRange = lumiRangeList[0]
97 return True
98
99 elif len(lumiRangeList) == 0:
100
101 print('LumiGRLParser.selectRange() - No NamedLumiRange object found!')
102 return False
103
104 # More than one range found
105 if self.lumiRangeName is None:
106 print('LumiGRLParser.selectRange() - %d NamedLumiRange objects found, but no lumiRangeName specified!' % len(lumiRangeList))
107 return False
108
109
110 # More than one, match by name
111 found = False
112 for lbr in lumiRangeList:
113 name = lbr.findtext('Name', '')
114
115 if self.lumiRangeName == name:
116 found = True
117 self.lumiRange = lbr
118 break
119
120 if not found:
121 print("LumiGRLParser.selectRange() - Couldn't find %s in available NamedLumiRange objects!" % self.lumiRangeName)
122 return False
123
124 return True
125

Member Data Documentation

◆ iovDict

python.LumiGRLParser.LumiGRLParser.iovDict = dict()

Definition at line 29 of file LumiGRLParser.py.

◆ iovList

list python.LumiGRLParser.LumiGRLParser.iovList = []

Definition at line 26 of file LumiGRLParser.py.

◆ lumiRange

python.LumiGRLParser.LumiGRLParser.lumiRange = None

Definition at line 19 of file LumiGRLParser.py.

◆ lumiRangeName

python.LumiGRLParser.LumiGRLParser.lumiRangeName = None

Definition at line 18 of file LumiGRLParser.py.

◆ runList

list python.LumiGRLParser.LumiGRLParser.runList = []

Definition at line 22 of file LumiGRLParser.py.

◆ tree

python.LumiGRLParser.LumiGRLParser.tree = None

Definition at line 15 of file LumiGRLParser.py.


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