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

Public Member Functions

def __init__ (self)
 
def LoadGainsXml (self, name)
 
def LoadReferenceXml (self, name)
 
def LoadGainsSqlite (self, name)
 
def LoadReferenceSqlite (self, name)
 
def LoadReferenceOracle (self, mapping_tool)
 
def getGain (self, coolId)
 
def getChi2 (self, coolId)
 
def getOffset (self, coolId)
 
def getReferenceGain (self, coolId)
 
def passesSelection (self, coolId)
 

Public Attributes

 measured_gains
 
 reference_gains
 
 measured_chi2
 
 measured_offset
 
 UNIX2COOL
 
 run_nr
 
 strategy
 

Detailed Description

Definition at line 287 of file PlotCalibrationGains.py.

Constructor & Destructor Documentation

◆ __init__()

def PlotCalibrationGains.GainReader.__init__ (   self)

Definition at line 289 of file PlotCalibrationGains.py.

289  def __init__(self):
290 
291  self.measured_gains={}
292  self.reference_gains={}
293  self.measured_chi2={}
294  self.measured_offset={}
295  self.UNIX2COOL = 1000000000
296 
297  self.run_nr=None
298  self.strategy=None
299 

Member Function Documentation

◆ getChi2()

def PlotCalibrationGains.GainReader.getChi2 (   self,
  coolId 
)

Definition at line 486 of file PlotCalibrationGains.py.

486  def getChi2(self,coolId):
487  if (coolId in self.measured_chi2):
488  return float(self.measured_chi2[coolId])
489  else:
490  return ''
491 

◆ getGain()

def PlotCalibrationGains.GainReader.getGain (   self,
  coolId 
)

Definition at line 480 of file PlotCalibrationGains.py.

480  def getGain(self,coolId):
481  if (coolId in self.measured_gains):
482  return float(self.measured_gains[coolId])
483  else:
484  return ''
485 

◆ getOffset()

def PlotCalibrationGains.GainReader.getOffset (   self,
  coolId 
)

Definition at line 492 of file PlotCalibrationGains.py.

492  def getOffset(self,coolId):
493  if (coolId in self.measured_offset):
494  return float(self.measured_offset[coolId])
495  else:
496  return ''
497 
498 

◆ getReferenceGain()

def PlotCalibrationGains.GainReader.getReferenceGain (   self,
  coolId 
)

Definition at line 499 of file PlotCalibrationGains.py.

499  def getReferenceGain(self,coolId):
500  if (coolId in self.reference_gains):
501  return float(self.reference_gains[coolId])
502  else:
503  return ''
504 

◆ LoadGainsSqlite()

def PlotCalibrationGains.GainReader.LoadGainsSqlite (   self,
  name 
)

Definition at line 340 of file PlotCalibrationGains.py.

340  def LoadGainsSqlite(self,name):
341 
342  # get database service and open database
343  dbSvc = cool.DatabaseSvcFactory.databaseService()
344 
345  dbString='sqlite://;schema='+name+';dbname=L1CALO'
346  try:
347  db = dbSvc.openDatabase(dbString, False)
348  except Exception as e:
349  print ('Error: Problem opening database', e)
350  sys.exit(1)
351 
352  folder_name = '/TRIGGER/L1Calo/V1/Results/EnergyScanResults'
353  folder=db.getFolder(folder_name)
354 
355  startUtime = int(time.time())
356  endUtime = int(time.time())
357  startValKey = startUtime * self.UNIX2COOL
358  endValKey = endUtime * self.UNIX2COOL
359  chsel = cool.ChannelSelection(0,sys.maxsize)
360 
361  try:
362  itr=folder.browseObjects(startValKey, endValKey, chsel)
363  except Exception as e:
364  print (e)
365  sys.exit(1)
366 
367  for row in itr:
368  CoolId = hex(int(row.channelId()))
369  payload = row.payload()
370  self.measured_gains[CoolId] = payload['Slope']
371  self.measured_chi2[CoolId] = payload['Chi2']
372  self.measured_offset[CoolId] = payload['Offset']
373 
374 # print (self.measured_gains)
375 
376  folder_gen_name = '/TRIGGER/L1Calo/V1/Results/EnergyScanRunInfo'
377  folder_gen=db.getFolder(folder_gen_name)
378 
379  try:
380  itr=folder_gen.browseObjects(startValKey, endValKey, chsel)
381  for row in itr:
382  payload = row.payload()
383  self.run_nr = payload['RunNumber']
384  self.strategy = payload['GainStrategy']
385  print ("Run nr. = ", self.run_nr , " Strategy = ", self.strategy)
386 
387  except Exception: # Doesn't seem to catch C++ exceptions :-(
388  print ("Warning, in LoadGainsSqlite can't get runtype info! Hope this is not serious!")
389 
390 
391  # close database
392  db.closeDatabase()
393 

