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
 
 directory
 
 dqmrootfile1
 
 dqmrootfile2
 
 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
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 604 of file dqm_interfaces.py.

Referenced by dqm_interfaces.DirWalkerFile.walk().

605  def __fill_single_dir(self,dir_name,directory,mother_name="",depth=0):
606  #print "MOTHER NAME = +%s+" %mother_name
607  #print "About to study %s (in dir %s)" %(dir_name,getcwd())
608 
609  # see if in black_list
610  this_dir=DirID(dir_name,depth)
611  #print this_dir
612  if this_dir in self.black_list:
613  #print "Directory %s skipped because black-listed" %dir_name
614  return 0
615 
616  depth+=1
617 
618  self.cd(dir_name)
619  #print self.ls()
620 
621  #print "Test %s with thre %s" %(self.stat_test.name, self.stat_test.threshold)
622 
623  contents=self.ls()
624  if depth==1:
625  n_top_contents=len(contents)
626 
627  #print contents
628  cont_counter=1
629  comparisons=[]
630  for name,obj_type in contents.items():
631  if obj_type=="TDirectoryFile":
632  #We have a dir, launch recursion!
633  #Some feedback on the progress
634  if depth==1:
635  print "Studying directory %s, %s/%s" %(name,cont_counter,n_top_contents)
636  cont_counter+=1
637 
638  #print "Studying directory",name
639  # ok recursion on!
640  subdir=Directory(name)
641  subdir.draw_success=directory.draw_success
642  subdir.do_pngs=directory.do_pngs
643  self.__fill_single_dir(name,subdir,join(mother_name,dir_name),depth)
644  if not subdir.is_empty():
645  if depth==1:
646  print " ->Appending %s..." %name,
647  directory.subdirs.append(subdir)
648  if depth==1:
649  print "Appended."
650  else:
651  # We have probably an histo. Let's make the plot and the png.
652  if obj_type[:2]!="TH" and obj_type[:3]!="TPr" :
653  continue
654  h1,h2=self.getObjs(name)
655  #print "COMPARISON : +%s+%s+" %(mother_name,dir_name)
656  path = join(mother_name,dir_name,name)
657  if path in self.black_list_histos:
658  print " Skipping %s" %(path)
659  directory.comparisons.append(Comparison(name,
660  join(mother_name,dir_name),
661  h1,h2,
662  deepcopy(self.stat_test),
663  draw_success=directory.draw_success,
664  do_pngs=directory.do_pngs, skip=True))
665  else:
666  directory.comparisons.append(Comparison(name,
667  join(mother_name,dir_name),
668  h1,h2,
669  deepcopy(self.stat_test),
670  draw_success=directory.draw_success,
671  do_pngs=directory.do_pngs, skip=False))
672 
673  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 599 of file dqm_interfaces.py.

600  def getObjs(self,name):
601  h1=self.dqmrootfile1.getObj(name)
602  h2=self.dqmrootfile2.getObj(name)
603  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 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  contents={}
594  keys = filter(lambda key: contents1.has_key(key),contents2.keys())
595  for key in keys:
596  #if contents1[key]==contents2[key]:
597  contents[key]=contents1[key]
598  return contents
def dqm_interfaces.DirWalkerFile.walk (   self)

Definition at line 674 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, lumi::Lumi2DB::LumiSource.run, relval_steps.InputInfo.run, WZInterestingEventSelector::event.run, options.ConnectionHLTMenu.run, EfficiencyPlotter.run, MatacqProducer::MatacqEventId.run, DTResolutionAnalysisTest.run, L1TLTC.run, MuonRecoTest.run, MuonTrackResidualsTest.run, DTDataIntegrityTest.run, HitEff.run, DTBlockedROChannelsTest.run, ME::Header.run, DTResolutionTest.run, DTtTrigCalibrationTest.run, DTDeadChannelTest.run, DTEfficiencyTest.run, cms::GammaJetAnalysis.run, DTChamberEfficiencyTest.run, DTNoiseTest.run, DTLocalTriggerBaseTest.run, EcalDeadCellDeltaRFilter.run, SiPixelErrorEstimation.run, EcalDeadCellTriggerPrimitiveFilter.run, Types.EventID.run, and dqm_interfaces.DirWalkerFile.run.

675  def walk(self):
676  # Build the top dir in the rootfile first
677  rundir=""
678  if self.run<0:
679  # change dir in the first one...
680  #print self.ls().keys()
681  first_run_dir = ""
682  try:
683  first_run_dir = filter(lambda k: "Run " in k, self.ls().keys())[0]
684  except:
685  print "\nRundir not there: Is this a generic rootfile?\n"
686  rundir=first_run_dir
687  try:
688  self.run= int(rundir.split(" ")[1])
689  except:
690  print "Setting run number to 0"
691  self.run= 0
692  else:
693  rundir="Run %s"%self.run
694 
695  try:
696  self.cd(rundir, False, True) #True -> for checking the Rundir in case of different runs
697  except:
698  print "\nRundir not there: Is this a generic rootfile?\n"
699 
700  # Let's rock!
701  self.__fill_single_dir(self.directory.name,self.directory)
702  print "Finished"
703  n_left_threads=len(tcanvas_print_processes)
704  if n_left_threads>0:
705  print "Waiting for %s threads to finish..." %n_left_threads
706  for p in tcanvas_print_processes:
707  p.join()
708 
709 #-------------------------------------------------------------------------------

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

Definition at line 545 of file dqm_interfaces.py.

Referenced by dataset.Dataset.__getDataType(), dataset.Dataset.__getFileInfoList(), 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__().