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 1225 of file validation.py.

Constructor & Destructor Documentation

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

Definition at line 1226 of file validation.py.

1226  def __init__(self, samples, newdir):
1227  self._samples = samples
1228  self._newdir = newdir
1229  if not os.path.exists(newdir):
1230  os.makedirs(newdir)
1231 
1233 
def __init__(self, samples, newdir)
Definition: validation.py:1226

Member Function Documentation

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

Definition at line 1273 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().

1273  def _doPlots(self, plotterFolder, dqmSubFolder):
1274  plotterFolder.create(self._openFiles, self._labels, dqmSubFolder)
1275  newsubdir = self._subdirprefix+plotterFolder.getSelectionName(dqmSubFolder)
1276  newdir = os.path.join(self._newdir, newsubdir)
1277  if not os.path.exists(newdir):
1278  os.makedirs(newdir)
1279  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1280 
1281  for tableCreator in plotterFolder.getTableCreators():
1282  self._htmlReport.addTable(tableCreator.create(self._openFiles, self._labels, dqmSubFolder))
1283 
1284 
1285  if len(fileList) == 0:
1286  return fileList
1287 
1288  dups = _findDuplicates(fileList)
1289  if len(dups) > 0:
1290  print "Plotter produced multiple files with names", ", ".join(dups)
1291  print "Typically this is a naming problem in the plotter configuration"
1292  sys.exit(1)
1293 
1294  print "Created plots in %s" % newdir
1295  return map(lambda n: n.replace(newdir, newsubdir), fileList)
def validation.SimpleValidation._doPlotsForPlotter (   self,
  plotter,
  sample,
  limitSubFoldersOnlyTo = None 
)
private

Definition at line 1264 of file validation.py.

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

1264  def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None):
1265  plotterInstance = plotter.readDirs(*self._openFiles)
1266  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
1267  if sample is not None and not _processPlotsForSample(plotterFolder, sample):
1268  continue
1269  plotFiles = self._doPlots(plotterFolder, dqmSubFolder)
1270  if len(plotFiles) > 0:
1271  self._htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
1272 
def _doPlots(self, plotterFolder, dqmSubFolder)
Definition: validation.py:1273
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:460
def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None)
Definition: validation.py:1264
def validation.SimpleValidation.createHtmlReport (   self,
  validationName = "" 
)

Definition at line 1234 of file validation.py.

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

1234  def createHtmlReport(self, validationName=""):
1235  if hasattr(self._htmlReport, "write"):
1236  raise Exception("HTML report object already created. There is probably some logic error in the calling code.")
1237  self._htmlReport = html.HtmlReport(validationName, self._newdir)
1238  return self._htmlReport
1239 
def createHtmlReport(self, validationName="")
Definition: validation.py:1234
def validation.SimpleValidation.doPlots (   self,
  plotters,
  plotterDrawArgs = {},
  kwargs 
)

Definition at line 1240 of file validation.py.

1240  def doPlots(self, plotters, plotterDrawArgs={}, **kwargs):
1241  self._plotterDrawArgs = plotterDrawArgs
1242 
1243  for sample in self._samples:
1244  self._subdirprefix = sample.label()
1245  self._labels = sample.legendLabels()
1246  self._htmlReport.beginSample(sample)
1247 
1248  self._openFiles = []
1249  for f in sample.files():
1250  if os.path.exists(f):
1251  self._openFiles.append(ROOT.TFile.Open(f))
1252  else:
1253  print "File %s not found (from sample %s), ignoring it" % (f, sample.name())
1254  self._openFiles.append(None)
1255 
1256  for plotter in plotters:
1257  self._doPlotsForPlotter(plotter, sample, **kwargs)
1258 
1259  for tf in self._openFiles:
1260  if tf is not None:
1261  tf.Close()
1262  self._openFiles = []
1263 
def doPlots(self, plotters, plotterDrawArgs={}, kwargs)
Definition: validation.py:1240
def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None)
Definition: validation.py:1264

Member Data Documentation

validation.SimpleValidation._htmlReport
private

Definition at line 1232 of file validation.py.

Referenced by validation.SimpleValidation.createHtmlReport().

validation.SimpleValidation._labels
private

Definition at line 1245 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

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

Definition at line 1241 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

validation.SimpleValidation._samples
private

Definition at line 1227 of file validation.py.

validation.SimpleValidation._subdirprefix
private

Definition at line 1244 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().