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 Member Functions | Private Attributes
plotting.Plotter Class Reference

Public Member Functions

def __init__
 
def append
 
def create
 
def draw
 
def getPossibleDirectoryNames
 
def set
 
def setPossibleDirectoryNames
 

Private Member Functions

def _getDir
 

Private Attributes

 _labels
 
 _plotGroups
 
 _possibleDirs
 
 _saveFormat
 

Detailed Description

Represent a collection of PlotGroups.

Definition at line 733 of file plotting.py.

Constructor & Destructor Documentation

def plotting.Plotter.__init__ (   self,
  possibleDirs,
  plotGroups,
  saveFormat = ".pdf" 
)
Constructor.

Arguments:
possibleDirs -- List of strings for possible directories of histograms in TFiles
plotGroups   -- List of PlotGroup objects
saveFormat   -- String specifying the plot format (default '.pdf')

Definition at line 735 of file plotting.py.

736  def __init__(self, possibleDirs, plotGroups, saveFormat=".pdf"):
737  """Constructor.
738 
739  Arguments:
740  possibleDirs -- List of strings for possible directories of histograms in TFiles
741  plotGroups -- List of PlotGroup objects
742  saveFormat -- String specifying the plot format (default '.pdf')
743  """
744  self._possibleDirs = possibleDirs
745  self._plotGroups = plotGroups
746  self._saveFormat = saveFormat
747 
748  ROOT.gROOT.SetStyle("Plain")
749  ROOT.gStyle.SetPadRightMargin(0.07)
750  ROOT.gStyle.SetPadLeftMargin(0.13)
751  ROOT.gStyle.SetTitleFont(42, "XYZ")
752  ROOT.gStyle.SetTitleSize(0.05, "XYZ")
753  ROOT.gStyle.SetTitleOffset(1.2, "Y")
754  #ROOT.gStyle.SetTitleFontSize(0.05)
755  ROOT.gStyle.SetLabelFont(42, "XYZ")
756  ROOT.gStyle.SetLabelSize(0.05, "XYZ")
757  ROOT.gStyle.SetTextSize(0.05)
758 
759  ROOT.TH1.AddDirectory(False)

Member Function Documentation

def plotting.Plotter._getDir (   self,
  tfile,
  subdir 
)
private
Get TDirectory from TFile.

Definition at line 773 of file plotting.py.

References plotting.Plotter._possibleDirs, and join().

774  def _getDir(self, tfile, subdir):
775  """Get TDirectory from TFile."""
776  if tfile is None:
777  return None
778  for pd in self._possibleDirs:
779  d = tfile.Get(pd)
780  if d:
781  if subdir is not None:
782  # Pick associator if given
783  d = d.Get(subdir)
784  if d:
785  return d
786  else:
787  msg = "Did not find subdirectory '%s' from directory '%s' in file %s" % (subdir, pd, tfile.GetName())
788  if missingOk:
789  print msg
790  return None
791  else:
792  raise Exception(msg)
793  else:
794  return d
795  msg = "Did not find any of directories '%s' from file %s" % (",".join(self._possibleDirs), tfile.GetName())
796  if missingOk:
797  print msg
798  return None
799  else:
800  raise Exception(msg)
static std::string join(char **cmd)
Definition: RemoteFile.cc:18
def plotting.Plotter.append (   self,
  plotGroup 
)

Definition at line 767 of file plotting.py.

Referenced by diclist.diclist.add(), and BeautifulSoup.Tag.setString().

768  def append(self, plotGroup):
769  self._plotGroups.append(plotGroup)
def plotting.Plotter.create (   self,
  files,
  labels,
  subdir = None 
)
Create histograms from a list of TFiles.

Arguments:
files  -- List of TFiles
labels -- List of strings for legend labels corresponding the files
subdir -- Optional string for subdirectory inside the possibleDirs; if list of strings, then each corresponds to a TFile

Definition at line 801 of file plotting.py.

