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

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

Member Function Documentation

◆ getData()

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

Definition at line 1300 of file TileCalibTools.py.

1300 def getData(self, ros, drawer, channel):
1301 dictKey = (int(ros), int(drawer), int(channel))
1302 data = self.__dataDict.get(dictKey,[])
1303 return data
1304
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:132

◆ getDict()

python.TileCalibTools.TileASCIIParser.getDict ( self)

Definition at line 1306 of file TileCalibTools.py.

1306 def getDict(self):
1307 import copy
1308 return copy.deepcopy(self.__dataDict)
1309

◆ PMT2channel()

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

Definition at line 1311 of file TileCalibTools.py.

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

Member Data Documentation

◆ __dataDict

python.TileCalibTools.TileASCIIParser.__dataDict = {}
private

Definition at line 1245 of file TileCalibTools.py.


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