/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 | Static Public Member Functions | Private Member Functions | Private Attributes
StatisticsSvc Class Reference

#include <StatisticsSvc.h>

Inheritance diagram for StatisticsSvc:
Inheritance graph
[legend]
Collaboration diagram for StatisticsSvc:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 StatisticsSvc (const std::string &name, ISvcLocator *svc)
 ~StatisticsSvc ()
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvInterface)
virtual StatusCode put (const std::string &path, TObject *object)
 Place the object at the specified path.
virtual TObject * get (const std::string &path)
 Return the object which exists at this path If there is no object, or if the path does not exist, return 0.
virtual bool exists (const std::string &path)
 Return true if a folder or object exists at the given path.
virtual std::vector< std::string > getContents (const std::string &path)
 Return a list of the names of the objects which exist in the folder An empty list is returned if the path does not exist, or contains no objects.
virtual std::vector< std::string > getSubFolders (const std::string &path)
 Return a list of the names of the subfolders which exist in the folder An empty list is returned if the folder does not exist, or contains no subfolders.
virtual TH1F * getTH1F (const std::string &path)
 Convenience methods for retrieving particular types of TObjects.
virtual TH2F * getTH2F (const std::string &path)
 Return the TH2F which exists at this path Return 0 if unsuccessful.
virtual TH3F * getTH3F (const std::string &path)
 Return the TH3F which exists at this path Return 0 if unsuccessful.
virtual TTree * getTree (const std::string &path)
 Return the TTree which exists at this path Return 0 if unsuccessful.
virtual TGraph * getGraph (const std::string &path)
 Return the TGraph which exists at this path Return 0 if unsuccessful.

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Member Functions

StatusCode checkOptions (std::string &handle, std::string &filename)
StatusCode parsePath (const std::string &fullpath, std::string &top, std::string &rest)
StatusCode reverseParsePath (const std::string &fullpath, std::string &rest, std::string &bottom)
StatusCode getManager (const std::string &path, HistMan *&hm, std::string &localPath, bool report=true)
void dump ()
void dumpPath (const std::string &path, std::ostringstream &dumpStr)

Private Attributes

