/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Public Attributes
figures::FigureGenerator Class Reference

List of all members.

Public Member Functions

def __init__
def process
def openFile
def processPath
def makeDirectory

Public Attributes

 filename
 fileRoot
 diskRoot
 file
 format
 canvas

Detailed Description

Figure Generator Class

Definition at line 9 of file figures.py.


Constructor & Destructor Documentation

def figures::FigureGenerator::__init__ (   self,
  filename,
  fileRoot,
  diskRoot 
)

Definition at line 11 of file figures.py.

00012                                                     :
00013         "Constructor"
00014         self.filename = filename
00015         self.fileRoot = fileRoot
00016         self.diskRoot = diskRoot
00017         self.file = None
00018         self.format = "png"
00019         return


Member Function Documentation

def figures::FigureGenerator::process (   self)
Generate directories and figures

Definition at line 20 of file figures.py.

00021                      :
00022         """Generate directories and figures"""
00023         if not self.openFile():
00024             return
00025         self.processPath("")
00026         return
        
def figures::FigureGenerator::openFile (   self)

Definition at line 27 of file figures.py.

00028                       :
00029         "Open root file"
00030         import ROOT
00031         gROOT = ROOT.gROOT
00032         gROOT.SetBatch(True)
00033         # Avoid verbose output
00034         ROOT.gErrorIgnoreLevel = ROOT.kInfo
00035         gROOT.SetStyle("Plain")
00036         ROOT.gStyle.SetTitleFillColor(0)
00037         ROOT.gStyle.SetTitleBorderSize(0)
00038         ROOT.gStyle.SetPalette(1)
00039         # I don't like ROOT.  I have to set China timezone here
00040         # to get proper time axis in figure generation
00041         ROOT.gSystem.Setenv("TZ","PRC")
00042         rootFile = ROOT.TFile(self.filename)
00043         if not rootFile:
00044             print "Failed to open root file:",filename
00045             return False
00046         self.file = rootFile
00047         self.canvas = ROOT.TCanvas()
00048         return True

def figures::FigureGenerator::processPath (   self,
  itemPath 
)
Process a path in the current root file

Definition at line 49 of file figures.py.

00050                                    :
00051         """Process a path in the current root file"""
00052         #print "Processing:",itemPath
00053         filePath = self.fileRoot
00054         diskPath = self.diskRoot
00055         if len(itemPath)>0:
00056             filePath += "/"+itemPath
00057             diskPath += "/"+itemPath
00058         content = self.file.Get(filePath)
00059         if not content and itemPath=="":
00060             print "FIXME: Sim data has no run number"
00061             self.fileRoot = self.fileRoot[:-7] + "0000000"
00062             filePath = self.fileRoot
00063             content = self.file.Get(filePath)
00064         if not content:
00065             print "Failed to get item at: ", filePath
00066             return
00067         if content.IsA().InheritsFrom("TH1"):
00068             # Found a histogram.  Draw it.
00069             if content.IsA().InheritsFrom("TH2F"):
00070                 # Draw 2-D histograms with colz option
00071                 content.Draw("colz");
00072             elif content.IsA().InheritsFrom("TH1F"):
00073                 # Draw 1-D histograms with log scale
00074                 self.canvas.SetLogy(1)
00075                 content.Draw();
00076             else:
00077                 content.Draw();
00078             self.canvas.SaveAs(diskPath+"."+self.format)
00079             self.canvas.SetLogy(0)
00080         elif content.IsA().InheritsFrom("TGraph"):
00081             # Found a graph.  Draw it.
00082             content.Draw("APL");
00083             self.canvas.SaveAs(diskPath+"."+self.format)
00084         elif content.IsA().InheritsFrom("TDirectory"):
00085             self.makeDirectory(diskPath)
00086             keylist = content.GetListOfKeys()
00087             for key in keylist:
00088                 dirItem = key.ReadObj()
00089                 dirItemPath = None
00090                 if len(itemPath)>0:
00091                     dirItemPath = itemPath+"/"+dirItem.GetName()
00092                 else:
00093                     dirItemPath = dirItem.GetName()
00094                 self.processPath(dirItemPath)
00095         else:
00096             # Won't handle this object
00097             print "Not handing %s of type %s" % (filePath,content.ClassName())
00098         return

def figures::FigureGenerator::makeDirectory (   self,
  diskPath 
)
Make sure the output directory exists

Definition at line 99 of file figures.py.

00100                                      :
00101         """Make sure the output directory exists"""
00102         import os
00103         os.system("mkdir -p "+diskPath)
00104         return


Member Data Documentation

Definition at line 11 of file figures.py.

Definition at line 11 of file figures.py.

Definition at line 11 of file figures.py.

Definition at line 11 of file figures.py.

Definition at line 11 of file figures.py.

Definition at line 27 of file figures.py.


The documentation for this class was generated from the following file:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:54:09 for RunDiagnostics by doxygen 1.7.4