1 from __future__
import print_function
2 from __future__
import absolute_import
13 from builtins
import range
14 from array
import array
15 from copy
import deepcopy
16 from os
import chdir,getcwd,listdir,makedirs,rmdir
17 from os.path
import exists,join
25 from .definitions
import *
26 from .utils
import setTDRStyle
33 ROOT.gROOT.SetBatch(ROOT.kTRUE)
39 if msg_level>=_log_level:
40 print(
"[%s] %s" %(asctime(),message))
52 def __init__(self,sample1="",sample2="",release1="",release2="",run1="",run2="",tier1=0,tier2=0):
64 def __init__(self,name,mother_dir="",meta=CompInfo(),draw_success=
False,do_pngs=
False):
79 Weighted.__init__(self,name)
98 '''Walk all subdirs and calculate weight,fails and successes. 99 Moreove propagate the sample and releases names. 119 self.
subdirs = [subdir
for subdir
in self.
subdirs if not subdir.is_empty()]
122 if comp.status == SKIPED:
129 if comp.status == FAIL:
132 elif comp.status == SUCCESS:
142 subdir.calcStats(make_pie)
143 subdir.meta=self.
meta 144 self.
weight+=subdir.weight
162 subdirdict[subdir.name]=subdir
168 subdirnames.append(subdir.name)
174 Build the HTML snippet to render a piechart with chart.js 177 img_link =
"https://raw.githubusercontent.com/cms-PdmV/RelMonService2/5ee98db210c0898fd34b4deac3653fa2bdff269b/report_website/lime_circle.png" 178 html =
'<img src="%s" height=%d width=%d>' %(img_link,w,w)
180 html =
'<a href="%s"> %s </a>' %(link,html)
183 name = random.getrandbits(64)
185 html +=
'<canvas id="%s" height=%d width=%d></canvas>'%(name,w,w)
187 html +=
'<script> new Chart("%s",'%(name)
188 html +=
'{ type: "pie",' 192 html +=
'labels: ["Success", "Null" , "Failure", "Skipped"],' 193 html +=
'datasets: [{ backgroundColor: ["lime","yellow","red","grey"],' 197 html +=
'options: { ' 200 html +=
'onClick : function(event) { window.open("%s", "_blank");},'%(link)
203 html +=
'legend: { display: false }, responsive : false, hover: {mode: null}, tooltips: {enabled: false}' 206 html +=
'}}); </script>' 215 fail_comps=[comp
for comp
in self.
comparisons if comp.status==FAIL]
216 fail_comps=sorted(fail_comps,key=
lambda comp:comp.name )
217 if len(fail_comps)>0:
219 for comp
in fail_comps:
220 print(indent+
" - %s: %s Test Failed (pval = %s) " %(comp.name,comp.test_name,comp.rank))
222 subdir.print_report(indent+
" ",verbose)
233 if self.
weight == 0:
return 0
236 if self.
weight == 0:
return 0
240 if self.
weight == 0:
return 1
244 if self.
weight == 0:
return 0
257 if not exists(full_path)
and len(full_path)>0:
271 valsa=
array(
'f',vals)
272 colorsa=
array(
'i',colors)
273 can = ROOT.TCanvas(
"cpie",
"TPie test",100,100);
275 pie = TPie(
"ThePie",self.
name,len(vals),valsa,colorsa);
288 pie.SetAngularOffset(0.);
289 pie.SetLabelsOffset(-.3);
295 print(
"len(vals) = %s (vals=%s)" %(len(vals),vals))
296 print(
"valsa = %s" %valsa)
297 print(
"colorsa = %s" %colorsa)
300 """Eliminate from the tree the directory the expandable ones. 308 subdir.mother_dir=subdir.mother_dir.replace(
"/"+expandable_dir,
"")
309 if subdir.name==expandable_dir:
315 exp_dir=self.
subdirs[exp_index]
316 for subsubdir
in exp_dir.subdirs:
318 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"/"+expandable_dir,
"")
319 while "//" in subsubdir.mother_dir:
320 print(subsubdir.mother_dir)
321 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"//",
"/")
325 for comp
in exp_dir.comparisons:
326 comp.mother_dir=comp.mother_dir.replace(
"/"+expandable_dir,
"")
327 while "//" in comp.mother_dir:
329 comp.mother_dir=comp.mother_dir.replace(
"/")
338 self.
prune(expandable_dir)
341 subdir.prune(expandable_dir)
345 return "%s seems to be empty. Please check!" %self.
name 348 content+=
" %s\n" % subdir
350 content+=
" %s\n" % comp
354 from multiprocessing
import Process
356 canvas.Print(img_name)
358 tcanvas_print_processes=[]
364 def __init__(self,name,mother_dir,h1,h2,stat_test,draw_success=False,do_pngs=False, skip=False):
370 Weighted.__init__(self,name)
372 stat_test.set_operands(h1,h2)
380 self.
status=stat_test.get_status()
381 self.
rank=stat_test.get_rank()
411 tcanvas_print_processes.append(p)
412 n_proc=len(tcanvas_print_processes)
415 for iprocess
in range(0,n_proc):
416 p=tcanvas_print_processes[iprocess]
418 p_to_remove.append(iprocess)
421 for iprocess
in p_to_remove:
422 tcanvas_print_processes.pop(iprocess-adjustment)
430 canvas=ROOT.TCanvas(self.
name,self.
name,Comparison.canvas_xsize,Comparison.canvas_ysize)
434 obj1.SetTitle(self.
name)
436 if obj1.GetNbinsY()!=0
and not "2" in obj1.ClassName() :
437 obj1 .SetLineWidth(2)
438 obj2 .SetLineWidth(2)
440 obj1.SetMarkerStyle(8)
441 obj1.SetMarkerSize(.8)
443 obj2.SetMarkerStyle(8)
444 obj2.SetMarkerSize(.8)
446 obj1.SetMarkerColor(ROOT.kBlue)
447 obj1.SetLineColor(ROOT.kBlue)
449 obj2.SetMarkerColor(ROOT.kRed)
450 obj2.SetLineColor(ROOT.kRed)
454 obj2.Draw(
"HistSames")
478 print(
"This comparison failed %f" %self.
rank)
485 lat_text=
"#scale[.7]{#color[%s]{%s: %2.2f}}" %(color,self.
test_name,self.
rank)
486 lat=ROOT.TLatex(.1,.91,lat_text)
502 lat_text1=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj1.GetLineColor(),n1)
503 lat1=ROOT.TLatex(.3,.91,lat_text1)
508 lat_text2=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj2.GetLineColor(),n2)
509 lat2=ROOT.TLatex(.6,.91,lat_text2)
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE constexpr float zip(ConstView const &tracks, int32_t i)
def __get_full_path(self)
def __init__(self, name, mother_dir, h1, h2, stat_test, draw_success=False, do_pngs=False, skip=False)
def calcStats(self, make_pie=True)
def prune(self, expandable_dir)
def replace(string, replacements)
def get_success_rate(self)
def __create_on_disk(self)
def __init__(self, sample1="", sample2="", release1="", release2="", run1="", run2="", tier1=0, tier2=0)
def print_report(self, indent="", verbose=False)
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
def get_summary_chart_name(self)
def __init__(self, name, mother_dir="", meta=CompInfo(), draw_success=False, do_pngs=False)
def get_subdirs_names(self)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def get_subdirs_dict(self)
def tcanvas_slow(self, canvas)
def get_piechart_js(self, w=400, link=None)
static std::string join(char **cmd)
def print_multi_threaded(canvas, img_name)
def logger(msg_level, message)
def __create_pie_image(self)
def __init__(self, name, weight=1)
def __make_image(self, obj1, obj2)
def get_skiped_rate(self)