std::map< std::string,
std::string > 
m_input
 Property: Input List of path, input files pairs {"path0": "myfile0.root", <etc.
std::map< std::string,
std::string > 
m_output
 Property: Output List of path, output file pairs {"path1": "myfile1.root", <etc.
IMessageSvc * m_msgSvc
std::map< std::string, TFile * > m_files
std::map< std::string, HistMan * > m_histMan

Detailed Description

Definition at line 25 of file StatisticsSvc.h.


Constructor & Destructor Documentation

StatisticsSvc::StatisticsSvc ( const std::string &  name,
ISvcLocator *  svc 
)

Definition at line 12 of file StatisticsSvc.cc.

  : Service(name,svc),
    m_msgSvc(0)
{
  
  declareProperty("Input",m_input /*map<string,string>*/,
                  "List of path, input file pairs.");
  declareProperty("Output",m_output /*map<string,string>*/,
                  "List of path, output file pairs.");
}
StatisticsSvc::~StatisticsSvc ( )

Definition at line 23 of file StatisticsSvc.cc.

{
}

Member Function Documentation

StatusCode StatisticsSvc::initialize ( ) [virtual]

Definition at line 52 of file StatisticsSvc.cc.

{
  StatusCode sc = this->Service::initialize();
  if( sc.isFailure() ) return sc;
  
  m_msgSvc = msgSvc();
  if( !m_msgSvc ) return StatusCode::FAILURE;

  {
    std::ostringstream msgStr;
    msgStr << "initialize()";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::INFO,msgStr.str()); 
  }

  std::map<std::string, std::string> fileModeByFilename;
  std::vector<std::string> inHandles;
  std::vector<std::string> inFiles;
  std::vector<std::string> outHandles;
  std::vector<std::string> outFiles;

  m_input = xrootdify_map(m_input);
  m_output = xrootdify_map(m_output);

  // Parse the input files 
  std::map<std::string,std::string>::const_iterator inputIter, 
    inputEnd = m_input.end();
  for(inputIter=m_input.begin(); inputIter != inputEnd; inputIter++){
    std::string handle = inputIter->first;
    std::string filename = inputIter->second;
    sc = checkOptions(handle, filename);    
    if( sc.isFailure() ) return sc;

    // Check if handle already exists
    if( std::find(inHandles.begin(), inHandles.end(), handle) 
        != inHandles.end() ){
        std::ostringstream msgStr;
        msgStr << "initialize(): File handle " 
               << handle << " already associated with input file " 
               << m_input[handle];
        m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
        return StatusCode::FAILURE;
    }
    // Check if filename already exists
    if( std::find(inFiles.begin(), inFiles.end(), filename) != inFiles.end() ){
        std::ostringstream msgStr;
        msgStr << "initialize(): Filename " 
               << filename << " already associated with an input handle.";
        m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
        return StatusCode::FAILURE;
    }
    // Add handle, filename to file lists
    inHandles.push_back(handle);
    inFiles.push_back(filename);
    m_histMan[handle] = 0;
    // Default to Read-only
    fileModeByFilename[filename]="READ";
  }

  // Parse the output files 
  std::map<std::string,std::string>::const_iterator outputIter, 
    outputEnd = m_output.end();
  for(outputIter=m_output.begin(); outputIter != outputEnd; outputIter++){
    std::string handle = outputIter->first;
    std::string filename = outputIter->second;
    sc = checkOptions(handle, filename);
    if( sc.isFailure() ) return sc;
    // Check if output handle already exists
    if( std::find(outHandles.begin(), outHandles.end(), handle) 
        != outHandles.end() ){
        std::ostringstream msgStr;
        msgStr << "initialize(): Output File handle " 
               << handle << " already associated with file " 
               << m_output[handle];
        m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
        return StatusCode::FAILURE;
    }
    // Check if output filename already exists
    if( std::find(outFiles.begin(), outFiles.end(), filename) 
        != outFiles.end() ){
        std::ostringstream msgStr;
        msgStr << "initialize(): Output Filename " 
               << filename << " already associated with an output handle.";
        m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
        return StatusCode::FAILURE;
    }

    // Check if output filename is same as input filename
    if( std::find(inFiles.begin(), inFiles.end(), filename) != inFiles.end()){
      // Check if associated with the same handle
      std::map<std::string, std::string>::iterator inputIter
        = m_input.find(handle);
      if( inputIter == m_input.end() || m_input[handle] != m_output[handle] ){
        std::ostringstream msgStr;
        msgStr << "initialize(): Output Filename " 
               << filename << " already associated with separate input handle";
        m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str());
        return StatusCode::FAILURE;
      }
      // Filenames and Input/Output handles match.  Open file in UPDATE mode
      fileModeByFilename[filename] = "UPDATE";
    }else{
      // If file not present in input files, default to RECREATE file
      fileModeByFilename[filename]="RECREATE";
      m_histMan[handle] = 0;
    }

    // Add handle, filename to outputs
    outHandles.push_back(handle);
    outFiles.push_back(filename);
  }

  // Open all the files
  TDirectory* prevDirectory = gDirectory; // Catch current directory
  std::map<std::string, std::string>::iterator fileIter, 
    fileEnd = fileModeByFilename.end();
  for(fileIter = fileModeByFilename.begin(); fileIter != fileEnd; fileIter++){
    std::string filename = fileIter->first;
    std::string fileMode = fileIter->second;
    // FIXME: Should we check if this file is already known to gROOT?
    TFile* file = TFile::Open(filename.c_str(), fileMode.c_str());
    if( !file || file->IsZombie() || !file->IsOpen() ){
      std::ostringstream msgStr;
      msgStr << "initialize(): Failed to open file " 
             << filename << " with mode " << fileMode;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
      return StatusCode::FAILURE;
    }
    m_files[filename] = file;
  }

  // Initialize the HistMan instances for each handle
  std::map<std::string, HistMan*>::iterator hmIter, 
    hmEnd = m_histMan.end();
  for(hmIter = m_histMan.begin(); hmIter != hmEnd; hmIter++){
    std::string handle = hmIter->first;
    TFile* file = 0;
    if(m_input.find(handle) != m_input.end()){
      // Associate with input file
      file = m_files[ m_input[handle] ];
      std::ostringstream msgStr;
      msgStr << "initialize(): Reading handle " << handle
             << " from file " << file->GetName() << " with mode " 
             << fileModeByFilename[file->GetName()];
      m_msgSvc->reportMessage("StatisticsSvc",MSG::INFO,msgStr.str());
    }else if( m_output.find(handle) != m_output.end() ){
      // Associate with output file
      file = m_files[ m_output[handle] ];
    }else{
      std::ostringstream msgStr;
      msgStr << "initialize(): Error associating " << handle
             << " with either input or output file.";
      m_msgSvc->reportMessage("StatisticsSvc",MSG::INFO,msgStr.str());
      return StatusCode::FAILURE;
    }
    HistMan* histMan = new HistMan( *file, false );
    if(!histMan){
      std::ostringstream msgStr;
      msgStr << "initialize(): Failed to create HistMan for " 
             << handle;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
      return StatusCode::FAILURE;
    }
    m_histMan[ handle ] = histMan;
  }

  gDirectory = prevDirectory; // Restore ROOT's current directory
  {
    std::ostringstream msgStr;
    msgStr << "initialize(): finished";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::INFO,msgStr.str()); 
  }
  return sc;
}
StatusCode StatisticsSvc::finalize ( ) [virtual]