◆ LoadGainsXml()

def PlotCalibrationGains.GainReader.LoadGainsXml (   self,
  name 
)

Definition at line 300 of file PlotCalibrationGains.py.

300  def LoadGainsXml(self,name):
301 
302  input_file = open(name)
303 
304  for line in input_file.readlines():
305  parts = line.split(' ')
306  if parts[0] == '<Channel':
307  list_cool=parts[1].split('\'')
308  cool_id=list_cool[1]
309 
310  list_gain=parts[2].split('\'')
311  gain=list_gain[1]
312  self.measured_gains[cool_id]=gain
313 
314  list_offset=parts[3].split('\'')
315  offset=list_offset[1]
316  self.measured_offset[cool_id]=offset
317 
318  list_chi2=parts[4].split('\'')
319  chi2=list_chi2[1]
320  self.measured_chi2[cool_id]=chi2
321 
322 
323  input_file.close()
324 

◆ LoadReferenceOracle()

def PlotCalibrationGains.GainReader.LoadReferenceOracle (   self,
  mapping_tool 
)

Definition at line 431 of file PlotCalibrationGains.py.

431  def LoadReferenceOracle(self,mapping_tool):
432 
433  # get database service and open database
434  dbSvc = cool.DatabaseSvcFactory.databaseService()
435 
436  dbString = 'oracle://ATLAS_COOLPROD;schema=ATLAS_COOLONL_TRIGGER;dbname=CONDBR2'
437  try:
438  db = dbSvc.openDatabase(dbString, False)
439  except Exception as e:
440  print ('Error: Problem opening database', e)
441  sys.exit(1)
442 
443  folder_name = "/TRIGGER/Receivers/Factors/CalibGains"
444  folder=db.getFolder(folder_name)
445 
446  startUtime = int(time.time())
447  endUtime = int(time.time())
448  startValKey = startUtime * self.UNIX2COOL
449  endValKey = endUtime * self.UNIX2COOL
450  chsel = cool.ChannelSelection(0,sys.maxsize)
451 
452  try:
453  itr=folder.browseObjects(startValKey, endValKey, chsel)
454  except Exception as e:
455  print (e)
456  sys.exit(1)
457 
458  for row in itr:
459  ReceiverId = hex(int(row.channelId()))
460  PPMId = mapping_tool.getPPMfromReceiver(ReceiverId)
461  payload = row.payload()
462  gain = payload['factor']
463 
464  if PPMId is not None:
465  if self.strategy is None: #run type not known
466  self.reference_gains[PPMId]=gain
467  else:
468  if mapping_tool.getReceiverfromPPM(PPMId,self.strategy) == ReceiverId: # correct receiver?
469 # print ("Using receiver nr.", ReceiverId, "for PPM nr.",PPMId)
470  self.reference_gains[PPMId]=gain
471 # else:
472 # print ("Skipping receiver nr.", ReceiverId, "for PPM nr.",PPMId)
473 
474 

◆ LoadReferenceSqlite()

def PlotCalibrationGains.GainReader.LoadReferenceSqlite (   self,
  name 
)

Definition at line 394 of file PlotCalibrationGains.py.

