CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
plotting.PlotFolder Class Reference
Inheritance diagram for plotting.PlotFolder:
trackingPlots.TrackingPlotFolder

Public Member Functions

def __init__
 
def append
 
def create
 
def draw
 
def getPage
 
def getPurpose
 
def getSection
 
def getSelectionName
 
def limitSubFolder
 
def loopSubFolders
 
def onlyForPileup
 
def set
 
def translateSubFolder
 

Private Member Functions

def _getDir
 

Private Attributes

 _labels
 
 _loopSubFolders
 
 _onlyForPileup
 
 _page
 
 _plotGroups
 
 _purpose
 
 _section
 

Detailed Description

Represents a collection of PlotGroups, produced from a single folder in a DQM file

Definition at line 1597 of file plotting.py.

Constructor & Destructor Documentation

def plotting.PlotFolder.__init__ (   self,
  plotGroups,
  kwargs 
)
Constructor.

Arguments:
plotGroups     -- List of PlotGroup objects

Keyword arguments
loopSubFolders -- Should the subfolders be looped over? (default: True)
onlyForPileup  -- Plots this folder only for pileup samples
purpose        -- html.PlotPurpose member class for the purpose of the folder, used for grouping of the plots to the HTML pages
page           -- Optional string for the page in HTML generatin
section        -- Optional string for the section within a page in HTML generation

Definition at line 1599 of file plotting.py.

Referenced by trackingPlots.TrackingPlotFolder._init__().

1600  def __init__(self, *plotGroups, **kwargs):
1601  """Constructor.
1602 
1603  Arguments:
1604  plotGroups -- List of PlotGroup objects
1605 
1606  Keyword arguments
1607  loopSubFolders -- Should the subfolders be looped over? (default: True)
1608  onlyForPileup -- Plots this folder only for pileup samples
1609  purpose -- html.PlotPurpose member class for the purpose of the folder, used for grouping of the plots to the HTML pages
1610  page -- Optional string for the page in HTML generatin
1611  section -- Optional string for the section within a page in HTML generation
1612  """
1613  self._plotGroups = plotGroups
1614  self._loopSubFolders = kwargs.pop("loopSubFolders", True)
1615  self._onlyForPileup = kwargs.pop("onlyForPileup", False)
1616  self._purpose = kwargs.pop("purpose", None)
1617  self._page = kwargs.pop("page", None)
1618  self._section = kwargs.pop("section", None)
1619  if len(kwargs) > 0:
1620  raise Exception("Got unexpected keyword arguments: "+ ",".join(kwargs.keys()))
static std::string join(char **cmd)
Definition: RemoteFile.cc:18

Member Function Documentation

def plotting.PlotFolder._getDir (   self,
  tfile,
  possibleDqmFolders,
  dqmSubFolder 
)
private
Get TDirectory from TFile.

Definition at line 1692 of file plotting.py.

References join().

1693  def _getDir(self, tfile, possibleDqmFolders, dqmSubFolder):
1694  """Get TDirectory from TFile."""
1695  if tfile is None:
1696  return None
1697  for pdf in possibleDqmFolders:
1698  d = tfile.Get(pdf)
1699  if d:
1700  if dqmSubFolder is not None:
1701  # Pick associator if given
1702  d = d.Get(dqmSubFolder)
1703  if d:
1704  return d
1705  else:
1706  print "Did not find subdirectory '%s' from directory '%s' in file %s" % (dqmSubFolder, pdf, tfile.GetName())
1707  return None
1708  else:
1709  return d
1710  print "Did not find any of directories '%s' from file %s" % (",".join(possibleDqmFolders), tfile.GetName())
1711  return None
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def plotting.PlotFolder.append (   self,
  plotGroup 
)

Definition at line 1638 of file plotting.py.

Referenced by diclist.diclist.add(), and BeautifulSoup.Tag.setString().

1639  def append(self, plotGroup):
1640  self._plotGroups.append(plotGroup)
def plotting.PlotFolder.create (   self,
  files,
  labels,
  possibleDqmFolders,
  dqmSubFolder = None,
  isPileupSample = True,
  requireAllHistograms = False 
)
Create histograms from a list of TFiles.

