ATLAS Offline Software
Functions | Variables
ReadCool Namespace Reference

Functions

def StartDate (period)
 --> Definitions: More...
 
def ConvertedRunNumber (rNumber)
 
def RunListInDBTotal (start_date, end_date, file_name, string_pattern)
 
def channelValueQuery (server, schema, dbname, folder, iov0, iov1, tag, channels)
 
def RunListInDB (array, server, schema, dbname, folder, tag, channels)
 
def GetNumberOfNoisyModulesInDB (array, server, schema, dbname, folder, tag, channels)
 
def GetNumberOfNoisyStripsInDB (array, server, schema, dbname, folder, tag, channels)
 
def GetNoisyModulesAverageInDB (array)
 
def DisplayInfoForRunsInDB (runs, noisy_mods, noisy_strips)
 
def UnpackData (data)
 
def iov_keygen (iov)
 
def DumpFolderSummary (db_string, folder, tag, run=None)
 
def ReadRtCool (db_string, folder, tag, run_number)
 
def ReadT0Cool (db_string, folder, tag, run_number)
 
def GetFolderTag (db_string, folder)
 

Variables

 argv
 

Function Documentation

◆ channelValueQuery()

def ReadCool.channelValueQuery (   server,
  schema,
  dbname,
  folder,
  iov0,
  iov1,
  tag,
  channels 
)

Definition at line 64 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

64 def channelValueQuery(server, schema, dbname, folder, iov0, iov1, tag, channels):
65  timespan= str(iov0) + '-' + str(iov1)
66  prefix='http://voatlas11.cern.ch:8080/cooldb/'
67  d = '/'
68  url = prefix+server+d+schema+d+dbname+folder+'/timespan/'+timespan+'/tag/'+tag+'/channels/'+channels
69  httpHeaders={'Accept':'text/xml'}
70  textData=None
71  # print(url)
72  request=urllib2.Request(url,textData, httpHeaders)
73  u=urllib2.urlopen(request)
74  xmlDocString = u.read()
75  return xmlDocString
76 

◆ ConvertedRunNumber()

def ReadCool.ConvertedRunNumber (   rNumber)

Definition at line 23 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

23 def ConvertedRunNumber(rNumber):
24  RNumber = long(rNumber)
25  return RNumber << 32
26 

◆ DisplayInfoForRunsInDB()

def ReadCool.DisplayInfoForRunsInDB (   runs,
  noisy_mods,
  noisy_strips 
)

Definition at line 168 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

168 def DisplayInfoForRunsInDB(runs, noisy_mods, noisy_strips):
169  if (len(runs) != 0):
170  for i in range(len(runs)):
171  print("Run: ",runs[i], " --> Num. noisy modules: ", noisy_mods[i], " --> Num. noisy channels: ", noisy_strips[i])
172  else:
173  print("--> No information found.")
174 

◆ DumpFolderSummary()

def ReadCool.DumpFolderSummary (   db_string,
  folder,
  tag,
  run = None 
)

Definition at line 31 of file MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py.

31 def DumpFolderSummary(db_string, folder, tag, run=None):
32 
33  try:
34  db=AtlCoolLib.indirectOpen(db_string, readOnly=True, debug=True)
35  except Exception as e:
36  print ('Problem opening database',e)
37  sys.exit(-1)
38 
39 #get folder and tag
40  cool_folder=db.getFolder(folder)
41  cool_tag=ResolveTag(cool_folder, tag)
42 
43  counters={}
44  if run:
45  objs=cool_folder.browseObjects((run<<32), ((run+1)<<32), cool.ChannelSelection.all(), cool_tag)
46  else:
47  objs=cool_folder.browseObjects(0, (999999<<32), cool.ChannelSelection.all(), cool_tag)
48  for obj in objs:
49  file_col=obj.payload()['file']
50  file_items=re.split('[A-Z,a-z]*', file_col)
51  site="default"
52  head_id=-1
53  if len(file_items)==2:
54  try:
55  head_id = int(file_items[1])
56  site = re.sub("[0-9]", "", file_col)
57  except ValueError:
58  site=file_col
59  ts="NOTS"
60  if TimeSlewingApplied(obj):
61  ts="TS"
62  ident=(obj.since()>>32, obj.until()>>32, site, head_id, ts)
63  if ident not in counters:
64  counters[ident] = 0
65  counters[ident] +=1
66  for ident in sorted(counters.keys(), key=iov_keygen):
67  print ("[", ident[0], ",", ident[1], "[", ident[2], ident[3], ident[4], ":" , counters[ident])
68 
69 

◆ GetFolderTag()

def ReadCool.GetFolderTag (   db_string,
  folder 
)

