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

Constructor & Destructor Documentation

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

Definition at line 1227 of file validation.py.

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

Member Function Documentation

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

Definition at line 1274 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(), genParticles_cff.map, and edm.print().

Referenced by validation.SimpleValidation._doPlotsForPlotter().

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

Definition at line 1265 of file validation.py.

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

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

Definition at line 1235 of file validation.py.

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

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

Definition at line 1241 of file validation.py.

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

Member Data Documentation

validation.SimpleValidation._htmlReport
private

Definition at line 1233 of file validation.py.

Referenced by validation.SimpleValidation.createHtmlReport().

validation.SimpleValidation._labels
private

Definition at line 1246 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

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

Definition at line 1242 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

validation.SimpleValidation._samples
private

Definition at line 1228 of file validation.py.

validation.SimpleValidation._subdirprefix
private

Definition at line 1245 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().