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

Constructor & Destructor Documentation

◆ __init__()

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

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

Member Function Documentation

◆ create()

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

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

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

◆ draw()

def plotting.PlotterFolder.draw (   self,
args,
**  kwargs 
)
Draw and save all plots using settings of a given algorithm.

Definition at line 2827 of file plotting.py.

2827  def draw(self, *args, **kwargs):
2828  """Draw and save all plots using settings of a given algorithm."""
2829  return self._plotFolder.draw(*args, **kwargs)
2830 
2831 

References plotting.PlotterFolder._plotFolder.

◆ getDQMSubFolders()

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

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

References plotting.PlotterFolder._dqmSubFolders, and plotting.PlotterFolder._plotFolder.

◆ getName()

def plotting.PlotterFolder.getName (   self)

◆ getPage()

def plotting.PlotterFolder.getPage (   self)

Definition at line 2745 of file plotting.py.

2745  def getPage(self):
2746  return self._plotFolder.getPage()
2747 

References plotting.PlotterFolder._plotFolder.

◆ getPossibleDQMFolders()

def plotting.PlotterFolder.getPossibleDQMFolders (   self)

Definition at line 2763 of file plotting.py.

2763  def getPossibleDQMFolders(self):
2764  return self._possibleDqmFolders
2765 

References plotting.PlotterFolder._possibleDqmFolders.

◆ getPurpose()

def plotting.PlotterFolder.getPurpose (   self)

Definition at line 2742 of file plotting.py.

2742  def getPurpose(self):
2743  return self._plotFolder.getPurpose()
2744 

References plotting.PlotterFolder._plotFolder.

◆ getSection()

def plotting.PlotterFolder.getSection (   self)

Definition at line 2748 of file plotting.py.

2748  def getSection(self):
2749  return self._plotFolder.getSection()
2750 

References plotting.PlotterFolder._plotFolder.

◆ getSelectionName()

def plotting.PlotterFolder.getSelectionName (   self,
  dqmSubFolder 
)

Definition at line 2790 of file plotting.py.

2790  def getSelectionName(self, dqmSubFolder):
2791  return next(self.getSelectionNameIterator(dqmSubFolder))
2792 

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

◆ getSelectionNameIterator()

def plotting.PlotterFolder.getSelectionNameIterator (   self,
  dqmSubFolder 
)

◆ getTableCreators()

def plotting.PlotterFolder.getTableCreators (   self)

Definition at line 2781 of file plotting.py.

2781  def getTableCreators(self):
2782  return self._tableCreators
2783 

References plotting.PlotterFolder._tableCreators.

◆ onlyForBHadron()

def plotting.PlotterFolder.onlyForBHadron (   self)

Definition at line 2760 of file plotting.py.

2760  def onlyForBHadron(self):
2761  return self._plotFolder.onlyForBHadron()
2762 

References plotting.PlotterFolder._plotFolder.

◆ onlyForConversion()

def plotting.PlotterFolder.onlyForConversion (   self)

Definition at line 2757 of file plotting.py.

2757  def onlyForConversion(self):
2758  return self._plotFolder.onlyForConversion()
2759 

References plotting.PlotterFolder._plotFolder.

◆ onlyForElectron()

def plotting.PlotterFolder.onlyForElectron (   self)

Definition at line 2754 of file plotting.py.

2754  def onlyForElectron(self):
2755  return self._plotFolder.onlyForElectron()
2756 

References plotting.PlotterFolder._plotFolder.

◆ onlyForPileup()

def plotting.PlotterFolder.onlyForPileup (   self)

Definition at line 2751 of file plotting.py.

2751  def onlyForPileup(self):
2752  return self._plotFolder.onlyForPileup()
2753 

References plotting.PlotterFolder._plotFolder.

Member Data Documentation

◆ _dqmSubFolders

plotting.PlotterFolder._dqmSubFolders
private

Definition at line 2721 of file plotting.py.

Referenced by plotting.PlotterFolder.getDQMSubFolders().

◆ _fallbackDqmSubFolders

plotting.PlotterFolder._fallbackDqmSubFolders
private

Definition at line 2736 of file plotting.py.

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

◆ _fallbackNames

plotting.PlotterFolder._fallbackNames
private

◆ _name

plotting.PlotterFolder._name
private

◆ _plotFolder

plotting.PlotterFolder._plotFolder
private

◆ _possibleDqmFolders

plotting.PlotterFolder._possibleDqmFolders
private

◆ _tableCreators

plotting.PlotterFolder._tableCreators
private
ntuplePlotting.draw
def draw(name, histos, styles=_defaultStyles, legendLabels=[], **kwargs)
Definition: ntuplePlotting.py:25
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
getName
TString getName(TString structure, int layer, TString geometry)
Definition: DMRtrends.cc:235
plotting._getDirectoryDetailed
def _getDirectoryDetailed(tfile, possibleDirs, subDir=None)
Definition: plotting.py:74
trackingPlots.onlyForPileup
onlyForPileup
Definition: trackingPlots.py:309
plotting._getObject
def _getObject(tdirectory, name)
Definition: plotting.py:50
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31