Definition at line 226 of file StatisticsSvc.cc.

{

  {
    std::ostringstream msgStr;
    msgStr << "finalize():";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::INFO,msgStr.str()); 
  }

  // DEBUG: dump the statistics store contents
  this->dump();

  // Write output files
  std::map<std::string, std::string>::iterator outputIter, 
    outputEnd = m_output.end();
  for(outputIter=m_output.begin(); outputIter != outputEnd; outputIter++){
    std::string handle = outputIter->first;
    std::string filename = outputIter->second;
    TFile* file = m_files[filename];
    HistMan* histMan = m_histMan[handle];
    if( !file ){
      std::ostringstream msgStr;
      msgStr << "finalize(): Unexpected Err! Bad file handle: "
             << handle;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
      return StatusCode::FAILURE;
    }
    if( !histMan ){
      std::ostringstream msgStr;
      msgStr << "finalize(): Unexpected Error! "
             << "Bad HistMan handle: " << handle;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
      return StatusCode::FAILURE;
    }
    // Write out histman contents to correct file
    {
      std::ostringstream msgStr;
      msgStr << "finalize(): Writing handle " << handle
             << " to file " << file->GetName();
      m_msgSvc->reportMessage("StatisticsSvc",MSG::INFO,msgStr.str()); 
    }
    histMan->WriteOut( *file );
  }

  // Delete all HistMan instances
  std::map<std::string, HistMan*>::iterator hmIter, hmEnd = m_histMan.end();
  for(hmIter=m_histMan.begin(); hmIter != hmEnd; hmIter++){
    std::string handle = hmIter->first;
    HistMan* histMan = hmIter->second;
    delete histMan;
    m_histMan[handle] = 0;
  }
  m_histMan.clear();

  // Close all input and output files
  std::map<std::string, TFile*>::iterator fileIter, fileEnd = m_files.end();
  for(fileIter=m_files.begin(); fileIter != fileEnd; fileIter++){
    std::string filename = fileIter->first;
    TFile* file = fileIter->second;
    if( !file ){
      std::ostringstream msgStr;
      msgStr << "finalize(): Unexpected Err! Bad file: "
             << filename;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
      return StatusCode::FAILURE;
    }
    file->Close();
    delete file;
    m_files[filename] = 0;
  }
  m_files.clear();

  {
    std::ostringstream msgStr;
    msgStr << "finalize(): done";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::INFO,msgStr.str()); 
  }

  return this->Service::finalize();
}
StatusCode StatisticsSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvInterface 
) [virtual]

Definition at line 307 of file StatisticsSvc.cc.

{
  StatusCode sc = StatusCode::FAILURE;
  if (ppvInterface) {
    *ppvInterface = 0;
    
    if (IStatisticsSvc::interfaceID().versionMatch(riid)) {
      *ppvInterface = static_cast<IStatisticsSvc*>(this);
      sc = StatusCode::SUCCESS;
      addRef();
    }
    else sc = Service::queryInterface( riid, ppvInterface );    
  }
  return sc;
}
StatusCode StatisticsSvc::put ( const std::string &  path,
TObject *  object 
) [virtual]

