Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:11

0001 #! /usr/bin/env python
0002 
0003 """ This macro can be used to merge the information from the accurate HV
0004 map derived from pedestal runs studies with the old db map into a new
0005 accurate map.
0006 """
0007 
0008 import sys
0009 
0010 print("Reading psu-detId map from map.txt")
0011 
0012 inputMap = open("map.txt", "r")
0013 
0014 outputFile = open("newMap.txt", "w")
0015 
0016 for line in inputMap:
0017     # 369120285         cms_trk_dcs_05:CAEN/CMS_TRACKER_SY1527_4/branchController09/easyCrate1/easyBoard14/channel000
0018     # print dir(line)
0019     splittedLine = line.rsplit("/", 1)
0020     # print splittedLine[0]+"/"
0021     detId = splittedLine[0].split()[0]
0022 
0023     channel = ""
0024 
0025     HVmap = open("HVmap.txt", "r")
0026     for HVline in HVmap:
0027         if detId in HVline:
0028             channel = HVline.split()[1].strip()
0029 
0030     if channel == "" or "undefined" in channel:
0031         if channel == "":
0032             print("channel not found for detId = ", detId)
0033         else:
0034             print("channel is undefined in HV map ", end=' ')
0035         print("leaving channel 0")
0036         outputFile.write(line)
0037         # break
0038     else:
0039         # print splittedLine[0]+"/"+channel
0040         outputFile.write(splittedLine[0]+"/"+channel+"\n")
0041 
0042     # break