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.TileASCIIParser2 Class Reference
Inheritance diagram for python.TileCalibTools.TileASCIIParser2:
Collaboration diagram for python.TileCalibTools.TileASCIIParser2:

Public Member Functions

def __init__ (self, fileName, calibId="", readGain=True)
 
def getData (self, ros, drawer, channel, adc, iov=(MAXRUN, MAXLBK))
 
def getDict (self)
 
def channel2PMT (self, ros, drawer, chan)
 
def PMT2channel (self, partition, pmt)
 

Private Attributes

 __dataDict
 
 __manyIOVs
 
 __readGain
 

Detailed Description

This is a class capable of parsing TileCal conditions data stored in
ASCII files. This version of parser can be used when mutiple IOVs are
given in the file. First column is (run,lumi) pair in this case

Definition at line 1224 of file TileCalibTools.py.

Constructor & Destructor Documentation

◆ __init__()

def python.TileCalibTools.TileASCIIParser2.__init__ (   self,
  fileName,
  calibId = "",
  readGain = True 
)
Input:
- fileName          : input file name
- calibId           : like Ped, Las, ... or (r,l) or (run,lumi) but can be empty string as well
- readGain          : if False, no gain field in input file

Definition at line 1232 of file TileCalibTools.py.

1232  def __init__(self, fileName, calibId="", readGain=True):
1233  """
1234  Input:
1235  - fileName : input file name
1236  - calibId : like Ped, Las, ... or (r,l) or (run,lumi) but can be empty string as well
1237  - readGain : if False, no gain field in input file
1238  """
1239 
1240  TileCalibLogger.__init__(self,"TileASCIIParser2")
1241  self.__dataDict = {}
1242  self.__manyIOVs = (calibId=="(run,lumi)" or calibId=="(r,l)" )
1243  self.__readGain = readGain
1244  iov=(0,0)
1245  gain=-1
1246 
1247  try:
1248  lines = open(fileName,"r").readlines()
1249  except Exception as e:
1250  self.log().error( "TileCalibASCIIParser2::ERROR: Problem opening input file:" )
1251  self.log().error( e )
1252  return
1253 
1254  self.log().info("Parsing file %s",fileName)
1255  if len(calibId)>0:
1256  self.log().info("Looking for prefix %s",calibId)
1257 
1258  for line in lines:
1259  fields = line.strip().split()
1260  #=== ignore empty and comment lines
1261  if not len(fields) :
1262  continue
1263  if fields[0].startswith("#"):
1264  continue
1265 
1266  #=== read in fields
1267  if len(calibId)>0:
1268  pref = fields[0]
1269  frag = fields[1]
1270  chan = fields[2]
1271  if str(chan)[0:2].lower() == "pm":
1272  chan = self.PMT2channel(frag,fields.pop(2))
1273  if readGain:
1274  gain = fields[3]
1275  data = fields[4:]
1276  else:
1277  data = fields[3:]
1278 
1279  #=== check for correct calibId
1280  if self.__manyIOVs:
1281  iov=tuple(int(i) for i in pref[1:-1].split(","))
1282  if len(iov)!=2 or pref[0]!="(" or pref[-1]!=")":
1283  raise Exception("%s is not %s IOV" % (pref,calibId))
1284  elif pref!=calibId:
1285  raise Exception("%s is not calibId=%s" % (pref,calibId))
1286  else:
1287  frag = fields[0]
1288  chan = fields[1]
1289  if str(chan)[0:2].lower() == "pm":
1290  chan = self.PMT2channel(frag,fields.pop(2))
1291  if readGain:
1292  gain = fields[2]
1293  data = fields[3:]
1294  else:
1295  data = fields[2:]
1296 
1297  #=== decode fragment
1298  if frag.startswith('0x') or frag.startswith('-0x'):
1299  frg = int(frag,16)
1300  ros = frg>>8
1301  if frg<0:
1302  mod = (-frg)&255
1303  else:
1304  mod = frg&255
1305  elif (frag.startswith("AUX") or
1306  frag.startswith("LBA") or
1307  frag.startswith("LBC") or
1308  frag.startswith("EBA") or
1309  frag.startswith("EBC") or
1310  frag.startswith("ALL") or
1311  frag.startswith("XXX") ):
1312  part_dict = {'AUX':0,'LBA':1,'LBC':2,'EBA':3,'EBC':4,'ALL':5,'XXX':-1}
1313  partname = str(frag[0:3])
1314  ros=part_dict[partname]
1315  mod = int(frag[3:])-1
1316  else:
1317  raise Exception("Unknown fragment %s" % frag)
1318 
1319  chn = int(chan)
1320  adc = int(gain)
1321 
1322  #=== fill dictionary
1323  if ros<0:
1324  rosmin=0
1325  rosmax=5
1326  elif ros>=5:
1327  rosmin=1
1328  rosmax=5
1329  else:
1330  rosmin=ros
1331  rosmax=ros+1
1332 
1333  if mod<0 or mod>=64:
1334  modmin=0
1335  modmax=64
1336  else:
1337  modmin=mod
1338  modmax=mod+1
1339 
1340  allchannels=True
1341  if chn<-2:
1342  chnmin=0
1343  chnmax=-chn
1344  elif chn<0:
1345  chnmin=0
1346  chnmax=48
1347  allchannels=(chn==-1) # if chn=-2 only connected channels will be updated
1348  else:
1349  chnmin=chn
1350  chnmax=chn+1
1351 
1352  if adc<-1:
1353  adcmin=0
1354  adcmax=-adc
1355  elif adc<0:
1356  adcmin=0
1357  adcmax=2
1358  else:
1359  adcmin=adc
1360  adcmax=adc+1
1361 
1362  for ros in range(rosmin,rosmax):
1363  for mod in range(modmin,modmax):
1364  for chn in range(chnmin,chnmax):
1365  if allchannels or self.channel2PMT(ros,mod,chn)>0:
1366  for adc in range (adcmin,adcmax):
1367  dictKey = (ros,mod,chn,adc)
1368  if self.__manyIOVs:
1369  if dictKey in self.__dataDict:
1370  self.__dataDict[dictKey] += [(iov,data)]
1371  else:
1372  self.__dataDict[dictKey] = [(iov,data)]
1373  else:
1374  self.__dataDict[dictKey] = data
1375 