394  def LoadReferenceSqlite(self,name):
395 
396  # get database service and open database
397  dbSvc = cool.DatabaseSvcFactory.databaseService()
398 
399  dbString='sqlite://;schema='+name+';dbname=L1CALO'
400  try:
401  db = dbSvc.openDatabase(dbString, False)
402  except Exception as e:
403  print ('Error: Problem opening database', e)
404  sys.exit(1)
405 
406  folder_name = '/TRIGGER/L1Calo/V1/Results/EnergyScanResults'
407  folder=db.getFolder(folder_name)
408 
409  startUtime = int(time.time())
410  endUtime = int(time.time())
411  startValKey = startUtime * self.UNIX2COOL
412  endValKey = endUtime * self.UNIX2COOL
413  chsel = cool.ChannelSelection(0,sys.maxsize)
414 
415  try:
416  itr=folder.browseObjects(startValKey, endValKey, chsel)
417  except Exception as e:
418  print (e)
419  sys.exit(1)
420 
421  for row in itr:
422  CoolId = hex(int(row.channelId()))
423  payload = row.payload()
424  self.reference_gains[CoolId]=payload['Slope']
425 
426 # print (self.measured_gains)
427  # close database
428  db.closeDatabase()
429 
430 

◆ LoadReferenceXml()

def PlotCalibrationGains.GainReader.LoadReferenceXml (   self,
  name 
)

Definition at line 325 of file PlotCalibrationGains.py.

325  def LoadReferenceXml(self,name):
326 
327  input_gains_reference = open(name)
328 
329  for line in input_gains_reference.readlines():
330  parts = line.split(' ')
331  if parts[0] == '<Channel':
332  list_cool=parts[1].split('\'')
333  cool_id=list_cool[1]
334 
335  list_gain=parts[2].split('\'')
336  gain=list_gain[1]
337  self.reference_gains[cool_id]=gain
338 
339 

◆ passesSelection()

def PlotCalibrationGains.GainReader.passesSelection (   self,
  coolId 
)

Definition at line 505 of file PlotCalibrationGains.py.

505  def passesSelection(self,coolId):
506  if ((coolId in self.measured_gains) and
507  (self.getGain(coolId) > 0.5 and self.getGain(coolId)<1.6) and
508 # (self.getGain(coolId) > 0.5 and self.getGain(coolId)<2.1) and
509 # (self.getOffset(coolId) > -2 and self.getOffset(coolId) < 2)):
510  (self.getOffset(coolId) > -10 and self.getOffset(coolId) < 10)):
511  return True
512  else:
513  return False
514 
515 

Member Data Documentation

◆ measured_chi2

PlotCalibrationGains.GainReader.measured_chi2

Definition at line 293 of file PlotCalibrationGains.py.

◆ measured_gains

PlotCalibrationGains.GainReader.measured_gains

Definition at line 291 of file PlotCalibrationGains.py.

◆ measured_offset

PlotCalibrationGains.GainReader.measured_offset

Definition at line 294 of file PlotCalibrationGains.py.

◆ reference_gains

PlotCalibrationGains.GainReader.reference_gains

Definition at line 292 of file PlotCalibrationGains.py.

◆ run_nr

PlotCalibrationGains.GainReader.run_nr

Definition at line 297 of file PlotCalibrationGains.py.

◆ strategy

PlotCalibrationGains.GainReader.strategy

Definition at line 298 of file PlotCalibrationGains.py.

◆ UNIX2COOL

PlotCalibrationGains.GainReader.UNIX2COOL

Definition at line 295 of file PlotCalibrationGains.py.


The documentation for this class was generated from the following file:
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
PlotRamps.passesSelection
def passesSelection(gain, offset)
Definition: PlotRamps.py:8
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
Trk::open
@ open
Definition: BinningType.h:40
muCombUtil::getChi2
double getChi2(int &ndof, double ipt, double eta1, double seta1, double phi1, double sphi1, double ipt1, double sipt1, double eta2, double seta2, double phi2, double sphi2, double ipt2, double sipt2, bool useAbsPt)
Get OLD style (i.e. muFast time) Chi2.
Definition: muCombUtil.cxx:374
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
getOffset
void getOffset(boost::tokenizer< boost::char_separator< char > >::iterator &token, uint32_t &offset)
Definition: interpretSeeds.cxx:21