ATLAS Offline Software
Functions | Variables
CheckValues Namespace Reference

Functions

def CalculateTOT (Q, params)
 
def CheckThresholds (calib, iov, _file)
 
def ValThreshold (layer, pix, listavg, perc=1)
 
def figurIBL (title, hist, xlabel, namef)
 
def figur (title, hist, xlabel, namef)
 
def plot (axs, arr, xlabel, islog=False)
 
def CheckThresholdsIBL (_file)
 

Variables

 parser
 
 required
 
 True
 
 help
 
 action
 
 args = parser.parse_args()
 
 new_calib
 
 new_iov
 

Function Documentation

◆ CalculateTOT()

def CheckValues.CalculateTOT (   Q,
  params 
)

Definition at line 9 of file CheckValues.py.

9 def CalculateTOT(Q,params):
10  num = params[1] + Q
11  den = params[2] + Q
12  if den == 0:
13  return 0
14  return params[0]*(num/den)
15 

◆ CheckThresholds()

def CheckValues.CheckThresholds (   calib,
  iov,
  _file 
)

Definition at line 16 of file CheckValues.py.

16 def CheckThresholds(calib,iov,_file):
17 
18  import os
19  os.makedirs("plots/parameters", exist_ok=True)
20 
21  mapping = ReadCSV()
22 
23  expectedTOTint = { "IBL": {"normal":[],"long":[]},
24  "Blayer": {"normal":[],"long":[],"ganged":[]},
25  "L1" : {"normal":[],"long":[],"ganged":[]},
26  "L2" : {"normal":[],"long":[],"ganged":[]},
27  "Disk" : {"normal":[],"long":[],"ganged":[]}}
28  CalibThreshold = { "IBL": {"normal":[],"long":[]},
29  "Blayer": {"normal":[],"long":[],"ganged":[]},
30  "L1" : {"normal":[],"long":[],"ganged":[]},
31  "L2" : {"normal":[],"long":[],"ganged":[]},
32  "Disk" : {"normal":[],"long":[],"ganged":[]}}
33  CalibRMS = { "IBL": {"normal":[],"long":[]},
34  "Blayer": {"normal":[],"long":[],"ganged":[]},
35  "L1" : {"normal":[],"long":[],"ganged":[]},
36  "L2" : {"normal":[],"long":[],"ganged":[]},
37  "Disk" : {"normal":[],"long":[],"ganged":[]}}
38  CalibNoise = { "IBL": {"normal":[],"long":[]},
39  "Blayer": {"normal":[],"long":[],"ganged":[]},
40  "L1" : {"normal":[],"long":[],"ganged":[]},
41  "L2" : {"normal":[],"long":[],"ganged":[]},
42  "Disk" : {"normal":[],"long":[],"ganged":[]}}
43  CalibIntime = { "IBL": {"normal":[],"long":[]},
44  "Blayer": {"normal":[],"long":[],"ganged":[]},
45  "L1" : {"normal":[],"long":[],"ganged":[]},
46  "L2" : {"normal":[],"long":[],"ganged":[]},
47  "Disk" : {"normal":[],"long":[],"ganged":[]}}
48 
49  report = {}
50  for mod, FEs in calib.items():
51  mod_name = mapping[str(mod)]
52  mod_layer = ""
53  if mod_name.startswith("L0"):
54  mod_layer = "Blayer"
55  elif mod_name.startswith("L1"):
56  mod_layer = "L1"
57  elif mod_name.startswith("L2"):
58  mod_layer = "L2"
59  elif mod_name.startswith("D"):
60  mod_layer = "Disk"
61  else:
62  mod_layer = "IBL"
63  if mod_name.startswith("LI_S15"):
64  continue
65 
66  key = "%-16s - %s" % (mod_name,mod)
67  if key not in report:
68  report[key] = ""
69 
70  for ife in range(len(FEs)):
71  fe = FEs[ife]
72  if mod_layer == "IBL":
73 
74  bool1, str1 = ValThreshold(mod_layer,"normal",fe[0],5)
75  bool2, str2 = ValThreshold(mod_layer,"long" ,fe[2],5)
76  if bool1:
77  report[key] += ("\tFE%02u: "% ife) + str1
78  if bool2:
79  report[key] += ("\tFE%02u: "% ife) + str2
80 
81  CalibThreshold[mod_layer]["normal"].append(fe[0])
82  CalibThreshold[mod_layer]["long"].append(fe[2])
83 
84  CalibRMS[mod_layer]["normal"].append(fe[1])
85  CalibRMS[mod_layer]["long"].append(fe[3])
86  else:
87 
88  bool1, str1 = ValThreshold(mod_layer,"normal",fe[0],5)
89  bool2, str2 = ValThreshold(mod_layer,"long" ,fe[4],5)
90  bool3, str3 = ValThreshold(mod_layer,"ganged",fe[8],5)
91  if bool1:
92  report[key] += ("\tFE%02u: "% ife) + str1
93  if bool2:
94  report[key] += ("\tFE%02u: "% ife) + str2
95  if bool3:
96  report[key] += ("\tFE%02u: "% ife) + str3
97 
98  totint_nor = CalculateTOT(fe[3],fe[12:15])
99  totint_lon = CalculateTOT(fe[7],fe[15:18])
100  totint_gan = CalculateTOT(fe[11],fe[15:18])
101 
102  expectedTOTint[mod_layer]["normal"].append(totint_nor)
103  expectedTOTint[mod_layer]["long"].append(totint_lon)
104  expectedTOTint[mod_layer]["ganged"].append(totint_gan)
105 
106  CalibThreshold[mod_layer]["normal"].append(fe[0])
107  CalibThreshold[mod_layer]["long"].append(fe[4])
108  CalibThreshold[mod_layer]["ganged"].append(fe[8])
109 
110  CalibRMS[mod_layer]["normal"].append(fe[1])
111  CalibRMS[mod_layer]["long"].append(fe[5])
112  CalibRMS[mod_layer]["ganged"].append(fe[9])
113 
114  CalibNoise[mod_layer]["normal"].append(fe[2])
115  CalibNoise[mod_layer]["long"].append(fe[6])
116  CalibNoise[mod_layer]["ganged"].append(fe[10])
117 
118  CalibIntime[mod_layer]["normal"].append(fe[3])
119  CalibIntime[mod_layer]["long"].append(fe[7])
120  CalibIntime[mod_layer]["ganged"].append(fe[11])
121 
122  # writing log files
123  fout = open("CheckValues_log.txt", "w")
124 
125  fout.write("_______________ LOG _______________\n\n" )
126  fout.write("File chosen:\n" )
127  fout.write("Calibration : '%s'\n" % (_file) )
128  fout.write("Data base IOV: %s\n\n" % (iov) )
129 
130  fout.write("\n Threshold FE values validation:\n")
131  fout.write("-"*40+"\n")
132  for key, val in report.items():
133  if val == "":
134  continue
135  fout.write(key+"\n")
136  fout.write(val)
137  fout.write("-"*40)
138 
139  fout.write("\n\n\n\n Threshold MEAN values validation:\n")
140  fout.write("-"*40+"\n")
141  for i in ["IBL","Blayer","L1","L2","Disk"]:
142 
143  for j in CalibThreshold[i]:
144  if len(CalibThreshold[i][j]) == 0:
145  continue
146  _bool_, _str_ = ValThreshold(i,j,np.average(CalibThreshold[i][j]))
147  fout.write("\t"+_str_)
148 
149  if i == "IBL":
150  figurIBL(i,CalibThreshold, "Threshold","CalibThreshold_"+i+".png")
151  figurIBL(i,CalibRMS , "RMS" ,"CalibRMS_"+i+".png")
152  else:
153  figur(i,expectedTOTint, "ToT for intime threshold", "totIntime_"+i+".png")
154  figur(i,CalibThreshold, "Threshold","CalibThreshold_"+i+".png")
155  figur(i,CalibRMS , "RMS" ,"CalibRMS_"+i+".png")
156  figur(i,CalibNoise , "Noise" ,"CalibNoise_"+i+".png")
157  figur(i,CalibIntime , "Intime" ,"CalibIntime_"+i+".png")
158 
159  fout.write("-"*40+"\n\n")
160 
161  totalFE = 0
162  totalParams = 0
163  fe_indiv = {"IBL":0,"Blayer":0,"L1":0,"L2":0,"Disk":0}
164  params_indiv = {"IBL":0,"Blayer":0,"L1":0,"L2":0,"Disk":0}
165  for key, FEs in calib.items():
166 
167  mod_name = mapping[str(key)]
168  mod_layer = ""
169  if mod_name.startswith("L0"):
170  mod_layer = "Blayer"
171  elif mod_name.startswith("L1"):
172  mod_layer = "L1"
173  elif mod_name.startswith("L2"):
174  mod_layer = "L2"
175  elif mod_name.startswith("D"):
176  mod_layer = "Disk"
177  else:
178  mod_layer = "IBL"
179 
180  totalFE += len(FEs)
181  fe_indiv[mod_layer] += len(FEs)
182  for fe in FEs:
183  totalParams += len(fe)
184  params_indiv[mod_layer] += len(fe)
185 
186 
187  fout.write("Modules checked : %6u\n" % (len(calib)))
188  fout.write("FrontEnds checked : %6u\n" % (totalFE))
189  for key, value in fe_indiv.items():
190  fout.write(" - %-6s:%6u \n" % (key,value))
191  fout.write("Parameters checked: %6u\n" % (totalParams))
192  for key, value in params_indiv.items():
193  fout.write(" - %-6s:%6u \n" % (key,value))
194 
195 
196  fout.close()
197 
198  #open and read the file for terminal print:
199  fin = open("CheckValues_log.txt", "r")
200  print(fin.read())
201 
202 

