3 if __name__==
"__main__":
6 parser = argparse.ArgumentParser(prog=
'python -m PixelCalibAlgs.PixelCalibrationConfig.',
7 description=
"""Calibration tool for pixel.\n\n
8 Example: python -m PixelCalibAlgs.PixelCalibrationConfig --folder "global/path/to/folder/" --thr "threshold_file" --thr_intime "intime_file"
9 --tot "tot_file --layers [Blayer, L1, L2, disk] [--saveInfo --runCal --skipPlots]""")
11 parser.add_argument(
'--folder' , required=
True, help=
"Directory path to the files")
12 parser.add_argument(
'--thr' , required=
True, help=
"Threshold file, format must be \"SCAN_SXXXXXXXXX\" THRESHOLD_SCAN (0Preset_full)")
13 parser.add_argument(
'--thr_intime', required=
True, help=
"Threshold intime file, format must be \"SCAN_SXXXXXXXXX\" THRESHOLD_SCAN (0Preset_short_intime) ")
14 parser.add_argument(
'--tot' , required=
True, help=
"Time over threshold file, format must be \"SCAN_SXXXXXXXXX\" TOT_CALIB (Test_Han)")
15 parser.add_argument(
'--layers' , required=
True, nargs=
'+', choices={
"Blayer",
"L1",
"L2",
"disk"}, help=
"Layers we should run to update the calibration.")
16 parser.add_argument(
'--tag' , type=str, default=
"PixelChargeCalibration-DATA-RUN2-UPD4-27", help=
"Tag in order to read the DB")
17 parser.add_argument(
'--saveInfo' , action=
'store_true', help=
"Creates a root file with the fitting plots - Slower running time")
18 parser.add_argument(
'--runCal' , action=
'store_true', help=
"Runs only the Pixel Calibration layers")
19 parser.add_argument(
'--skipPlots' , action=
'store_true', help=
"Skips the plotting step - Slower running time")
23 args = parser.parse_args()
28 print(
"Running PixelCalibration layers..")
30 for layer
in args.layers :
31 extraArgs =
"saveInfo" if args.saveInfo
else ""
32 command =
'PixelCalibration directory_path=' + args.folder +
' THR=' + args.thr +
' THRintime=' + args.thr_intime +
' TOT=' + args.tot +
' ' + layer +
' ' + extraArgs +
' > log_' + layer
33 print(
"Command: %s\n" % command)
34 proc.append(subprocess.Popen(command, shell=
True))
37 for l
in range(len(args.layers)) :
44 print(
"Jobs finished")
47 print(
"Merging calibration output...")
48 from PixelCalibAlgs.FileMerger
import MergeCalibFiles
53 print(
"Creating Reference file..")
55 command =
'MakeReferenceFile tagName=%s' % (args.tag)
56 print(
"Command: %s\n" % command)
57 (subprocess.Popen(command, shell=
True)).communicate()
60 print(
"Updating last IOV and creating calibration candidate file..")
62 from PixelCalibAlgs.Recovery
import UpdateCalib
67 print(
"Jobs finished")
70 print(
"Validation new vs. previous calibration.")
73 from PixelCalibAlgs.EvoMonitoring
import setupRunEvo
74 setupRunEvo(
"PIX_FINAL_calibration_candidate.txt", args.tag+
".log" )
78 print(
"Jobs finished")