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

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

References dqm_interfaces.DirWalkerFile.workdir.

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

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

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

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

Definition at line 627 of file dqm_interfaces.py.

627  def getObjs(self,name):
628  h1=self.dqmrootfile1.getObj(name)
629  h2=self.dqmrootfile2.getObj(name)
630  return h1,h2
631 
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, and dqm_interfaces.DirWalkerFile.different_histograms.

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Definition at line 707 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.__fill_single_dir(), TFileDirectory.cd(), TFileService.cd(), DQMStore::IBooker.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.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(), edm.print(), uploadPayloads.FileObj.run, splitter.FileObj.run, uploader.FileObj.run, RPCRunIOV::RunIOV_Item.run, beamspot::BeamSpotContainer.run, TB06RecoH2.run, TB06Reco.run, RPCDQMObject.run, MultiEventFilter::Event.run, L1Analysis::L1AnalysisEventDataFormat.run, lumi::Lumi2DB::LumiSource.run, generateEDF.LumiInfo.run, EfficiencyPlotter.run, WZInterestingEventSelector::event.run, Point.run, options.ConnectionHLTMenu.run, MuonRecoTest.run, DTResolutionAnalysisTest.run, BeamSpotRcdReader::theBSfromDB.run, MatacqProducer::MatacqEventId.run, DTBlockedROChannelsTest.run, DTDataIntegrityTest.run, DTChamberEfficiencyTest.run, DTResolutionTest.run, ME::Header.run, DTEfficiencyTest.run, personalPlayback.Playback.run, DQMNet::CoreObject.run, MatrixUtil.InputInfo.run, DTLocalTriggerBaseTest.run, HitEff.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.

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