ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.LumiGRLParser.LumiGRLParser Class Reference
Collaboration diagram for python.LumiGRLParser.LumiGRLParser:

Public Member Functions

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

Public Attributes

 tree
 
 lumiRangeName
 
 lumiRange
 
 runList
 
 iovList
 
 iovDict
 

Detailed Description

Definition at line 11 of file LumiGRLParser.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 13 of file LumiGRLParser.py.

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

Member Function Documentation

◆ lumiBlockList()

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

Definition at line 128 of file LumiGRLParser.py.

128  def lumiBlockList(self, runnum):
129 
130  lbList = []
131  for iov in self.iovDict.get(runnum, []):
132  lbList.extend(range(iov[0], iov[1]))
133 
134  return lbList
135 

◆ parseFile()

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

Definition at line 36 of file LumiGRLParser.py.

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

◆ selectRange()

def python.LumiGRLParser.LumiGRLParser.selectRange (   self)

Definition at line 79 of file LumiGRLParser.py.

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

Member Data Documentation

◆ iovDict

python.LumiGRLParser.LumiGRLParser.iovDict

Definition at line 30 of file LumiGRLParser.py.

◆ iovList

python.LumiGRLParser.LumiGRLParser.iovList

Definition at line 27 of file LumiGRLParser.py.

◆ lumiRange

python.LumiGRLParser.LumiGRLParser.lumiRange

Definition at line 20 of file LumiGRLParser.py.

◆ lumiRangeName

python.LumiGRLParser.LumiGRLParser.lumiRangeName

Definition at line 19 of file LumiGRLParser.py.

◆ runList

python.LumiGRLParser.LumiGRLParser.runList

Definition at line 23 of file LumiGRLParser.py.

◆ tree

python.LumiGRLParser.LumiGRLParser.tree

Definition at line 16 of file LumiGRLParser.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70