CMS 3D CMS Logo

Public Member Functions | Public Attributes | Static Public Attributes | Private Member Functions

dirstructure::Comparison Class Reference

Inheritance diagram for dirstructure::Comparison:
dirstructure::Weighted

List of all members.

Public Member Functions

def __init__
def __repr__
def tcanvas_slow

Public Attributes

 do_pngs
 draw_success
 img_name
 mother_dir
 name
 png_name
 rank
 status
 test_name
 test_thr

Static Public Attributes

int canvas_xsize = 500
int canvas_ysize = 400

Private Member Functions

def __get_img_name
def __make_image
def __make_img_dir

Detailed Description

Definition at line 334 of file dirstructure.py.


Constructor & Destructor Documentation

def dirstructure::Comparison::__init__ (   self,
  name,
  mother_dir,
  h1,
  h2,
  stat_test,
  draw_success = False,
  do_pngs = False,
  skip = False 
)

Definition at line 337 of file dirstructure.py.

00338                                                                                                  :
00339     self.name=name
00340     self.png_name="placeholder.png"
00341     self.mother_dir=mother_dir
00342     self.img_name=""
00343     #self.draw_success=draw_success
00344     Weighted.__init__(self,name)
00345 
00346     stat_test.set_operands(h1,h2)
00347     if skip:
00348         self.status = SKIPED
00349         self.test_name=stat_test.name
00350         self.test_name=stat_test.name
00351         self.test_thr=stat_test.threshold
00352         self.rank = 0
00353     else:
00354         self.status=stat_test.get_status()
00355         self.rank=stat_test.get_rank()
00356         self.test_name=stat_test.name
00357         self.test_thr=stat_test.threshold
00358         self.do_pngs=do_pngs
00359         self.draw_success=draw_success or not do_pngs
00360         if ((self.status==FAIL or self.status==NULL or self.status == SKIPED or self.draw_success) and self.do_pngs):
00361             self.__make_image(h1,h2)      
00362         #self.__make_image(h1,h2)


Member Function Documentation

def dirstructure::Comparison::__get_img_name (   self) [private]

Definition at line 367 of file dirstructure.py.

00368                           :
00369     #self.__make_img_dir()    
00370     #print "MOTHER: ",self.mother_dir
00371     self.img_name="%s/%s.png"%(self.mother_dir,self.name)
00372     self.img_name=self.img_name.replace("Run summary","")
00373     self.img_name=self.img_name.replace("/","_")
00374     self.img_name=self.img_name.strip("_")
00375     #print "IMAGE NAME: %s " %self.img_name
00376     return self.img_name

def dirstructure::Comparison::__make_image (   self,
  obj1,
  obj2 
) [private]

Definition at line 398 of file dirstructure.py.

