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 295 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 
)

Definition at line 298 of file dirstructure.py.

00299                                                                                      :
00300     self.name=name
00301     self.png_name="placeholder.png"
00302     self.mother_dir=mother_dir
00303     self.img_name=""
00304     #self.draw_success=draw_success
00305     Weighted.__init__(self,name)
00306 
00307     stat_test.set_operands(h1,h2)
00308     self.status=stat_test.get_status()    
00309     self.rank=stat_test.get_rank()        
00310     self.test_name=stat_test.name    
00311     self.test_thr=stat_test.threshold
00312     self.do_pngs=do_pngs
00313     self.draw_success=draw_success or not do_pngs
00314     if ((self.status==FAIL or self.status==NULL or self.draw_success) and self.do_pngs):
00315       self.__make_image(h1,h2)      
00316     #self.__make_image(h1,h2)


Member Function Documentation

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

Definition at line 321 of file dirstructure.py.

00322                           :
00323     #self.__make_img_dir()    
00324     #print "MOTHER: ",self.mother_dir
00325     self.img_name="%s/%s.png"%(self.mother_dir,self.name)
00326     self.img_name=self.img_name.replace("Run summary","")
00327     self.img_name=self.img_name.replace("/","_")
00328     self.img_name=self.img_name.strip("_")
00329     #print "IMAGE NAME: %s " %self.img_name
00330     return self.img_name

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

Definition at line 352 of file dirstructure.py.

00353                                   :
00354     self.img_name=self.__get_img_name()
00355     if self.rank==-1:
00356       return 0
00357    
00358     canvas=TCanvas(self.name,self.name,Comparison.canvas_xsize,Comparison.canvas_ysize)
00359     objs=(obj1,obj2)
00360 
00361     # Add some specifics for the graphs
00362     obj1.SetTitle(self.name)
00363     
00364     if obj1.GetNbinsY()!=0 and not "2" in obj1.ClassName() :
00365       obj1 .SetLineWidth(2)
00366       obj2 .SetLineWidth(2)
00367 
00368       obj1.SetMarkerStyle(8)
00369       obj1.SetMarkerSize(.8)
00370 
00371       obj2.SetMarkerStyle(8)
00372       obj2.SetMarkerSize(.8)
00373 
00374       obj1.SetMarkerColor(kBlue)
00375       obj1.SetLineColor(kBlue)
00376 
00377       obj2.SetMarkerColor(kRed)
00378       obj2.SetLineColor(kRed)
00379 
00380       obj1.Draw("EP")
00381       #Statsbox      
00382       obj2.Draw("HistSames")
00383       #gPad.Update()
00384       #if 'stats' in map(lambda o: o.GetName(),list(gPad.GetListOfPrimitives())):
00385         #st = gPad.GetPrimitive("stats")      
00386         #st.SetY1NDC(0.575)
00387         #st.SetY2NDC(0.735)
00388         #st.SetLineColor(kRed)
00389         #st.SetTextColor(kRed)
00390         #print st      
00391     else:
00392       obj1.Draw("Colz")
00393       gPad.Update()
00394       #if 'stats' in map(lambda o: o.GetName(),list(gPad.GetListOfPrimitives())):
00395         #st = gPad.GetPrimitive("stats")      
00396         #st.SetY1NDC(0.575)
00397         #st.SetY2NDC(0.735)
00398         #st.SetLineColor(kRed)
00399         #st.SetTextColor(kRed)
00400         #print st
00401       obj2.Draw("ColSame")
00402 
00403     # Put together the TLatex for the stat test if possible    
00404     color=kGreen+2 # which is green, as everybody knows
00405     if self.status==FAIL:
00406       print "This comparison failed %f" %self.rank
00407       color=kRed
00408     elif self.status==NULL:
00409       color=kYellow
00410     
00411     lat_text="#scale[.7]{#color[%s]{%s: %2.2f}}" %(color,self.test_name,self.rank)
00412     lat=TLatex(.1,.91,lat_text)
00413     lat.SetNDC()
00414     lat.Draw()
00415   
00416     # Put also the stats together!
00417     n1=obj1.GetEntries()
00418     if n1> 100000:
00419       n1="%e"%n1
00420     else:
00421       n1="%s"%n1
00422     n2=obj2.GetEntries()
00423     if n2> 100000:
00424       n2="%e"%n2
00425     else:
00426       n2="%s"%n2
00427 
00428     lat_text1="#scale[.7]{#color[%s]{Entries: %s}}" %(obj1.GetLineColor(),n1)
00429     lat1=TLatex(.3,.91,lat_text1)
00430     lat1.SetNDC()
00431     lat1.Draw()
00432         
00433     
00434     lat_text2="#scale[.7]{#color[%s]{Entries: %s}}" %(obj2.GetLineColor(),n2)
00435     lat2=TLatex(.6,.91,lat_text2)
00436     lat2.SetNDC()
00437     lat2.Draw()
00438     
00439 
00440     self.tcanvas_slow(canvas)

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

Definition at line 317 of file dirstructure.py.

00317                           :    
00318     if not exists(self.mother_dir):
00319       makedirs(self.mother_dir)
00320     
def dirstructure::Comparison::__repr__ (   self)

Definition at line 441 of file dirstructure.py.

00442                     :
00443     return "%s , (%s=%s). IMG=%s. status=%s" %(self.name,self.test_name,self.rank,self.img_name,self.status)
00444 
00445 #-------------------------------------------------------------------------------  
def dirstructure::Comparison::tcanvas_slow (   self,
  canvas 
)

Definition at line 331 of file dirstructure.py.

00332                                :
00333     #print "About to print %s" %self.img_name
00334     #print_multi_threaded(canvas,self.img_name)
00335     #print "-->Printed"
00336 
00337     p = Process(target=print_multi_threaded, args=(canvas,self.img_name))
00338     p.start()
00339     tcanvas_print_processes.append(p)
00340     n_proc=len(tcanvas_print_processes)
00341     if n_proc>3:
00342       p_to_remove=[]
00343       for iprocess in xrange(0,n_proc):
00344         p=tcanvas_print_processes[iprocess]
00345         p.join()
00346         p_to_remove.append(iprocess)
00347 
00348       adjustment=0
00349       for iprocess in p_to_remove:
00350         tcanvas_print_processes.pop(iprocess-adjustment)
00351         adjustment+=1


Member Data Documentation

Definition at line 296 of file dirstructure.py.

Definition at line 297 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Reimplemented from dirstructure::Weighted.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.

Definition at line 298 of file dirstructure.py.