def getDetIDs(): """ Since the detector CPD position - detector serial number mapping has never changed, load a channel map and print it out. ==> copied this output into DetInfo::detID """ from ROOT import TFile, GATDataSet, MJTChannelMap run = bkg.getRunList(5, 1)[0] gds = GATDataSet(run) chMap = gds.GetChannelMap() # chMap.DumpDetectorNames() dets = det.allDets for d in dets: detName = chMap.GetDetectorName(int(d[0]), int(d[1]), int(d[2])) # now match it to the IDs used in DataSetInfo.cc::Load(X)DetectorMap detID = '1' if detName[0] == "P" else '2' detID += detName[1:] tmp = list(detID) if detID[0] == '1': if tmp[-1] == "A": tmp[-1] = '0' if tmp[-1] == "B": tmp[-1] = '1' if tmp[-1] == "C": tmp[-1] = '2' detID = ''.join(tmp) print("'%s':%s," % (d, detID))
def getDetPos(run): """ Load position info for all enabled channels in a run. """ from ROOT import GATDataSet gds = GATDataSet(run) chMap = gds.GetChannelMap() chSet = gds.GetChannelSettings() enabledIDs = chSet.GetEnabledIDList() enabledIDs = [enabledIDs[idx] for idx in range(enabledIDs.size())] detPos = {} for ch in enabledIDs: hglg = "H" if ch % 2 == 0 else "L" pos = "%sD%d-%s" % (chMap.GetString( ch, "kStringName"), chMap.GetInt(ch, "kDetectorPosition"), hglg) detPos[ch] = pos return detPos