ATLAS Offline Software
IBLCalibrationConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 import sys
3 
4 def scanFullName(oname):
5 
6  if "-" in oname:
7  nname = oname.replace("-", "")
8  if nname.startswith("S"):
9  return f"SCAN_S000{nname[1:]}"
10 
11  elif len(oname) == 15 and oname.startswith("SCAN_S000"):
12  return oname
13 
14  else:
15  print(f"ERROR: Scan name '{oname}' is wrong. Should have for example 'SCAN_S000092961' or 'S092-961' format")
16  sys.exit(1)
17 
18 if __name__=="__main__":
19 
20  import argparse
21  parser = argparse.ArgumentParser(prog='python -m PixelCalibAlgs.IBLCalibrationConfig',
22  description="""Calibration tool for IBL.\n\n
23  Example: python -m PixelCalibAlgs.IBLCalibrationConfig --folder "global/path/to/folder/"
24  --thr "threshold_file"
25  --totLowQ "totLowCharge_file"
26  --totHisDis "totHisDisConfig_file"
27  [--runCal --skipPlots]""")
28 
29  parser.add_argument('--folder' , type=str, default="/eos/atlas/atlascerngroupdisk/det-pix/p1/scan-data/", help="Directory path to the files")
30  parser.add_argument('--thr' , required=True, help="Format must be \"SCAN_SXXXXXXXXX\" or \"SXXX-XXX\" - THRESHOLD_SCAN (0Preset_full)")
31  parser.add_argument('--totLowQ' , required=True, help="Format must be \"SCAN_SXXXXXXXXX\" or \"SXXX-XXX\" - TOT_CALIB (0Preset_lowcharge) ")
32  parser.add_argument('--totHisDis' , required=True, help="Format must be \"SCAN_SXXXXXXXXX\" or \"SXXX-XXX\" - TOT_CALIB (0Preset_lowcharge_HisDisConfig)")
33  parser.add_argument('--tag' , type=str, default="PixelChargeCalibration-DATA-RUN2-UPD4-28", help="Tag in order to read the DB")
34  parser.add_argument('--runCal' , action='store_true', help="Runs only the IBL Calibration layer")
35  parser.add_argument('--skipPlots' , action='store_true', help="Skips the plotting step - Slower the running time")
36 
37  args = parser.parse_args()
38 
39  args.thr = scanFullName(args.thr)
40  args.totHisDis = scanFullName(args.totHisDis)
41  args.totLowQ = scanFullName(args.totLowQ)
42 
43  try:
44  print("Running IBLCalibration layers..")
45  command = 'IBLCalibration directory_path=' + args.folder + ' THR=' + args.thr + ' TOT_HISDIS=' + args.totHisDis + ' TOT_LOWQ=' + args.totLowQ
46  print("Command: %s\n" % command)
47  import subprocess
48  stdout, stderr = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
49  print("OUTPUT: \n%s" % (stdout.decode('ascii')))
50  print("ERRORS: %s" % ("NONE" if stderr.decode('ascii')=='' else "\n"+stderr.decode('ascii')))
51  if stderr:
52  exit(1)
53 
54  except OSError as e:
55  print("IBLCalibration.cxx execution CRASHED - Please check\n",e)
56  sys.exit(e.errno)
57 
58 
59 
60  # Use --runCal = True if you plan to run just the calibration
61  if args.runCal:
62  print("Jobs finished")
63  exit(0)
64 
65  print("Creating Reference file..")
66  # Downloads the last IOV
67  command = 'MakeReferenceFile tagName=%s' % (args.tag)
68  print("Command: %s\n" % command)
69  (subprocess.Popen(command, shell=True)).communicate()
70  print("Done\n")
71 
72  if args.skipPlots:
73  print("Jobs finished")
74  exit(0)
75 
76  from PixelCalibAlgs.CheckValues import CheckThresholdsIBL
77  CheckThresholdsIBL("ChargeCalib_ToTbin1_FrtEnd2_"+args.totHisDis+".TXT")
78 
79  print("Validation new vs. previous calibration.")
80  # Plots the old vs. new charge for all FE (includes IBL)
81  from PixelCalibAlgs.EvoMonitoring import setupRunEvo
82  setupRunEvo("ChargeCalib_ToTbin1_FrtEnd2_"+args.totHisDis+".TXT", args.tag+".log" )
83  print("Done\n")
84 
85 
86  print("Jobs finished")
87  exit(0)
88 
CheckValues.CheckThresholdsIBL
def CheckThresholdsIBL(_file)
Definition: CheckValues.py:249
EvoMonitoring.setupRunEvo
def setupRunEvo(path_newCalib, path_oldCalib)
Definition: EvoMonitoring.py:233
calibdata.exit
exit
Definition: calibdata.py:235
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
IBLCalibrationConfig.scanFullName
def scanFullName(oname)
Definition: IBLCalibrationConfig.py:4