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

Public Member Functions

def __init__ (self, dbstr=None, folderstr=None)
 
def setFolder (self, dbstr, folderstr)
 
def setTag (self, tagstr='')
 
def setChannel (self, channelIdList=[])
 
def setChannelAll (self)
 
def setChannelId (self, channelId)
 
def setIOVRange (self, iovstart=cool.ValidityKeyMin, iovend=cool.ValidityKeyMax)
 
def setIOVRangeFromRun (self, runnum)
 
def readData (self)
 
def readChannelList (self, channels)
 

Public Attributes

 verbose
 
 dbstr
 
 folderstr
 
 channelIdList
 
 tag
 
 iovstart
 
 iovend
 
 folder
 
 data
 

Detailed Description

Definition at line 34 of file CoolDataReader.py.

Constructor & Destructor Documentation

◆ __init__()

def python.CoolDataReader.CoolDataReader.__init__ (   self,
  dbstr = None,
  folderstr = None 
)

Definition at line 36 of file CoolDataReader.py.

36  def __init__(self, dbstr=None, folderstr=None):
37 
38  self.verbose = False
39 
40  # Defined variables
41  self.dbstr = None
42  self.folderstr = None
43  self.channelIdList = []
44  self.tag = ''
45  self.iovstart = None
46  self.iovend = None
47 
48  self.folder = None
49  self.data = []
50 
51  # Initialize to default values
52  self.setChannel()
53  self.setTag()
54  self.setFolder(dbstr, folderstr)
55  self.setIOVRange()
56 

Member Function Documentation

◆ readChannelList()

def python.CoolDataReader.CoolDataReader.readChannelList (   self,
  channels 
)

Definition at line 142 of file CoolDataReader.py.

142  def readChannelList(self, channels):
143 
144  # Open iterator over our defined IOV range
145  try:
146  itr = self.folder.browseObjects(self.iovstart, self.iovend, channels, self.tag)
147  except Exception as e:
148  print('CoolDataReader.readData() - exception reading folder:', self.folderstr)
149  print(e)
150  print('CoolDataReader.readData() - will try to reconnect (once)')
151 
152  # Force re-opening connection
153  dbHandler = LumiDBHandler()
154  dbHandler.verbose = True
155  self.folder = dbHandler.getFolder(self.dbstr, self.folderstr, force=True)
156 
157  if self.folder is None:
158  print('CoolDataReader.readData() - forced re-opening failed!')
159  return self.data
160 
161  # OK, lets try reading this again
162  print('CoolDataReader.readData() - trying to re-read re-opened folder!')
163  try:
164  itr = self.folder.browseObjects(self.iovstart, self.iovend, channels, self.tag)
165  except Exception as e:
166  print('CoolDataReader.readData() - exception reading folder:', self.folderstr)
167  print(e)
168  return self.data
169 
170  while itr.goToNext():
171  obj = itr.currentRef()
172  # print obj.payload()
173  self.data.append(obj.clone())
174 
175  itr.close()
176 
177 
178 

◆ readData()

def python.CoolDataReader.CoolDataReader.readData (   self)

Definition at line 88 of file CoolDataReader.py.

88  def readData(self):
89 
90  self.data = []
91 
92  # Open the DB connection here if needed
93  if self.folder is None:
94  dbHandler = LumiDBHandler()
95  self.folder = dbHandler.getFolder(self.dbstr, self.folderstr)
96 
97  if self.folder is None:
98  print("Can't access DB", self.dbstr, 'folder', self.folderstr, '!')
99  return self.data
100 
101  # Create the channel list
102  if len(self.channelIdList) == 0:
103  channels = cool.ChannelSelection.all()
104  self.readChannelList(channels)
105 
106  else:
107  # Build the channel list here
108  self.channelIdList.sort() # Must be sorted!
109 
110  # Must read channels 50 at a time due to COOL limit...
111  ichan = 0
112  while (ichan < len(self.channelIdList)) :
113 
114  jchan = 0
115  channels = None
116  firstChan = True
117 
118  for channelId in self.channelIdList[ichan:]:
119  jchan += 1
120  if firstChan:
121  firstChan = False
122  channels = cool.ChannelSelection(channelId)
123  else:
124  channels.addChannel(channelId)
125  if jchan == 50: break
126 
127  # Remeber how many we have read for next time
128  if self.verbose:
129  print('CoolDataReader.readData() - loaded %d channels from %d' % (jchan, ichan))
130  ichan += jchan
131 
132  if self.verbose:
133  print('CoolDataReader.readData() - browsing', self.iovstart, self.iovend, 'with channel', channels, 'and tag', self.tag)
134 
135  self.readChannelList(channels)
136 
137  # End of loop building channel list and reading
138 
139  # End of if statement reading data
140  return self.data
141 

