ATLAS Offline Software
Loading...
Searching...
No Matches
PixelCalibrationConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3if __name__=="__main__":
4
5 import argparse
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]""")
10
11 parser.add_argument('--folder' , type=str, default="/eos/atlas/atlascerngroupdisk/det-pix/p1/scan-data/", 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-28", 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")
20
21
22
23 args = parser.parse_args()
24
25 from PixelCalibAlgs.IBLCalibrationConfig import scanFullName
26 args.thr = scanFullName(args.thr)
27 args.thr_intime = scanFullName(args.thr_intime)
28 args.tot = scanFullName(args.tot)
29
30 import subprocess
31 proc = []
32
33 print("Running PixelCalibration layers..")
34 # Executing layers
35 for layer in args.layers :
36 extraArgs = "saveInfo" if args.saveInfo else ""
37 command = 'PixelCalibration directory_path=' + args.folder + ' THR=' + args.thr + ' THRintime=' + args.thr_intime + ' TOT=' + args.tot + ' ' + layer + ' ' + extraArgs +' > log_' + layer
38 print("Command: %s\n" % command)
39 proc.append(subprocess.Popen(command, shell=True))
40
41 # Waiting to get the processes finished
42 for l in range(len(args.layers)) :
43 proc[l].communicate()
44 print("Done\n")
45
46 # This is meant to run just one layer from a different calibration path and other layer from other path.
47 # We need to merge after the output of PixelCalibration. Use --runCal = True if you plan to test or run other layer afterwards
48 if args.runCal:
49 print("Jobs finished")
50 exit(0)
51
52 print("Merging calibration output...")
53 from PixelCalibAlgs.FileMerger import MergeCalibFiles
54 # Sending an array of all the layer - the ones not present will be skipped and reported
55 MergeCalibFiles(["Blayer", "L1", "L2", "disk"])
56 print("Done\n")
57
58 print("Creating Reference file..")
59 # Downloads the last IOV
60 command = 'MakeReferenceFile tagName=%s' % (args.tag)
61 print("Command: %s\n" % command)
62 (subprocess.Popen(command, shell=True)).communicate()
63 print("Done\n")
64
65 print("Updating last IOV and creating calibration candidate file..")
66 # Updates last IOV with the new calibration
67 from PixelCalibAlgs.Recovery import UpdateCalib
68 UpdateCalib(args.tag)
69 print("Done\n")
70
71 if args.skipPlots:
72 print("Jobs finished")
73 exit(0)
74
75 print("Validation new vs. previous calibration.")
76 # Plots the old vs. new charge for all FE (includes IBL)
77 # Meant to be used for pixel, but can be used for IBL in standalone (reading central DB using MakeReferenceFile.cxx step)
78 from PixelCalibAlgs.EvoMonitoring import setupRunEvo
79 setupRunEvo("PIX_FINAL_calibration_candidate.txt", args.tag+".log" )
80 print("Done\n")
81
82
83 print("Jobs finished")
84 exit(0)
85
void print(char *figname, TCanvas *c1)