Definition at line 159 of file MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py.

159 def GetFolderTag(db_string, folder):
160  dbSvc=cool.DatabaseSvcFactory.databaseService()
161  try:
162  db=dbSvc.openDatabase(db_string)
163  except Exception as e:
164  print ('Problem opening database',e)
165  sys.exit(-1)
166 
167 #get folder and tag
168  cool_folder=db.getFolder(folder)
169  for x in cool_folder.listTags():
170  return x
171 

◆ GetNoisyModulesAverageInDB()

def ReadCool.GetNoisyModulesAverageInDB (   array)

Definition at line 157 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

157 def GetNoisyModulesAverageInDB(array):
158  sum=0
159  if (len(array) != 0):
160  for j in range(len(array)):
161  sum=sum+array[j]
162  NoisyModulesAverage = sum/len(array)
163  else:
164  NoisyModulesAverage = -999
165  return NoisyModulesAverage
166 

◆ GetNumberOfNoisyModulesInDB()

def ReadCool.GetNumberOfNoisyModulesInDB (   array,
  server,
  schema,
  dbname,
  folder,
  tag,
  channels 
)

Definition at line 100 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

100 def GetNumberOfNoisyModulesInDB(array, server, schema, dbname, folder, tag, channels):
101  Array_numNoisyModules=[]
102  if (array[0] != -999):
103  for i in range(len(array)):
104  runNumber=array[i]
105  iovSince=ConvertedRunNumber(runNumber)
106  iovUntil=ConvertedRunNumber(runNumber+1)-1
107 
108  derived_string=channelValueQuery(server, schema, dbname, folder, iovSince, iovUntil, tag, channels)
109 
110  derived=NonvalidatingReader.parseString(derived_string,uri="dummy")
111  numNoisyModules=derived.xpath(u'count(//channel)')
112  if numNoisyModules !=0.0:
113  Array_numNoisyModules.append(numNoisyModules)
114  else:
115  Array_numNoisyModules.append(-999)
116 
117  return Array_numNoisyModules
118 

◆ GetNumberOfNoisyStripsInDB()

def ReadCool.GetNumberOfNoisyStripsInDB (   array,
  server,
  schema,
  dbname,
  folder,
  tag,
  channels 
)

Definition at line 120 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

120 def GetNumberOfNoisyStripsInDB(array, server, schema, dbname, folder, tag, channels):
121  Array_numNoisyStrips = []
122  if (array[0] != -999):
123  for i in range(len(array)):
124  runNumber=array[i]
125  iovSince=ConvertedRunNumber(runNumber)
126  iovUntil=ConvertedRunNumber(runNumber+1)-1
127 
128  derived_string=channelValueQuery(server, schema, dbname, folder, iovSince, iovUntil, tag, channels)
129 
130  derived=NonvalidatingReader.parseString(derived_string,uri="dummy")
131  numNoisyModules=derived.xpath(u'count(//channel)')
132  if numNoisyModules !=0.0:
133 
134  allDefectStripsList=(derived.xpath(u"//channel/value[@name='DefectList']"))
135  numNoisyStrips=0
136  numNoisyStripsAdds=0
137 
138  for strips in allDefectStripsList:
139  words=strips.firstChild.data.split()
140  for j in range(len(words)):
141  jk=words[j]
142  if jk.find("-")>=0:
143  sep=jk.replace ( '-', ' ' )
144  sep1=sep.split()
145  numNoisyStripsAdds=numNoisyStripsAdds+int(sep1[1])-int(sep1[0])
146 
147  numNoisyStrips=numNoisyStrips+len(strips.firstChild.data.split())
148 
149  Array_numNoisyStrips.append(numNoisyStrips + numNoisyStripsAdds)
150 
151  else:
152  Array_numNoisyStrips.append(-999)
153 
154  return Array_numNoisyStrips
155 

◆ iov_keygen()

def ReadCool.iov_keygen (   iov)

Definition at line 28 of file MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py.

28 def iov_keygen(iov):
29  return iov[0]*10000000 + iov[1]
30 

◆ ReadRtCool()

def ReadCool.ReadRtCool (   db_string,
  folder,
  tag,
  run_number 
)

Definition at line 70 of file MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py.

