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

Constructor & Destructor Documentation

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

Definition at line 1229 of file validation.py.

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

Member Function Documentation

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

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

1276  def _doPlots(self, plotterFolder, dqmSubFolder):
1277  plotterFolder.create(self._openFiles, self._labels, dqmSubFolder)
1278  newsubdir = self._subdirprefix+plotterFolder.getSelectionName(dqmSubFolder)
1279  newdir = os.path.join(self._newdir, newsubdir)
1280  if not os.path.exists(newdir):
1281  os.makedirs(newdir)
1282  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1283 
1284  for tableCreator in plotterFolder.getTableCreators():
1285  self._htmlReport.addTable(tableCreator.create(self._openFiles, self._labels, dqmSubFolder))
1286 
1287 
1288  if len(fileList) == 0:
1289  return fileList
1290 
1291  dups = _findDuplicates(fileList)
1292  if len(dups) > 0:
1293  print("Plotter produced multiple files with names", ", ".join(dups))
1294  print("Typically this is a naming problem in the plotter configuration")
1295  sys.exit(1)
1296 
1297  if self._plotterDrawArgs.get("separate", False):
1298  if not os.path.exists("%s/res"%newdir):
1299  os.makedirs("%s/res"%newdir)
1300  downloadables = ["index.php", "res/jquery-ui.js", "res/jquery.js", "res/style.css", "res/style.js", "res/theme.css"]
1301  for d in downloadables:
1302  if not os.path.exists("%s/%s" % (newdir,d)):
1303  urllib.urlretrieve("https://raw.githubusercontent.com/musella/php-plots/master/%s"%d, "%s/%s"%(newdir,d))
1304 
1305  print("Created plots in %s" % newdir)
1306  return map(lambda n: n.replace(newdir, newsubdir), fileList)
1307 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def _doPlots(self, plotterFolder, dqmSubFolder)
Definition: validation.py:1276
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
def _findDuplicates(lst)
Definition: validation.py:1175
def validation.SimpleValidation._doPlotsForPlotter (   self,
  plotter,
  sample,
  limitSubFoldersOnlyTo = None 
)
private

Definition at line 1267 of file validation.py.

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

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

Definition at line 1237 of file validation.py.

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

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

Definition at line 1243 of file validation.py.

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

Member Data Documentation

validation.SimpleValidation._htmlReport
private

Definition at line 1235 of file validation.py.

Referenced by validation.SimpleValidation.createHtmlReport().

validation.SimpleValidation._labels
private

Definition at line 1248 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

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

Definition at line 1244 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().

validation.SimpleValidation._samples
private

Definition at line 1230 of file validation.py.

validation.SimpleValidation._subdirprefix
private

Definition at line 1247 of file validation.py.

Referenced by validation.SimpleValidation._doPlots().