CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes | Private Member Functions
dqm_interfaces.DirWalkerFile Class Reference
Inheritance diagram for dqm_interfaces.DirWalkerFile:

Public Member Functions

def __del__
 
def __init__
 
def cd
 
def getObjs
 
def ls
 
def walk
 

Public Attributes

 black_list
 
 black_list_histos
 
 different_histograms
 
 directory
 
 dqmrootfile1
 
 dqmrootfile2
 
 filename1
 
 filename2
 
 name
 
 run
 
 stat_test
 
 workdir
 

Private Member Functions

def __fill_single_dir
 

Detailed Description

Definition at line 543 of file dqm_interfaces.py.

Constructor & Destructor Documentation

def dqm_interfaces.DirWalkerFile.__init__ (   self,
  name,
  topdirname,
  rootfilename1,
  rootfilename2,
  run = -1,
  black_list = [],
  stat_test = "KS",
  test_threshold = .5,
  draw_success = True,
  do_pngs = False,
  black_list_histos = [] 
)

Definition at line 544 of file dqm_interfaces.py.

545  def __init__(self, name, topdirname,rootfilename1, rootfilename2, run=-1, black_list=[], stat_test="KS", test_threshold=.5,draw_success=True,do_pngs=False, black_list_histos=[]):
546  self.name=name
547  self.dqmrootfile1=DQMRootFile(abspath(rootfilename1))
548  self.dqmrootfile2=DQMRootFile(abspath(rootfilename2))
549  self.run=run
550  self.stat_test=Statistical_Tests[stat_test](test_threshold)
551  self.workdir=getcwd()
552  self.black_list=black_list
553  self.directory=Directory(topdirname)
554  #print "DIRWALKERFILE %s %s" %(draw_success,do_pngs)
555  self.directory.draw_success=draw_success
556  self.directory.do_pngs=do_pngs
557  self.black_list_histos = black_list_histos
559  self.filename1 = basename(rootfilename2)
560  self.filename2 = basename(rootfilename1)
def dqm_interfaces.DirWalkerFile.__del__ (   self)

Definition at line 561 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.workdir.

562  def __del__(self):
563  chdir(self.workdir)

Member Function Documentation

def dqm_interfaces.DirWalkerFile.__fill_single_dir (   self,
  dir_name,
  directory,
  mother_name = "",
  depth = 0 
)
private

Definition at line 632 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.walk().

633  def __fill_single_dir(self,dir_name,directory,mother_name="",depth=0):
634  #print "MOTHER NAME = +%s+" %mother_name
635  #print "About to study %s (in dir %s)" %(dir_name,getcwd())
636 
637  # see if in black_list
638  this_dir=DirID(dir_name,depth)
639  #print " ## this_dir: %s"%(this_dir)
640  if this_dir in self.black_list:
641  #print "Directory %s skipped because black-listed" %dir_name
642  return 0
643 
644  depth+=1
645 
646  self.cd(dir_name)
647  #if dir_name == 'HLTJETMET':
648  # print self.ls()
649 
650  #print "Test %s with thre %s" %(self.stat_test.name, self.stat_test.threshold)
651 
652  contents=self.ls()
653  if depth==1:
654  n_top_contents=len(contents)
655 
656  #print contents
657  cont_counter=1
658  comparisons=[]
659  for name,obj_type in contents.items():
660  if obj_type=="TDirectoryFile":
661  #We have a dir, launch recursion!
662  #Some feedback on the progress
663  if depth==1:
664  print "Studying directory %s, %s/%s" %(name,cont_counter,n_top_contents)
665  cont_counter+=1
666 
667  #print "Studying directory",name
668  # ok recursion on!
669  subdir=Directory(name)
670  subdir.draw_success=directory.draw_success
671  subdir.do_pngs=directory.do_pngs
672  self.__fill_single_dir(name,subdir,join(mother_name,dir_name),depth)
673  if not subdir.is_empty():
674  if depth==1:
675  print " ->Appending %s..." %name,
676  directory.subdirs.append(subdir)
677  if depth==1:
678  print "Appended."
679  else:
680  # We have probably an histo. Let's make the plot and the png.
681  if obj_type[:2]!="TH" and obj_type[:3]!="TPr" :
682  continue
683  h1,h2=self.getObjs(name)
684  #print "COMPARISON : +%s+%s+" %(mother_name,dir_name)
685  path = join(mother_name,dir_name,name)
686  if path in self.black_list_histos:
687  print " Skipping %s" %(path)
688  directory.comparisons.append(Comparison(name,
689  join(mother_name,dir_name),
690  h1,h2,
691  deepcopy(self.stat_test),
692  draw_success=directory.draw_success,
693  do_pngs=directory.do_pngs, skip=True))
694  else:
695  directory.comparisons.append(Comparison(name,
696  join(mother_name,dir_name),
697  h1,h2,
698  deepcopy(self.stat_test),
699  draw_success=directory.draw_success,
700  do_pngs=directory.do_pngs, skip=False))
701  directory.filename1 = self.filename1
702  directory.filename2 = self.filename2
703  directory.different_histograms['file1'] = self.different_histograms['file1']
704  directory.different_histograms['file2'] = self.different_histograms['file2']
705 
706  self.cd("..")
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def dqm_interfaces.DirWalkerFile.cd (   self,
  directory_name,
  on_disk = False,
  regexp = False 
)

