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 Attributes
plotting.PlotterFolder Class Reference

Public Member Functions

def __init__
 
def create
 
def draw
 
def getDQMSubFolders
 
def getName
 
def getPage
 
def getPossibleDQMFolders
 
def getPurpose
 
def getSection
 
def getSelectionName
 
def getSelectionNameIterator
 
def getTableCreators
 
def onlyForPileup
 

Private Attributes

 _dqmSubFolders
 
 _fallbackDqmSubFolders
 
 _fallbackNames
 
 _name
 
 _plotFolder
 
 _possibleDqmFolders
 
 _tableCreators
 

Detailed Description

Plotter for one DQM folder.

This class is supposed to be instantiated by the Plotter class (or
PlotterItem, to be more specific), and not used directly by the
user.

Definition at line 1952 of file plotting.py.

Constructor & Destructor Documentation

def plotting.PlotterFolder.__init__ (   self,
  name,
  possibleDqmFolders,
  dqmSubFolders,
  plotFolder,
  fallbackNames,
  fallbackDqmSubFolders,
  tableCreators 
)
Constructor

Arguments:
name               -- Name of the folder (is used in the output directory naming)
possibleDqmFolders -- List of strings for possible directories of histograms in TFiles
dqmSubFolders      -- List of lists of strings for list of subfolders per input file, or None if no subfolders
plotFolder         -- PlotFolder object
fallbackNames      -- List of names for backward compatibility (can be empty). These are used only by validation.Validation (class responsible of the release validation workflow) in case the reference file pointed by 'name' does not exist.
fallbackDqmSubFolders -- List of dicts of (string->string) for mapping the subfolder names found in the first file to another names. Use case is comparing files that have different iteration naming convention.
tableCreators      -- List of PlotterTableItem objects for tables to be created from this folder

Definition at line 1959 of file plotting.py.

1960  def __init__(self, name, possibleDqmFolders, dqmSubFolders, plotFolder, fallbackNames, fallbackDqmSubFolders, tableCreators):
1961  """
1962  Constructor
1963 
1964  Arguments:
1965  name -- Name of the folder (is used in the output directory naming)
1966  possibleDqmFolders -- List of strings for possible directories of histograms in TFiles
1967  dqmSubFolders -- List of lists of strings for list of subfolders per input file, or None if no subfolders
1968  plotFolder -- PlotFolder object
1969  fallbackNames -- List of names for backward compatibility (can be empty). These are used only by validation.Validation (class responsible of the release validation workflow) in case the reference file pointed by 'name' does not exist.
1970  fallbackDqmSubFolders -- List of dicts of (string->string) for mapping the subfolder names found in the first file to another names. Use case is comparing files that have different iteration naming convention.
1971  tableCreators -- List of PlotterTableItem objects for tables to be created from this folder
1972  """
1973  self._name = name
1974  self._possibleDqmFolders = possibleDqmFolders
1975  self._plotFolder = plotFolder
1976  #self._dqmSubFolders = [map(lambda sf: DQMSubFolder(sf, self._plotFolder.translateSubFolder(sf)), lst) for lst in dqmSubFolders]
1977  if dqmSubFolders is None:
1978  self._dqmSubFolders = None
1979  else:
1980  # Match the subfolders between files in case the lists differ
1981  # equality is by the 'translated' name
1982  subfolders = {}
1983  for sf_list in dqmSubFolders:
1984  for sf in sf_list:
1985  sf_translated = self._plotFolder.translateSubFolder(sf)
1986  if sf_translated is not None and not sf_translated in subfolders:
1987  subfolders[sf_translated] = DQMSubFolder(sf, sf_translated)
1988 
1989  self._dqmSubFolders = subfolders.values()
1990  self._dqmSubFolders.sort(key=lambda sf: sf.subfolder)
1992  self._fallbackNames = fallbackNames
1993  self._fallbackDqmSubFolders = fallbackDqmSubFolders
1994  self._tableCreators = tableCreators

Member Function Documentation