802  def create(self, files, labels, subdir=None):
803  """Create histograms from a list of TFiles.
804 
805  Arguments:
806  files -- List of TFiles
807  labels -- List of strings for legend labels corresponding the files
808  subdir -- Optional string for subdirectory inside the possibleDirs; if list of strings, then each corresponds to a TFile
809  """
810  dirs = []
811  self._labels = []
812  if isinstance(subdir, list):
813  for f, l, s in zip(files, labels, subdir):
814  d = self._getDir(f, s)
815  dirs.append(d)
816  self._labels.append(l)
817  else:
818  for f, l in zip(files, labels):
819  d = self._getDir(f, subdir)
820  dirs.append(d)
821  self._labels.append(l)
822 
823  for pg in self._plotGroups:
824  pg.create(dirs)
def plotting.Plotter.draw (   self,
  algo,
  prefix = None,
  separate = False,
  saveFormat = None 
)
Draw and save all plots using settings of a given algorithm.

Arguments:
algo     -- String for the algorithm
prefix   -- Optional string for file name prefix (default None)
separate -- Save the plots of a group to separate files instead of a file per group (default False)
saveFormat -- If given, overrides the saveFormat

Definition at line 825 of file plotting.py.

References DigiInvestigatorHistogramMaker._labels, SeedMultiplicityAnalyzer._labels, hitfit::Constraint_Intermed_Labels._labels, plotting.Plotter._labels, plotting.Plotter._plotGroups, and plotting.Plotter._saveFormat.

826  def draw(self, algo, prefix=None, separate=False, saveFormat=None):
827  """Draw and save all plots using settings of a given algorithm.
828 
829  Arguments:
830  algo -- String for the algorithm
831  prefix -- Optional string for file name prefix (default None)
832  separate -- Save the plots of a group to separate files instead of a file per group (default False)
833  saveFormat -- If given, overrides the saveFormat
834  """
835  ret = []
836 
837  sf = self._saveFormat
838  if saveFormat is not None:
839  sf = saveFormat
840 
841  for pg in self._plotGroups:
842  ret.extend(pg.draw(algo, self._labels, prefix=prefix, separate=separate, saveFormat=sf))
843  return ret
844 
def plotting.Plotter.getPossibleDirectoryNames (   self)
Return the list of possible directory names.

Definition at line 763 of file plotting.py.

References plotting.Plotter._possibleDirs.

764  def getPossibleDirectoryNames(self):
765  """Return the list of possible directory names."""
766  return self._possibleDirs
def getPossibleDirectoryNames
Definition: plotting.py:763
def plotting.Plotter.set (   self,
  plotGroups 
)

Definition at line 770 of file plotting.py.

References plotting.Plotter._plotGroups.

Referenced by betterConfigParser.BetterConfigParser.getGeneral().

771  def set(self, plotGroups):
772  self._plotGroups = plotGroups
def plotting.Plotter.setPossibleDirectoryNames (   self,
  possibleDirs 
)

Definition at line 760 of file plotting.py.

References plotting.Plotter._possibleDirs.

761  def setPossibleDirectoryNames(self, possibleDirs):
762  self._possibleDirs = possibleDirs
def setPossibleDirectoryNames
Definition: plotting.py:760

Member Data Documentation

plotting.Plotter._labels
private

Definition at line 810 of file plotting.py.

Referenced by validation.SimpleValidation._doPlots(), and plotting.Plotter.draw().

plotting.Plotter._plotGroups
private

Definition at line 744 of file plotting.py.

Referenced by plotting.Plotter.draw(), and plotting.Plotter.set().

plotting.Plotter._possibleDirs
private

Definition at line 743 of file plotting.py.

Referenced by plotting.Plotter._getDir(), plotting.Plotter.getPossibleDirectoryNames(), and plotting.Plotter.setPossibleDirectoryNames().

plotting.Plotter._saveFormat
private

Definition at line 745 of file plotting.py.

Referenced by plotting.Plotter.draw().