Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 1102 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 1109 of file TileCalibTools.py.

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

Member Function Documentation

◆ getData()

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

Definition at line 1172 of file TileCalibTools.py.

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

◆ getDict()

def python.TileCalibTools.TileASCIIParser.getDict (   self)

Definition at line 1178 of file TileCalibTools.py.

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

◆ PMT2channel()

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

Definition at line 1183 of file TileCalibTools.py.

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

Member Data Documentation

◆ __dataDict

python.TileCalibTools.TileASCIIParser.__dataDict
private

Definition at line 1117 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