70 def ReadRtCool(db_string, folder, tag, run_number):
71 
72  try:
73  db=AtlCoolLib.indirectOpen(db_string, readOnly=True, debug=True)
74  except Exception as e:
75  print ('Problem opening database',e)
76  sys.exit(-1)
77 
78 #get folder and tag
79  cool_folder=db.getFolder(folder)
80  cool_tag=ResolveTag(cool_folder, tag)
81 
82 #data to be filled
83  graphs={}
84  splines={}
85  iovs=set([])
86 
87  myiov=(run_number<<32)
88 
89  objs=cool_folder.browseObjects(myiov,myiov, cool.ChannelSelection.all(), cool_tag)
90  for obj in objs:
91  iov=(obj.since(), obj.until())
92  iovs.add(iov)
93  sp=UnpackData(obj.payload()['data']).split('\n')
94  sp1=sp[0].split(',')
95  chamber=int(sp1[0])
96  n_points=int(sp1[1])
97  sp2=sp[1].split(',')
98  graphs[chamber]=TGraphErrors(n_points)
99  up=MuonFixedIdUnpack(chamber)
100  if up.stationNameString()=='XXX':
101  print ("Invalid station name in ", obj.payload()['file'])
102  sys.exit(1)
103  nm=up.stationNameString() + "_" + str(up.stationPhi()) + "_" + str(up.stationEta())
104 # print (nm)
105  ts_applied=TimeSlewingApplied(obj)
106  for i in range(0, n_points):
107  r=float(sp2[3*i])
108  t=float(sp2[3*i+1])
109  s=float(sp2[3*i+2])
110  if not ts_applied:
111  t_new=NoTs2Ts(r, t)
112  t=t_new
113  graphs[chamber].SetPoint(i, r, t)
114  graphs[chamber].SetPointError(i, 0, s)
115  splines[chamber]=TSpline3("sp_" + nm, graphs[chamber])
116  if gDirectory.IsWritable():
117  splines[chamber].Write("sp_" + nm)
118  graphs[chamber].Write("gr_" + nm)
119 
120  return graphs, splines, iovs
121 
122 

◆ ReadT0Cool()

def ReadCool.ReadT0Cool (   db_string,
  folder,
  tag,
  run_number 
)

Definition at line 123 of file MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py.

123 def ReadT0Cool(db_string, folder, tag, run_number):
124 
125  try:
126  db=AtlCoolLib.indirectOpen(db_string, readOnly=True, debug=True)
127  except Exception as e:
128  print ('Problem opening database',e)
129  sys.exit(-1)
130 
131 #get folder and tag
132  cool_folder=db.getFolder(folder)
133  cool_tag=ResolveTag(cool_folder, tag)
134  myiov=(run_number<<32)
135 #data
136  t0_values={}
137 
138  objs=cool_folder.browseObjects(myiov,myiov, cool.ChannelSelection.all(), cool_tag)
139 
140  for obj in objs:
141  sp=UnpackData(obj.payload()['data']).split('\n')
142  sp1=sp[0].split(',')
143  ch_sp=sp1[0][2:].split("_")
144  ch_id=(ch_sp[0], int(ch_sp[1]), int(ch_sp[2]))
145  ntubes=int(sp1[-1])
146 
147  t0_items=sp[1].split(",")
148  t0_values[ch_id] = []
149  ts_applied=TimeSlewingApplied(obj)
150  for i in range(0, ntubes):
151  t0=float(t0_items[3*i+0])
152  if not ts_applied:
153  t0+= GasmonDriftTimeOffsetT0
154  t0_values[ch_id].append((t0, int(t0_items[3*i+1]), float(t0_items[3*i+2])))
155 
156  return t0_values
157 
158 

◆ RunListInDB()

def ReadCool.RunListInDB (   array,
  server,
  schema,
  dbname,
  folder,
  tag,
  channels 
)

Definition at line 78 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

78 def RunListInDB(array, server, schema, dbname, folder, tag, channels):
79  Array_runsInDB=[]
80  if (len(array) != 0):
81  for i in range(len(array)):
82  runNumber=array[i]
83  iovSince=ConvertedRunNumber(runNumber)
84  iovUntil=ConvertedRunNumber(runNumber+1)-1
85 
86  derived_string=channelValueQuery(server, schema, dbname, folder, iovSince, iovUntil, tag, channels)
87 
88  derived=NonvalidatingReader.parseString(derived_string,uri="dummy")
89  numNoisyModules=derived.xpath(u'count(//channel)')
90 
91  if numNoisyModules !=0.0:
92  Array_runsInDB.append(runNumber)
93  else:
94  Array_runsInDB.append(-999)
95 
96  return Array_runsInDB
97 
98 

◆ RunListInDBTotal()

def ReadCool.RunListInDBTotal (   start_date,
  end_date,
  file_name,
  string_pattern 
)

Definition at line 28 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

