ATLAS Offline Software
PixelCalibrationConfig.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 if __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' , required=True, help="Directory path to the files")
12  parser.add_argument('--thr' , required=True, help="Threshold file, format must be \"SCAN_SXXXXXXXXX\" ")
13  parser.add_argument('--thr_intime', required=True, help="Threshold intime file, format must be \"SCAN_SXXXXXXXXX\" ")
14  parser.add_argument('--tot' , required=True, help="Time over threshold file, format must be \"SCAN_SXXXXXXXXX\" ")
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")
20 
21 
22 
23  args = parser.parse_args()
24 
25  import subprocess
26  proc = []
27 
28  print("Running PixelCalibration layers..")
29  # Executing 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))
35 
36  # Waiting to get the processes finished
37  for l in range(len(args.layers)) :
38  proc[l].communicate()
39  print("Done\n")
40 
41  # This is meant to run just one layer from a different calibration path and other layer from other path.
42  # We need to merge after the output of PixelCalibration. Use --runCal = True if you plan to test or run other layer afterwards
43  if args.runCal:
44  print("Jobs finished")
45  exit(0)
46 
47  print("Merging calibration output...")
48  from PixelCalibAlgs.FileMerger import MergeCalibFiles
49  # Sending an array of all the layer - the ones not present will be skipped and reported
50  MergeCalibFiles(["Blayer", "L1", "L2", "disk"])
51  print("Done\n")
52 
53  print("Creating Reference file..")
54  # Downloads the last IOV
55  command = 'MakeReferenceFile %s' % (args.tag)
56  print("Command: %s\n" % command)
57  (subprocess.Popen(command, shell=True)).communicate()
58  print("Done\n")
59 
60  print("Updating last IOV and creating calibration candidate file..")
61  # Updates last IOV with the new calibration
62  from PixelCalibAlgs.Recovery import UpdateCalib
63  UpdateCalib(args.tag)
64  print("Done\n")
65 
66  if args.skipPlots:
67  print("Jobs finished")
68  exit(0)
69 
70  print("Validation new vs. previous calibration.")
71  # Plots the old vs. new charge for all FE (includes IBL)
72  # Meant to be used for pixel, but can be used for IBL in standalone (reading central DB using MakeReferenceFile.cxx step)
73  from PixelCalibAlgs.EvoMonitoring import setupRunEvo
74  setupRunEvo("FINAL_calibration_candidate.txt", args.tag+".log" )
75  print("Done\n")
76 
77 
78  print("Jobs finished")
79  exit(0)
80 
FileMerger.MergeCalibFiles
def MergeCalibFiles(layers)
Definition: FileMerger.py:8
EvoMonitoring.setupRunEvo
def setupRunEvo(path_newCalib, path_oldCalib)
Definition: EvoMonitoring.py:253
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
calibdata.exit
exit
Definition: calibdata.py:236
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
Recovery.UpdateCalib
def UpdateCalib(tag)
Definition: Recovery.py:209