◆ setChannel()

def python.CoolDataReader.CoolDataReader.setChannel (   self,
  channelIdList = [] 
)

Definition at line 68 of file CoolDataReader.py.

68  def setChannel(self, channelIdList=[]):
69  self.channelIdList = channelIdList
70 

◆ setChannelAll()

def python.CoolDataReader.CoolDataReader.setChannelAll (   self)

Definition at line 71 of file CoolDataReader.py.

71  def setChannelAll(self):
72  self.setChannel()
73 

◆ setChannelId()

def python.CoolDataReader.CoolDataReader.setChannelId (   self,
  channelId 
)

Definition at line 74 of file CoolDataReader.py.

74  def setChannelId(self, channelId):
75  self.setChannel([channelId])
76 

◆ setFolder()

def python.CoolDataReader.CoolDataReader.setFolder (   self,
  dbstr,
  folderstr 
)

Definition at line 57 of file CoolDataReader.py.

57  def setFolder(self, dbstr, folderstr):
58  # Force re-opening connection if these are different
59  if (dbstr != self.dbstr) or (folderstr != self.folderstr):
60  self.folder = None
61 
62  self.dbstr = dbstr
63  self.folderstr = folderstr
64 

◆ setIOVRange()

def python.CoolDataReader.CoolDataReader.setIOVRange (   self,
  iovstart = cool.ValidityKeyMin,
  iovend = cool.ValidityKeyMax 
)

Definition at line 77 of file CoolDataReader.py.

77  def setIOVRange(self, iovstart=cool.ValidityKeyMin, iovend=cool.ValidityKeyMax):
78  self.iovstart = iovstart
79  self.iovend = iovend
80 

◆ setIOVRangeFromRun()

def python.CoolDataReader.CoolDataReader.setIOVRangeFromRun (   self,
  runnum 
)

Definition at line 81 of file CoolDataReader.py.

81  def setIOVRangeFromRun(self, runnum):
82  self.iovstart = runnum << 32
83  self.iovend = ((runnum+1) << 32) - 1
84 

◆ setTag()

def python.CoolDataReader.CoolDataReader.setTag (   self,
  tagstr = '' 
)

Definition at line 65 of file CoolDataReader.py.

65  def setTag(self, tagstr=''):
66  self.tag = tagstr
67 

Member Data Documentation

◆ channelIdList

python.CoolDataReader.CoolDataReader.channelIdList

Definition at line 43 of file CoolDataReader.py.

◆ data

python.CoolDataReader.CoolDataReader.data

Definition at line 49 of file CoolDataReader.py.

◆ dbstr

python.CoolDataReader.CoolDataReader.dbstr

Definition at line 41 of file CoolDataReader.py.

◆ folder

python.CoolDataReader.CoolDataReader.folder

Definition at line 48 of file CoolDataReader.py.

◆ folderstr

python.CoolDataReader.CoolDataReader.folderstr

Definition at line 42 of file CoolDataReader.py.

◆ iovend

python.CoolDataReader.CoolDataReader.iovend

Definition at line 46 of file CoolDataReader.py.

◆ iovstart

python.CoolDataReader.CoolDataReader.iovstart

Definition at line 45 of file CoolDataReader.py.

◆ tag

python.CoolDataReader.CoolDataReader.tag

Definition at line 44 of file CoolDataReader.py.

◆ verbose

python.CoolDataReader.CoolDataReader.verbose

Definition at line 38 of file CoolDataReader.py.


The documentation for this class was generated from the following file:
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70