28 def RunListInDBTotal(start_date, end_date, file_name, string_pattern):
29  prefix="http://atlas-service-runinformation.web.cern.ch/atlas-service-runinformation/cgi-bin/runnumbers.py?"
30  url=prefix+"start.date="+start_date+"%2012:06:00&end.date="+end_date+"%2012:06:00&format=html"
31  # print(url)
32  request=urllib2.Request(url)
33  u=urllib2.urlopen(request)
34  DocString = u.read()
35 
36  DocString_1 = DocString.replace ( '<td>', ' ' )
37  DocString_2 = DocString_1.replace ( '</td>', ' ' )
38  DocString_3 = DocString_2.replace ( '<tr>', ' ' )
39  DocString_4 = DocString_3.replace ( '</tr>', ' ' )
40  DocString_5 = DocString_4.replace ( '<th>Name</th><th>Number</th><th>Start At (UTC)</th><th>Duration</th><th>Partition</th>', ' ' )
41 
42 
43  f=open(file_name, 'w')
44  f.write(DocString_5)
45  f.close()
46 
47  Runs = []
48  if os.path.exists(file_name):
49  f = open(file_name,'r')
50  for line in f.readlines():
51  if line.find(string_pattern)>= 0:
52  ar=string.split(line)
53  Runs.append(int(ar[1]))
54  f.close()
55  else:
56  print("-->ERROR: athena_checkUpload: Can't find input file !")
57 
58 
59  os.remove(file_name)
60 
61  return Runs
62 

◆ StartDate()

def ReadCool.StartDate (   period)

--> Definitions:

Definition at line 17 of file InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py.

17 def StartDate(period):
18 
19  start_date = (datetime.date.today() - datetime.timedelta(period)).isoformat()
20  return start_date
21 

◆ UnpackData()

def ReadCool.UnpackData (   data)

Definition at line 18 of file MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py.

18 def UnpackData(data):
19  if type(data)==str:
20  return data
21  if type(data)==coral.Blob:
22  blob=StringIO.StringIO()
23  for i in range(data.size()):
24  blob.write(chr(data[i]))
25  unpacked=zlib.decompress(blob.getvalue())
26  return unpacked
27 

Variable Documentation

◆ argv

ReadCool.argv
MuonCalibConvertTimeSlewing.NoTs2Ts
def NoTs2Ts(r, t)
Definition: MuonCalibConvertTimeSlewing.py:24
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MuonFixedIdUnpack
Definition: MuonFixedIdUnpack.py:1
ReadCool.ConvertedRunNumber
def ConvertedRunNumber(rNumber)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:23
ReadCool.DumpFolderSummary
def DumpFolderSummary(db_string, folder, tag, run=None)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:31
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
ReadCool.ReadT0Cool
def ReadT0Cool(db_string, folder, tag, run_number)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:123
ReadCool.RunListInDBTotal
def RunListInDBTotal(start_date, end_date, file_name, string_pattern)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:28
ReadCool.UnpackData
def UnpackData(data)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:18
MuonCalibConvertTimeSlewing.TimeSlewingApplied
def TimeSlewingApplied(obj)
Definition: MuonCalibConvertTimeSlewing.py:27
ReadCool.GetNoisyModulesAverageInDB
def GetNoisyModulesAverageInDB(array)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:157
ReadCool.iov_keygen
def iov_keygen(iov)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:28
ReadCool.RunListInDB
def RunListInDB(array, server, schema, dbname, folder, tag, channels)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:78
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
ReadCool.GetNumberOfNoisyStripsInDB
def GetNumberOfNoisyStripsInDB(array, server, schema, dbname, folder, tag, channels)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:120
ReadCool.GetNumberOfNoisyModulesInDB
def GetNumberOfNoisyModulesInDB(array, server, schema, dbname, folder, tag, channels)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:100
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
ReadCool.channelValueQuery
def channelValueQuery(server, schema, dbname, folder, iov0, iov1, tag, channels)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:64
ReadCool.StartDate
def StartDate(period)
--> Definitions:
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:17
ReadCool.GetFolderTag
def GetFolderTag(db_string, folder)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:159
Trk::open
@ open
Definition: BinningType.h:40
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
ReadCool.DisplayInfoForRunsInDB
def DisplayInfoForRunsInDB(runs, noisy_mods, noisy_strips)
Definition: InnerDetector/InDetCalibAlgs/SCT_CalibAlgs/share/ReadCool.py:168
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
ReadCool.ReadRtCool
def ReadRtCool(db_string, folder, tag, run_number)
Definition: MuonSpectrometer/MuonCalib/MuonCalibDbOperations/python/ReadCool.py:70
MuonCalibResolveTag.ResolveTag
def ResolveTag(folder, tag)
Definition: MuonCalibResolveTag.py:5
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38