test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
validation.SimpleValidation Class Reference

Public Member Functions

def __init__
 
def createHtmlReport
 
def doPlots
 

Private Member Functions

def _doPlots
 
def _doPlotsForPlotter
 

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.

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

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, and join().

Referenced by validation.SimpleValidation._doPlotsForPlotter().

1072  def _doPlots(self, plotterFolder, dqmSubFolder):
1073  plotterFolder.create(self._openFiles, self._labels, dqmSubFolder)
1074  fileList = plotterFolder.draw(**self._plotterDrawArgs)
1075 
1076  for tableCreator in plotterFolder.getTableCreators():
1077  self._htmlReport.addTable(tableCreator.create(self._openFiles, self._labels, dqmSubFolder))
1078 
1079  newsubdir = self._subdirprefix+plotterFolder.getSelectionName(dqmSubFolder)
1080  newdir = os.path.join(self._newdir, newsubdir)
1081 
1082  if len(fileList) == 0:
1083  return fileList
1084 
1085  dups = _findDuplicates(fileList)
1086  if len(dups) > 0:
1087  print "Plotter produced multiple files with names", ", ".join(dups)
1088  print "Typically this is a naming problem in the plotter configuration"
1089  sys.exit(1)
1090 
1091  print "Moving plots to %s" % newdir
1092  if not os.path.exists(newdir):
1093  os.makedirs(newdir)
1094  for f in fileList:
1095  shutil.move(f, os.path.join(newdir, f))
1096  return map(lambda n: os.path.join(newsubdir, n), fileList)
def _findDuplicates
Definition: validation.py:973
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
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().

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

Definition at line 1032 of file validation.py.

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

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

Definition at line 1038 of file validation.py.

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

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

Definition at line 1026 of file validation.py.

Referenced by validation.SimpleValidation._doPlots(), and validation.SimpleValidation.createHtmlReport().

validation.SimpleValidation._openFiles
private

Definition at line 1046 of file validation.py.

Referenced by validation.SimpleValidation._doPlots(), and validation.SimpleValidation._doPlotsForPlotter().

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