Definition at line 564 of file dqm_interfaces.py.

References relativeConstraints.keys.

Referenced by dqm_interfaces.DirWalkerFile.walk().

565  def cd(self,directory_name, on_disk=False, regexp=False,):
566  if regexp == True:
567  if len(directory_name)!=0:
568  if on_disk:
569  if not exists(directory_name):
570  makedirs(directory_name)
571  chdir(directory_name)
572  tmp = self.dqmrootfile2.ls().keys()
573  for elem in tmp:
574  if "Run" in elem:
575  next_dir = elem
576  self.dqmrootfile2.cd(next_dir)
577  tmp = self.dqmrootfile1.ls().keys()
578  for elem in tmp:
579  if "Run" in elem:
580  next_dir = elem
581  self.dqmrootfile1.cd(next_dir)
582  else:
583  if len(directory_name)!=0:
584  if on_disk:
585  if not exists(directory_name):
586  makedirs(directory_name)
587  chdir(directory_name)
588  self.dqmrootfile2.cd(directory_name)
589  self.dqmrootfile1.cd(directory_name)
def dqm_interfaces.DirWalkerFile.getObjs (   self,
  name 
)

Definition at line 627 of file dqm_interfaces.py.

628  def getObjs(self,name):
629  h1=self.dqmrootfile1.getObj(name)
630  h2=self.dqmrootfile2.getObj(name)
631  return h1,h2
def dqm_interfaces.DirWalkerFile.ls (   self,
  directory_name = "" 
)
Return common objects to the 2 files.

Definition at line 590 of file dqm_interfaces.py.

References dirstructure.Directory.different_histograms, dqm_interfaces.DirWalkerFile.different_histograms, and alcazmumu_cfi.filter.

Referenced by dqm_interfaces.DirWalkerFile.walk().

591  def ls(self,directory_name=""):
592  """Return common objects to the 2 files.
593  """
594  contents1=self.dqmrootfile1.ls(directory_name)
595  contents2=self.dqmrootfile2.ls(directory_name)
596  #print "cont1: %s"%(contents1)
597  #print "cont2: %s"%(contents2)
598  contents={}
599  self.different_histograms['file1']= {}
600  self.different_histograms['file2']= {}
601  keys = filter(lambda key: contents1.has_key(key),contents2.keys()) #set of all possible contents from both files
602  #print " ## keys: %s" %(keys)
603  for key in keys: #iterate on all unique keys
604  if contents1[key]!=contents2[key]:
605  diff_file1 = set(contents1.keys()) - set(contents2.keys()) #set of contents that file1 is missing
606  diff_file2 = set(contents2.keys()) - set(contents1.keys()) #--'-- that file2 is missing
607  for key1 in diff_file1:
608  obj_type = contents1[key1]
609  if obj_type == "TDirectoryFile":
610  self.different_histograms['file1'][key1] = contents1[key1] #if direcory
611  #print "\n Missing inside a dir: ", self.ls(key1)
612  #contents[key] = contents1[key1]
613  if obj_type[:2]!="TH" and obj_type[:3]!="TPr" : #if histogram
614  continue
615  self.different_histograms['file1'][key1] = contents1[key1]
616  for key1 in diff_file2:
617  obj_type = contents2[key1]
618  if obj_type == "TDirectoryFile":
619  self.different_histograms['file2'][key1] = contents2[key1] #if direcory
620  #print "\n Missing inside a dir: ", self.ls(key1)
621  #contents[key] = contents2[key1]
622  if obj_type[:2]!="TH" and obj_type[:3]!="TPr" : #if histogram
623  continue
624  self.different_histograms['file2'][key1] = contents2[key1]
625  contents[key]=contents1[key]
626  return contents
def dqm_interfaces.DirWalkerFile.walk (   self)

Definition at line 707 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.__fill_single_dir(), TFileDirectory.cd(), ResidualFitter.cd(), DQMStore.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), python.rootplot.utilities.RootFile.cd(), dqm_interfaces.DQMRootFile.cd(), dqm_interfaces.DirWalkerFile.cd(), Book.directory, dqm_interfaces.DirFetcher.directory, dqm_interfaces.DirWalkerDB.directory, dqm_interfaces.DirWalkerFile.directory, alcazmumu_cfi.filter, relativeConstraints.keys, evf::lsTriplet.ls, ProcLinear.ls, WZInterestingEventSelector::event.ls, evf::prg.ls, ProcMatrix.ls, EcalDeadCellDeltaRFilter.ls, EcalDeadCellTriggerPrimitiveFilter.ls, dqm_interfaces.DQMcommunicator.ls(), dqm_interfaces.DQMRootFile.ls(), dqm_interfaces.DirWalkerFile.ls(), splitter.FileObj.run, uploader.FileObj.run, uploadPayloads.FileObj.run, RPCRunIOV::RunIOV_Item.run, RPCDQMObject.run, MultiEventFilter::Event.run, TB06Reco.run, TB06RecoH2.run, generateEDF.LumiInfo.run, relval_steps.InputInfo.run, MuonPair.run, lumi::Lumi2DB::LumiSource.run, WZInterestingEventSelector::event.run, options.ConnectionHLTMenu.run, EfficiencyPlotter.run, MatacqProducer::MatacqEventId.run, DTResolutionAnalysisTest.run, MuonTrackResidualsTest.run, MuonRecoTest.run, DTDataIntegrityTest.run, DTBlockedROChannelsTest.run, HitEff.run, ME::Header.run, DTResolutionTest.run, DTtTrigCalibrationTest.run, DTDeadChannelTest.run, DTEfficiencyTest.run, cms::GammaJetAnalysis.run, DTChamberEfficiencyTest.run, DTNoiseTest.run, DTLocalTriggerBaseTest.run, EcalDeadCellDeltaRFilter.run, EcalDeadCellTriggerPrimitiveFilter.run, Types.EventID.run, SiPixelErrorEstimation.run, and dqm_interfaces.DirWalkerFile.run.

708  def walk(self):
709  # Build the top dir in the rootfile first
710  rundir=""
711  if self.run<0:
712  # change dir in the first one...
713  #print self.ls().keys()
714  first_run_dir = ""
715  try:
716  first_run_dir = filter(lambda k: "Run " in k, self.ls().keys())[0]
717  except:
718  print "\nRundir not there: Is this a generic rootfile?\n"
719  rundir=first_run_dir
720  try:
721  self.run= int(rundir.split(" ")[1])
722  except:
723  print "Setting run number to 0"
724  self.run= 0
725  else:
726  rundir="Run %s"%self.run
727 
728  try:
729  self.cd(rundir, False, True) #True -> for checking the Rundir in case of different runs
730  except:
731  print "\nRundir not there: Is this a generic rootfile?\n"
732 
733  # Let's rock!
734  self.__fill_single_dir(self.directory.name,self.directory)
735  print "Finished"
736  n_left_threads=len(tcanvas_print_processes)
737  if n_left_threads>0:
738  print "Waiting for %s threads to finish..." %n_left_threads
739  for p in tcanvas_print_processes:
740  p.join()
741 
742 #-------------------------------------------------------------------------------

Member Data Documentation

dqm_interfaces.DirWalkerFile.black_list

Definition at line 551 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.black_list_histos

Definition at line 556 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.different_histograms

Definition at line 557 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.ls().

dqm_interfaces.DirWalkerFile.directory

Definition at line 552 of file dqm_interfaces.py.

Referenced by utils.unpickler.run(), and dqm_interfaces.DirWalkerFile.walk().

dqm_interfaces.DirWalkerFile.dqmrootfile1

Definition at line 546 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.dqmrootfile2

Definition at line 547 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.filename1

Definition at line 558 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.filename2

Definition at line 559 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.name

Definition at line 545 of file dqm_interfaces.py.

Referenced by dataset.Dataset.__getFileInfoList(), cuy.divideElement.__init__(), cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), BeautifulSoup.Tag._invert(), utils.StatisticalTest.get_status(), and Vispa.Views.PropertyView.Property.valueChanged().

dqm_interfaces.DirWalkerFile.run

Definition at line 548 of file dqm_interfaces.py.

Referenced by Types.LuminosityBlockID.cppID(), and dqm_interfaces.DirWalkerFile.walk().

dqm_interfaces.DirWalkerFile.stat_test

Definition at line 549 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.workdir

Definition at line 550 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.__del__().