ATLAS Offline Software
createCablingJSON.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 import json
3 from copy import deepcopy
4 
5 
13 station_name = "BIS"
14 eta_index = 7 # To represent BIS78 (Station eta, always 7 for BIS78)
15 doubletR = 1 # Chamber mounted below the Mdts (Always 1 for BIS78)
16 doubletPhi = 1 # Single phi module (Always 1 for BIS78)
17 sub_detector = 101 # 0x65 (same as the RPCs)
18 idTranslateDict = []
19 
20 
21 
22 flatCableBIS78 = [0, 4, 8, 12, 16, 20, 24, 28, 1, 5, 9, 13, 17, 21, 25, 29, 2, 6, 10, 14, 18, 22, 26, 30, 3, 7, 11, 15, 19, 23, 27, 31]
23 readoutDict =[
24 {
25  "flatCableId" : 0,
26  "pinAssignment" : [(p+1,t) for t, p in enumerate(flatCableBIS78)]
27 },
28 {
29  "flatCableId" : 2,
30  "pinAssignment" : [(s,t) for s, t in enumerate([ 0, 8, 16, 24, 1, 9, 17, 25],1)]
31 },
32 {
33  "flatCableId" : 1,
34  "pinAssignment" : [(s,t) for s,t in enumerate([4,12,20,28,5,13, 21, 29, 6, 14, 22, 30, 7, 15, 23, 31],1)]
35 },
36 
37 
38 
39 ]
40 
41 
42 for sector in range(1, 9):
43  for doubZ in [1, 2]:
44  for measPhi in [0,1]:
45  for gasGap in [0, 1, 2]:
46  cabling_data = {
47 
48  "station": station_name,
49  "eta": eta_index,
50  "phi" : sector,
51  "doubletR" : doubletR,
52  "doubletZ" : doubZ,
53  "doubletPhi": doubletPhi,
54  "measPhi": measPhi,
55  "gasGap": gasGap + 1,
56 
57  "subDetector": sub_detector,
58  "tdcSector" : sector*2+16, # sector A2 -> 0x0012, sector A4 -> 0x0014, ..., sector A12 -> 0x001c, ...,
59  "flatCableId" : 0,
60  }
61 
62  if measPhi == 0: # Eta
63  if doubZ == 1:
64  cabling_data["firstStrip"] = 1
65  """
66  cabling_data["lastStrip"] = 32 # Standard: 32 eta strips for BIS7 -> special case: BIS7 with 40 eta strips added below
67  cabling_data["firstTdcChan"] = 0
68  cabling_data["lastTdcChan"] = 31 # Standard: 32 channels per TDC
69  """
70  cabling_data["tdc"] = gasGap
71  elif doubZ == 2:
72  cabling_data["firstStrip"] = 1 # MN: Problem: should firstStrip be -15, to start with strip 1 in channel 17?
73  """
74  cabling_data["lastStrip"] = 16 # Standard: 16 eta strips for BIS8 cabled on the second half of the TDC (that means the strips 1-16)
75  cabling_data["firstTdcChan"] = 16
76  cabling_data["lastTdcChan"] = 31 # Last 16 TDC channels
77  """
78  cabling_data["tdc"] = gasGap + 9
79  cabling_data["flatCableId"] = 1
80  idTranslateDict.append(deepcopy(cabling_data))
81 
82  if measPhi == 1: # Phi
83  if doubZ == 1:
84  cabling_data["firstStrip"] = 1
85  """
86  cabling_data["lastStrip"] = 32 # Total 64 phi strips for BIS7 -> First half
87  cabling_data["firstTdcChan"] = 1
88  cabling_data["lastTdcChan"] = 32 # Standard: 32 channels per TDC
89  """
90  cabling_data["tdc"] = gasGap + 3
91  elif doubZ == 2:
92  cabling_data["firstStrip"] = 1
93  """
94  cabling_data["lastStrip"] = 32 # Total 64 phi strips for BIS7 -> First half
95  cabling_data["firstTdcChan"] = 0
96  cabling_data["lastTdcChan"] = 31 # Standard: 32 channels per TDC
97  """
98  cabling_data["tdc"] = gasGap + 12
99  idTranslateDict.append(deepcopy(cabling_data))
100  if doubZ == 1:
101  cabling_data["firstStrip"] = 33
102  """
103  cabling_data["lastStrip"] = 64 # Total 64 phi strips for BIS7 -> Second half
104  cabling_data["firstTdcChan"] = 0
105  cabling_data["lastTdcChan"] = 31 # Standard: 32 channels per TDC
106  """
107  cabling_data["tdc"] = gasGap + 6
108  elif doubZ == 2:
109  cabling_data["firstStrip"] = 33
110  """
111  cabling_data["lastStrip"] = 64 # Total 64 phi strips for BIS7 -> Second half
112  cabling_data["firstTdcChan"] = 0
113  cabling_data["lastTdcChan"] = 31 # Standard: 32 channels per TDC
114  """
115  cabling_data["tdc"] = gasGap + 15
116 
117  idTranslateDict.append(deepcopy(cabling_data))
118 
119 # MN: Should we allow the doubling of TDC when different chambers are cabled in the same TDC?
120 # MN: need to review finalize() checks in: MuonSpectrometer/MuonCablings/MuonCablingData/src/MuonNRPC_CablingMap.cxx
121 # MN: For the moment using a different TDC number (WRONG!) to test the code
122  if measPhi == 0: # Eta
123  if doubZ == 1:
124  cabling_data["firstStrip"] = 33
125  """
126  cabling_data["lastStrip"] = 40 # Special case: BIS7 with 40 eta strips -> Adding the 8 leftover strips
127  cabling_data["firstTdcChan"] = 0
128  cabling_data["lastTdcChan"] = 7 # First 8 channels of the TDC used for BIS8 eta strips
129  """
130  cabling_data["tdc"] = gasGap + 9
131  cabling_data["flatCableId"] = 2
132  idTranslateDict.append(deepcopy(cabling_data))
133 
134 
135 print (len(idTranslateDict))
136 
137 json_dict= {"chamberMap" : idTranslateDict,
138  "readoutCards": readoutDict }
139 with open("CablingFile.json", "w") as my_file:
140  my_file.write(json.dumps(json_dict,indent=4))
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
Trk::open
@ open
Definition: BinningType.h:40