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

Constructor & Destructor Documentation

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

Definition at line 1195 of file validation.py.

1195  def __init__(self, samples, newdir):
1196  self._samples = samples
1197  self._newdir = newdir
1198  if not os.path.exists(newdir):
1199  os.makedirs(newdir)
1200 
1202 
def __init__(self, samples, newdir)
Definition: validation.py:1195

Member Function Documentation

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

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

1242  def _doPlots(self, plotterFolder, dqmSubFolder):
1243  plotterFolder.create(self._openFiles, self._labels, dqmSubFolder)
1244  newsubdir = self._subdirprefix+plotterFolder.getSelectionName(dqmSubFolder)
1245  newdir = os.path.join(self._newdir, newsubdir)
1246  if not os.path.exists(newdir):
1247  os.makedirs(newdir)
1248  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1249 
1250  for tableCreator in plotterFolder.getTableCreators():
1251  self._htmlReport.addTable(tableCreator.create(self._openFiles, self._labels, dqmSubFolder))
1252 
1253 
1254  if len(fileList) == 0:
1255  return fileList
1256 
1257  dups = _findDuplicates(fileList)
1258  if len(dups) > 0:
1259  print "Plotter produced multiple files with names", ", ".join(dups)
1260  print "Typically this is a naming problem in the plotter configuration"
1261  sys.exit(1)
1262 
1263  print "Created plots in %s" % newdir
1264  return map(lambda n: n.replace(newdir, newsubdir), fileList)
def validation.SimpleValidation._doPlotsForPlotter (   self,
  plotter,
  sample,
  limitSubFoldersOnlyTo = None 
)
private

Definition at line 1233 of file validation.py.

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

1233  def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None):
1234  plotterInstance = plotter.readDirs(*self._openFiles)
1235  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
1236  if sample is not None and not _processPlotsForSample(plotterFolder, sample):
1237  continue
1238  plotFiles = self._doPlots(plotterFolder, dqmSubFolder)
1239  if len(plotFiles) > 0:
1240  self._htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
1241 
def _doPlots(self, plotterFolder, dqmSubFolder)
Definition: validation.py:1242
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:429
def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None)
Definition: validation.py:1233
def validation.SimpleValidation.createHtmlReport (   self,
  validationName = "" 
)

Definition at line 1203 of file validation.py.

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

1203  def createHtmlReport(self, validationName=""):
1204  if hasattr(self._htmlReport, "write"):
1205  raise Exception("HTML report object already created. There is probably some logic error in the calling code.")
1206  self._htmlReport = html.HtmlReport(validationName, self._newdir)
1207  return self._htmlReport
1208 
def createHtmlReport(self, validationName="")
Definition: validation.py:1203
def validation.SimpleValidation.doPlots (   self,
  plotters,
  plotterDrawArgs = {},
  kwargs 
)

Definition at line 1209 of file validation.py.

1209  def doPlots(self, plotters, plotterDrawArgs={}, **kwargs):
1210  self._plotterDrawArgs = plotterDrawArgs
1211 
1212  for sample in self._samples:
1213  self._subdirprefix = sample.label()
1214  self._labels = sample.legendLabels()
1215  self._htmlReport.beginSample(sample)
1216 
1217  self._openFiles = []
1218  for f in sample.files():
1219  if os.path.exists(f):
1220  self._openFiles.append(ROOT.TFile.Open(f))
1221  else:
1222  print "File %s not found (from sample %s), ignoring it" % (f, sample.name())
1223  self._openFiles.append(None)
1224 
1225  for plotter in plotters:
1226  self._doPlotsForPlotter(plotter, sample, **kwargs)
1227 
1228  for tf in self._openFiles:
1229  if tf is not None:
1230  tf.Close()
1231  self._openFiles = []
1232 
def doPlots(self, plotters, plotterDrawArgs={}, kwargs)
Definition: validation.py:1209
def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None)
Definition: validation.py:1233

Member Data Documentation

validation.SimpleValidation._htmlReport
private

Definition at line 1201 of file validation.py.

Referenced by validation.SimpleValidation.createHtmlReport().

validation.SimpleValidation._labels
private

Definition at line 1214 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

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

Definition at line 1210 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

validation.SimpleValidation._samples
private

Definition at line 1196 of file validation.py.

validation.SimpleValidation._subdirprefix
private

Definition at line 1213 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().