-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_simple_channel_map
More file actions
executable file
·64 lines (49 loc) · 2.23 KB
/
make_simple_channel_map
File metadata and controls
executable file
·64 lines (49 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from petsys import daqd, config
from copy import deepcopy
import argparse
import struct
import sys
def main():
parser = argparse.ArgumentParser(description='Make a simple channel and trigger map')
parser.add_argument("-o", type=str, required=True, help="Output file")
parser.add_argument("--port", type=int, required=True, action="append", help="Port ID")
parser.add_argument("--slave", type=int, required=True, action="append", help="Slave ID")
parser.add_argument("--trigger-port", dest="trigger_port", type=str, required=False, action="append", help="File name")
parser.add_argument("--noTriggerBoard", dest="noTrigger", action="store_true", help="enable only if the system has a DAQ board but no Clock & Trigger board")
args = parser.parse_args()
channelOutputFile = open(args.o + "_channel.tsv", "w")
triggerOutputFile = open(args.o + "_trigger.tsv", "w")
if not args.noTrigger and args.trigger_port is None:
print("ERROR: Please enter same number of trigger_port IDs as FEB/Ds in the system")
exit(1)
if not args.noTrigger and len(args.trigger_port) != len(args.port):
print("ERROR: Please enter same number of trigger_port IDs as FEB/Ds in the system")
exit(1)
region_list = []
for i in range(len(args.port)):
portID = int(args.port[i])
slaveID = int(args.slave[i])
if args.noTrigger:
trigger_port = i
else:
trigger_port = int(args.trigger_port[i])
for quadrant in range(4):
trigger_region = 4 * trigger_port + quadrant
region_list.append(trigger_region)
for asicID in range(4*quadrant, 4*quadrant + 4):
for channelID in range(64):
channelOutputFile.write("%(portID)s\t%(slaveID)d\t%(asicID)d\t%(channelID)d\t%(trigger_region)d\t0\t0\t0.0\t0.0\t0.0\n" % locals())
triggerOutputFile.write("%(trigger_region)d\t%(trigger_region)d\tM\n" % locals())
for i in range(0, len(region_list)):
for j in range(i+1, len(region_list)):
trigger_region1 = region_list[i]
trigger_region2 = region_list[j]
if trigger_region1 == trigger_region2:
continue
triggerOutputFile.write("%(trigger_region1)d\t%(trigger_region2)d\tC\n" % locals())
channelOutputFile.close()
triggerOutputFile.close()
if __name__ == '__main__':
main()