◆ CheckThresholdsIBL()

def CheckValues.CheckThresholdsIBL (   _file)

Definition at line 248 of file CheckValues.py.

248 def CheckThresholdsIBL(_file):
249  from PixelCalibAlgs.EvoMonitoring import ReadCalibOutput
250  new_calib, new_iov = ReadCalibOutput(_file)
251 
252  CheckThresholds(new_calib,new_iov,_file)
253 
254 

◆ figur()

def CheckValues.figur (   title,
  hist,
  xlabel,
  namef 
)

Definition at line 229 of file CheckValues.py.

229 def figur(title,hist,xlabel,namef):
230  fig = Figure(figsize=(13,10))
231  fig.suptitle(title)
232  plot(fig.add_subplot(2,3,1),hist[title]["normal"] if len(hist[title]["normal"]) else [-1], xlabel+" - normal")
233  plot(fig.add_subplot(2,3,2),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - long")
234  plot(fig.add_subplot(2,3,3),hist[title]["ganged"] if len(hist[title]["ganged"]) else [-1], xlabel+" - ganged")
235  plot(fig.add_subplot(2,3,4),hist[title]["normal"] if len(hist[title]["normal"]) else [-1], xlabel+" - normal" ,True)
236  plot(fig.add_subplot(2,3,5),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - long" ,True)
237  plot(fig.add_subplot(2,3,6),hist[title]["ganged"] if len(hist[title]["ganged"]) else [-1], xlabel+" - ganged" ,True)
238  FigureCanvasAgg(fig).print_figure("plots/parameters/"+namef, dpi=150)
239 

◆ figurIBL()

def CheckValues.figurIBL (   title,
  hist,
  xlabel,
  namef 
)

Definition at line 220 of file CheckValues.py.

220 def figurIBL(title,hist,xlabel,namef):
221  fig = Figure(figsize=(13,10))
222  fig.suptitle(title)
223  plot(fig.add_subplot(2,2,1),hist[title]["normal"]if len(hist[title]["normal"]) else [-1], xlabel+" - normal")
224  plot(fig.add_subplot(2,2,2),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - normal")
225  plot(fig.add_subplot(2,2,3),hist[title]["normal"]if len(hist[title]["normal"]) else [-1], xlabel+" - normal",True)
226  plot(fig.add_subplot(2,2,4),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - normal",True)
227  FigureCanvasAgg(fig).print_figure("plots/parameters/"+namef, dpi=150)
228 

◆ plot()

def CheckValues.plot (   axs,
  arr,
  xlabel,
  islog = False 
)

Definition at line 240 of file CheckValues.py.

240 def plot(axs,arr, xlabel, islog = False):
241  axs.hist(arr, bins=60)
242  axs.set_xlabel(xlabel)
243  if islog:
244  axs.set_yscale("log")
245  axs.set_ylabel("Counts [log scale]" if islog else "Counts")
246 
247 

◆ ValThreshold()

def CheckValues.ValThreshold (   layer,
  pix,
  listavg,
  perc = 1 
)

Definition at line 203 of file CheckValues.py.

203 def ValThreshold (layer, pix, listavg, perc=1):
204 
205  # Those values are coming from online crew - Analog thresholds
206  # https://twiki.cern.ch/twiki/bin/viewauth/Atlas/PixelConditionsRUN3
207  realThresholds = { "IBL": 1500, "Blayer": 4700 , "L1": 4300, "L2": 4300, "Disk": 4300}
208 
209  dev = abs((realThresholds[layer]-listavg)/listavg*100)
210  status = "OK"
211  # If it deviates more than 1%
212  if dev > perc:
213  status = "NEEDS CHECKING!!!"
214  if perc != 1 and status == "OK":
215  return False, "OK"
216 
217  _str_ = "%-25s: %6.1fe (exp.: %4ue), dev.: %6.2f%% - status (>%i%%): %s\n" % (layer+" avg. thr. ["+pix+"]", listavg, realThresholds[layer], dev, perc, status)
218  return True, _str_
219 

Variable Documentation

◆ action

CheckValues.action

Definition at line 263 of file CheckValues.py.

◆ args

CheckValues.args = parser.parse_args()

Definition at line 264 of file CheckValues.py.

◆ help

CheckValues.help

Definition at line 262 of file CheckValues.py.

◆ new_calib

CheckValues.new_calib

Definition at line 270 of file CheckValues.py.

◆ new_iov

CheckValues.new_iov

Definition at line 270 of file CheckValues.py.

◆ parser

CheckValues.parser
Initial value:
1 = argparse.ArgumentParser(prog='python -m PixelCalibAlgs.CheckValues',
2  description=)

Definition at line 258 of file CheckValues.py.

◆ required

CheckValues.required

Definition at line 262 of file CheckValues.py.

◆ True

CheckValues.True

Definition at line 262 of file CheckValues.py.

plot
Definition: PhysicsAnalysis/ElectronPhotonID/ElectronPhotonFourMomentumCorrection/python/plot.py:1
dumpHVPathFromNtuple.append
bool append
Definition: dumpHVPathFromNtuple.py:91
CheckValues.figur
def figur(title, hist, xlabel, namef)
Definition: CheckValues.py:229
CheckValues.CheckThresholdsIBL
def CheckThresholdsIBL(_file)
Definition: CheckValues.py:248
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
CheckValues.CalculateTOT
def CalculateTOT(Q, params)
Definition: CheckValues.py:9
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
CheckValues.CheckThresholds
def CheckThresholds(calib, iov, _file)
Definition: CheckValues.py:16
EvoMonitoring.ReadCalibOutput
def ReadCalibOutput(file)
Definition: EvoMonitoring.py:213
Trk::open
@ open
Definition: BinningType.h:40
CheckValues.figurIBL
def figurIBL(title, hist, xlabel, namef)
Definition: CheckValues.py:220
plot
bool plot
Definition: listroot.cxx:44
EvoMonitoring.ReadCSV
def ReadCSV()
Definition: EvoMonitoring.py:204
str
Definition: BTagTrackIpAccessor.cxx:11
CheckValues.ValThreshold
def ValThreshold(layer, pix, listavg, perc=1)
Definition: CheckValues.py:203