CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 545 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 546 of file dqm_interfaces.py.

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

Definition at line 563 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.workdir.

564  def __del__(self):
565  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 634 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Definition at line 566 of file dqm_interfaces.py.

References relativeConstraints.keys.

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Definition at line 629 of file dqm_interfaces.py.

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

Definition at line 592 of file dqm_interfaces.py.

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

Referenced by dqm_interfaces.DirWalkerFile.walk().

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

Definition at line 709 of file dqm_interfaces.py.

References dqm_interfaces.DirWalkerFile.__fill_single_dir(), dqm::implementation::NavigatorBase.cd(), TFileDirectory.cd(), TFileService.cd(), Folder.cd(), dqm_interfaces.DQMcommunicator.cd(), mkfit::ConfigJsonPatcher.cd(), python.rootplot.utilities.RootFile.cd(), dqm_interfaces.DQMRootFile.cd(), dqm_interfaces.DirWalkerFile.cd(), dqm::implementation::DQMStore.cd(), Book.directory, edmIntegrityCheck.IntegrityCheck.directory, dqm_interfaces.DirFetcher.directory, dqm_interfaces.DirWalkerDB.directory, dqm_interfaces.DirWalkerFile.directory, alcazmumu_cfi.filter, relativeConstraints.keys, WZInterestingEventSelector::event.ls, BeamSpotRcdReader::theBSfromDB.ls, BeamSpotOnlineRecordsReader::theBSOfromDB.ls, MatrixUtil.InputInfo.ls, EcalDeadCellDeltaRFilter.ls, dqm_interfaces.DQMcommunicator.ls(), dqm_interfaces.DQMRootFile.ls(), dqm_interfaces.DirWalkerFile.ls(), print(), uploadPayloads.FileObj.run, RPCRunIOV::RunIOV_Item.run, splitter.FileObj.run, uploader.FileObj.run, beamspot::BeamSpotContainer.run, TB06RecoH2.run, RPCDQMObject.run, TB06Reco.run, MultiEventFilter::Event.run, L1Analysis::L1AnalysisEventDataFormat.run, EfficiencyPlotter.run, lumi::Lumi2DB::LumiSource.run, generateEDF.LumiInfo.run, WZInterestingEventSelector::event.run, MuonRecoTest.run, MatacqProducer::MatacqEventId.run, DTResolutionAnalysisTest.run, options.ConnectionHLTMenu.run, Point.run, BeamSpotRcdReader::theBSfromDB.run, DTDataIntegrityTest.run, BeamSpotOnlineRecordsReader::theBSOfromDB.run, DTBlockedROChannelsTest.run, DTResolutionTest.run, DTChamberEfficiencyTest.run, DTEfficiencyTest.run, ME::Header.run, personalPlayback.Playback.run, DQMNet::CoreObject.run, DTLocalTriggerBaseTest.run, MatrixUtil.InputInfo.run, EcalDeadCellDeltaRFilter.run, HitEff.run, cond::RunInfo_t.run, SiPixelErrorEstimation.run, personalPlayback.FrameworkJob.run, dqm_interfaces.DirWalkerFile.run, JsonOutputProducer::JsonEvent.run, SummaryOutputProducer.run, and SummaryOutputProducer::Event.run.

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

Member Data Documentation

dqm_interfaces.DirWalkerFile.black_list

Definition at line 553 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.black_list_histos

Definition at line 558 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.different_histograms

Definition at line 559 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.ls().

dqm_interfaces.DirWalkerFile.directory

Definition at line 554 of file dqm_interfaces.py.

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

dqm_interfaces.DirWalkerFile.dqmrootfile1

Definition at line 548 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.dqmrootfile2

Definition at line 549 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.filename1

Definition at line 560 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.filename2

Definition at line 561 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.name

Definition at line 547 of file dqm_interfaces.py.

Referenced by config.CFG.__str__(), geometryComparison.GeometryComparison.createScript(), validation.Sample.digest(), utils.StatisticalTest.get_status(), primaryVertexResolution.PrimaryVertexResolution.getRepMap(), primaryVertexValidation.PrimaryVertexValidation.getRepMap(), zMuMuValidation.ZMuMuValidation.getRepMap(), and VIDSelectorBase.VIDSelectorBase.initialize().

dqm_interfaces.DirWalkerFile.run

Definition at line 550 of file dqm_interfaces.py.

Referenced by DTWorkflow.DTWorkflow.all(), Types.EventID.cppID(), Types.LuminosityBlockID.cppID(), o2olib.O2OTool.execute(), and dqm_interfaces.DirWalkerFile.walk().

dqm_interfaces.DirWalkerFile.stat_test

Definition at line 551 of file dqm_interfaces.py.

dqm_interfaces.DirWalkerFile.workdir

Definition at line 552 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.__del__().