Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:44:28

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 from __future__ import print_function
0008 
0009 import sys
0010 
0011 print("Reading psu-detId map from map.txt")
0012 
0013 inputMap = open("map.txt", "r")
0014 
0015 outputFile = open("newMap.txt", "w")
0016 
0017 for line in inputMap:
0018     # 369120285         cms_trk_dcs_05:CAEN/CMS_TRACKER_SY1527_4/branchController09/easyCrate1/easyBoard14/channel000
0019     # print dir(line)
0020     splittedLine = line.rsplit("/", 1)
0021     # print splittedLine[0]+"/"
0022     detId = splittedLine[0].split()[0]
0023 
0024     channel = ""
0025 
0026     HVmap = open("HVmap.txt", "r")
0027     for HVline in HVmap:
0028         if detId in HVline:
0029             channel = HVline.split()[1].strip()
0030 
0031     if channel == "" or "undefined" in channel:
0032         if channel == "":
0033             print("channel not found for detId = ", detId)
0034         else:
0035             print("channel is undefined in HV map ", end=' ')
0036         print("leaving channel 0")
0037         outputFile.write(line)
0038         # break
0039     else:
0040         # print splittedLine[0]+"/"+channel
0041         outputFile.write(splittedLine[0]+"/"+channel+"\n")
0042 
0043     # break