Arguments:
files  -- List of TFiles
labels -- List of strings for legend labels corresponding the files
possibleDqmFolders -- List of strings for possible directories of histograms in TFiles
dqmSubFolder -- Optional string for subdirectory inside the dqmFolder; if list of strings, then each corresponds to a TFile
isPileupSample -- Is sample pileup (some PlotGroups may limit themselves to pileup)
requireAllHistograms -- If True, a plot is produced if histograms from all files are present (default: False)

Definition at line 1644 of file plotting.py.

1645  def create(self, files, labels, possibleDqmFolders, dqmSubFolder=None, isPileupSample=True, requireAllHistograms=False):
1646  """Create histograms from a list of TFiles.
1647 
1648  Arguments:
1649  files -- List of TFiles
1650  labels -- List of strings for legend labels corresponding the files
1651  possibleDqmFolders -- List of strings for possible directories of histograms in TFiles
1652  dqmSubFolder -- Optional string for subdirectory inside the dqmFolder; if list of strings, then each corresponds to a TFile
1653  isPileupSample -- Is sample pileup (some PlotGroups may limit themselves to pileup)
1654  requireAllHistograms -- If True, a plot is produced if histograms from all files are present (default: False)
1655  """
1656 
1657  if len(files) != len(labels):
1658  raise Exception("len(files) should be len(labels), now they are %d and %d" % (len(files), len(labels)))
1659 
1660  dirs = []
1661  self._labels = []
1662  if isinstance(dqmSubFolder, list):
1663  if len(dqmSubFolder) != len(files):
1664  raise Exception("When dqmSubFolder is a list, len(dqmSubFolder) should be len(files), now they are %d and %d" % (len(dqmSubFolder), len(files)))
1665  else:
1666  dqmSubFolder = [dqmSubFolder]*len(files)
1667 
1668  for fil, sf in zip(files, dqmSubFolder):
1669  dirs.append(self._getDir(fil, possibleDqmFolders, sf))
1670  self._labels = labels
1671 
1672  for pg in self._plotGroups:
1673  if pg.onlyForPileup() and not isPileupSample:
1674  continue
1675  pg.create(dirs, requireAllHistograms)
def plotting.PlotFolder.draw (   self,
  prefix = None,
  separate = False,
  saveFormat = ".pdf",
  ratio = False 
)
Draw and save all plots using settings of a given algorithm.

Arguments:
prefix   -- Optional string for file name prefix (default None)
separate -- Save the plots of a group to separate files instead of a file per group (default False)
saveFormat   -- String specifying the plot format (default '.pdf')
ratio    -- Add ratio to the plot (default False)

Definition at line 1676 of file plotting.py.

References DigiInvestigatorHistogramMaker._labels, SeedMultiplicityAnalyzer._labels, hitfit::Constraint_Intermed_Labels._labels, plotting.PlotFolder._labels, and plotting.PlotFolder._plotGroups.

1677  def draw(self, prefix=None, separate=False, saveFormat=".pdf", ratio=False):
1678  """Draw and save all plots using settings of a given algorithm.
1679 
1680  Arguments:
1681  prefix -- Optional string for file name prefix (default None)
1682  separate -- Save the plots of a group to separate files instead of a file per group (default False)
1683  saveFormat -- String specifying the plot format (default '.pdf')
1684  ratio -- Add ratio to the plot (default False)
1685  """
1686  ret = []
1687 
1688  for pg in self._plotGroups:
1689  ret.extend(pg.draw(self._labels, prefix=prefix, separate=separate, saveFormat=saveFormat, ratio=ratio))
1690  return ret
1691 
def plotting.PlotFolder.getPage (   self)

Definition at line 1632 of file plotting.py.

References plotting.PlotFolder._page.

1633  def getPage(self):
1634  return self._page
def plotting.PlotFolder.getPurpose (   self)

Definition at line 1629 of file plotting.py.

References plotting.PlotFolder._purpose.

1630  def getPurpose(self):
1631  return self._purpose
def plotting.PlotFolder.getSection (   self)

Definition at line 1635 of file plotting.py.

References plotting.PlotFolder._section.

1636  def getSection(self):
1637  return self._section
def plotting.PlotFolder.getSelectionName (   self,
  plotFolderName,
  translatedDqmSubFolder 
)
Get selection name (used in output directory name and legend) from the name of PlotterFolder, and a return value of translateSubFolder

