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

Public Member Functions

def __init__ (self, fileName, calibId, isSingleLineFormat=True)
 
def getData (self, ros, drawer, channel)
 
def getDict (self)
 
def PMT2channel (self, ros, drawer, pmt)
 

Private Attributes

 __dataDict
 

Detailed Description

This is a class capable of parsing TileCal conditions data stored in
ASCII files. Both the single and multi-line formats are supported.

Definition at line 1101 of file TileCalibTools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.TileCalibTools.TileASCIIParser.__init__ (   self,
  fileName,
  calibId,
  isSingleLineFormat = True 
)
Input:
- fileName          : input file name
- isSingleLineFormat: if False, multi line format is assumed

Definition at line 1108 of file TileCalibTools.py.

1108  def __init__(self, fileName, calibId, isSingleLineFormat=True):
1109  """
1110  Input:
1111  - fileName : input file name
1112  - isSingleLineFormat: if False, multi line format is assumed
1113  """
1114 
1115  TileCalibLogger.__init__(self,"TileASCIIParser")
1116  self.__dataDict = {}
1117  try:
1118  lines = open(fileName,"r").readlines()
1119  except Exception as e:
1120  self.log().error( "TileCalibASCIIParser::ERROR: Problem opening input file:" )
1121  self.log().error( e )
1122  return
1123 
1124  for line in lines:
1125  fields = line.strip().split()
1126  #=== ignore empty and comment lines
1127  if not len(fields) :
1128  continue
1129  if fields[0].startswith("#"):
1130  continue
1131 
1132  #=== read in fields
1133  type = fields[0]
1134  frag = fields[1]
1135  chan = fields[2]
1136  data = fields[3:]
1137  if not isSingleLineFormat:
1138  raise Exception("Multiline format not implemented yet")
1139 
1140  #=== check for correct calibId
1141  if type!=calibId:
1142  raise Exception("%s is not calibId=%s" % (type,calibId))
1143 
1144  #=== decode fragment
1145  if not (frag.startswith('0x') or frag.startswith('-0x') or frag.startswith('h_')):
1146  raise Exception("Misformated fragment %s" % frag)
1147  if frag.startswith('0x') or frag.startswith('-0x'):
1148  frg = int(frag,16)
1149  ros = frg>>8
1150  if frg<0:
1151  mod = (-frg)&255
1152  else:
1153  mod = frg&255
1154  chn = int(chan)
1155  elif frag.startswith('h_'):
1156  part_dict = {'LBA':1,'LBC':2,'EBA':3,'EBC':4}
1157  partname = str(frag[2:5])
1158  ros=part_dict[partname]
1159  mod = int(frag[5:])-1
1160  if (chan.startswith('ch')):
1161  chn = int(chan[2:])
1162  else:
1163  pmt = int (chan)
1164  chn=self.PMT2channel(ros,mod,pmt)
1165 
1166  #=== fill dictionary
1167  dictKey = (ros,mod,chn)
1168  self.__dataDict[dictKey] = data
1169 

Member Function Documentation

◆ getData()

def python.TileCalibTools.TileASCIIParser.getData (   self,
  ros,
  drawer,
  channel 
)

Definition at line 1171 of file TileCalibTools.py.

1171  def getData(self, ros, drawer, channel):
1172  dictKey = (int(ros), int(drawer), int(channel))
1173  data = self.__dataDict.get(dictKey,[])
1174  return data
1175 

◆ getDict()

def python.TileCalibTools.TileASCIIParser.getDict (   self)

Definition at line 1177 of file TileCalibTools.py.

1177  def getDict(self):
1178  import copy
1179  return copy.deepcopy(self.__dataDict)
1180 

◆ PMT2channel()

def python.TileCalibTools.TileASCIIParser.PMT2channel (   self,
  ros,
  drawer,
  pmt 
)

Definition at line 1182 of file TileCalibTools.py.

1182  def PMT2channel(self,ros,drawer,pmt):
1183  "Reorder the PMTs (SV: how to get that from region.py???)"
1184  "This takes ros [1-4], drawer [0-63], pmt [1-48]"
1185 
1186  PMT2chan_Special={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1187  11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17, 19:18, 20:19,
1188  21:20,22:21,23:22,24:23,27:24,26:25,25:26,31:27,32:28,28:29,
1189  33:30,29:31,30:32,36:33,35:34,34:35,44:36,38:37,37:38,43:39,42:40,
1190  41:41,45:42,39:43,40:44,48:45,47:46,46:47}
1191 
1192 
1193  PMT2chan_LB={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1194  11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:18,20:19,
1195  21:20,22:21,23:22,24:23,27:24,26:25,25:26,30:27,29:28,28:29,
1196  33:30,32:31,31:32,36:33,35:34,34:35,39:36,38:37,37:38,42:39,41:40,
1197  40:41,45:42,44:43,43:44,48:45,47:46,46:47}
1198 
1199 
1200  PMT2chan_EB={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1201  11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:18,20:19,
1202  21:20,22:21,23:22,24:23,25:24,26:25,27:26,28:27,31:28,32:29,
1203  33:30,29:31,30:32,35:33,36:34,34:35,44:36,38:37,37:38,43:39,42:40,
1204  41:41,39:42,40:43,45:44,46:45,47:46,48:47}
1205 
1206  if ros <= 2:
1207  chan = PMT2chan_LB[pmt]
1208  elif (ros == 3 and drawer == 14) or (ros == 4 and drawer == 17):
1209  chan = PMT2chan_Special[pmt]
1210  else:
1211  chan = PMT2chan_EB[pmt]
1212 
1213  return chan
1214 
1215 #======================================================================
1216 #===
1217 #=== TileASCIIParser2
1218 #===
1219 #======================================================================
1220 
1221 #
1222 #______________________________________________________________________

Member Data Documentation

◆ __dataDict

python.TileCalibTools.TileASCIIParser.__dataDict
private

Definition at line 1116 of file TileCalibTools.py.


The documentation for this class was generated from the following file:
InDetSimDataHelpers::getData
const InDetSimData * getData(const InDetSimDataCollection &coll, const Identifier &id)
Definition: InDetSimDataDict.h:24
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
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
str
Definition: BTagTrackIpAccessor.cxx:11
error
Definition: IImpactPoint3dEstimator.h:70
Trk::split
@ split
Definition: LayerMaterialProperties.h:38