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 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.

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

Definition at line 558 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.workdir.

559  def __del__(self):
560  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 629 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

References relativeConstraints.keys.

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Definition at line 624 of file dqm_interfaces.py.

625  def getObjs(self,name):
626  h1=self.dqmrootfile1.getObj(name)
627  h2=self.dqmrootfile2.getObj(name)
628  return h1,h2
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 alcazmumu_cfi.filter.

Referenced by dqm_interfaces.DirWalkerFile.walk().

588  def ls(self,directory_name=""):
589  """Return common objects to the 2 files.
590  """
591  contents1=self.dqmrootfile1.ls(directory_name)
592  contents2=self.dqmrootfile2.ls(directory_name)
593  #print "cont1: %s"%(contents1)
594  #print "cont2: %s"%(contents2)
595  contents={}
596  self.different_histograms['file1']= {}
597  self.different_histograms['file2']= {}
598  keys = filter(lambda key: key in contents1,contents2.keys()) #set of all possible contents from both files
599  #print " ## keys: %s" %(keys)
600  for key in keys: #iterate on all unique keys
601  if contents1[key]!=contents2[key]:
602  diff_file1 = set(contents1.keys()) - set(contents2.keys()) #set of contents that file1 is missing
603  diff_file2 = set(contents2.keys()) - set(contents1.keys()) #--'-- that file2 is missing
604  for key1 in diff_file1:
605  obj_type = contents1[key1]
606  if obj_type == "TDirectoryFile":
607  self.different_histograms['file1'][key1] = contents1[key1] #if direcory
608  #print "\n Missing inside a dir: ", self.ls(key1)
609  #contents[key] = contents1[key1]
610  if obj_type[:2]!="TH" and obj_type[:3]!="TPr" : #if histogram
611  continue
612  self.different_histograms['file1'][key1] = contents1[key1]
613  for key1 in diff_file2:
614  obj_type = contents2[key1]
615  if obj_type == "TDirectoryFile":
616  self.different_histograms['file2'][key1] = contents2[key1] #if direcory
617  #print "\n Missing inside a dir: ", self.ls(key1)
618  #contents[key] = contents2[key1]
619  if obj_type[:2]!="TH" and obj_type[:3]!="TPr" : #if histogram
620  continue
621  self.different_histograms['file2'][key1] = contents2[key1]
622  contents[key]=contents1[key]
623  return contents
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, alcazmumu_cfi.filter, 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(), EcalDeadCellTriggerPrimitiveFilter.ls, dqm_interfaces.DQMRootFile.ls(), dqm_interfaces.DirWalkerFile.ls(), uploadPayloads.FileObj.run, splitter.FileObj.run, uploader.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, options.ConnectionHLTMenu.run, MuonRecoTest.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, EcalDeadCellTriggerPrimitiveFilter.run, conddblib.TimeType.run, SiPixelErrorEstimation.run, personalPlayback.FrameworkJob.run, dqm_interfaces.DirWalkerFile.run, JsonOutputProducer::JsonEvent.run, SummaryOutputProducer.run, and SummaryOutputProducer::Event.run.

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

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

Definition at line 542 of file dqm_interfaces.py.

Referenced by cuy.divideElement.__init__(), cuy.plotElement.__init__(), cuy.additionElement.__init__(), cuy.superimposeElement.__init__(), cuy.graphElement.__init__(), config.CFG.__str__(), validation.Sample.digest(), utils.StatisticalTest.get_status(), VIDSelectorBase.VIDSelectorBase.initialize(), and Vispa.Views.PropertyView.Property.valueChanged().

dqm_interfaces.DirWalkerFile.run

Definition at line 545 of file dqm_interfaces.py.

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

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__().