/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

makeFecCableMap-Old.py
Go to the documentation of this file.
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 0xRC, where R goes from 'A' to 'F'
00070     for near site, opposite  direction than Row convention. C goes from
00071     1 to 9'''
00072 
00073     global nFecConnectorsPerBoard
00074     nearrows = [row for row in reversed(range(0x0,0xF+1))]
00075     farrows = [row for row in reversed(range(0x0,0x8+1))]
00076     cols = [col for col in range(0x0,0x8+1)]
00077     boards = {}
00078     boardsnear = [row<<4|col for row in nearrows for col in cols]
00079     boardsfar = [row<<4|col for row in farrows for col in cols]
00080     fecIds = {}
00081     detectors = getRpcDetectors()
00082     rpcSensors = getRpcSensors()
00083     for detector in detectors:
00084         if detector.site() == Site.kFar:
00085             boards[detector] = boardsfar
00086         else:
00087             boards[detector] = boardsnear
00088 
00089     for detector in detectors:
00090         if detector.site() == Site.kFar:
00091             fecIds[detector] = [FecChannelId(board, connector,
00092                                              detector.site(),
00093                                              detector.detectorId())
00094                                 for board in boardsfar
00095                                 for connector in range(1,nFecConnectorsPerBoard+1)]
00096         else :
00097             fecIds[detector] = [FecChannelId(board, connector,
00098                                              detector.site(),
00099                                              detector.detectorId())
00100                                 for board in boardsnear
00101                                 for connector in range(1,nFecConnectorsPerBoard+1)]
00102 
00103     return fecIds
00104 
00105 def getRpcHardwareIds():
00106     '''Return unique ids of RPC modules, packed together with layer and strip info.
00107     For now, the module number is simply ordinal number site by site.
00108     In future there should be file specifying IDs of actual modules installed,
00109     and we can read from there'''
00110     return None
00111 
00112 def getFecHardwareIds():
00113     '''Return unique ids of RPC FECs, packed together with channel number.
00114     For now, the card number is simply ordinal number site by site.
00115     In future there should be file specifying IDs of actual FECs installed on the modules,
00116     and we will read from there'''
00117     return None
00118 
00119 def rpcDescription(rpcId):
00120     "Return a string representation of RPC ID"
00121     return "%s-row%02d-column%02d-layer%02d-strip-%02d" % (rpcId.detName(),
00122                                                            rpcId.panelRow(),
00123                                                            rpcId.panelColumn(),
00124                                                            rpcId.layer(),
00125                                                            rpcId.strip())
00126 
00127 def channelDescription(channelId):
00128     "Return a string representation of FEE/FEC channel ID"
00129     return "%s-board%02d-connector%02d" % (channelId.detName(),
00130                                            channelId.board(),
00131                                            channelId.connector())
00132 
00133 def hardwareDescription(hardwareId):
00134     "Return a string representation of the hardware ID"
00135     if hardwareId.type() == Hardware.kFee:
00136         return "%s-%d" % (Hardware.AsString(hardwareId.type()),
00137                           hardwareId.boardId())
00138     else:
00139         return "%s-%d" % (Hardware.AsString(hardwareId.type()),
00140                           hardwareId.id())
00141 
00142 def printFecCableMap():
00143     "Print a map of the cable connections"
00144     detectors = getRpcDetectors()
00145     rpcIds = getRpcSensors()
00146     channelIds = getFecChannelIds()
00147     boardHardwareNumber = {}
00148     nextFecBoardNumber = 1
00149     print "#  ChannelID" "\t\t" "Description" "\t"\
00150         "ElecHardwareId" "\t\t" "Description" "\t"\
00151         "SensorID" "\t\t" "Description" "\t"\
00152         "SensorHardwareID" "\t\t" "Description"
00153     for detector in detectors:
00154         rpcIndex = 0
00155         siteRpcs = rpcIds[detector] # Sensitive detectors
00156         nRpcs = len(siteRpcs) # How many do we have
00157         for channelId in channelIds[detector]:
00158             # Go through all expected channels for the site.
00159             # Begining at col 1 and row 1, which is at the corner
00160             # close to electronics room (for DB hall) and further from
00161             # hall entrance. Iterating row-vise.
00162             rpcId = None
00163             rpcHardwareId = None
00164             if rpcIndex < nRpcs: # We still have a Sensor for this channel
00165                 rpcId = siteRpcs[rpcIndex] # Current Sensor
00166                 #iPanel = int(math.ceil(len(channelIds[detector])/nFecConnectorsPerBoard)) # number of FEC boards in total, equivalent to number of RPC modules
00167                 #iPanel = rpcIndex
00168                 #rpcHardwareId = RpcHardwareId(iPanel, rpcId.layer(), rpcId.strip())
00169                 rpcHardwareId = RpcHardwareId(nextFecBoardNumber, rpcId.layer(), rpcId.strip())
00170             else: # We don't have any Sensor left, create new empty one. Create empty hardware representation, too.
00171                 rpcId = RpcSensor()
00172                 rpcHardwareId = HardwareId()
00173             boardId = channelId.boardId().fullPackedData()
00174             if not boardHardwareNumber.has_key( boardId ):
00175                 # Add an unique FEC board id into the map
00176                 boardHardwareNumber[boardId] = nextFecBoardNumber
00177                 nextFecBoardNumber += 1
00178             # create unique hardware channel id
00179             fecHardwareId = FecHardwareId(boardHardwareNumber[boardId],
00180                                           channelId.connector())
00181             print "%12d %30s %14d %11s %12d %33s %16d %13s" % (
00182                 channelId.fullPackedData(),
00183                 channelDescription(channelId),
00184                 fecHardwareId.fullPackedData(),
00185                 hardwareDescription(fecHardwareId),
00186                 rpcId.fullPackedData(),
00187                 rpcDescription(rpcId),
00188                 rpcHardwareId.fullPackedData(),
00189                 hardwareDescription(rpcHardwareId))
00190             rpcIndex += 1
00191 
00192 if __name__ == "__main__":
00193     printFecCableMap()  #FEC
00194 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:59:23 for DataSvc by doxygen 1.7.4