00399                                   :
00400     self.img_name=self.__get_img_name()
00401     if self.rank==-1:
00402       return 0
00403    
00404     canvas=TCanvas(self.name,self.name,Comparison.canvas_xsize,Comparison.canvas_ysize)
00405     objs=(obj1,obj2)
00406 
00407     # Add some specifics for the graphs
00408     obj1.SetTitle(self.name)
00409     
00410     if obj1.GetNbinsY()!=0 and not "2" in obj1.ClassName() :
00411       obj1 .SetLineWidth(2)
00412       obj2 .SetLineWidth(2)
00413 
00414       obj1.SetMarkerStyle(8)
00415       obj1.SetMarkerSize(.8)
00416 
00417       obj2.SetMarkerStyle(8)
00418       obj2.SetMarkerSize(.8)
00419 
00420       obj1.SetMarkerColor(kBlue)
00421       obj1.SetLineColor(kBlue)
00422 
00423       obj2.SetMarkerColor(kRed)
00424       obj2.SetLineColor(kRed)
00425 
00426       obj1.Draw("EP")
00427       #Statsbox      
00428       obj2.Draw("HistSames")
00429       #gPad.Update()
00430       #if 'stats' in map(lambda o: o.GetName(),list(gPad.GetListOfPrimitives())):
00431         #st = gPad.GetPrimitive("stats")      
00432         #st.SetY1NDC(0.575)
00433         #st.SetY2NDC(0.735)
00434         #st.SetLineColor(kRed)
00435         #st.SetTextColor(kRed)
00436         #print st      
00437     else:
00438       obj1.Draw("Colz")
00439       gPad.Update()
00440       #if 'stats' in map(lambda o: o.GetName(),list(gPad.GetListOfPrimitives())):
00441         #st = gPad.GetPrimitive("stats")      
00442         #st.SetY1NDC(0.575)
00443         #st.SetY2NDC(0.735)
00444         #st.SetLineColor(kRed)
00445         #st.SetTextColor(kRed)
00446         #print st
00447       obj2.Draw("ColSame")
00448 
00449     # Put together the TLatex for the stat test if possible    
00450     color=kGreen+2 # which is green, as everybody knows
00451     if self.status==FAIL:
00452       print "This comparison failed %f" %self.rank
00453       color=kRed
00454     elif self.status==NULL:
00455       color=kYellow
00456     elif self.status==SKIPED:
00457       color=kBlue #check if kBlue exists ;)
00458     
00459     lat_text="#scale[.7]{#color[%s]{%s: %2.2f}}" %(color,self.test_name,self.rank)
00460     lat=TLatex(.1,.91,lat_text)
00461     lat.SetNDC()
00462     lat.Draw()
00463   
00464     # Put also the stats together!
00465     n1=obj1.GetEntries()
00466     if n1> 100000:
00467       n1="%e"%n1
00468     else:
00469       n1="%s"%n1
00470     n2=obj2.GetEntries()
00471     if n2> 100000:
00472       n2="%e"%n2
00473     else:
00474       n2="%s"%n2
00475 
00476     lat_text1="#scale[.7]{#color[%s]{Entries: %s}}" %(obj1.GetLineColor(),n1)
00477     lat1=TLatex(.3,.91,lat_text1)
00478     lat1.SetNDC()
00479     lat1.Draw()
00480         
00481     
00482     lat_text2="#scale[.7]{#color[%s]{Entries: %s}}" %(obj2.GetLineColor(),n2)
00483     lat2=TLatex(.6,.91,lat_text2)
00484     lat2.SetNDC()
00485     lat2.Draw()
00486     
00487 
00488     self.tcanvas_slow(canvas)

def dirstructure::Comparison::__make_img_dir (   self) [private]

Definition at line 363 of file dirstructure.py.

00363                           :    
00364     if not exists(self.mother_dir):
00365       makedirs(self.mother_dir)
00366     
def dirstructure::Comparison::__repr__ (   self)

Definition at line 489 of file dirstructure.py.

00490                     :
00491     return "%s , (%s=%s). IMG=%s. status=%s" %(self.name,self.test_name,self.rank,self.img_name,self.status)
00492 
00493 #-------------------------------------------------------------------------------  
def dirstructure::Comparison::tcanvas_slow (   self,
  canvas 
)

Definition at line 377 of file dirstructure.py.

00378                                :
00379     #print "About to print %s" %self.img_name
00380     #print_multi_threaded(canvas,self.img_name)
00381     #print "-->Printed"
00382 
00383     p = Process(target=print_multi_threaded, args=(canvas,self.img_name))
00384     p.start()
00385     tcanvas_print_processes.append(p)
00386     n_proc=len(tcanvas_print_processes)
00387     if n_proc>3:
00388       p_to_remove=[]
00389       for iprocess in xrange(0,n_proc):
00390         p=tcanvas_print_processes[iprocess]
00391         p.join()
00392         p_to_remove.append(iprocess)
00393 
00394       adjustment=0
00395       for iprocess in p_to_remove:
00396         tcanvas_print_processes.pop(iprocess-adjustment)
00397         adjustment+=1


Member Data Documentation

Definition at line 335 of file dirstructure.py.

Definition at line 336 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Reimplemented from dirstructure::Weighted.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.

Definition at line 337 of file dirstructure.py.