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

2520  def __init__(self, name, possibleDqmFolders, dqmSubFolders, plotFolder, fallbackNames, fallbackDqmSubFolders, tableCreators):
2521  """
2522  Constructor
2523 
2524  Arguments:
2525  name -- Name of the folder (is used in the output directory naming)
2526  possibleDqmFolders -- List of strings for possible directories of histograms in TFiles
2527  dqmSubFolders -- List of lists of strings for list of subfolders per input file, or None if no subfolders
2528  plotFolder -- PlotFolder object
2529  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.
2530  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.
2531  tableCreators -- List of PlotterTableItem objects for tables to be created from this folder
2532  """
2533  self._name = name
2534  self._possibleDqmFolders = possibleDqmFolders
2535  self._plotFolder = plotFolder
2536  #self._dqmSubFolders = [map(lambda sf: DQMSubFolder(sf, self._plotFolder.translateSubFolder(sf)), lst) for lst in dqmSubFolders]
2537  if dqmSubFolders is None:
2538  self._dqmSubFolders = None
2539  else:
2540  # Match the subfolders between files in case the lists differ
2541  # equality is by the 'translated' name
2542  subfolders = {}
2543  for sf_list in dqmSubFolders:
2544  for sf in sf_list:
2545  sf_translated = self._plotFolder.translateSubFolder(sf)
2546  if sf_translated is not None and not sf_translated in subfolders:
2547  subfolders[sf_translated] = DQMSubFolder(sf, sf_translated)
2548 
2549  self._dqmSubFolders = subfolders.values()
2550  self._dqmSubFolders.sort(key=lambda sf: sf.subfolder)
2551 
2552  self._fallbackNames = fallbackNames
2553  self._fallbackDqmSubFolders = fallbackDqmSubFolders
2554  self._tableCreators = tableCreators
2555 
def __init__(self, name, possibleDqmFolders, dqmSubFolders, plotFolder, fallbackNames, fallbackDqmSubFolders, tableCreators)
Definition: plotting.py:2520

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

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

2607  def create(self, files, labels, dqmSubFolder, isPileupSample=True, requireAllHistograms=False):
2608  """Create histograms from a list of TFiles.
2609  Arguments:
2610  files -- List of TFiles
2611  labels -- List of strings for legend labels corresponding the files
2612  dqmSubFolder -- DQMSubFolder object for a subfolder (or None for no subfolder)
2613  isPileupSample -- Is sample pileup (some PlotGroups may limit themselves to pileup)
2614  requireAllHistograms -- If True, a plot is produced if histograms from all files are present (default: False)
2615  """
2616 
2617  subfolder = dqmSubFolder.subfolder if dqmSubFolder is not None else None
2618  neventsHisto = self._plotFolder.getNumberOfEventsHistogram()
2619  dirsNEvents = []
2620 
2621  for tfile in files:
2622  ret = _getDirectoryDetailed(tfile, self._possibleDqmFolders, subfolder)
2623  # If file and any of possibleDqmFolders exist but subfolder does not, try the fallbacks
2625  for fallbackFunc in self._fallbackDqmSubFolders:
2626  fallback = fallbackFunc(subfolder)
2627  if fallback is not None:
2628  ret = _getDirectoryDetailed(tfile, self._possibleDqmFolders, fallback)
2629  if ret is not GetDirectoryCode.SubDirNotExist:
2630  break
2631  d = GetDirectoryCode.codesToNone(ret)
2632  nev = None
2633  if neventsHisto is not None and tfile is not None:
2634  hnev = _getObject(tfile, neventsHisto)
2635  if hnev is not None:
2636  nev = hnev.GetEntries()
2637  dirsNEvents.append( (d, nev) )
2638 
2639  self._plotFolder.create(dirsNEvents, labels, isPileupSample, requireAllHistograms)
2640 
def _getDirectoryDetailed(tfile, possibleDirs, subDir=None)
Definition: plotting.py:69
def create(self, files, labels, dqmSubFolder, isPileupSample=True, requireAllHistograms=False)
Definition: plotting.py:2607
def _getObject(tdirectory, name)
Definition: plotting.py:45
def plotting.PlotterFolder.draw (   self,
  args,
  kwargs 
)
Draw and save all plots using settings of a given algorithm.

Definition at line 2641 of file plotting.py.

2641  def draw(self, *args, **kwargs):
2642  """Draw and save all plots using settings of a given algorithm."""
2643  return self._plotFolder.draw(*args, **kwargs)
2644 
2645 
def draw(self, args, kwargs)
Definition: plotting.py:2641
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 2580 of file plotting.py.

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

