/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 #!/usr/bin/env python 00002 # 00003 # Make a text table of the mapping between: 00004 # Detector Sensors: Identifies PMT/RPC by geometry in the experiment 00005 # Electronics Channels IDs: Identifies crate/board/connectors in electronics 00006 # Hardware IDs: Identifies specific pieces of hardware/barcodes 00007 # 00008 # Unconnected channels/hardware are identified using IDs of type 'Unknown' 00009 # 00010 # ! For RPCs only ! 00011 00012 00013 import math 00014 from GaudiPython import gbl 00015 00016 # Make shortcuts to DayaBay classes 00017 Detector = gbl.DayaBay.Detector 00018 Site = gbl.Site 00019 DetectorId = gbl.DetectorId 00020 HardwareId = gbl.DayaBay.HardwareId 00021 Hardware = gbl.DayaBay.Hardware 00022 00023 # RPC specifics 00024 FecChannelId = gbl.DayaBay.FecChannelId 00025 HardwareId = gbl.DayaBay.HardwareId 00026 RpcSensor = gbl.DayaBay.RpcSensor 00027 RpcHardwareId = gbl.DayaBay.RpcHardwareId 00028 FecHardwareId = gbl.DayaBay.FecHardwareId 00029 00030 ## file variables 00031 # list of RPC subsystems 00032 RpcDetectors = [ Detector(Site.kDayaBay, DetectorId.kRPC), 00033 Detector(Site.kLingAo, DetectorId.kRPC), 00034 Detector(Site.kFar, DetectorId.kRPC) ] 00035 00036 # global constants 00037 nFecConnectorsPerBoard = 32 00038 00039 def getRpcDetectors(): 00040 "Return a list of the RPC Detectors" 00041 global RpcDetectors 00042 return RpcDetectors 00043 00044 def getRpcSensors(): 00045 "Return a map of the RPC sensors by detector" 00046 RpcColumns = range(1,10) 00047 NearRpcRows = range(1,7) 00048 FarRpcRows = range(1,10) 00049 RpcLayers = range(1,5) 00050 RpcStrips = range(1,9) 00051 NearRpcSensors= [ [row, column, layer, strip] for row in NearRpcRows for column in RpcColumns for layer in RpcLayers for strip in RpcStrips ] 00052 FarRpcSensors= [ [row, column, layer, strip] for row in FarRpcRows for column in RpcColumns for layer in RpcLayers for strip in RpcStrips ] 00053 00054 RpcSensors = {} 00055 for detector in getRpcDetectors(): 00056 rpcSensors = [] 00057 if detector.site() == Site.kFar: 00058 rpcSensors = FarRpcSensors 00059 else: 00060 rpcSensors = NearRpcSensors 00061 RpcSensors[detector] = [ RpcSensor(row, column, layer, strip, 00062 detector.site(), 00063 detector.detectorId()) 00064 for [row, column, layer, strip] in rpcSensors] 00065 return RpcSensors 00066 00067 def getFecChannelIds(): 00068 "Return a list of the FEC channel IDs" 00069 '''FECs are identified as 0xCF, where C stands for Control FPGA (CF) in 00070 an ROM and goes from 0 to 3 at near halls, and from 0 to 5 at far hall. 00071 Opposite direction than Row convention. Each CF serves for up to 15 FECs. 00072 F stands for FEC id served by the CF, and runs from 0 to 14 for even CF Id, 00073 or from 0 to 11 for odd CF Id.''' 00074 00075 global nFecConnectorsPerBoard 00076 boards = {} 00077 boardsnear = [] 00078 boardsfar = [] 00079 fecIds = {} 00080 detectors = getRpcDetectors() 00081 rpcSensors = getRpcSensors() 00082 00083 # near sites 00084 for row in range(6) : 00085 for col in range(9) : 00086 cf = (1 - row/3)*2 + col/5 00087 fec = (2 - row%3)*(5 - (cf&0x1)) + col%5 00088 id = cf<<4|fec 00089 boardsnear.append(id) 00090 #print "(%d, %d) "%(cf,fec), 00091 #print "" 00092 00093 # far site 00094 for row in range(9) : 00095 for col in range(9) : 00096 cf = (2 - row/3)*2 + col/5 00097 fec = (2 - row%3)*(5 - (cf&0x1)) + col%5 00098 id = cf<<4|fec 00099 boardsfar.append(id) 00100 #print "(%d, %d, %d) "%(cf,fec,id), 00101 #print "" 00102 00103 for detector in detectors: 00104 if detector.site() == Site.kFar: 00105 boards[detector] = boardsfar 00106 else: 00107 boards[detector] = boardsnear 00108 00109 for detector in detectors: 00110 if detector.site() == Site.kFar: 00111 fecIds[detector] = [FecChannelId(board, connector, 00112 detector.site(), 00113 detector.detectorId()) 00114 for board in boardsfar 00115 for connector in range(1,nFecConnectorsPerBoard+1)] 00116 else : 00117 fecIds[detector] = [FecChannelId(board, connector, 00118 detector.site(), 00119 detector.detectorId()) 00120 for board in boardsnear 00121 for connector in range(1,nFecConnectorsPerBoard+1)] 00122 00123 return fecIds 00124 00125 def getRpcHardwareIds(): 00126 '''Return unique ids of RPC modules, packed together with layer and strip info. 00127 For now, the module number is simply ordinal number site by site. 00128 In future there should be file specifying IDs of actual modules installed, 00129 and we can read from there''' 00130 return None 00131 00132 def getFecHardwareIds(): 00133 '''Return unique ids of RPC FECs, packed together with channel number. 00134 For now, the card number is simply ordinal number site by site. 00135 In future there should be file specifying IDs of actual FECs installed on the modules, 00136 and we will read from there''' 00137 return None 00138 00139 def rpcDescription(rpcId): 00140 "Return a string representation of RPC ID" 00141 return "%s-row%02d-column%02d-layer%02d-strip-%02d" % (rpcId.detName(), 00142 rpcId.panelRow(), 00143 rpcId.panelColumn(), 00144 rpcId.layer(), 00145 rpcId.strip()) 00146 00147 def channelDescription(channelId): 00148 "Return a string representation of FEE/FEC channel ID" 00149 return "%s-board%02d-connector%02d" % (channelId.detName(), 00150 channelId.board(), 00151 channelId.connector()) 00152 00153 def hardwareDescription(hardwareId): 00154 "Return a string representation of the hardware ID" 00155 if hardwareId.type() == Hardware.kFee: 00156 return "%s-%d" % (Hardware.AsString(hardwareId.type()), 00157 hardwareId.boardId()) 00158 else: 00159 return "%s-%d" % (Hardware.AsString(hardwareId.type()), 00160 hardwareId.id()) 00161 00162 def getRotBoxNumber(site, row, column): 00163 rowLimitNear = 4 00164 rowLimitFar = 5 00165 columnLimit = 5 00166 rowLimit = 0 00167 if site == Site.kFar : 00168 rowLimit = rowLimitFar 00169 else : 00170 rowLimit = rowLimitNear 00171 rotNum = 0 00172 if row < rowLimit : 00173 rotNum += 2 00174 if column < columnLimit : 00175 rotNum += 1 00176 return rotNum 00177 00178 def printFecCableMap(): 00179 "Print a map of the cable connections" 00180 detectors = getRpcDetectors() 00181 rpcIds = getRpcSensors() 00182 channelIds = getFecChannelIds() 00183 boardHardwareNumber = {} 00184 nextRomBoardSerial = 1 00185 nextRtmBoardSerial = 1 00186 nextRotBoxSerial = 1 00187 nextFecBoardSerial = 0 00188 romBoardNumber = 1 00189 rtmBoardNumber = 1 00190 rpcSerial = 0 00191 00192 print "# Temporary fake map" 00193 print "# site" " " "detectorId" " "\ 00194 "romBoard" " " "romBoardSerial" " "\ 00195 "rtmBoard" " " "rtmBoardSerial" " "\ 00196 "rotBox" " " "rotBoxSerial" " "\ 00197 "fecBoard" " " "fecBoardSerial" " "\ 00198 "connector" " "\ 00199 "rpcRow" " " "rpcColumn" " " "rpcLayer" " " "rpcStrip" " "\ 00200 "rpcModuleSerial" 00201 00202 for detector in detectors: 00203 rpcIndex = 0 00204 siteRpcs = rpcIds[detector] # Sensitive detectors 00205 nRpcs = len(siteRpcs) # How many do we have 00206 for channelId in channelIds[detector]: 00207 # Go through all expected channels for the site. 00208 # Begining at col 1 and row 1, which is at the corner 00209 # close to electronics room (for DB hall) and further from 00210 # hall entrance. Iterating row-vise. 00211 rpcId = None 00212 rpcHardwareId = None 00213 if rpcIndex < nRpcs: # We still have a Sensor for this channel 00214 rpcId = siteRpcs[rpcIndex] # Current Sensor 00215 rpcHardwareId = RpcHardwareId(nextFecBoardSerial, rpcId.layer(), rpcId.strip()) 00216 else: # We don't have any Sensor left, create new empty one. Create empty hardware representation, too. 00217 rpcId = RpcSensor() 00218 rpcHardwareId = HardwareId() 00219 boardId = channelId.boardId().fullPackedData() 00220 if not boardHardwareNumber.has_key( boardId ): 00221 # Add an unique FEC board id into the map 00222 nextFecBoardSerial += 1 00223 rpcSerial += 1 00224 boardHardwareNumber[boardId] = nextFecBoardSerial 00225 # create unique hardware channel id 00226 fecHardwareId = FecHardwareId(boardHardwareNumber[boardId], 00227 channelId.connector()) 00228 site = channelId.site() 00229 detectorId = channelId.detectorId() 00230 rotBoxNumber = getRotBoxNumber(site, rpcId.panelRow(), rpcId.panelColumn()) 00231 rotBoxSerial = site * 10 + rotBoxNumber 00232 fecNumber = channelId.board() 00233 fecSerial = nextFecBoardSerial 00234 connector = channelId.connector() 00235 rpcRow = rpcId.panelRow() 00236 rpcColumn = rpcId.panelColumn() 00237 rpcLayer = rpcId.layer() 00238 rpcStrip = rpcId.strip() 00239 print "%4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d %4d" % ( 00240 site, detectorId, romBoardNumber, nextRomBoardSerial, 00241 rtmBoardNumber, nextRtmBoardSerial, 00242 rotBoxNumber, rotBoxSerial, 00243 fecNumber, fecSerial, connector, 00244 #rpcRow, rpcColumn, rpcLayer, rpcStrip, rpcSerial) # new geometry description, from r11988 00245 rpcColumn, rpcRow, rpcLayer, rpcStrip, rpcSerial) # old geometry description 00246 rpcIndex += 1 00247 nextRomBoardSerial += 1 00248 nextRtmBoardSerial += 1 00249 00250 if __name__ == "__main__": 00251 printFecCableMap() #FEC 00252