Place the object at the specified path.

IStatisticsSvc implementation ////////////////////////////////////////////.

if the subdirectories do not exist, they will be automatically created. If the location is occupied by another object, it is deleted and replaced by the new object. StatusCode::SUCCESS is returned if the object was successfully placed.

Implements IStatisticsSvc.

Definition at line 326 of file StatisticsSvc.cc.

                                                                   {
  // Check if object is valid
  if(!object){
    std::ostringstream msgStr;
    msgStr << "put(): Invalid object at: " << path;
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
    return StatusCode::FAILURE;
  }
  // Check path
  std::string localPathPlusName, localPath, name;
  HistMan* histMan = 0;
  StatusCode sc = getManager(path, histMan, localPathPlusName);
  if( sc.isFailure() ) return sc;
  // Break object name off end of path
  sc = reverseParsePath(localPathPlusName, localPath, name);
  if( sc.isFailure() ){
    std::ostringstream msgStr;
    msgStr << "put(): Invalid path + name: " << localPathPlusName;
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
    return sc;
  }
  // Reset object name to name at path end
  if(name != object->GetName()){
    std::ostringstream msgStr;
    TNamed* namedObj = dynamic_cast<TNamed*>(object);
    if(!namedObj){
      msgStr << "put(): Cannot put unnamed object (" << name << "," 
             << object->GetName() << " in statistics service.";  
      m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str());
      return StatusCode::FAILURE;
    }else{
      msgStr << "put(): Changing object name: " << namedObj->GetName() 
             << " to " << name;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str()); 
      namedObj->SetName(name.c_str());
    }
  }
  // Add object to store
  TObject* checkObj = histMan->Adopt(localPath.c_str(), object);
  if(!checkObj){
    // Path location is occupied.  Replacing...
    std::ostringstream msgStr;
    msgStr << "put(): Replacing object at " << path;
    m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str()); 
    histMan->Adopt(localPath.c_str(), object);
  }
  return StatusCode::SUCCESS;
}
TObject * StatisticsSvc::get ( const std::string &  path) [virtual]

Return the object which exists at this path If there is no object, or if the path does not exist, return 0.

Implements IStatisticsSvc.

Definition at line 375 of file StatisticsSvc.cc.

                                                {
  if(path.size()==1 && path[0]=='/') return 0;  // Root path has no object
  std::string localPath;
  HistMan* histMan = 0;
  StatusCode sc = this->getManager(path, histMan, localPath);
  if( sc.isFailure() ) return 0;
  TObject* obj = histMan->GetObject(localPath.c_str());
  if(!obj){
    std::ostringstream msgStr;
    msgStr << "get(): No entry at " << path;
    m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str());
    return 0;
  }  
  return obj;
}
bool StatisticsSvc::exists ( const std::string &  path) [virtual]

Return true if a folder or object exists at the given path.

Implements IStatisticsSvc.

Definition at line 391 of file StatisticsSvc.cc.

                                               {
  if(path.size()==1 && path[0]=='/') return true;  // Root path always exists
  std::string localPath;
  HistMan* histMan = 0;
  bool report = false; // Don't report errors if path doesn't exists
  StatusCode sc = this->getManager(path, histMan, localPath, report);
  if( sc.isFailure() ) return false;
  TObject* obj = histMan->GetObjectOrFolder(localPath.c_str());
  if(!obj) return false;
  return true;
}
std::vector< std::string > StatisticsSvc::getContents ( const std::string &  path) [virtual]

Return a list of the names of the objects which exist in the folder An empty list is returned if the path does not exist, or contains no objects.

Implements IStatisticsSvc.

Definition at line 403 of file StatisticsSvc.cc.

                                                                    {
  std::vector<std::string> empty, contents;
  if(path.size()==1 && path[0]=='/') return empty; // Root path has not objects
  std::string localPath;
  HistMan* histMan = 0;
  StatusCode sc = getManager(path, histMan, localPath);
  if( sc.isFailure() ) return empty;
  // Get objects
  std::vector<TObject*> objects = histMan->GetObjects(localPath.c_str());
  std::vector<TObject*>::iterator objIter, objEnd = objects.end();
  for(objIter=objects.begin(); objIter!=objEnd; objIter++){
    TObject* object = *objIter;
    if(!object){
      std::ostringstream msgStr;
      msgStr << "getContents(): Broken object at " << localPath;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str());
      return empty;
    }
    contents.push_back( object->GetName() );
  }
  return contents;
}
std::vector< std::string > StatisticsSvc::getSubFolders ( const std::string &  path) [virtual]

