CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
plotting.PlotterFolder Class Reference

Public Member Functions

def __init__ (self, name, possibleDqmFolders, dqmSubFolders, plotFolder, fallbackNames, fallbackDqmSubFolders, tableCreators)
 
def create (self, files, labels, dqmSubFolder, isPileupSample=True, requireAllHistograms=False)
 
def draw (self, args, kwargs)
 
def getDQMSubFolders (self, limitOnlyTo=None)
 
def getName (self)
 
def getPage (self)
 
def getPossibleDQMFolders (self)
 
def getPurpose (self)
 
def getSection (self)
 
def getSelectionName (self, dqmSubFolder)
 
def getSelectionNameIterator (self, dqmSubFolder)
 
def getTableCreators (self)
 
def onlyForBHadron (self)
 
def onlyForConversion (self)
 
def onlyForElectron (self)
 
def onlyForPileup (self)
 

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 2692 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 2699 of file plotting.py.

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

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 2789 of file plotting.py.

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

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

Definition at line 2823 of file plotting.py.

2823  def draw(self, *args, **kwargs):
2824  """Draw and save all plots using settings of a given algorithm."""
2825  return self._plotFolder.draw(*args, **kwargs)
2826 
2827 
def draw(self, args, kwargs)
Definition: plotting.py:2823
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 2762 of file plotting.py.

References plotting.PlotterFolder._dqmSubFolders.

2762  def getDQMSubFolders(self, limitOnlyTo=None):
2763  """Get list of subfolders, possibly limiting to some of them.
2764 
2765  Keyword arguments:
2766  limitOnlyTo -- Object depending on the PlotFolder type for limiting the set of subfolders to be processed
2767  """
2768 
2769  if self._dqmSubFolders is None:
2770  return [None]
2771 
2772  if limitOnlyTo is None:
2773  return self._dqmSubFolders
2774 
2775  return [s for s in self._dqmSubFolders if self._plotFolder.limitSubFolder(limitOnlyTo, s.translated)]
2776 
def getDQMSubFolders(self, limitOnlyTo=None)
Definition: plotting.py:2762
def plotting.PlotterFolder.getName (   self)
def plotting.PlotterFolder.getPage (   self)

Definition at line 2741 of file plotting.py.

2741  def getPage(self):
2742  return self._plotFolder.getPage()
2743 
def plotting.PlotterFolder.getPossibleDQMFolders (   self)

Definition at line 2759 of file plotting.py.

References plotting.PlotterFolder._possibleDqmFolders.

2760  return self._possibleDqmFolders
2761 
def getPossibleDQMFolders(self)
Definition: plotting.py:2759
def plotting.PlotterFolder.getPurpose (   self)

Definition at line 2738 of file plotting.py.

2738  def getPurpose(self):
2739  return self._plotFolder.getPurpose()
2740 
def plotting.PlotterFolder.getSection (   self)

Definition at line 2744 of file plotting.py.

2744  def getSection(self):
2745  return self._plotFolder.getSection()
2746 
def plotting.PlotterFolder.getSelectionName (   self,
  dqmSubFolder 
)

Definition at line 2786 of file plotting.py.

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

2786  def getSelectionName(self, dqmSubFolder):
2787  return next(self.getSelectionNameIterator(dqmSubFolder))
2788 
def getSelectionName(self, dqmSubFolder)
Definition: plotting.py:2786
def getSelectionNameIterator(self, dqmSubFolder)
Definition: plotting.py:2780
def plotting.PlotterFolder.getSelectionNameIterator (   self,
  dqmSubFolder 
)
Get a generator for the 'selection name', looping over the name and fallbackNames

Definition at line 2780 of file plotting.py.

References plotting.PlotterFolder._fallbackNames, TrackerHitsObject._name, FP420HitsObject._name, PGeometricDet::Item._name, LikelihoodSpecies._name, TrackingRecHitAlgorithm._name, LikelihoodPdfProduct._name, Logger._name, hcaldqm::DQModule._name, LikelihoodPdf._name, citk::IsolationConeDefinitionBase._name, DrellYanValidation._name, WValidation._name, hcaldqm::flag::Flag._name, hcaldqm::quantity::Quantity._name, HistoParams< T >._name, GeometricTimingDetExtra._name, CutApplicatorBase._name, GeometricDetExtra._name, HistoParams< TH2F >._name, HistoParams< TProfile2D >._name, Vispa.Views.PropertyView.Property._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().

2780  def getSelectionNameIterator(self, dqmSubFolder):
2781  """Get a generator for the 'selection name', looping over the name and fallbackNames"""
2782  for name in [self._name]+self._fallbackNames:
2783  for selname in self._plotFolder.iterSelectionName(name, dqmSubFolder.translated if dqmSubFolder is not None else None):
2784  yield selname
2785 
def getSelectionNameIterator(self, dqmSubFolder)
Definition: plotting.py:2780
def plotting.PlotterFolder.getTableCreators (   self)

Definition at line 2777 of file plotting.py.

References plotting.PlotterFolder._tableCreators.

2777  def getTableCreators(self):
2778  return self._tableCreators
2779 
def getTableCreators(self)
Definition: plotting.py:2777
def plotting.PlotterFolder.onlyForBHadron (   self)

Definition at line 2756 of file plotting.py.

2756  def onlyForBHadron(self):
2757  return self._plotFolder.onlyForBHadron()
2758 
def onlyForBHadron(self)
Definition: plotting.py:2756
def plotting.PlotterFolder.onlyForConversion (   self)

Definition at line 2753 of file plotting.py.

2754  return self._plotFolder.onlyForConversion()
2755 
def onlyForConversion(self)
Definition: plotting.py:2753
def plotting.PlotterFolder.onlyForElectron (   self)

Definition at line 2750 of file plotting.py.

2750  def onlyForElectron(self):
2751  return self._plotFolder.onlyForElectron()
2752 
def onlyForElectron(self)
Definition: plotting.py:2750
def plotting.PlotterFolder.onlyForPileup (   self)

Definition at line 2747 of file plotting.py.

2747  def onlyForPileup(self):
2748  return self._plotFolder.onlyForPileup()
2749 
def onlyForPileup(self)
Definition: plotting.py:2747

Member Data Documentation

plotting.PlotterFolder._dqmSubFolders
private

Definition at line 2717 of file plotting.py.

Referenced by plotting.PlotterFolder.getDQMSubFolders().

plotting.PlotterFolder._fallbackDqmSubFolders
private

Definition at line 2732 of file plotting.py.

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

plotting.PlotterFolder._fallbackNames
private
plotting.PlotterFolder._name
private
plotting.PlotterFolder._plotFolder
private
plotting.PlotterFolder._possibleDqmFolders
private
plotting.PlotterFolder._tableCreators
private