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 319 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 322 of file dirstructure.py.

00323                                                                                                  :
00324     self.name=name
00325     self.png_name="placeholder.png"
00326     self.mother_dir=mother_dir
00327     self.img_name=""
00328     #self.draw_success=draw_success
00329     Weighted.__init__(self,name)
00330 
00331     stat_test.set_operands(h1,h2)
00332     if skip:
00333         self.status = SKIPED
00334         self.test_name=stat_test.name
00335         self.test_name=stat_test.name
00336         self.test_thr=stat_test.threshold
00337         self.rank = 0
00338     else:
00339         self.status=stat_test.get_status()
00340         self.rank=stat_test.get_rank()
00341         self.test_name=stat_test.name
00342         self.test_thr=stat_test.threshold
00343         self.do_pngs=do_pngs
00344         self.draw_success=draw_success or not do_pngs
00345         if ((self.status==FAIL or self.status==NULL or self.status == SKIPED or self.draw_success) and self.do_pngs):
00346             self.__make_image(h1,h2)      
00347         #self.__make_image(h1,h2)


Member Function Documentation

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

Definition at line 352 of file dirstructure.py.

00353                           :
00354     #self.__make_img_dir()    
00355     #print "MOTHER: ",self.mother_dir
00356     self.img_name="%s/%s.png"%(self.mother_dir,self.name)
00357     self.img_name=self.img_name.replace("Run summary","")
00358     self.img_name=self.img_name.replace("/","_")
00359     self.img_name=self.img_name.strip("_")
00360     #print "IMAGE NAME: %s " %self.img_name
00361     return self.img_name

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

Definition at line 383 of file dirstructure.py.

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

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

Definition at line 348 of file dirstructure.py.

00348                           :    
00349     if not exists(self.mother_dir):
00350       makedirs(self.mother_dir)
00351     
def dirstructure::Comparison::__repr__ (   self)

Definition at line 474 of file dirstructure.py.

00475                     :
00476     return "%s , (%s=%s). IMG=%s. status=%s" %(self.name,self.test_name,self.rank,self.img_name,self.status)
00477 
00478 #-------------------------------------------------------------------------------  
def dirstructure::Comparison::tcanvas_slow (   self,
  canvas 
)

Definition at line 362 of file dirstructure.py.

00363                                :
00364     #print "About to print %s" %self.img_name
00365     #print_multi_threaded(canvas,self.img_name)
00366     #print "-->Printed"
00367 
00368     p = Process(target=print_multi_threaded, args=(canvas,self.img_name))
00369     p.start()
00370     tcanvas_print_processes.append(p)
00371     n_proc=len(tcanvas_print_processes)
00372     if n_proc>3:
00373       p_to_remove=[]
00374       for iprocess in xrange(0,n_proc):
00375         p=tcanvas_print_processes[iprocess]
00376         p.join()
00377         p_to_remove.append(iprocess)
00378 
00379       adjustment=0
00380       for iprocess in p_to_remove:
00381         tcanvas_print_processes.pop(iprocess-adjustment)
00382         adjustment+=1


Member Data Documentation

Definition at line 320 of file dirstructure.py.

Definition at line 321 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Reimplemented from dirstructure::Weighted.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.

Definition at line 322 of file dirstructure.py.