ATLAS Offline Software
Loading...
Searching...
No Matches
python.TileCalibTools.TileASCIIParser Class Reference
Inheritance diagram for python.TileCalibTools.TileASCIIParser:
Collaboration diagram for python.TileCalibTools.TileASCIIParser:

Public Member Functions

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

Private Attributes

dict __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 1218 of file TileCalibTools.py.

Constructor & Destructor Documentation

◆ __init__()

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

1225 def __init__(self, fileName, calibId, isSingleLineFormat=True):
1226 """
1227 Input:
1228 - fileName : input file name
1229 - isSingleLineFormat: if False, multi line format is assumed
1230 """
1231
1232 TileCalibLogger.__init__(self,"TileASCIIParser")
1233 self.__dataDict = {}
1234 try:
1235 lines = open(fileName,"r").readlines()
1236 except Exception as e:
1237 self.log().error( "TileCalibASCIIParser::ERROR: Problem opening input file:" )
1238 self.log().error( e )
1239 return
1240
1241 for line in lines:
1242 fields = line.strip().split()
1243 #=== ignore empty and comment lines
1244 if not len(fields) :
1245 continue
1246 if fields[0].startswith("#"):
1247 continue
1248
1249 #=== read in fields
1250 type = fields[0]
1251 frag = fields[1]
1252 chan = fields[2]
1253 data = fields[3:]
1254 if not isSingleLineFormat:
1255 raise Exception("Multiline format not implemented yet")
1256
1257 #=== check for correct calibId
1258 if type!=calibId:
1259 raise Exception("%s is not calibId=%s" % (type,calibId))
1260
1261 #=== decode fragment
1262 if not (frag.startswith('0x') or frag.startswith('-0x') or frag.startswith('h_')):
1263 raise Exception("Misformated fragment %s" % frag)
1264 if frag.startswith('0x') or frag.startswith('-0x'):
1265 frg = int(frag,16)
1266 ros = frg>>8
1267 if frg<0:
1268 mod = (-frg)&255
1269 else:
1270 mod = frg&255
1271 chn = int(chan)
1272 elif frag.startswith('h_'):
1273 part_dict = {'LBA':1,'LBC':2,'EBA':3,'EBC':4}
1274 partname = str(frag[2:5])
1275 ros=part_dict[partname]
1276 mod = int(frag[5:])-1
1277 if (chan.startswith('ch')):
1278 chn = int(chan[2:])
1279 else:
1280 pmt = int (chan)
1281 chn=self.PMT2channel(ros,mod,pmt)
1282
1283 #=== fill dictionary
1284 dictKey = (ros,mod,chn)
1285 self.__dataDict[dictKey] = data
1286
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

Member Function Documentation

◆ getData()

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

Definition at line 1288 of file TileCalibTools.py.

1288 def getData(self, ros, drawer, channel):
1289 dictKey = (int(ros), int(drawer), int(channel))
1290 data = self.__dataDict.get(dictKey,[])
1291 return data
1292
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130

◆ getDict()

python.TileCalibTools.TileASCIIParser.getDict ( self)

Definition at line 1294 of file TileCalibTools.py.

1294 def getDict(self):
1295 import copy
1296 return copy.deepcopy(self.__dataDict)
1297

◆ PMT2channel()

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

Definition at line 1299 of file TileCalibTools.py.

1299 def PMT2channel(self,ros,drawer,pmt):
1300 "Reorder the PMTs (SV: how to get that from region.py???)"
1301 "This takes ros [1-4], drawer [0-63], pmt [1-48]"
1302
1303 PMT2chan_Special={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1304 11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17, 19:18, 20:19,
1305 21:20,22:21,23:22,24:23,27:24,26:25,25:26,31:27,32:28,28:29,
1306 33:30,29:31,30:32,36:33,35:34,34:35,44:36,38:37,37:38,43:39,42:40,
1307 41:41,45:42,39:43,40:44,48:45,47:46,46:47}
1308
1309
1310 PMT2chan_LB={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1311 11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:18,20:19,
1312 21:20,22:21,23:22,24:23,27:24,26:25,25:26,30:27,29:28,28:29,
1313 33:30,32:31,31:32,36:33,35:34,34:35,39:36,38:37,37:38,42:39,41:40,
1314 40:41,45:42,44:43,43:44,48:45,47:46,46:47}
1315
1316
1317 PMT2chan_EB={1:0,2:1,3:2,4:3,5:4,6:5,7:6,8:7,9:8,10:9,
1318 11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:18,20:19,
1319 21:20,22:21,23:22,24:23,25:24,26:25,27:26,28:27,31:28,32:29,
1320 33:30,29:31,30:32,35:33,36:34,34:35,44:36,38:37,37:38,43:39,42:40,
1321 41:41,39:42,40:43,45:44,46:45,47:46,48:47}
1322
1323 if ros <= 2:
1324 chan = PMT2chan_LB[pmt]
1325 elif (ros == 3 and drawer == 14) or (ros == 4 and drawer == 17):
1326 chan = PMT2chan_Special[pmt]
1327 else:
1328 chan = PMT2chan_EB[pmt]
1329
1330 return chan
1331
1332#======================================================================
1333#===
1334#=== TileASCIIParser2
1335#===
1336#======================================================================
1337
1338#
1339#______________________________________________________________________

Member Data Documentation

◆ __dataDict

python.TileCalibTools.TileASCIIParser.__dataDict = {}
private

Definition at line 1233 of file TileCalibTools.py.


The documentation for this class was generated from the following file: