/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
MergeStats::MergeAlg Class Reference
Inheritance diagram for MergeStats::MergeAlg:
Inheritance graph
[legend]
Collaboration diagram for MergeStats::MergeAlg:
Collaboration graph
[legend]

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.


Constructor & Destructor Documentation

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

Definition at line 24 of file MergeStats.py.

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


Member Function Documentation

def MergeStats::MergeAlg::initialize (   self)

Definition at line 31 of file MergeStats.py.

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

def MergeStats::MergeAlg::execute (   self)

Definition at line 47 of file MergeStats.py.

00048                      :
00049         return SUCCESS
        
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.

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

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

Definition at line 72 of file MergeStats.py.

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

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

Definition at line 110 of file MergeStats.py.

00111                             :
00112         self.msgSvc.reportMessage(self.name(), ERROR, message)
        

Member Data Documentation

Definition at line 24 of file MergeStats.py.

Definition at line 24 of file MergeStats.py.

Definition at line 24 of file MergeStats.py.

Definition at line 31 of file MergeStats.py.

Definition at line 31 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 Fri May 16 2014 09:54:00 for StatisticsSvc by doxygen 1.7.4