Return a list of the names of the subfolders which exist in the folder An empty list is returned if the folder does not exist, or contains no subfolders.

Implements IStatisticsSvc.

Definition at line 426 of file StatisticsSvc.cc.

                                                                      {
  std::vector<std::string> empty, contents;
  if(path.size()==1 && path[0]=='/'){
    // Catch request for root path
    std::map<std::string, HistMan*>::iterator hmIter, hmEnd = m_histMan.end();
    std::ostringstream msgStr;
    msgStr << "Adding root folders: ";
    for(hmIter = m_histMan.begin(); hmIter != hmEnd; hmIter++){
      contents.push_back( hmIter->first );
      msgStr << " " << hmIter->first;
    }
    m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str());
    return contents;
  }
  std::string localPath;
  HistMan* histMan = 0;
  StatusCode sc = getManager(path, histMan, localPath);
  if( sc.isFailure() ) return empty;
  // Get sub-folders
  std::vector<TFolder*> folders = 
    histMan->GetSubFolders(localPath.c_str());
  std::vector<TFolder*>::iterator folderIter, folderEnd = folders.end();
  for(folderIter=folders.begin(); folderIter!=folderEnd; folderIter++){
    TFolder* folder = *folderIter;
    if(!folder){
      std::ostringstream msgStr;
      msgStr << "getSubFolders(): Broken folder at " << localPath;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str());
      return empty;
    }
    contents.push_back( folder->GetName() );
  }
  return contents;
}
TH1F * StatisticsSvc::getTH1F ( const std::string &  path) [virtual]

Convenience methods for retrieving particular types of TObjects.

Return the TH1F which exists at this path Return 0 if unsuccessful.

Implements IStatisticsSvc.

Definition at line 462 of file StatisticsSvc.cc.

                                                 {
  TObject* obj = this->get(path);
  if(!obj) return 0;
  TH1F* hist = dynamic_cast<TH1F*>(obj);
  if(!hist){
    std::string msgStr ="Failed to cast object at "+path+" to histogram (TH1F)";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr);
    return 0;
  }
  return hist;
}
TH2F * StatisticsSvc::getTH2F ( const std::string &  path) [virtual]

Return the TH2F which exists at this path Return 0 if unsuccessful.

Implements IStatisticsSvc.

Definition at line 474 of file StatisticsSvc.cc.

                                                 {
  TObject* obj = this->get(path);
  if(!obj) return 0;
  TH2F* hist = dynamic_cast<TH2F*>(obj);
  if(!hist){
    std::string msgStr ="Failed to cast object at "+path+" to histogram (TH2F)";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr);
    return 0;
  }
  return hist;
}
TH3F * StatisticsSvc::getTH3F ( const std::string &  path) [virtual]

Return the TH3F which exists at this path Return 0 if unsuccessful.

Implements IStatisticsSvc.

Definition at line 486 of file StatisticsSvc.cc.

                                                 {
  TObject* obj = this->get(path);
  if(!obj) return 0;
  TH3F* hist = dynamic_cast<TH3F*>(obj);
  if(!hist){
    std::string msgStr ="Failed to cast object at "+path+" to histogram (TH3F)";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr);
    return 0;
  }
  return hist;
}
TTree * StatisticsSvc::getTree ( const std::string &  path) [virtual]

Return the TTree which exists at this path Return 0 if unsuccessful.

Implements IStatisticsSvc.

Definition at line 498 of file StatisticsSvc.cc.

                                                  {
  TObject* obj = this->get(path);
  if(!obj) return 0;
  TTree* tree = dynamic_cast<TTree*>(obj);
  if(!tree){
    std::string msgStr ="Failed to cast object at "+path+" to tree";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr);
    return 0;
  }
  return tree;
}
TGraph * StatisticsSvc::getGraph ( const std::string &  path) [virtual]

Return the TGraph which exists at this path Return 0 if unsuccessful.

Implements IStatisticsSvc.

Definition at line 510 of file StatisticsSvc.cc.

                                                    {
  TObject* obj = this->get(path);
  if(!obj) return 0;
  TGraph* graph = dynamic_cast<TGraph*>(obj);
  if(!graph){
    std::string msgStr ="Failed to cast object at "+path+" to graph (TGraph)";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr);
    return 0;
  }
  return graph;
}
StatusCode StatisticsSvc::checkOptions ( std::string &  handle,
std::string &  filename 
) [private]

Definition at line 524 of file StatisticsSvc.cc.

                                                           {
  // No double slashes in filename
  if( filename.find("root://") == std::string::npos && 
      filename.find("//")      != std::string::npos ) {
    std::ostringstream msgStr;
    msgStr << "checkOptions(): filename "  
           << filename << " is not supported (cannot contain '//').";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str());
    return StatusCode::FAILURE;
  }
  // Slashes '/' not allowed in handle name
  if( handle.find('/') != std::string::npos){
    std::ostringstream msgStr;
    msgStr << "checkOptions(): handle "  
           << handle << " is not supported (cannot contain '/').";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str());
    return StatusCode::FAILURE;
  }
  // handle or filename cannot be empty strings
  if( handle.size()==0 || filename.size()==0 ){
    std::ostringstream msgStr;
    msgStr << "checkOptions(): Null handle \"" << handle 
           << "\" or filename \"" << filename << "\"";
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str());
    return StatusCode::FAILURE;
  }
  return StatusCode::SUCCESS;
}
StatusCode StatisticsSvc::parsePath ( const std::string &  fullpath,
std::string &  top,
std::string &  rest 
) [private]

Definition at line 554 of file StatisticsSvc.cc.

                                                                    {
  // Break top level directory off of path:
  // Input:
  //   fullpath = /path1/path2/path3
  // Output:
  //   top = path1
  //   rest = /path2/path3
  char sep = '/';
  if(fullpath.length()<1 || fullpath[0] != sep) return StatusCode::FAILURE;
  std::string::size_type pos = fullpath.find(sep, 1);
  if(pos == std::string::npos){
    // If top level directory
    top = std::string(fullpath, 1, std::string::npos);
    rest = "";
  }else{
    top = std::string(fullpath, 1, pos-1);
    rest = std::string(fullpath, pos, std::string::npos);
  }
  return StatusCode::SUCCESS;
}
StatusCode StatisticsSvc::reverseParsePath ( const std::string &  fullpath,
std::string &  rest,
std::string &  bottom 
) [private]

Definition at line 576 of file StatisticsSvc.cc.

                                                             {
  // Break bottom level directory off of path:
  // Input:
  //   fullpath = /path1/path2/path3
  // Output:
  //   rest = /path1/path2
  //   bottom = path3
  char sep = '/';
  if(fullpath.length()<1 || fullpath[fullpath.length()-1] == sep) 
    return StatusCode::FAILURE;
  std::string::size_type pos = fullpath.rfind(sep);
  if(pos == std::string::npos || pos == 0
     || pos == (fullpath.length()-1) ) return StatusCode::FAILURE;
  rest = std::string(fullpath, 0, pos);
  bottom = std::string(fullpath, pos+1, std::string::npos);
  return StatusCode::SUCCESS;
}
StatusCode StatisticsSvc::getManager ( const std::string &  path,
HistMan *&  hm,
std::string &  localPath,
bool  report = true 
) [private]

Definition at line 596 of file StatisticsSvc.cc.

                                                   {
  // Internal function to get the correct histman and localpath for
  // the requested path.
  std::string handle, subPath;
  StatusCode sc = parsePath(path, handle, subPath);
  if( sc.isFailure() ){
    std::ostringstream msgStr;
    msgStr << "getManager(): Invalid path: " << path;
    m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str()); 
    return StatusCode::FAILURE;
  }
  // Find the hist manager for this handle
  HistMan* hm = 0;
  std::map<std::string, HistMan*>::iterator hmIter = m_histMan.find(handle);
  if( hmIter == m_histMan.end() ){
    if(report){
      std::ostringstream msgStr;
      msgStr << "getManager(): Creating transient path for unknown handle " 
             << handle 
             << " used in full path "
             << path;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::WARNING,msgStr.str());
    }
    std::string transientPath = "//root/transient_";
    transientPath.append( handle );
    TFolder* folder = new TFolder(transientPath.c_str(),
                                  "Transient Statistics Folder");
    hm = new HistMan(folder, false);
    m_histMan[handle] = hm;
  }else{
    hm = hmIter->second;
    if(!hm){
      std::ostringstream msgStr;
      msgStr << "getManager(): Invalid HistMan for " << handle 
             << " used in full path " << path;
      m_msgSvc->reportMessage("StatisticsSvc",MSG::ERROR,msgStr.str());
      return StatusCode::FAILURE;
    }
  }
  // Remove '/' from start of local pathname
  if( subPath.length() > 0 && subPath[0] == '/' )
    localPath = std::string(subPath, 1, std::string::npos);
  else
    localPath = subPath;
  histMan = hm;
  return StatusCode::SUCCESS;
}
void StatisticsSvc::dump ( ) [private]

Definition at line 646 of file StatisticsSvc.cc.

                        {
  // Print the statistics store contents
  std::ostringstream dumpStr;
  dumpStr << "StatisticsSvc contents:\n";
  std::map<std::string, HistMan*>::iterator hmIter, hmEnd = m_histMan.end();
  for(hmIter = m_histMan.begin(); hmIter != hmEnd; hmIter++){
    std::string handle = hmIter->first;
    std::string filename = "[TRANSIENT ONLY]";
    std::map<std::string, std::string>::iterator outputIter 
      = m_output.find(handle);
    if( outputIter != m_output.end() )
      filename = outputIter->second;
    dumpStr << "\nPATH=" << handle << " written to: " << filename << "\n";
    std::string currentPath = "/"+handle;
    dumpStr << currentPath << "\n";
    this->dumpPath(currentPath, dumpStr);
  }
  m_msgSvc->reportMessage("StatisticsSvc",MSG::DEBUG,dumpStr.str());
}
void StatisticsSvc::dumpPath ( const std::string &  path,
std::ostringstream &  dumpStr 
) [private]

Definition at line 666 of file StatisticsSvc.cc.

                                                       {
  // Append objects
  std::vector<std::string> names = this->getContents(path);
  std::vector<std::string>::iterator nameIter, nameEnd = names.end();
  for(nameIter=names.begin(); nameIter != nameEnd; nameIter++){
    std::string fullpath = path + "/" + (*nameIter);
    std::string type;
    TObject* obj = this->get(fullpath);
    if(!obj) type = "BROKEN";
    else     type = obj->ClassName();
    dumpStr << fullpath << " (" << type << ")\n";
  }
  // Descend directories
  names = this->getSubFolders(path);
  nameEnd = names.end();
  for(nameIter=names.begin(); nameIter != nameEnd; nameIter++){
    std::string fullpath = path + "/" + (*nameIter);
    dumpStr << fullpath << "\n";
    this->dumpPath(fullpath,dumpStr);
  }
  return;
}
static const InterfaceID& IStatisticsSvc::interfaceID ( ) [inline, static, inherited]

Definition at line 38 of file IStatisticsSvc.h.

                                         {
    return IID_IStatisticsSvc;
  }

Member Data Documentation

std::map<std::string,std::string> StatisticsSvc::m_input [private]

Property: Input List of path, input files pairs {"path0": "myfile0.root", <etc.

>} If file is present in input and output, it is opened in "UPDATE" mode. 'path' must be a simple name; it cannot contain '/'.

Definition at line 94 of file StatisticsSvc.h.

std::map<std::string,std::string> StatisticsSvc::m_output [private]

Property: Output List of path, output file pairs {"path1": "myfile1.root", <etc.

>} If file is present in input and output, it is opened in "UPDATE" mode. 'path' must be a simple name; it cannot contain '/'.

Definition at line 100 of file StatisticsSvc.h.

IMessageSvc* StatisticsSvc::m_msgSvc [private]

Definition at line 103 of file StatisticsSvc.h.

std::map<std::string, TFile*> StatisticsSvc::m_files [private]

Definition at line 106 of file StatisticsSvc.h.

std::map<std::string, HistMan*> StatisticsSvc::m_histMan [private]

Definition at line 109 of file StatisticsSvc.h.


The documentation for this class was generated from the following files:
| 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