2580  def getDQMSubFolders(self, limitOnlyTo=None):
2581  """Get list of subfolders, possibly limiting to some of them.
2582 
2583  Keyword arguments:
2584  limitOnlyTo -- Object depending on the PlotFolder type for limiting the set of subfolders to be processed
2585  """
2586 
2587  if self._dqmSubFolders is None:
2588  return [None]
2589 
2590  if limitOnlyTo is None:
2591  return self._dqmSubFolders
2592 
2593  return filter(lambda s: self._plotFolder.limitSubFolder(limitOnlyTo, s.translated), self._dqmSubFolders)
2594 
def getDQMSubFolders(self, limitOnlyTo=None)
Definition: plotting.py:2580
def plotting.PlotterFolder.getName (   self)
def plotting.PlotterFolder.getPage (   self)

Definition at line 2562 of file plotting.py.

2562  def getPage(self):
2563  return self._plotFolder.getPage()
2564 
def plotting.PlotterFolder.getPossibleDQMFolders (   self)

Definition at line 2577 of file plotting.py.

References plotting.PlotterFolder._possibleDqmFolders.

2578  return self._possibleDqmFolders
2579 
def getPossibleDQMFolders(self)
Definition: plotting.py:2577
def plotting.PlotterFolder.getPurpose (   self)

Definition at line 2559 of file plotting.py.

2559  def getPurpose(self):
2560  return self._plotFolder.getPurpose()
2561 
def plotting.PlotterFolder.getSection (   self)

Definition at line 2565 of file plotting.py.

2565  def getSection(self):
2566  return self._plotFolder.getSection()
2567 
def plotting.PlotterFolder.getSelectionName (   self,
  dqmSubFolder 
)

Definition at line 2604 of file plotting.py.

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

2604  def getSelectionName(self, dqmSubFolder):
2605  return next(self.getSelectionNameIterator(dqmSubFolder))
2606 
def getSelectionName(self, dqmSubFolder)
Definition: plotting.py:2604
def getSelectionNameIterator(self, dqmSubFolder)
Definition: plotting.py:2598
def plotting.PlotterFolder.getSelectionNameIterator (   self,
  dqmSubFolder 
)
Get a generator for the 'selection name', looping over the name and fallbackNames

Definition at line 2598 of file plotting.py.

References plotting.PlotterFolder._fallbackNames, FP420HitsObject._name, TrackerHitsObject._name, PGeometricDet::Item._name, TrackingRecHitAlgorithm._name, LikelihoodSpecies._name, L1TMuon::PtAssignmentUnit._name, L1TMuon::PtRefinementUnit._name, LikelihoodPdfProduct._name, LikelihoodPdf._name, citk::IsolationConeDefinitionBase._name, Logger._name, hcaldqm::DQModule._name, DrellYanValidation._name, WValidation._name, HistoParams< T >._name, hcaldqm::flag::Flag._name, hcaldqm::quantity::Quantity._name, CutApplicatorBase._name, ElectronMVAEstimatorRun2Phys14NonTrig._name, PhotonMVAEstimatorRun2Spring15NonTrig._name, PhotonMVAEstimatorRun2Phys14NonTrig._name, ElectronMVAEstimatorRun2Spring15Trig._name, GeometricDetExtra._name, ElectronMVAEstimatorRun2Spring15NonTrig._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, plotting.Plot._name, plotting.PlotGroup._name, and plotting.PlotterFolder._name.

Referenced by plotting.PlotterFolder.getSelectionName().

2598  def getSelectionNameIterator(self, dqmSubFolder):
2599  """Get a generator for the 'selection name', looping over the name and fallbackNames"""
2600  for name in [self._name]+self._fallbackNames:
2601  for selname in self._plotFolder.iterSelectionName(name, dqmSubFolder.translated if dqmSubFolder is not None else None):
2602  yield selname
2603 
def getSelectionNameIterator(self, dqmSubFolder)
Definition: plotting.py:2598
def plotting.PlotterFolder.getTableCreators (   self)

Definition at line 2595 of file plotting.py.

References plotting.PlotterFolder._tableCreators.

2595  def getTableCreators(self):
2596  return self._tableCreators
2597 
def getTableCreators(self)
Definition: plotting.py:2595
def plotting.PlotterFolder.onlyForConversion (   self)

Definition at line 2574 of file plotting.py.

2575  return self._plotFolder.onlyForConversion()
2576 
def onlyForConversion(self)
Definition: plotting.py:2574
def plotting.PlotterFolder.onlyForElectron (   self)

Definition at line 2571 of file plotting.py.

2571  def onlyForElectron(self):
2572  return self._plotFolder.onlyForElectron()
2573 
def onlyForElectron(self)
Definition: plotting.py:2571
def plotting.PlotterFolder.onlyForPileup (   self)

Definition at line 2568 of file plotting.py.

2568  def onlyForPileup(self):
2569  return self._plotFolder.onlyForPileup()
2570 
def onlyForPileup(self)
Definition: plotting.py:2568

Member Data Documentation

plotting.PlotterFolder._dqmSubFolders
private

Definition at line 2538 of file plotting.py.

Referenced by plotting.PlotterFolder.getDQMSubFolders().

plotting.PlotterFolder._fallbackDqmSubFolders
private

Definition at line 2553 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