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

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

Function Documentation

◆ CalculateTOT()

def CheckValues.CalculateTOT (   Q,
  params 
)

Definition at line 10 of file CheckValues.py.

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

◆ CheckThresholds()

def CheckValues.CheckThresholds (   calib,
  iov,
  _file 
)

Definition at line 17 of file CheckValues.py.

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

◆ CheckThresholdsIBL()

def CheckValues.CheckThresholdsIBL (   _file)

Definition at line 249 of file CheckValues.py.

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

◆ figur()

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

Definition at line 230 of file CheckValues.py.

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

◆ figurIBL()

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

Definition at line 221 of file CheckValues.py.

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

◆ plot()

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

Definition at line 241 of file CheckValues.py.

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

◆ ValThreshold()

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

Definition at line 204 of file CheckValues.py.

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

Variable Documentation

◆ action

CheckValues.action

Definition at line 264 of file CheckValues.py.

◆ args

CheckValues.args = parser.parse_args()

Definition at line 265 of file CheckValues.py.

◆ help

CheckValues.help

Definition at line 263 of file CheckValues.py.

◆ MaxThreshold

int CheckValues.MaxThreshold = 10

Definition at line 8 of file CheckValues.py.

◆ new_calib

CheckValues.new_calib

Definition at line 271 of file CheckValues.py.

◆ new_iov

CheckValues.new_iov

Definition at line 271 of file CheckValues.py.

◆ parser

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

Definition at line 259 of file CheckValues.py.

◆ required

CheckValues.required

Definition at line 263 of file CheckValues.py.

◆ True

CheckValues.True

Definition at line 263 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:230
CheckValues.CheckThresholdsIBL
def CheckThresholdsIBL(_file)
Definition: CheckValues.py:249
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
CheckValues.CalculateTOT
def CalculateTOT(Q, params)
Definition: CheckValues.py:10
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:26
CheckValues.CheckThresholds
def CheckThresholds(calib, iov, _file)
Definition: CheckValues.py:17
EvoMonitoring.ReadCalibOutput
def ReadCalibOutput(file)
Definition: EvoMonitoring.py:215
Trk::open
@ open
Definition: BinningType.h:40
CheckValues.figurIBL
def figurIBL(title, hist, xlabel, namef)
Definition: CheckValues.py:221
plot
bool plot
Definition: listroot.cxx:44
EvoMonitoring.ReadCSV
def ReadCSV()
Definition: EvoMonitoring.py:206
str
Definition: BTagTrackIpAccessor.cxx:11
CheckValues.ValThreshold
def ValThreshold(layer, pix, listavg, perc=1)
Definition: CheckValues.py:204