File indexing completed on 2024-04-06 12:02:54
0001 import pandas as pd
0002 import argparse
0003
0004 parser = argparse.ArgumentParser()
0005 parser.add_argument("-l","--logicid", help="Logicid mapping", default="params_EBEE_logicid.csv")
0006 parser.add_argument("-i","--inputfile", type=str, help="Input file", required=True)
0007 parser.add_argument("-o","--outputfile", type=str, help="Output file", required=True)
0008 args = parser.parse_args()
0009
0010
0011 gmap = pd.read_csv(args.logicid, sep=",")
0012
0013 final_map = {}
0014 for lid in gmap.stripid:
0015 final_map[lid] = 0
0016
0017
0018 with open(args.inputfile) as lm:
0019 for l in lm.readlines():
0020 if l.startswith("#") or len(l)==0 : continue
0021 n = l.strip().split(" ")
0022
0023 if n[0] == "ALL":
0024
0025 for k in final_map.keys():
0026 final_map[k] = n[1]
0027
0028 if n[0] == "SUBDET":
0029 if n[1] == "EB":
0030 for strip in gmap[(gmap.FED >= 610)&(gmap.FED <=645)].stripid:
0031 final_map[strip] = n[2]
0032 if n[1] == "EE":
0033 for strip in gmap[(gmap.FED < 610)&(gmap.FED >645)].stripid:
0034 final_map[strip] = n[2]
0035 if n[1] == "EE-":
0036 for strip in gmap[gmap.FED < 610].stripid:
0037 final_map[strip] = n[2]
0038 if n[1] == "EE+":
0039 for strip in gmap[gmap.FED > 645].stripid:
0040 final_map[strip] = n[2]
0041
0042 if n[0] == "FED":
0043
0044 for strip in gmap[gmap.FED == int(n[1])].stripid:
0045 final_map[strip] = n[2]
0046
0047 if n[0] == "TT":
0048
0049 for strip in gmap[gmap.TT == int(n[1])].stripid:
0050 final_map[strip] = n[2]
0051
0052 if n[0] == "FEDTT":
0053
0054 for strip in gmap[(gmap.FED == int(n[1])) & (gmap.TT == int(n[2]))].stripid:
0055 final_map[strip] = n[3]
0056
0057 if n[0] == "STRIP":
0058 final_map[int(n[1])] = n[2]
0059
0060
0061 with open(args.outputfile, "w") as of:
0062 for k,v in final_map.items():
0063 of.write("{} {}\n".format(k,v))
0064
0065