Definition at line 1723 of file plotting.py.

1724  def getSelectionName(self, plotFolderName, translatedDqmSubFolder):
1725  """Get selection name (used in output directory name and legend) from the name of PlotterFolder, and a return value of translateSubFolder"""
1726  ret = ""
1727  if plotFolderName != "":
1728  ret += "_"+plotFolderName
1729  if translatedDqmSubFolder is not None:
1730  ret += "_"+translatedDqmSubFolder
1731  return ret
def plotting.PlotFolder.limitSubFolder (   self,
  limitOnlyTo,
  translatedDqmSubFolder 
)
Return True if this subfolder should be processed

Arguments:
limitOnlyTo            -- List/set/similar containing the translatedDqmSubFolder 
translatedDqmSubFolder -- Return value of translateSubFolder

Definition at line 1732 of file plotting.py.

1733  def limitSubFolder(self, limitOnlyTo, translatedDqmSubFolder):
1734  """Return True if this subfolder should be processed
1735 
1736  Arguments:
1737  limitOnlyTo -- List/set/similar containing the translatedDqmSubFolder
1738  translatedDqmSubFolder -- Return value of translateSubFolder
1739  """
1740  return translatedDqmSubFolder in limitOnlyTo
def plotting.PlotFolder.loopSubFolders (   self)
Return True if the PlotGroups of this folder should be applied to the all subfolders

Definition at line 1621 of file plotting.py.

References plotting.PlotFolder._loopSubFolders.

1622  def loopSubFolders(self):
1623  """Return True if the PlotGroups of this folder should be applied to the all subfolders"""
1624  return self._loopSubFolders
def plotting.PlotFolder.onlyForPileup (   self)
Return True if the folder is intended only for pileup samples

Definition at line 1625 of file plotting.py.

References plotting.PlotFolder._onlyForPileup.

1626  def onlyForPileup(self):
1627  """Return True if the folder is intended only for pileup samples"""
1628  return self._onlyForPileup
def plotting.PlotFolder.set (   self,
  plotGroups 
)

Definition at line 1641 of file plotting.py.

References plotting.PlotFolder._plotGroups.

Referenced by betterConfigParser.BetterConfigParser.getGeneral().

1642  def set(self, plotGroups):
1643  self._plotGroups = plotGroups
def plotting.PlotFolder.translateSubFolder (   self,
  dqmSubFolderName 
)
Method called to (possibly) translate a subfolder name to more 'readable' form

The implementation in this (base) class just returns the
argument. The idea is that a deriving class might want to do
something more complex (like trackingPlots.TrackingPlotFolder
does)

Definition at line 1713 of file plotting.py.

1714  def translateSubFolder(self, dqmSubFolderName):
1715  """Method called to (possibly) translate a subfolder name to more 'readable' form
1716 
1717  The implementation in this (base) class just returns the
1718  argument. The idea is that a deriving class might want to do
1719  something more complex (like trackingPlots.TrackingPlotFolder
1720  does)
1721  """
1722  return dqmSubFolderName

Member Data Documentation

plotting.PlotFolder._labels
private

Definition at line 1660 of file plotting.py.

Referenced by validation.SimpleValidation._doPlots(), and plotting.PlotFolder.draw().

plotting.PlotFolder._loopSubFolders
private

Definition at line 1613 of file plotting.py.

Referenced by plotting.PlotFolder.loopSubFolders().

plotting.PlotFolder._onlyForPileup
private

Definition at line 1614 of file plotting.py.

Referenced by plotting.PlotGroup.onlyForPileup(), and plotting.PlotFolder.onlyForPileup().

plotting.PlotFolder._page
private

Definition at line 1616 of file plotting.py.

Referenced by plotting.PlotFolder.getPage().

plotting.PlotFolder._plotGroups
private

Definition at line 1612 of file plotting.py.

Referenced by plotting.PlotFolder.draw(), and plotting.PlotFolder.set().

plotting.PlotFolder._purpose
private

Definition at line 1615 of file plotting.py.

Referenced by plotting.PlotFolder.getPurpose().

plotting.PlotFolder._section
private

Definition at line 1617 of file plotting.py.

Referenced by plotting.PlotFolder.getSection().