def plotting.PlotterFolder.create (   self,
  files,
  labels,
  dqmSubFolder,
  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
dqmSubFolder -- DQMSubFolder object for a subfolder (or None for no subfolder)
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 2040 of file plotting.py.

References plotting.PlotterFolder._fallbackDqmSubFolders, plotting._getDirectoryDetailed(), and plotting.PlotterFolder._possibleDqmFolders.

2041  def create(self, files, labels, dqmSubFolder, isPileupSample=True, requireAllHistograms=False):
2042  """Create histograms from a list of TFiles.
2043  Arguments:
2044  files -- List of TFiles
2045  labels -- List of strings for legend labels corresponding the files
2046  dqmSubFolder -- DQMSubFolder object for a subfolder (or None for no subfolder)
2047  isPileupSample -- Is sample pileup (some PlotGroups may limit themselves to pileup)
2048  requireAllHistograms -- If True, a plot is produced if histograms from all files are present (default: False)
2049  """
2050 
2051  subfolder = dqmSubFolder.subfolder if dqmSubFolder is not None else None
2052  dirs = []
2053 
2054  for tfile in files:
2055  ret = _getDirectoryDetailed(tfile, self._possibleDqmFolders, subfolder)
2056  # If file and any of possibleDqmFolders exist but subfolder does not, try the fallbacks
2058  for fallbackFunc in self._fallbackDqmSubFolders:
2059  fallback = fallbackFunc(subfolder)
2060  if fallback is not None:
2061  ret = _getDirectoryDetailed(tfile, self._possibleDqmFolders, fallback)
2062  if ret is not GetDirectoryCode.SubDirNotExist:
2063  break
2064  dirs.append(GetDirectoryCode.codesToNone(ret))
2065 
2066  self._plotFolder.create(dirs, labels, isPileupSample, requireAllHistograms)
def _getDirectoryDetailed
Definition: plotting.py:38
def plotting.PlotterFolder.draw (   self,
  args,
  kwargs 
)
Draw and save all plots using settings of a given algorithm.

Definition at line 2067 of file plotting.py.

2068  def draw(self, *args, **kwargs):
2069  """Draw and save all plots using settings of a given algorithm."""
2070  return self._plotFolder.draw(*args, **kwargs)
2071 
def plotting.PlotterFolder.getDQMSubFolders (   self,
  limitOnlyTo = None 
)
Get list of subfolders, possibly limiting to some of them.

Keyword arguments:
limitOnlyTo -- Object depending on the PlotFolder type for limiting the set of subfolders to be processed

Definition at line 2013 of file plotting.py.

References plotting.PlotterFolder._dqmSubFolders, and alcazmumu_cfi.filter.

2014  def getDQMSubFolders(self, limitOnlyTo=None):
2015  """Get list of subfolders, possibly limiting to some of them.
2016 
2017  Keyword arguments:
2018  limitOnlyTo -- Object depending on the PlotFolder type for limiting the set of subfolders to be processed
2019  """
2020 
2021  if self._dqmSubFolders is None:
2022  return [None]
2023 
2024  if limitOnlyTo is None:
2025  return self._dqmSubFolders
2026 
2027  return filter(lambda s: self._plotFolder.limitSubFolder(limitOnlyTo, s.translated), self._dqmSubFolders)
def plotting.PlotterFolder.getName (   self)

Definition at line 1995 of file plotting.py.

References FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, L1TMuon::PtAssignmentUnit._name, L1TMuon::PtRefinementUnit._name, LikelihoodPdfProduct._name, LikelihoodPdf._name, hcaldqm::Container._name, citk::IsolationConeDefinitionBase._name, hcaldqm::DQModule._name, Logger._name, DrellYanValidation._name, WValidation._name, HistoParams< T >._name, CutApplicatorBase._name, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, ElectronMVAEstimatorRun2Spring15Trig._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15NonTrig._name, HistoParams< TH2F >._name, HistoParams< TProfile2D >._name, plotting.Subtract._name, plotting.FakeDuplicate._name, plotting.AggregateBins._name, Vispa.Views.PropertyView.Property._name, SequenceTypes.SequencePlaceholder._name, plotting.AggregateHistos._name, plotting.ROC._name, plotting.Plot._name, plotting.PlotGroup._name, and plotting.PlotterFolder._name.

1996  def getName(self):
1997  return self._name
def plotting.PlotterFolder.getPage (   self)

Definition at line 2001 of file plotting.py.

2002  def getPage(self):
2003  return self._plotFolder.getPage()
def plotting.PlotterFolder.getPossibleDQMFolders (   self)

Definition at line 2010 of file plotting.py.

References plotting.PlotterFolder._possibleDqmFolders.

2011  def getPossibleDQMFolders(self):
2012  return self._possibleDqmFolders
def plotting.PlotterFolder.getPurpose (   self)

Definition at line 1998 of file plotting.py.

1999  def getPurpose(self):
2000  return self._plotFolder.getPurpose()
def plotting.PlotterFolder.getSection (   self)

Definition at line 2004 of file plotting.py.

2005  def getSection(self):
2006  return self._plotFolder.getSection()
def plotting.PlotterFolder.getSelectionName (   self,
  dqmSubFolder 
)

Definition at line 2037 of file plotting.py.

References plotting.PlotterFolder.getSelectionNameIterator(), and GetRecoTauVFromDQM_MC_cff.next.

2038  def getSelectionName(self, dqmSubFolder):
2039  return next(self.getSelectionNameIterator(dqmSubFolder))
def plotting.PlotterFolder.getSelectionNameIterator (   self,
  dqmSubFolder 
)
Get a generator for the 'selection name', looping over the name and fallbackNames

Definition at line 2031 of file plotting.py.

References plotting.PlotterFolder._fallbackNames, FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, L1TMuon::PtAssignmentUnit._name, L1TMuon::PtRefinementUnit._name, LikelihoodPdfProduct._name, LikelihoodPdf._name, hcaldqm::Container._name, citk::IsolationConeDefinitionBase._name, hcaldqm::DQModule._name, Logger._name, DrellYanValidation._name, WValidation._name, HistoParams< T >._name, CutApplicatorBase._name, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, ElectronMVAEstimatorRun2Spring15Trig._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15NonTrig._name, HistoParams< TH2F >._name, HistoParams< TProfile2D >._name, plotting.Subtract._name, plotting.FakeDuplicate._name, plotting.AggregateBins._name, Vispa.Views.PropertyView.Property._name, SequenceTypes.SequencePlaceholder._name, plotting.AggregateHistos._name, plotting.ROC._name, plotting.Plot._name, plotting.PlotGroup._name, and plotting.PlotterFolder._name.

Referenced by plotting.PlotterFolder.getSelectionName().

2032  def getSelectionNameIterator(self, dqmSubFolder):
2033  """Get a generator for the 'selection name', looping over the name and fallbackNames"""
2034  for name in [self._name]+self._fallbackNames:
2035  for selname in self._plotFolder.iterSelectionName(name, dqmSubFolder.translated if dqmSubFolder is not None else None):
2036  yield selname
def plotting.PlotterFolder.getTableCreators (   self)

Definition at line 2028 of file plotting.py.

References plotting.PlotterFolder._tableCreators.

2029  def getTableCreators(self):
2030  return self._tableCreators
def plotting.PlotterFolder.onlyForPileup (   self)

Definition at line 2007 of file plotting.py.

2008  def onlyForPileup(self):
2009  return self._plotFolder.onlyForPileup()

Member Data Documentation

plotting.PlotterFolder._dqmSubFolders
private

Definition at line 1977 of file plotting.py.

Referenced by plotting.PlotterFolder.getDQMSubFolders().

plotting.PlotterFolder._fallbackDqmSubFolders
private

Definition at line 1992 of file plotting.py.

Referenced by plotting.PlotterFolder.create(), and plotting.PlotterItem.readDirs().

plotting.PlotterFolder._fallbackNames
private

Definition at line 1991 of file plotting.py.

Referenced by plotting.PlotterFolder.getSelectionNameIterator(), and plotting.PlotterItem.readDirs().

plotting.PlotterFolder._name
private

Definition at line 1972 of file plotting.py.

Referenced by plotting.PlotterFolder.getName(), plotting.PlotterItem.getName(), plotting.PlotterFolder.getSelectionNameIterator(), validation.SimpleSample.name(), trackingPlots.Iteration.name(), and plotting.PlotterItem.readDirs().

plotting.PlotterFolder._plotFolder
private

Definition at line 1974 of file plotting.py.

Referenced by plotting.PlotterItem.getPlotFolder(), and plotting.PlotterItem.readDirs().

plotting.PlotterFolder._possibleDqmFolders
private

Definition at line 1973 of file plotting.py.

Referenced by plotting.PlotterFolder.create(), and plotting.PlotterFolder.getPossibleDQMFolders().

plotting.PlotterFolder._tableCreators
private

Definition at line 1993 of file plotting.py.

Referenced by plotting.PlotterFolder.getTableCreators(), and plotting.PlotterItem.readDirs().