Member Function Documentation

◆ channel2PMT()

def python.TileCalibTools.TileASCIIParser2.channel2PMT (   self,
  ros,
  drawer,
  chan 
)

Definition at line 1394 of file TileCalibTools.py.

1394  def channel2PMT(self,ros,drawer,chan):
1395  "Convert channel numbet to PMT number, negative for disconnected channels"
1396  "This takes ros [1-4], drawer [0-63], chan [0-47]"
1397 
1398  chan2PMT_LB=[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
1399  13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1400  27, 26, 25, 30, 29, 28,-33,-32, 31, 36, 35, 34,
1401  39, 38, 37, 42, 41, 40, 45,-44, 43, 48, 47, 46 ]
1402 
1403  chan2PMT_EB=[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
1404  13, 14, 15, 16, 17, 18,-19,-20, 21, 22, 23, 24,
1405  -27,-26,-25,-31,-32,-28, 33, 29, 30,-36,-35, 34,
1406  44, 38, 37, 43, 42, 41,-45,-39,-40,-48,-47,-46 ]
1407 
1408  chan2PMT_Sp=[ -1, -2, -3, -4, 5, 6, 7, 8, 9, 10, 11, 12, # first 4 do not exist
1409  13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, # PMT 19 and 20 exist
1410  -27,-26,-25,-31,-32,-28, 33, 29, 30,-36,-35, 34,
1411  44, 38, 37, 43, 42, 41,-45,-39,-40,-48,-47,-46 ]
1412 
1413  if ros <= 2:
1414  pmt = chan2PMT_LB[chan]
1415  elif (ros == 3 and drawer == 14) or (ros == 4 and drawer == 17):
1416  pmt = chan2PMT_Sp[chan]
1417  else:
1418  pmt = chan2PMT_EB[chan]
1419 
1420  return pmt
1421 

◆ getData()

def python.TileCalibTools.TileASCIIParser2.getData (   self,
  ros,
  drawer,
  channel,
  adc,
  iov = (MAXRUN,MAXLBK) 
)

Definition at line 1377 of file TileCalibTools.py.

1377  def getData(self, ros, drawer, channel, adc, iov=(MAXRUN,MAXLBK)):
1378  dictKey = (int(ros), int(drawer), int(channel), int(adc))
1379  data = self.__dataDict.get(dictKey,[])
1380  if self.__manyIOVs and len(data)>0:
1381  before= [i for i in sorted(data) if i[0] <= iov ]
1382  if len(before)>0:
1383  data = before[-1][1]
1384  else:
1385  data = []
1386  return data
1387 

◆ getDict()

def python.TileCalibTools.TileASCIIParser2.getDict (   self)

Definition at line 1389 of file TileCalibTools.py.

1389  def getDict(self):
1390  import copy
1391  return copy.deepcopy(self.__dataDict)
1392 

◆ PMT2channel()

def python.TileCalibTools.TileASCIIParser2.PMT2channel (   self,
  partition,
  pmt 
)

Definition at line 1423 of file TileCalibTools.py.

1423  def PMT2channel(self,partition,pmt):
1424  "Convert PMT number to channel numbet"
1425  "This takes partition (LBA,LBC,EBA,EBC) and pmt [1-48]"
1426 
1427  chan2PMT_LB=[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
1428  13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1429  27, 26, 25, 30, 29, 28, 33, 32, 31, 36, 35, 34,
1430  39, 38, 37, 42, 41, 40, 45, 44, 43, 48, 47, 46 ]
1431 
1432  chan2PMT_EB=[ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
1433  13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
1434  27, 26, 25, 31, 32, 28, 33, 29, 30, 36, 35, 34,
1435  44, 38, 37, 43, 42, 41, 45, 39, 40, 48, 47, 46 ]
1436 
1437  chan = -1
1438  pm=abs(int(pmt))
1439 
1440  if pm>0 and pm<=48:
1441  if str(partition)[0].upper() == "E":
1442  chan = chan2PMT_EB.index(pm)
1443  else:
1444  chan = chan2PMT_LB.index(pm)
1445 
1446  return chan
1447 
1448 #======================================================================
1449 #===
1450 #=== TileASCIIParser3
1451 #===
1452 #======================================================================
1453 
1454 #______________________________________________________________________

Member Data Documentation

◆ __dataDict

python.TileCalibTools.TileASCIIParser2.__dataDict
private

Definition at line 1241 of file TileCalibTools.py.

◆ __manyIOVs

python.TileCalibTools.TileASCIIParser2.__manyIOVs
private

Definition at line 1242 of file TileCalibTools.py.

◆ __readGain

python.TileCalibTools.TileASCIIParser2.__readGain
private

Definition at line 1243 of file TileCalibTools.py.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename R::value_type > sorted(const R &r, PROJ proj={})
Helper function to create a sorted vector from an unsorted range.
InDetSimDataHelpers::getData
const InDetSimData * getData(const InDetSimDataCollection &coll, const Identifier &id)
Definition: InDetSimDataDict.h:24
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
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