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 1149 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 1156 of file TileCalibTools.py.

1156  def __init__(self, fileName, calibId, isSingleLineFormat=True):
1157  """
1158  Input:
1159  - fileName : input file name
1160  - isSingleLineFormat: if False, multi line format is assumed
1161  """
1162 
1163  TileCalibLogger.__init__(self,"TileASCIIParser")
1164  self.__dataDict = {}
1165  try:
1166  lines = open(fileName,"r").readlines()
1167  except Exception as e:
1168  self.log().error( "TileCalibASCIIParser::ERROR: Problem opening input file:" )
1169  self.log().error( e )
1170  return
1171 
1172  for line in lines:
1173  fields = line.strip().split()
1174  #=== ignore empty and comment lines
1175  if not len(fields) :
1176  continue
1177  if fields[0].startswith("#"):
1178  continue
1179 
1180  #=== read in fields
1181  type = fields[0]
1182  frag = fields[1]
1183  chan = fields[2]
1184  data = fields[3:]
1185  if not isSingleLineFormat:
1186  raise Exception("Multiline format not implemented yet")
1187 
1188  #=== check for correct calibId
1189  if type!=calibId:
1190  raise Exception("%s is not calibId=%s" % (type,calibId))
1191 
1192  #=== decode fragment
1193  if not (frag.startswith('0x') or frag.startswith('-0x') or frag.startswith('h_')):
1194  raise Exception("Misformated fragment %s" % frag)
1195  if frag.startswith('0x') or frag.startswith('-0x'):
1196  frg = int(frag,16)
1197  ros = frg>>8
1198  if frg<0:
1199  mod = (-frg)&255
1200  else:
1201  mod = frg&255
1202  chn = int(chan)
1203  elif frag.startswith('h_'):
1204  part_dict = {'LBA':1,'LBC':2,'EBA':3,'EBC':4}
1205  partname = str(frag[2:5])
1206  ros=part_dict[partname]
1207  mod = int(frag[5:])-1
1208  if (chan.startswith('ch')):
1209  chn = int(chan[2:])
1210  else:
1211  pmt = int (chan)
1212  chn=self.PMT2channel(ros,mod,pmt)
1213 
1214  #=== fill dictionary
1215  dictKey = (ros,mod,chn)
1216  self.__dataDict[dictKey] = data
1217 

Member Function Documentation

◆ getData()

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

Definition at line 1219 of file TileCalibTools.py.

1219  def getData(self, ros, drawer, channel):
1220  dictKey = (int(ros), int(drawer), int(channel))
1221  data = self.__dataDict.get(dictKey,[])
1222  return data
1223 

◆ getDict()

def python.TileCalibTools.TileASCIIParser.getDict (   self)

Definition at line 1225 of file TileCalibTools.py.

1225  def getDict(self):
1226  import copy
1227  return copy.deepcopy(self.__dataDict)
1228 

◆ PMT2channel()

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

Definition at line 1230 of file TileCalibTools.py.

1230  def PMT2channel(self,ros,drawer,pmt):
1231  "Reorder the PMTs (SV: how to get that from region.py???)"
1232  "This takes ros [1-4], drawer [0-63], pmt [1-48]"
1233 
1234  PMT2chan_Special={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1235  11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17, 19:18, 20:19,
1236  21:20,22:21,23:22,24:23,27:24,26:25,25:26,31:27,32:28,28:29,
1237  33:30,29:31,30:32,36:33,35:34,34:35,44:36,38:37,37:38,43:39,42:40,
1238  41:41,45:42,39:43,40:44,48:45,47:46,46:47}
1239 
1240 
1241  PMT2chan_LB={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1242  11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:18,20:19,
1243  21:20,22:21,23:22,24:23,27:24,26:25,25:26,30:27,29:28,28:29,
1244  33:30,32:31,31:32,36:33,35:34,34:35,39:36,38:37,37:38,42:39,41:40,
1245  40:41,45:42,44:43,43:44,48:45,47:46,46:47}
1246 
1247 
1248  PMT2chan_EB={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1249  11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:18,20:19,
1250  21:20,22:21,23:22,24:23,25:24,26:25,27:26,28:27,31:28,32:29,
1251  33:30,29:31,30:32,35:33,36:34,34:35,44:36,38:37,37:38,43:39,42:40,
1252  41:41,39:42,40:43,45:44,46:45,47:46,48:47}
1253 
1254  if ros <= 2:
1255  chan = PMT2chan_LB[pmt]
1256  elif (ros == 3 and drawer == 14) or (ros == 4 and drawer == 17):
1257  chan = PMT2chan_Special[pmt]
1258  else:
1259  chan = PMT2chan_EB[pmt]
1260 
1261  return chan
1262 
1263 #======================================================================
1264 #===
1265 #=== TileASCIIParser2
1266 #===
1267 #======================================================================
1268 
1269 #
1270 #______________________________________________________________________

Member Data Documentation

◆ __dataDict

python.TileCalibTools.TileASCIIParser.__dataDict
private

Definition at line 1164 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.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.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:130
str
Definition: BTagTrackIpAccessor.cxx:11
error
Definition: IImpactPoint3dEstimator.h:70
Trk::split
@ split
Definition: LayerMaterialProperties.h:38