| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

MergeStats::MergeAlg Class Reference

List of all members.

Public Member Functions

def __init__
def initialize
def execute
def finalize
def mergePaths
def mergeObjects
def error

Public Attributes

 Input
 Output
 DontAdd
 msgSvc
 statsSvc

Detailed Description

Definition at line 22 of file MergeStats.py.


Member Function Documentation

def MergeStats::MergeAlg::__init__ (   self,
  name 
)

Definition at line 24 of file MergeStats.py.

00024                            :
00025         GaudiAlgo.__init__(self,name)
00026         self.Input  = ['file1', 'file2']
00027         self.Output = 'file0'
00028         self.DontAdd = []
00029         return
00030 
    def initialize(self):

def MergeStats::MergeAlg::initialize (   self  ) 

Definition at line 31 of file MergeStats.py.

00031                         :
00032         status = GaudiAlgo.initialize(self)
00033         print "Init MergeAlg",self.name()
00034         if status.isFailure(): return status
00035 
00036         # Initialize services
00037         self.msgSvc = self.svc('IMessageSvc','MessageSvc')
00038         self.statsSvc = self.svc('IStatisticsSvc','StatisticsSvc')
00039 
00040         # Merge input paths to output path
00041         for path in self.Input:
00042             status = self.mergePaths('/'+path, '/'+self.Output )
00043             if status.isFailure(): break
00044 
00045         return status
00046 
    def execute(self):

def MergeStats::MergeAlg::execute (   self  ) 

Definition at line 47 of file MergeStats.py.

00047                      :
00048         return SUCCESS
00049         
    def finalize(self):        

def MergeStats::MergeAlg::finalize (   self  ) 

Definition at line 50 of file MergeStats.py.

00050                       :        
00051         print "Finalizing MergeAlg",self.name()
00052         status = GaudiAlgo.finalize(self)
00053         return status
00054 

def MergeStats::MergeAlg::mergePaths (   self,
  inputPath,
  outputPath 
)

Definition at line 55 of file MergeStats.py.

00055                                                :
00056         hasInPath = self.statsSvc.exists(inputPath)
00057         if( not hasInPath ):
00058             self.error("Input path doesn't exist: "+inputPath)
00059             return FAILURE
00060         contents = self.statsSvc.getContents(inputPath)
00061         for name in contents:
00062             status = self.mergeObjects(inputPath + "/" + name,
00063                                        outputPath + "/" + name)
00064             if status.isFailure(): return status
00065         subfolders = self.statsSvc.getSubFolders(inputPath)
00066         for folder in subfolders:
00067             status = self.mergePaths(inputPath+'/'+folder,
00068                                      outputPath+'/'+folder)
00069             if status.isFailure(): return status
00070         return SUCCESS
00071 
    def mergeObjects(self, inputPath, outputPath):

def MergeStats::MergeAlg::mergeObjects (   self,
  inputPath,
  outputPath 
)

Definition at line 72 of file MergeStats.py.

00072                                                  :
00073         inputObject = self.statsSvc.get(inputPath)
00074         if( inputObject == None ):
00075             self.error("No item at "+inputPath)
00076             return FAILURE
00077         hasOutput = self.statsSvc.exists(outputPath)
00078         if( not hasOutput ):
00079             # Add item to output
00080             status = self.statsSvc.put(outputPath, inputObject)
00081             if status.isFailure(): return status
00082         else:
00083             # Combine objects if possible
00084             for name in self.DontAdd:
00085                 if inputObject.GetName().find(name) > -1:
00086                     return SUCCESS
00087             outputObject = self.statsSvc.get(outputPath)
00088             if( outputObject == None ):
00089                 self.error("No item at "+outputPath)
00090                 return FAILURE
00091             if outputObject.IsA().InheritsFrom("TH1"):
00092                 # Add histograms
00093                 if( outputObject.TestBit( gbl.TH1.kIsAverage ) ):
00094                     # Average histograms must use TH1::Add
00095                     outputObject.Add( inputObject )
00096                 else:
00097                     # Other histograms should use TH1::Merge
00098                     ilist = gbl.TList();
00099                     ilist.Add(inputObject)
00100                     outputObject.Merge(ilist)
00101             elif outputObject.ClassName().startswith("TParameter"):
00102                 # Add parameters
00103                 outputObject.SetVal( outputObject.GetVal()
00104                                      + inputObject.GetVal() )
00105             else:
00106                 self.error("Can't add "+inputPath)
00107             
00108         return SUCCESS
00109 
    def error(self, message):

def MergeStats::MergeAlg::error (   self,
  message 
)

Definition at line 110 of file MergeStats.py.

00110                             :
00111         self.msgSvc.reportMessage(self.name(), ERROR, message)
00112         
inputMap = {}


Member Data Documentation

MergeStats::MergeAlg::Input

Definition at line 26 of file MergeStats.py.

MergeStats::MergeAlg::Output

Definition at line 27 of file MergeStats.py.

MergeStats::MergeAlg::DontAdd

Definition at line 28 of file MergeStats.py.

MergeStats::MergeAlg::msgSvc

Definition at line 37 of file MergeStats.py.

MergeStats::MergeAlg::statsSvc

Definition at line 38 of file MergeStats.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 Mon Apr 11 20:10:02 2011 for StatisticsSvc by doxygen 1.4.7