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 1096 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 1103 of file TileCalibTools.py.

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

Member Function Documentation

◆ getData()

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

Definition at line 1166 of file TileCalibTools.py.

1166  def getData(self, ros, drawer, channel):
1167  dictKey = (int(ros), int(drawer), int(channel))
1168  data = self.__dataDict.get(dictKey,[])
1169  return data
1170 

◆ getDict()

def python.TileCalibTools.TileASCIIParser.getDict (   self)

Definition at line 1172 of file TileCalibTools.py.

1172  def getDict(self):
1173  import copy
1174  return copy.deepcopy(self.__dataDict)
1175 

◆ PMT2channel()

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

Definition at line 1177 of file TileCalibTools.py.

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

Member Data Documentation

◆ __dataDict

python.TileCalibTools.TileASCIIParser.__dataDict
private

Definition at line 1111 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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py: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
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