Skip to content
Snippets Groups Projects
Commit d3501c2a authored by Stephen Wood's avatar Stephen Wood Committed by Eric Pooser
Browse files

Scaler script and map updates (#233)

* Make make_scaler_db.py have unix format rather than DOS format

* Generate special lines for Charge, Current and Time in scaler configs

* Accomadate extra "page" column in scaler.map
  in make_scaler_db.py conversion script

* Add extra "page" column to scaler.map for new xscaler
  (And remove underscore in SHMS HODO EDTM description)
parent 1234ded3
No related branches found
No related tags found
No related merge requests found
......@@ -109,6 +109,8 @@ variable 6 7 1 .ASUM.scaler HMS ASUM
variable 6 7 2 .ASUM.scalerRate HMS ASUM
variable 6 27 1 .BCM1.scaler bcm1
variable 6 27 2 .BCM1.scalerRate bcm1
variable 6 27 3 .BCM1.scalerCurrent bcm1
variable 6 27 4 .BCM1.scalerCharge bcm1
variable 0 14 1 .hod.1x14.posScaler HMS 1X+ paddle 14
variable 0 14 2 .hod.1x14.posScalerRate HMS 1X+ paddle 14
variable 2 17 1 .hod.2x3.negScaler HMS 2X- paddle 3
......@@ -147,6 +149,8 @@ variable 2 12 1 .hod.2x10.posScaler HMS 2X+ paddle 10
variable 2 12 2 .hod.2x10.posScalerRate HMS 2X+ paddle 10
variable 6 25 1 .BCM4A.scaler bcm4a
variable 6 25 2 .BCM4A.scalerRate bcm4a
variable 6 25 3 .BCM4A.scalerCurrent bcm4a
variable 6 25 4 .BCM4A.scalerCharge bcm4a
variable 0 31 1 .hod.1x16.negScaler HMS 1X- paddle 16
variable 0 31 2 .hod.1x16.negScalerRate HMS 1X- paddle 16
variable 0 15 1 .hod.1x16.posScaler HMS 1X+ paddle 16
......@@ -173,6 +177,8 @@ variable 3 1 1 .hod.2y3.posScaler HMS 2Y+ paddle 3
variable 3 1 2 .hod.2y3.posScalerRate HMS 2Y+ paddle 3
variable 6 29 1 .BCM17.scaler bcm17
variable 6 29 2 .BCM17.scalerRate bcm17
variable 6 29 3 .BCM17.scalerCurrent bcm17
variable 6 29 4 .BCM17.scalerCharge bcm17
variable 3 14 1 .Empty_17.scaler Empty
variable 3 14 2 .Empty_17.scalerRate Empty
variable 1 6 1 .hod.1y6.posScaler HMS 1Y+ paddle 6
......@@ -277,14 +283,19 @@ variable 0 1 1 .hod.1x3.posScaler HMS 1X+ paddle 3
variable 0 1 2 .hod.1x3.posScalerRate HMS 1X+ paddle 3
variable 6 26 1 .BCM4B.scaler bcm4b
variable 6 26 2 .BCM4B.scalerRate bcm4b
variable 6 26 3 .BCM4B.scalerCurrent bcm4b
variable 6 26 4 .BCM4B.scalerCharge bcm4b
variable 2 26 1 .hod.2x13.negScaler HMS 2X- paddle 13
variable 2 26 2 .hod.2x13.negScalerRate HMS 2X- paddle 13
variable 0 17 1 .hod.1x3.negScaler HMS 1X- paddle 3
variable 0 17 2 .hod.1x3.negScalerRate HMS 1X- paddle 3
variable 6 31 1 .1Mhz.scaler 1MHz
variable 6 31 2 .1Mhz.scalerRate 1MHz
variable 6 31 5 .1Mhz.scalerTime 1MHz
variable 6 30 1 .Unser.scaler Unser
variable 6 30 2 .Unser.scalerRate Unser
variable 6 30 3 .Unser.scalerCurrent Unser
variable 6 30 4 .Unser.scalerCharge Unser
variable 6 10 1 .DSUM.scaler HMS DSUM
variable 6 10 2 .DSUM.scalerRate HMS DSUM
variable 0 12 1 .hod.1x10.posScaler HMS 1X+ paddle 10
......@@ -305,6 +316,8 @@ variable 3 12 1 .hod.2y10.posScaler HMS 2Y+ paddle 10
variable 3 12 2 .hod.2y10.posScalerRate HMS 2Y+ paddle 10
variable 6 28 1 .BCM2.scaler bcm2
variable 6 28 2 .BCM2.scalerRate bcm2
variable 6 28 3 .BCM2.scalerCurrent bcm2
variable 6 28 4 .BCM2.scalerCharge bcm2
variable 3 6 1 .hod.2y6.posScaler HMS 2Y+ paddle 6
variable 3 6 2 .hod.2y6.posScalerRate HMS 2Y+ paddle 6
variable 3 22 1 .hod.2y6.negScaler HMS 2Y- paddle 6
......
......@@ -12,6 +12,8 @@ variable 2 7 1 .hod.2x8.posScaler SHMS 2X+ paddle 8
variable 2 7 2 .hod.2x8.posScalerRate SHMS 2X+ paddle 8
variable 7 30 1 .Unser.scaler Unser
variable 7 30 2 .Unser.scalerRate Unser
variable 7 30 3 .Unser.scalerCurrent Unser
variable 7 30 4 .Unser.scalerCharge Unser
variable 3 16 1 .hod.2y1.negScaler SHMS 2y- paddle 1
variable 3 16 2 .hod.2y1.negScalerRate SHMS 2y- paddle 1
variable 3 30 1 .hod.2y14.negScaler SHMS 2y- paddle 14
......@@ -40,6 +42,8 @@ variable 3 29 1 .hod.2y12.negScaler SHMS 2y- paddle 12
variable 3 29 2 .hod.2y12.negScalerRate SHMS 2y- paddle 12
variable 7 28 1 .BCM2.scaler bcm2
variable 7 28 2 .BCM2.scalerRate bcm2
variable 7 28 3 .BCM2.scalerCurrent bcm2
variable 7 28 4 .BCM2.scalerCharge bcm2
variable 1 20 1 .hod.1y2.posScaler SHMS 1Y+ paddle 2
variable 1 20 2 .hod.1y2.posScalerRate SHMS 1Y+ paddle 2
variable 0 5 1 .hod.1x4.posScaler SHMS 1X+ paddle 4
......@@ -56,6 +60,8 @@ variable 2 12 1 .hod.2x10.posScaler SHMS 2X+ paddle 10
variable 2 12 2 .hod.2x10.posScalerRate SHMS 2X+ paddle 10
variable 7 27 1 .BCM1.scaler bcm1
variable 7 27 2 .BCM1.scalerRate bcm1
variable 7 27 3 .BCM1.scalerCurrent bcm1
variable 7 27 4 .BCM1.scalerCharge bcm1
variable 2 28 1 .hod.2x10.negScaler SHMS 2X- paddle 10
variable 2 28 2 .hod.2x10.negScalerRate SHMS 2X- paddle 10
variable 0 1 1 .hod.1x3.posScaler SHMS 1X+ paddle 3
......@@ -140,6 +146,8 @@ variable 6 1 1 .pTRIG2.scaler SHMS TRIG2
variable 6 1 2 .pTRIG2.scalerRate SHMS TRIG2
variable 7 29 1 .BCM17.scaler bcm17
variable 7 29 2 .BCM17.scalerRate bcm17
variable 7 29 3 .BCM17.scalerCurrent bcm17
variable 7 29 4 .BCM17.scalerCharge bcm17
variable 1 18 1 .hod.1y5.posScaler SHMS 1Y+ paddle 5
variable 1 18 2 .hod.1y5.posScalerRate SHMS 1Y+ paddle 5
variable 1 2 1 .hod.1y5.negScaler SHMS 1Y- paddle 5
......@@ -172,8 +180,8 @@ variable 0 13 1 .hod.1x12.posScaler SHMS 1X+ paddle 12
variable 0 13 2 .hod.1x12.posScalerRate SHMS 1X+ paddle 12
variable 3 24 1 .hod.2y9.negScaler SHMS 2y- paddle 9
variable 3 24 2 .hod.2y9.negScalerRate SHMS 2y- paddle 9
variable 7 10 1 .HOD_EDTM.scaler SHMS_HODO_EDTM
variable 7 10 2 .HOD_EDTM.scalerRate SHMS_HODO_EDTM
variable 7 10 1 .HOD_EDTM.scaler SHMS HODO EDTM
variable 7 10 2 .HOD_EDTM.scalerRate SHMS HODO EDTM
variable 1 21 1 .hod.1y4.posScaler SHMS 1Y+ paddle 4
variable 1 21 2 .hod.1y4.posScalerRate SHMS 1Y+ paddle 4
variable 2 8 1 .hod.2x9.posScaler SHMS 2X+ paddle 9
......@@ -222,6 +230,7 @@ variable 3 7 1 .hod.2y8.posScaler SHMS 2y+ paddle 8
variable 3 7 2 .hod.2y8.posScalerRate SHMS 2y+ paddle 8
variable 7 31 1 .1Mhz.scaler 1MHz
variable 7 31 2 .1Mhz.scalerRate 1MHz
variable 7 31 5 .1Mhz.scalerTime 1MHz
variable 6 5 1 .pTRIG6.scaler SHMS TRIG6
variable 6 5 2 .pTRIG6.scalerRate SHMS TRIG6
variable 7 1 1 .S1Y.scaler SHMS S1Y
......@@ -272,8 +281,12 @@ variable 7 5 1 .S2XS2Y.scaler SHMS S2T
variable 7 5 2 .S2XS2Y.scalerRate SHMS S2T
variable 7 25 1 .BCM4A.scaler bcm4a
variable 7 25 2 .BCM4A.scalerRate bcm4a
variable 7 25 3 .BCM4A.scalerCurrent bcm4a
variable 7 25 4 .BCM4A.scalerCharge bcm4a
variable 7 26 1 .BCM4B.scaler bcm4b
variable 7 26 2 .BCM4B.scalerRate bcm4b
variable 7 26 3 .BCM4B.scalerCurrent bcm4b
variable 7 26 4 .BCM4B.scalerCharge bcm4b
variable 2 23 1 .hod.2x8.negScaler SHMS 2X- paddle 8
variable 2 23 2 .hod.2x8.negScalerRate SHMS 2X- paddle 8
variable 3 19 1 .hod.2y7.negScaler SHMS 2y- paddle 7
......
#!/usr/bin/python
# Deal with args
xscalerMapName = 'scaler.map'
cratemap = {
"4":{"spec":"H", "firstslot":6, "nslots":7, "roc":5, "offset":0},
"5":{"spec":"P", "firstslot":6, "nslots":8, "roc":8, "offset":640}
}
chandict = {}
nperslot = 32
clockrate = 1000000
class Channel:
def __init__(self, spec, slot, chan, comment=''):
self.spec = spec
self.slot = slot
self.chan = chan
self.comment = comment
def __str__(self):
string = self.spec+"."+str(self.slot)+"."+str(self.chan)+"."+self.comment
return string
with open(xscalerMapName, 'r') as fi:
for line in fi:
# Skip empty lines
if line.isspace():
continue
line = line.strip()
# Check if comment line
if line.startswith('#'):
continue
if line.startswith('DATE') or line.startswith('xscaler-'):
continue
splitline = line.split(None,6)
helicity = splitline[1]
spec = cratemap[splitline[2]]["spec"]
name = spec+splitline[0]
slot = int(splitline[3])+cratemap[splitline[2]]["firstslot"]
start = int(splitline[4])
nchan = splitline[5] # This better be 1
comment = splitline[6]
uniquename = name
count = 2
while chandict.has_key(uniquename):
uniquename = name+"_"+str(count)
count += 1
chandict[uniquename] = Channel(cratemap[splitline[2]]["spec"],slot,start,comment)
for spec in cratemap:
firstslot = cratemap[spec]["firstslot"]
nslots = cratemap[spec]["nslots"]
roc = cratemap[spec]["roc"]
lastslot = firstslot + nslots - 1
offset = cratemap[spec]["offset"]
specprefix = cratemap[spec]["spec"]
hcanaMapName = 'db_'+specprefix+'Scalevt.dat'
with open(hcanaMapName, 'w') as fo:
for slot in range(firstslot,firstslot+nslots):
if slot == lastslot:
rateinfo=' {0} {1}'.format(nperslot-1,clockrate)
else:
rateinfo=''
print >>fo, 'map 3801 {0} {1} {2:04x}{1:02x}{3:02x} ffffffff {4}'.\
format(roc, slot, offset+(slot-firstslot)*nperslot,nperslot,lastslot)\
+rateinfo
for name in chandict:
channel = chandict[name]
slot = channel.slot-firstslot
printname = "." + name[1:] + ".scaler" # Drop prefix
detPrefix = name[2:5]
printHodoName = "." + detPrefix + "." + name[5:10] + "."
if specprefix == channel.spec and slot<nslots:
chan = channel.chan
slot = channel.slot-firstslot
comment = channel.comment
if detPrefix == "hod":
if printHodoName.find("+") != -1:
printHodoName = printHodoName.replace("+", "")
printHodoName = printHodoName + "posScaler"
if printHodoName.find("-") != -1:
printHodoName = printHodoName.replace("-", "")
printHodoName = printHodoName + "negScaler"
print >>fo, 'variable', slot, chan, 1, printHodoName, comment
print >>fo, 'variable', slot, chan, 2, printHodoName+'Rate', comment
else:
print >>fo, 'variable', slot, chan, 1, printname, comment
print >>fo, 'variable', slot, chan, 2, printname+'Rate', comment
#!/usr/bin/python
# Generate hcana scaler definition files from the xscaler scaler map file
xscalerMapName = 'scaler.map'
cratemap = {
"4":{"spec":"H", "firstslot":6, "nslots":7, "roc":5, "offset":0},
"5":{"spec":"P", "firstslot":6, "nslots":8, "roc":8, "offset":640}
}
chandict = {}
nperslot = 32
clockrate = 1000000
class Channel:
def __init__(self, spec, slot, chan, comment=''):
self.spec = spec
self.slot = slot
self.chan = chan
self.comment = comment
def __str__(self):
string = self.spec+"."+str(self.slot)+"."+str(self.chan)+"."+self.comment
return string
with open(xscalerMapName, 'r') as fi:
for line in fi:
# Skip empty lines
if line.isspace():
continue
line = line.strip()
# Check if comment line
if line.startswith('#'):
continue
if line.startswith('DATE') or line.startswith('xscaler-'):
continue
splitline = line.split(None,7)
helicity = splitline[1]
spec = cratemap[splitline[2]]["spec"]
name = spec+splitline[0]
slot = int(splitline[3])+cratemap[splitline[2]]["firstslot"]
start = int(splitline[4])
nchan = splitline[5] # This better be 1
page = splitline[6] # We ignore this here
comment = splitline[7]
uniquename = name
count = 2
while chandict.has_key(uniquename):
uniquename = name+"_"+str(count)
count += 1
chandict[uniquename] = Channel(cratemap[splitline[2]]["spec"],slot,start,comment)
for spec in cratemap:
firstslot = cratemap[spec]["firstslot"]
nslots = cratemap[spec]["nslots"]
roc = cratemap[spec]["roc"]
lastslot = firstslot + nslots - 1
offset = cratemap[spec]["offset"]
specprefix = cratemap[spec]["spec"]
hcanaMapName = 'db_'+specprefix+'Scalevt.dat'
with open(hcanaMapName, 'w') as fo:
for slot in range(firstslot,firstslot+nslots):
if slot == lastslot:
rateinfo=' {0} {1}'.format(nperslot-1,clockrate)
else:
rateinfo=''
print >>fo, 'map 3801 {0} {1} {2:04x}{1:02x}{3:02x} ffffffff {4}'.\
format(roc, slot, offset+(slot-firstslot)*nperslot,nperslot,lastslot)\
+rateinfo
for name in chandict:
channel = chandict[name]
slot = channel.slot-firstslot
printname = "." + name[1:] + ".scaler" # Drop prefix
detPrefix = name[2:5]
if specprefix == channel.spec and slot<nslots:
chan = channel.chan
slot = channel.slot-firstslot
comment = channel.comment
if detPrefix == "hod":
printHodoName = "." + detPrefix + "." + name[5:10] + "."
if printHodoName.find("+") != -1:
printname = printHodoName.replace("+", "")+"posScaler"
if printHodoName.find("-") != -1:
printname = printHodoName.replace("-", "")+"negScaler"
print >>fo, 'variable', slot, chan, 1, printname, comment
print >>fo, 'variable', slot, chan, 2, printname+'Rate', comment
if name[1:4] == "BCM" or name[1:6] == "Unser":
print >>fo, 'variable', slot, chan, 3, printname+'Current', comment
print >>fo, 'variable', slot, chan, 4, printname+'Charge', comment
elif name[1:5] == "1Mhz":
print >>fo, 'variable', slot, chan, 5, printname+'Time', comment
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment