CMS 3D CMS Logo

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__ (self)
 
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=[])
 
def cd (self, directory_name, on_disk=False, regexp=False)
 
def getObjs (self, name)
 
def ls (self, directory_name="")
 
def walk (self)
 

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 (self, dir_name, directory, mother_name="", depth=0)
 

Detailed Description

Definition at line 540 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 541 of file dqm_interfaces.py.

541  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=[]):
542  self.name=name
543  self.dqmrootfile1=DQMRootFile(abspath(rootfilename1))
544  self.dqmrootfile2=DQMRootFile(abspath(rootfilename2))
545  self.run=run
546  self.stat_test=Statistical_Tests[stat_test](test_threshold)
547  self.workdir=getcwd()
548  self.black_list=black_list
549  self.directory=Directory(topdirname)
550  #print "DIRWALKERFILE %s %s" %(draw_success,do_pngs)
551  self.directory.draw_success=draw_success
552  self.directory.do_pngs=do_pngs
553  self.black_list_histos = black_list_histos
555  self.filename1 = basename(rootfilename2)
556  self.filename2 = basename(rootfilename1)
557 
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=[])
abspath
Definition: dataset.py:55
def dqm_interfaces.DirWalkerFile.__del__ (   self)

Definition at line 558 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.workdir.

558  def __del__(self):
559  chdir(self.workdir)
560 

Member Function Documentation

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

Definition at line 629 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

References relativeConstraints.keys.

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Definition at line 624 of file dqm_interfaces.py.

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

Definition at line 587 of file dqm_interfaces.py.

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

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Definition at line 704 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.__fill_single_dir(), TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), DQMStore::IBooker.cd(), DQMStore::IGetter.cd(), DQMStore.cd(), python.rootplot.utilities.RootFile.cd(), dqm_interfaces.DQMRootFile.cd(), dqm_interfaces.DirWalkerFile.cd(), Book.directory, edmIntegrityCheck.IntegrityCheck.directory, dqm_interfaces.DirFetcher.directory, dqm_interfaces.DirWalkerDB.directory, dqm_interfaces.DirWalkerFile.directory, ALCARECOTkAlBeamHalo_cff.filter, createfilelist.int, relativeConstraints.keys, ProcLinear.ls, WZInterestingEventSelector::event.ls, ProcMatrix.ls, BeamSpotRcdReader::theBSfromDB.ls, create_public_lumi_plots.LumiDataPoint.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.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, TB06Reco.run, TB06RecoH2.run, RPCDQMObject.run, MultiEventFilter::Event.run, L1Analysis::L1AnalysisEventDataFormat.run, generateEDF.LumiInfo.run, lumi::Lumi2DB::LumiSource.run, EfficiencyPlotter.run, WZInterestingEventSelector::event.run, MuonRecoTest.run, options.ConnectionHLTMenu.run, DTResolutionAnalysisTest.run, BeamSpotRcdReader::theBSfromDB.run, DTBlockedROChannelsTest.run, MatacqProducer::MatacqEventId.run, DTDataIntegrityTest.run, DTChamberEfficiencyTest.run, DTResolutionTest.run, ME::Header.run, DTEfficiencyTest.run, personalPlayback.Playback.run, HitEff.run, DQMNet::CoreObject.run, MatrixUtil.InputInfo.run, DTLocalTriggerBaseTest.run, EcalDeadCellDeltaRFilter.run, cond::RunInfo_t.run, SiPixelErrorEstimation.run, personalPlayback.FrameworkJob.run, dqm_interfaces.DirWalkerFile.run, JsonOutputProducer::JsonEvent.run, SummaryOutputProducer.run, and SummaryOutputProducer::Event.run.

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

Member Data Documentation

dqm_interfaces.DirWalkerFile.black_list

Definition at line 548 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.black_list_histos

Definition at line 553 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.different_histograms

Definition at line 554 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.ls().

dqm_interfaces.DirWalkerFile.directory

Definition at line 549 of file dqm_interfaces.py.

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

dqm_interfaces.DirWalkerFile.dqmrootfile1

Definition at line 543 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.dqmrootfile2

Definition at line 544 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.filename1

Definition at line 555 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.filename2

Definition at line 556 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.name
dqm_interfaces.DirWalkerFile.run
dqm_interfaces.DirWalkerFile.stat_test

Definition at line 546 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.workdir

Definition at line 547 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.__del__().