diff --git a/configs/so_optimizer.json b/configs/so_optimizer.json index dc562f5f5115b483c3c05e779cc317f941f23625..31e18f432e0d37ebb3847962e66df678dc69cd42 100644 --- a/configs/so_optimizer.json +++ b/configs/so_optimizer.json @@ -1,18 +1,18 @@ { - "targetChipNumber": 4, + "targetChipNumber": 1, "repetitions": 2, "parameters": [ { "name": "CmlTapBias0", - "min": 500, - "max": 800, + "min": 300, + "max": 900, "step": 100 }, { "name": "CmlTapBias1", - "min": 100, - "max": 300, + "min": 0, + "max": 400, "step": 100 } ], @@ -41,6 +41,18 @@ "min": 20, "max": 26, "step": 1 + }, + { + "name": "OutputActiveLanes", + "min": 1, + "max": 15, + "step": 1 + }, + { + "name": "CmlEn", + "min": 1, + "max": 7, + "step": 6 } ] } diff --git a/libDCS/parameterOptimizer.py b/libDCS/parameterOptimizer.py index 4034538dfbb38b763f9945451b0b112b8ff64eaa..b89a96666d7eda1f433b974166bcad53111d4afc 100644 --- a/libDCS/parameterOptimizer.py +++ b/libDCS/parameterOptimizer.py @@ -35,6 +35,8 @@ def count0(enMaskPath): data = json.load(file1) for y in data["Data"]: badPixels += y.count(0) + + return float(badPixels) except: @@ -75,10 +77,11 @@ def updatecfg(args, chipName, name_v1, name_v2, v1range, v2range, xtest, ytest): cfg = json.load(f) cfg["RD53A"]["GlobalConfig"][name_v1] = v1range[xtest] cfg["RD53A"]["GlobalConfig"][name_v2] = v2range[ytest] - + with open(chipCfg, 'w') as f: json.dump(cfg, f, indent=4) + def find(args): """Finds a minimum amongst some setting parameters""" @@ -173,12 +176,14 @@ def find(args): # run first digitalScan total = 0 for j in range(nReps): - print("[ info ][po] Running a digital scan at %i %i..." % (v1range[xtest0[i]], v2range[ytest0[i]])) + print("[ info ][po] Running a digital scan at %i %i... " % (v1range[xtest0[i]], v2range[ytest0[i]])) process = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) output, error = process.communicate() enMaskPath = args.basepath + "/data/optimizer/last_scan/" + chipName + "_EnMask.json" count = count0(enMaskPath) + print(" -> Counted %i" % count) + total += count if count < 0: @@ -211,12 +216,12 @@ def find(args): lookaround_y = min(prev3validY) if prev3validY != [] else randint(0, len(v2range) - 1) xtest1, ytest1 = whereToGoNext(lookaround_x, lookaround_y, results) - updatecfg(args, chipName, name_v1, name_v2, v1range, v2range, xtest1, ytest1) - print("[ info ][po] Entering the loop...") while True: + updatecfg(args, chipName, name_v1, name_v2, v1range, v2range, xtest1, ytest1) + # power cycle if args.powercycle: os.system("python3 libDCS/qaqc.py -e " + args.equip + " -c " + args.channel + " power-off") @@ -224,12 +229,8 @@ def find(args): print() - # If the matrix is filled - if xtest1 == None: - return - # If we have already tested this point - elif results[xtest1][ytest1] != ' ': + if results[xtest1][ytest1] != ' ': # Find another one random xtest1 = randint(0, len(v1range)) @@ -248,6 +249,8 @@ def find(args): enMaskPath = args.basepath + "/data/optimizer/last_scan/" + chipName + "_EnMask.json" count = count0(enMaskPath) + print(" -> Counted %i" % count) + total += count if count < 0: @@ -281,6 +284,11 @@ def find(args): print("") print(t) + # If the matrix is filled + if xtest1 == None: + return + +