CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
validation.SeparateValidation 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 1308 of file validation.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 1311 of file validation.py.

1311  def __init__(self, samples, newdir):
1312  self._samples = samples
1313  self._newdir = newdir
1314  if not os.path.exists(newdir):
1315  os.makedirs(newdir)
1316 
1317  self._htmlReport = html.HtmlReportDummy()
1318 

Member Function Documentation

◆ _doPlots()

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

Definition at line 1358 of file validation.py.

1358  def _doPlots(self, plotterFolder, dqmSubFolder):
1359  plotterFolder.create(self._openFiles, self._labels, dqmSubFolder)
1360  newsubdir = self._subdirprefix+plotterFolder.getSelectionName(dqmSubFolder)
1361  newdir = os.path.join(self._newdir, newsubdir)
1362  if not os.path.exists(newdir):
1363  os.makedirs(newdir)
1364  fileList = plotterFolder.draw(directory=newdir, **self._plotterDrawArgs)
1365 
1366  # check if plots are produced
1367  if len(fileList) == 0:
1368  return fileList
1369 
1370  # check if there are duplicated plot
1371  dups = _findDuplicates(fileList)
1372  if len(dups) > 0:
1373  print("Plotter produced multiple files with names", ", ".join(dups))
1374  print("Typically this is a naming problem in the plotter configuration")
1375  sys.exit(1)
1376 
1377  linkList = []
1378  for f in fileList:
1379  if f[:f.rfind("/")] not in linkList :
1380  if str(f[:f.rfind("/")]) != str(newdir) :
1381  linkList.append(f[:f.rfind("/")])
1382 
1383  for tableCreator in plotterFolder.getTableCreators():
1384  self._htmlReport.addTable(tableCreator.create(self._openFiles, self._labels, dqmSubFolder))
1385 
1386  for link in linkList :
1387  if not os.path.exists("%s/res"%link):
1388  os.makedirs("%s/res"%link)
1389  downloadables = ["index.php", "res/jquery-ui.js", "res/jquery.js", "res/style.css", "res/style.js", "res/theme.css"]
1390  for d in downloadables:
1391  if not os.path.exists("%s/%s" % (link,d)):
1392  urllib.request.urlretrieve("https://raw.githubusercontent.com/rovere/php-plots/master/%s"%d, "%s/%s"%(link,d))
1393 
1394  print("Created separated plots in %s" % newdir)
1395  return list(map(lambda n: n.replace(newdir, newsubdir), linkList))

References validation._findDuplicates(), validation.SimpleValidation._htmlReport, validation.SeparateValidation._htmlReport, DigiInvestigatorHistogramMaker._labels, SeedMultiplicityAnalyzer._labels, hitfit::Constraint_Intermed_Labels._labels, validation.SimpleValidation._labels, validation.SeparateValidation._labels, plotting.PlotFolder._labels, validation.SimpleValidation._newdir, validation.SeparateValidation._newdir, validation.SimpleValidation._openFiles, validation.SeparateValidation._openFiles, validation.Validation._plotterDrawArgs, validation.SimpleValidation._plotterDrawArgs, validation.SeparateValidation._plotterDrawArgs, validation.SimpleValidation._subdirprefix, validation.SeparateValidation._subdirprefix, join(), genParticles_cff.map, print(), and str.

Referenced by validation.SeparateValidation._doPlotsForPlotter().

◆ _doPlotsForPlotter()

def validation.SeparateValidation._doPlotsForPlotter (   self,
  plotter,
  sample,
  limitSubFoldersOnlyTo = None 
)
private

Definition at line 1349 of file validation.py.

1349  def _doPlotsForPlotter(self, plotter, sample, limitSubFoldersOnlyTo=None):
1350  plotterInstance = plotter.readDirs(*self._openFiles)
1351  for plotterFolder, dqmSubFolder in plotterInstance.iterFolders(limitSubFoldersOnlyTo=limitSubFoldersOnlyTo):
1352  if sample is not None and not _processPlotsForSample(plotterFolder, sample):
1353  continue
1354  plotFiles = self._doPlots(plotterFolder, dqmSubFolder)
1355  if len(plotFiles) > 0:
1356  self._htmlReport.addPlots(plotterFolder, dqmSubFolder, plotFiles)
1357 

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

◆ createHtmlReport()

def validation.SeparateValidation.createHtmlReport (   self,
  validationName = "" 
)

Definition at line 1319 of file validation.py.

1319  def createHtmlReport(self, validationName=""):
1320  if hasattr(self._htmlReport, "write"):
1321  raise Exception("HTML report object already created. There is probably some logic error in the calling code.")
1322  self._htmlReport = html.HtmlReport(validationName, self._newdir)
1323  return self._htmlReport
1324 

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

◆ doPlots()

def validation.SeparateValidation.doPlots (   self,
  plotters,
  plotterDrawArgs = {},
**  kwargs 
)

Definition at line 1325 of file validation.py.

1325  def doPlots(self, plotters, plotterDrawArgs={}, **kwargs):
1326  self._plotterDrawArgs = plotterDrawArgs
1327 
1328  for sample in self._samples:
1329  self._subdirprefix = sample.label()
1330  self._labels = sample.legendLabels()
1331  self._htmlReport.beginSample(sample)
1332 
1333  self._openFiles = []
1334  for f in sample.files():
1335  if os.path.exists(f):
1336  self._openFiles.append(ROOT.TFile.Open(f))
1337  else:
1338  print("File %s not found (from sample %s), ignoring it" % (f, sample.name()))
1339  self._openFiles.append(None)
1340 
1341  for plotter in plotters:
1342  self._doPlotsForPlotter(plotter, sample, **kwargs)
1343 
1344  for tf in self._openFiles:
1345  if tf is not None:
1346  tf.Close()
1347  self._openFiles = []
1348 

Member Data Documentation

◆ _htmlReport

validation.SeparateValidation._htmlReport
private

◆ _labels

validation.SeparateValidation._labels
private

Definition at line 1330 of file validation.py.

Referenced by validation.SeparateValidation._doPlots().

◆ _newdir

validation.SeparateValidation._newdir
private

◆ _openFiles

validation.SeparateValidation._openFiles
private

◆ _plotterDrawArgs

validation.SeparateValidation._plotterDrawArgs
private

Definition at line 1326 of file validation.py.

Referenced by validation.SeparateValidation._doPlots().

◆ _samples

validation.SeparateValidation._samples
private

Definition at line 1312 of file validation.py.

◆ _subdirprefix

validation.SeparateValidation._subdirprefix
private

Definition at line 1329 of file validation.py.

Referenced by validation.SeparateValidation._doPlots().

validation._findDuplicates
def _findDuplicates(lst)
Definition: validation.py:1175
join
static std::string join(char **cmd)
Definition: RemoteFile.cc:17
html.HtmlReportDummy
Definition: html.py:842
str
#define str(s)
Definition: TestProcessor.cc:53
print
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:46
Exception
mps_setup.append
append
Definition: mps_setup.py:85
validation._processPlotsForSample
def _processPlotsForSample(plotterFolder, sample)
Definition: validation.py:463
genParticles_cff.map
map
Definition: genParticles_cff.py:11
html.HtmlReport
Definition: html.py:779