ATLAS Offline Software
Functions | Variables
CheckValues Namespace Reference

Functions

def CalculateTOT (Q, params)
 
def CheckThresholds (calib)
 
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)
 

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)

Definition at line 16 of file CheckValues.py.

16 def CheckThresholds(calib):
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] += ("FE%02u: "% ife) + str1
78  if bool2:
79  report[key] += ("FE%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] += ("FE%02u: "% ife) + str1
93  if bool2:
94  report[key] += ("FE%02u: "% ife) + str2
95  if bool3:
96  report[key] += ("FE%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  print("\n Threshold FE values validation:")
123  print("-"*40)
124  for key, val in report.items():
125  if val == "":
126  continue
127  print(key)
128  print(val)
129  print("-"*40)
130 
131  print("\n\n\n\n Threshold MEAN values validation:")
132  print("-"*40)
133  for i in ["IBL","Blayer","L1","L2","Disk"]:
134  # for i in ["IBL"]:
135 
136  for j in CalibThreshold[i]:
137  if len(CalibThreshold[i][j]) == 0:
138  continue
139  _bool_, _str_ = ValThreshold(i,j,np.average(CalibThreshold[i][j]))
140  print(_str_, end="")
141 
142  if i == "IBL":
143  figurIBL(i,CalibThreshold, "Threshold","CalibThreshold_"+i+".png")
144  figurIBL(i,CalibRMS , "RMS" ,"CalibRMS_"+i+".png")
145  else:
146  figur(i,expectedTOTint, "ToT for intime threshold", "totIntime_"+i+".png")
147  figur(i,CalibThreshold, "Threshold","CalibThreshold_"+i+".png")
148  figur(i,CalibRMS , "RMS" ,"CalibRMS_"+i+".png")
149  figur(i,CalibNoise , "Noise" ,"CalibNoise_"+i+".png")
150  figur(i,CalibIntime , "Intime" ,"CalibIntime_"+i+".png")
151 
152  print("-"*40,"\n")
153 

◆ figur()

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

Definition at line 180 of file CheckValues.py.

180 def figur(title,hist,xlabel,namef):
181  fig = Figure(figsize=(13,10))
182  fig.suptitle(title)
183  plot(fig.add_subplot(2,3,1),hist[title]["normal"] if len(hist[title]["normal"]) else [-1], xlabel+" - normal")
184  plot(fig.add_subplot(2,3,2),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - long")
185  plot(fig.add_subplot(2,3,3),hist[title]["ganged"] if len(hist[title]["ganged"]) else [-1], xlabel+" - ganged")
186  plot(fig.add_subplot(2,3,4),hist[title]["normal"] if len(hist[title]["normal"]) else [-1], xlabel+" - normal" ,True)
187  plot(fig.add_subplot(2,3,5),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - long" ,True)
188  plot(fig.add_subplot(2,3,6),hist[title]["ganged"] if len(hist[title]["ganged"]) else [-1], xlabel+" - ganged" ,True)
189  FigureCanvasAgg(fig).print_figure("plots/parameters/"+namef, dpi=150)
190 

◆ figurIBL()

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

Definition at line 171 of file CheckValues.py.

171 def figurIBL(title,hist,xlabel,namef):
172  fig = Figure(figsize=(13,10))
173  fig.suptitle(title)
174  plot(fig.add_subplot(2,2,1),hist[title]["normal"]if len(hist[title]["normal"]) else [-1], xlabel+" - normal")
175  plot(fig.add_subplot(2,2,2),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - normal")
176  plot(fig.add_subplot(2,2,3),hist[title]["normal"]if len(hist[title]["normal"]) else [-1], xlabel+" - normal",True)
177  plot(fig.add_subplot(2,2,4),hist[title]["long"] if len(hist[title]["long"]) else [-1], xlabel+" - normal",True)
178  FigureCanvasAgg(fig).print_figure("plots/parameters/"+namef, dpi=150)
179 

◆ plot()

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

Definition at line 191 of file CheckValues.py.

191 def plot(axs,arr, xlabel, islog = False):
192  axs.hist(arr, bins=60)
193  axs.set_xlabel(xlabel)
194  if islog:
195  axs.set_yscale("log")
196  axs.set_ylabel("Counts [log scale]" if islog else "Counts")
197 
198 

◆ ValThreshold()

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

Definition at line 154 of file CheckValues.py.

154 def ValThreshold (layer, pix, listavg, perc=1):
155 
156  # Those values are coming from online crew - Analog thresholds
157  # https://twiki.cern.ch/twiki/bin/viewauth/Atlas/PixelConditionsRUN3
158  realThresholds = { "IBL": 1500, "Blayer": 4700 , "L1": 4300, "L2": 4300, "Disk": 4300}
159 
160  dev = abs((realThresholds[layer]-listavg)/listavg*100)
161  status = "OK"
162  # If it deviates more than 1%
163  if dev > perc:
164  status = "NEEDS CHECKING!!!"
165  if perc != 1 and status == "OK":
166  return False, "OK"
167 
168  _str_ = "\t%-25s: %6.1fe (exp.: %4ue), dev.: %6.2f%% - status (>%i%%): %s\n" % (layer+" avg. thr. ["+pix+"]", listavg, realThresholds[layer], dev, perc, status)
169  return True, _str_
170 

Variable Documentation

◆ action

CheckValues.action

Definition at line 207 of file CheckValues.py.

◆ args

CheckValues.args = parser.parse_args()

Definition at line 208 of file CheckValues.py.

◆ help

CheckValues.help

Definition at line 206 of file CheckValues.py.

◆ new_calib

CheckValues.new_calib

Definition at line 214 of file CheckValues.py.

◆ new_iov

CheckValues.new_iov

Definition at line 214 of file CheckValues.py.

◆ parser

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

Definition at line 202 of file CheckValues.py.

◆ required

CheckValues.required

Definition at line 206 of file CheckValues.py.

◆ True

CheckValues.True

Definition at line 206 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:180
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
CheckValues.CalculateTOT
def CalculateTOT(Q, params)
Definition: CheckValues.py:9
CheckValues.figurIBL
def figurIBL(title, hist, xlabel, namef)
Definition: CheckValues.py:171
plot
bool plot
Definition: listroot.cxx:44
CheckValues.CheckThresholds
def CheckThresholds(calib)
Definition: CheckValues.py:16
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
EvoMonitoring.ReadCSV
def ReadCSV()
Definition: EvoMonitoring.py:226
str
Definition: BTagTrackIpAccessor.cxx:11
CheckValues.ValThreshold
def ValThreshold(layer, pix, listavg, perc=1)
Definition: CheckValues.py:154