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
24 from .definitions
import *
25 from .utils
import setTDRStyle
32 ROOT.gROOT.SetBatch(ROOT.kTRUE)
38 if msg_level>=_log_level:
39 print(
"[%s] %s" %(asctime(),message))
51 def __init__(self,sample1="",sample2="",release1="",release2="",run1="",run2="",tier1=0,tier2=0):
63 def __init__(self,name,mother_dir="",meta=CompInfo(),draw_success=
False,do_pngs=
False):
78 Weighted.__init__(self,name)
97 '''Walk all subdirs and calculate weight,fails and successes. 98 Moreove propagate the sample and releases names. 118 self.
subdirs = [subdir
for subdir
in self.
subdirs if not subdir.is_empty()]
121 if comp.status == SKIPED:
128 if comp.status == FAIL:
131 elif comp.status == SUCCESS:
141 subdir.calcStats(make_pie)
142 subdir.meta=self.
meta 143 self.
weight+=subdir.weight
161 subdirdict[subdir.name]=subdir
167 subdirnames.append(subdir.name)
171 """Emit the ajax to build a pie chart using google apis... 173 url =
"https://chart.googleapis.com/chart?" 176 url+=
"&chco=00FF00|FFFF00|FF0000|7A7A7A" 177 url+=
"&chs=%sx%s" %(w,h)
188 fail_comps=[comp
for comp
in self.
comparisons if comp.status==FAIL]
189 fail_comps=sorted(fail_comps,key=
lambda comp:comp.name )
190 if len(fail_comps)>0:
192 for comp
in fail_comps:
193 print(indent+
" - %s: %s Test Failed (pval = %s) " %(comp.name,comp.test_name,comp.rank))
195 subdir.print_report(indent+
" ",verbose)
206 if self.
weight == 0:
return 0
209 if self.
weight == 0:
return 0
213 if self.
weight == 0:
return 1
217 if self.
weight == 0:
return 0
230 if not exists(full_path)
and len(full_path)>0:
244 valsa=
array(
'f',vals)
245 colorsa=
array(
'i',colors)
246 can = ROOT.TCanvas(
"cpie",
"TPie test",100,100);
248 pie = TPie(
"ThePie",self.
name,len(vals),valsa,colorsa);
261 pie.SetAngularOffset(0.);
262 pie.SetLabelsOffset(-.3);
268 print(
"len(vals) = %s (vals=%s)" %(len(vals),vals))
269 print(
"valsa = %s" %valsa)
270 print(
"colorsa = %s" %colorsa)
273 """Eliminate from the tree the directory the expandable ones. 281 subdir.mother_dir=subdir.mother_dir.replace(
"/"+expandable_dir,
"")
282 if subdir.name==expandable_dir:
288 exp_dir=self.
subdirs[exp_index]
289 for subsubdir
in exp_dir.subdirs:
291 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"/"+expandable_dir,
"")
292 while "//" in subsubdir.mother_dir:
293 print(subsubdir.mother_dir)
294 subsubdir.mother_dir=subsubdir.mother_dir.replace(
"//",
"/")
298 for comp
in exp_dir.comparisons:
299 comp.mother_dir=comp.mother_dir.replace(
"/"+expandable_dir,
"")
300 while "//" in comp.mother_dir:
302 comp.mother_dir=comp.mother_dir.replace(
"/")
311 self.
prune(expandable_dir)
314 subdir.prune(expandable_dir)
318 return "%s seems to be empty. Please check!" %self.
name 321 content+=
" %s\n" % subdir
323 content+=
" %s\n" % comp
327 from multiprocessing
import Process
329 canvas.Print(img_name)
331 tcanvas_print_processes=[]
337 def __init__(self,name,mother_dir,h1,h2,stat_test,draw_success=False,do_pngs=False, skip=False):
343 Weighted.__init__(self,name)
345 stat_test.set_operands(h1,h2)
353 self.
status=stat_test.get_status()
354 self.
rank=stat_test.get_rank()
384 tcanvas_print_processes.append(p)
385 n_proc=len(tcanvas_print_processes)
388 for iprocess
in range(0,n_proc):
389 p=tcanvas_print_processes[iprocess]
391 p_to_remove.append(iprocess)
394 for iprocess
in p_to_remove:
395 tcanvas_print_processes.pop(iprocess-adjustment)
403 canvas=ROOT.TCanvas(self.
name,self.
name,Comparison.canvas_xsize,Comparison.canvas_ysize)
407 obj1.SetTitle(self.
name)
409 if obj1.GetNbinsY()!=0
and not "2" in obj1.ClassName() :
410 obj1 .SetLineWidth(2)
411 obj2 .SetLineWidth(2)
413 obj1.SetMarkerStyle(8)
414 obj1.SetMarkerSize(.8)
416 obj2.SetMarkerStyle(8)
417 obj2.SetMarkerSize(.8)
419 obj1.SetMarkerColor(ROOT.kBlue)
420 obj1.SetLineColor(ROOT.kBlue)
422 obj2.SetMarkerColor(ROOT.kRed)
423 obj2.SetLineColor(ROOT.kRed)
427 obj2.Draw(
"HistSames")
451 print(
"This comparison failed %f" %self.
rank)
458 lat_text=
"#scale[.7]{#color[%s]{%s: %2.2f}}" %(color,self.
test_name,self.
rank)
459 lat=ROOT.TLatex(.1,.91,lat_text)
475 lat_text1=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj1.GetLineColor(),n1)
476 lat1=ROOT.TLatex(.3,.91,lat_text1)
481 lat_text2=
"#scale[.7]{#color[%s]{Entries: %s}}" %(obj2.GetLineColor(),n2)
482 lat2=ROOT.TLatex(.6,.91,lat_text2)
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)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
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_summary_chart_ajax(self, w=400, h=300)
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)