CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 onlyForBHadron
 
def onlyForConversion
 
def onlyForElectron
 
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 2703 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 2710 of file plotting.py.

2711  def __init__(self, name, possibleDqmFolders, dqmSubFolders, plotFolder, fallbackNames, fallbackDqmSubFolders, tableCreators):
2712  """
2713  Constructor
2714 
2715  Arguments:
2716  name -- Name of the folder (is used in the output directory naming)
2717  possibleDqmFolders -- List of strings for possible directories of histograms in TFiles
2718  dqmSubFolders -- List of lists of strings for list of subfolders per input file, or None if no subfolders
2719  plotFolder -- PlotFolder object
2720  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.
2721  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.
2722  tableCreators -- List of PlotterTableItem objects for tables to be created from this folder
2723  """
2724  self._name = name
2725  self._possibleDqmFolders = possibleDqmFolders
2726  self._plotFolder = plotFolder
2727  #self._dqmSubFolders = [map(lambda sf: DQMSubFolder(sf, self._plotFolder.translateSubFolder(sf)), lst) for lst in dqmSubFolders]
2728  if dqmSubFolders is None:
2729  self._dqmSubFolders = None
2730  else:
2731  # Match the subfolders between files in case the lists differ
2732  # equality is by the 'translated' name
2733  subfolders = {}
2734  for sf_list in dqmSubFolders:
2735  for sf in sf_list:
2736  sf_translated = self._plotFolder.translateSubFolder(sf)
2737  if sf_translated is not None and not sf_translated in subfolders:
2738  subfolders[sf_translated] = DQMSubFolder(sf, sf_translated)
2739 
2740  self._dqmSubFolders = sorted(subfolders.values(), key=lambda sf: sf.subfolder)
2742  self._fallbackNames = fallbackNames
2743  self._fallbackDqmSubFolders = fallbackDqmSubFolders
2744  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 2799 of file plotting.py.

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

2800  def create(self, files, labels, dqmSubFolder, isPileupSample=True, requireAllHistograms=False):
2801  """Create histograms from a list of TFiles.
2802  Arguments:
2803  files -- List of TFiles
2804  labels -- List of strings for legend labels corresponding the files
2805  dqmSubFolder -- DQMSubFolder object for a subfolder (or None for no subfolder)
2806  isPileupSample -- Is sample pileup (some PlotGroups may limit themselves to pileup)
2807  requireAllHistograms -- If True, a plot is produced if histograms from all files are present (default: False)
2808  """
2809 
2810  subfolder = dqmSubFolder.subfolder if dqmSubFolder is not None else None
2811  neventsHisto = self._plotFolder.getNumberOfEventsHistogram()
2812  dirsNEvents = []
2813 
2814  for tfile in files:
2815  ret = _getDirectoryDetailed(tfile, self._possibleDqmFolders, subfolder)
2816  # If file and any of possibleDqmFolders exist but subfolder does not, try the fallbacks
2818  for fallbackFunc in self._fallbackDqmSubFolders:
2819  fallback = fallbackFunc(subfolder)
2820  if fallback is not None:
2821  ret = _getDirectoryDetailed(tfile, self._possibleDqmFolders, fallback)
2822  if ret is not GetDirectoryCode.SubDirNotExist:
2823  break
2824  d = GetDirectoryCode.codesToNone(ret)
2825  nev = None
2826  if neventsHisto is not None and tfile is not None:
2827  hnev = _getObject(tfile, neventsHisto)
2828  if hnev is not None:
2829  nev = hnev.GetEntries()
2830  dirsNEvents.append( (d, nev) )
2831 
2832  self._plotFolder.create(dirsNEvents, labels, isPileupSample, requireAllHistograms)
def _getObject
Definition: plotting.py:49
def _getDirectoryDetailed
Definition: plotting.py:73
def plotting.PlotterFolder.draw (   self,
  args,
  kwargs 
)
Draw and save all plots using settings of a given algorithm.

Definition at line 2833 of file plotting.py.

2834  def draw(self, *args, **kwargs):
2835  """Draw and save all plots using settings of a given algorithm."""
2836  return self._plotFolder.draw(*args, **kwargs)
2837 
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 2772 of file plotting.py.

References plotting.PlotterFolder._dqmSubFolders.

2773  def getDQMSubFolders(self, limitOnlyTo=None):
2774  """Get list of subfolders, possibly limiting to some of them.
2775 
2776  Keyword arguments:
2777  limitOnlyTo -- Object depending on the PlotFolder type for limiting the set of subfolders to be processed
2778  """
2779 
2780  if self._dqmSubFolders is None:
2781  return [None]
2782 
2783  if limitOnlyTo is None:
2784  return self._dqmSubFolders
2785 
2786  return [s for s in self._dqmSubFolders if self._plotFolder.limitSubFolder(limitOnlyTo, s.translated)]
def plotting.PlotterFolder.getName (   self)

