CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
validation.SimpleValidation Class Reference

Public Member Functions

def __init__ (self, samples, newdir)
 
def createHtmlReport (self, validationName="")
 
def doPlots (self, plotters, plotterDrawArgs={}, kwargs)
 

Private Member Functions

def _doPlots (self, plotterFolder, dqmSubFolder)
 
def _doPlotsForPlotter (self, plotter, sample, limitSubFoldersOnlyTo=None)
 

Private Attributes

 _htmlReport
 
 _labels
 
 _newdir
 
 _openFiles
 
 _plotterDrawArgs
 
 _samples
 
 _subdirprefix
 

Detailed Description

Definition at line 1023 of file validation.py.

Constructor & Destructor Documentation

def validation.SimpleValidation.__init__ (   self,
  samples,
  newdir 
)

Definition at line 1024 of file validation.py.

1024  def __init__(self, samples, newdir):
1025  self._samples = samples
1026  self._newdir = newdir
1027  if not os.path.exists(newdir):
1028  os.makedirs(newdir)
1029 
1031 
def __init__(self, samples, newdir)
Definition: validation.py:1024

Member Function Documentation

def validation.SimpleValidation._doPlots (   self,
  plotterFolder,
  dqmSubFolder 
)
private

Definition at line 1071 of file validation.py.

References validation._findDuplicates(), DigiInvestigatorHistogramMaker._labels, SeedMultiplicityAnalyzer._labels, hitfit::Constraint_Intermed_Labels._labels, validation.SimpleValidation._labels, plotting.PlotFolder._labels, validation.SimpleValidation._newdir, validation.SimpleValidation._openFiles, validation.Validation._plotterDrawArgs, validation.SimpleValidation._plotterDrawArgs, validation.SimpleValidation._subdirprefix, join(), and genParticles_cff.map.

Referenced by validation.SimpleValidation._doPlotsForPlotter().

1071  def _doPlots(self, plotterFolder, dqmSubFolder):
1072  plotterFolder.create(self._openFiles, self._labels, dqmSubFolder)
1073  fileList = plotterFolder.draw(**self._plotterDrawArgs)
1074 
1075  for tableCreator in plotterFolder.getTableCreators():
1076  self._htmlReport.addTable(tableCreator.create(self._openFiles, self._labels, dqmSubFolder))
1077 
1078  newsubdir = self._subdirprefix+plotterFolder.getSelectionName(dqmSubFolder)
1079  newdir = os.path.join(self._newdir, newsubdir)
1080 
1081  if len(fileList) == 0:
1082  return fileList
1083 
1084  dups = _findDuplicates(fileList)
1085  if len(dups) > 0:
1086  print "Plotter produced multiple files with names", ", ".join(dups)
1087  print "Typically this is a naming problem in the plotter configuration"
1088  sys.exit(1)
1089 
1090  print "Moving plots to %s" % newdir
1091  if not os.path.exists(newdir):
1092  os.makedirs(newdir)
1093  for f in fileList:
1094  shutil.move(f, os.path.join(newdir, f))
1095  return map(lambda n: os.path.join(newsubdir, n), fileList)
def validation.SimpleValidation._doPlotsForPlotter (   self,
  plotter,
  sample,
  limitSubFoldersOnlyTo = None 
)
private

Definition at line 1062 of file validation.py.

References validation.Validation._doPlots(), validation.SimpleValidation._doPlots(), validation.SimpleValidation._openFiles, and validation._processPlotsForSample().

1062  def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None):
1063  plotterInstance = plotter.readDirs(*self._openFiles)
1064  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
1065  if sample is not None and not _processPlotsForSample(plotterFolder, sample):
1066  continue
1067  plotFiles = self._doPlots(plotterFolder, dqmSubFolder)
1068  if len(plotFiles) > 0:
1069  self._htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
1070 
def _doPlots(self, plotterFolder, dqmSubFolder)
Definition: validation.py:1071
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:266
def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None)
Definition: validation.py:1062
def validation.SimpleValidation.createHtmlReport (   self,
  validationName = "" 
)

Definition at line 1032 of file validation.py.

References validation.SimpleValidation._htmlReport, and validation.SimpleValidation._newdir.

1032  def createHtmlReport(self, validationName=""):
1033  if hasattr(self._htmlReport, "write"):
1034  raise Exception("HTML report object already created. There is probably some logic error in the calling code.")
1035  self._htmlReport = html.HtmlReport(validationName, self._newdir)
1036  return self._htmlReport
1037 
def createHtmlReport(self, validationName="")
Definition: validation.py:1032
def validation.SimpleValidation.doPlots (   self,
  plotters,
  plotterDrawArgs = {},
  kwargs 
)

Definition at line 1038 of file validation.py.

1038  def doPlots(self, plotters, plotterDrawArgs={}, **kwargs):
1039  self._plotterDrawArgs = plotterDrawArgs
1040 
1041  for sample in self._samples:
1042  self._subdirprefix = sample.label()
1043  self._labels = sample.legendLabels()
1044  self._htmlReport.beginSample(sample)
1045 
1046  self._openFiles = []
1047  for f in sample.files():
1048  if os.path.exists(f):
1049  self._openFiles.append(ROOT.TFile.Open(f))
1050  else:
1051  print "File %s not found (from sample %s), ignoring it" % (f, sample.name())
1052  self._openFiles.append(None)
1053 
1054  for plotter in plotters:
1055  self._doPlotsForPlotter(plotter, sample, **kwargs)
1056 
1057  for tf in self._openFiles:
1058  if tf is not None:
1059  tf.Close()
1060  self._openFiles = []
1061 
def doPlots(self, plotters, plotterDrawArgs={}, kwargs)
Definition: validation.py:1038
def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None)
Definition: validation.py:1062

Member Data Documentation

validation.SimpleValidation._htmlReport
private

Definition at line 1030 of file validation.py.

Referenced by validation.SimpleValidation.createHtmlReport().

validation.SimpleValidation._labels
private

Definition at line 1043 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

validation.SimpleValidation._newdir
private
validation.SimpleValidation._openFiles
private
validation.SimpleValidation._plotterDrawArgs
private

Definition at line 1039 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

validation.SimpleValidation._samples
private

Definition at line 1025 of file validation.py.

validation.SimpleValidation._subdirprefix
private

Definition at line 1042 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().