9 with client.File()
as f:
10 f.open(path+
"/board_mapping.json")
11 status, jsonStr = f.read()
13 self.
slots = {0:
'A',1:
'A',2:
'B',3:
'B',4:
'C',5:
'C',6:
'D',7:
'D'}
16 board_id = int(b.split(
'_')[1])
19 for slot
in self.
slots:
21 tmp = self.
boardMaps[
'MuFilter'][b][x].split(
'_')[0]
26 self.
names = {
'DS':2,
'US':1,
'Veto':0}
27 self.
sdict = {3:
'DS',2:
'US',1:
'Veto'}
28 for system
in self.
names:
29 sndswPath = os.environ[
'SNDSW_ROOT']
30 infile = sndswPath+
"/geometry/"+system+
"_SiPM_mapping.csv"
32 if os.path.isdir(sndswPath+
"/geometry"):
33 with open(infile,
"r")
as f:
34 reader = csv.DictReader(f, delimiter=
',')
35 for i, row
in enumerate(reader):
36 self.
SiPMmap[system][int(row[
'SiPM'])] = [int(row[
'CN']), int(row[
'pin']), int(row[
'TOFPET']), int(row[
'CHANNEL'])]
39 for o
in [
'Left',
'Right']:
40 self.
offMap[
'Veto_'+str(s)+o] =[10000 + (s-1)*1000+ 0,8,2]
41 self.
offMap[
'Veto_3Vert'] = [10000+2*1000+0,8,1]
43 for o
in [
'Left',
'Right']:
44 self.
offMap[
'US_'+str(s)+o] =[20000 + (s-1)*1000+ 9,-8,2]
47 self.
offMap[
'DS_'+str(s)+o] =[30000 + (s-1)*1000+ 119, -1,1]
49 for o
in [
'Left',
'Right']:
50 self.
offMap[
'DS_'+str(s)+o] =[30000 + (s-1)*1000+ 59,-1,2]
54 for slot
in self.
boardMaps[
'MuFilter'][board]:
55 key = self.
boardMaps[
'MuFilter'][board][slot]
60 station,mat = self.
boardMaps[
'Scifi'][board]
66 if type(aHit).__name__ ==
'int': fDetectorID = aHit
67 else: fDetectorID = aHit.GetDetectorID()
68 if not fDetectorID<1000000:
69 s = fDetectorID//1000000
70 mat = (fDetectorID%100000)//10000
71 orientation = (fDetectorID%1000000)//100000
72 chan = fDetectorID%1000
73 sipm = (fDetectorID%10000)//1000
74 sipmChannel = chan + sipm*128
75 station =
'M'+str(s)+
'X'
76 if orientation ==0 : station =
'M'+str(s)+
'Y'
78 return {
"sipmChannel":sipmChannel,
"board":board}
80 subsystem = fDetectorID//10000
81 plane = fDetectorID//1000 - 10*subsystem
82 bar_number = fDetectorID%1000
83 nSiPMs = aHit.GetnSiPMs()
84 nSides = aHit.GetnSides()
85 if (subsystem==3
and bar_number>59)
or (subsystem==1
and plane==2):
87 elif channel < nSiPMs: side =
'Left'
89 tag = self.
sdict[subsystem]+
'_'+str(plane+1)+side
90 direction = int(self.
offMap[tag][1]/nSiPMs)
91 sipmChannel = int( (fDetectorID - self.
offMap[tag][0])/direction * nSiPMs)
92 sipmChannel+=channel%(nSiPMs) + 1
94 result = self.
SiPMmap[self.
sdict[subsystem]][sipmChannel]
95 return {
"sipmChannel":sipmChannel,
"board":board,
"channel":result[3],
"tofpet":result[2],
"pin":result[1],
"CN":result[0]}
97 def test(nSiPMs = 8,subsystem = 2,plane = 3):
98 for side
in [
'Left',
'Right']:
99 for bar_number
in range(10):
100 fDetectorID = 20000+plane*1000+bar_number
101 tag = tself.sdict[subsystem]+
'_'+str(plane+1)+side
102 for n
in range(nSiPMs):
103 direction = int(tself.offMap[tag][1]/nSiPMs)
104 sipmChannel = int( (fDetectorID - tself.offMap[tag][0])/direction * nSiPMs) + n + 1
105 result = tself.SiPMmap[tself.sdict[subsystem]][sipmChannel]
106 print(fDetectorID,n,
" : ",sipmChannel,result)