Definition at line 2745 of file plotting.py.

References FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, TrackingRecHitAlgorithm._name, Logger._name, hcaldqm::DQModule._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, hcaldqm::flag::Flag._name, hcaldqm::quantity::Quantity._name, HistoParams< T >._name, CutApplicatorBase._name, HistoParams< TH2F >._name, HistoParams< TProfile2D >._name, SequenceTypes.SequencePlaceholder._name, plotting.Subtract._name, plotting.Transform._name, plotting.FakeDuplicate._name, plotting.CutEfficiency._name, plotting.AggregateBins._name, plotting.AggregateHistos._name, plotting.ROC._name, SequenceTypes.TaskPlaceholder._name, plotting.Plot._name, plotting.PlotGroup._name, and plotting.PlotterFolder._name.

2746  def getName(self):
2747  return self._name
def plotting.PlotterFolder.getPage (   self)

Definition at line 2751 of file plotting.py.

2752  def getPage(self):
2753  return self._plotFolder.getPage()
def plotting.PlotterFolder.getPossibleDQMFolders (   self)

Definition at line 2769 of file plotting.py.

References plotting.PlotterFolder._possibleDqmFolders.

2770  def getPossibleDQMFolders(self):
2771  return self._possibleDqmFolders
def plotting.PlotterFolder.getPurpose (   self)

Definition at line 2748 of file plotting.py.

2749  def getPurpose(self):
2750  return self._plotFolder.getPurpose()
def plotting.PlotterFolder.getSection (   self)

Definition at line 2754 of file plotting.py.

2755  def getSection(self):
2756  return self._plotFolder.getSection()
def plotting.PlotterFolder.getSelectionName (   self,
  dqmSubFolder 
)

Definition at line 2796 of file plotting.py.

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

2797  def getSelectionName(self, dqmSubFolder):
2798  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 2790 of file plotting.py.

References plotting.PlotterFolder._fallbackNames, FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, TrackingRecHitAlgorithm._name, Logger._name, hcaldqm::DQModule._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, hcaldqm::flag::Flag._name, hcaldqm::quantity::Quantity._name, HistoParams< T >._name, CutApplicatorBase._name, HistoParams< TH2F >._name, HistoParams< TProfile2D >._name, SequenceTypes.SequencePlaceholder._name, plotting.Subtract._name, plotting.Transform._name, plotting.FakeDuplicate._name, plotting.CutEfficiency._name, plotting.AggregateBins._name, plotting.AggregateHistos._name, plotting.ROC._name, SequenceTypes.TaskPlaceholder._name, plotting.Plot._name, plotting.PlotGroup._name, and plotting.PlotterFolder._name.

Referenced by plotting.PlotterFolder.getSelectionName().

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

Definition at line 2787 of file plotting.py.

References plotting.PlotterFolder._tableCreators.

2788  def getTableCreators(self):
2789  return self._tableCreators
def plotting.PlotterFolder.onlyForBHadron (   self)

Definition at line 2766 of file plotting.py.

2767  def onlyForBHadron(self):
2768  return self._plotFolder.onlyForBHadron()
def plotting.PlotterFolder.onlyForConversion (   self)

Definition at line 2763 of file plotting.py.

2764  def onlyForConversion(self):
2765  return self._plotFolder.onlyForConversion()
def plotting.PlotterFolder.onlyForElectron (   self)

Definition at line 2760 of file plotting.py.

2761  def onlyForElectron(self):
2762  return self._plotFolder.onlyForElectron()
def plotting.PlotterFolder.onlyForPileup (   self)

Definition at line 2757 of file plotting.py.

2758  def onlyForPileup(self):
2759  return self._plotFolder.onlyForPileup()

Member Data Documentation

plotting.PlotterFolder._dqmSubFolders
private

Definition at line 2728 of file plotting.py.

Referenced by plotting.PlotterFolder.getDQMSubFolders().

plotting.PlotterFolder._fallbackDqmSubFolders
private

Definition at line 2742 of file plotting.py.

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

plotting.PlotterFolder._fallbackNames
private

Definition at line 2741 of file plotting.py.

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

plotting.PlotterFolder._name
private

Definition at line 2723 of file plotting.py.

Referenced by trackingPlots.TimePerEventPlot.__str__(), trackingPlots.TimePerTrackPlot.__str__(), trackingPlots.TimePerEventPlot._create(), trackingPlots.TimePerTrackPlot.create(), 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 2725 of file plotting.py.

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

plotting.PlotterFolder._possibleDqmFolders
private

Definition at line 2724 of file plotting.py.

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

plotting.PlotterFolder._tableCreators
private

Definition at line 2743 of file plotting.py.

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