CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

HLTPerformanceInfo Class Reference

#include <HLTPerformanceInfo.h>

List of all members.

Classes

class  Module
class  Path

Public Types

typedef std::vector< ModuleModules
typedef std::vector< size_t > ModulesInPath
typedef std::vector< PathPathList

Public Member Functions

void addModule (const Module &m)
void addModuleToPath (const char *mod, const char *path)
void addModuleToPath (const size_t mod, const size_t path)
void addPath (const Path &p)
Modules::const_iterator beginModules () const
PathList::iterator beginPaths ()
void clear ()
void clearModules ()
Modules::const_iterator endModules () const
PathList::iterator endPaths ()
Modules::iterator findModule (const char *moduleInstanceName)
PathList::iterator findPath (const char *pathName)
const ModulegetModule (size_t m) const
const ModulegetModuleOnPath (size_t m, size_t p) const
const PathgetPath (size_t p) const
 HLTPerformanceInfo ()
double longestModuleCPUTime () const
const char * longestModuleCPUTimeName () const
double longestModuleTime () const
const char * longestModuleTimeName () const
int moduleIndexInPath (const char *mod, const char *path)
size_t numberOfModules () const
size_t numberOfPaths () const
void setStatusOfModulesFromPath (const char *pathName)
double totalCPUTime () const
double totalPathCPUTime (const size_t path)
double totalPathTime (const size_t path)
double totalTime () const
bool uniqueModule (const char *mod) const

Private Attributes

Modules modules_
PathList paths_

Detailed Description

Definition at line 11 of file HLTPerformanceInfo.h.


Member Typedef Documentation

typedef std::vector<Module> HLTPerformanceInfo::Modules

Definition at line 16 of file HLTPerformanceInfo.h.

typedef std::vector<size_t> HLTPerformanceInfo::ModulesInPath

Definition at line 17 of file HLTPerformanceInfo.h.

typedef std::vector<Path> HLTPerformanceInfo::PathList

Definition at line 14 of file HLTPerformanceInfo.h.


Constructor & Destructor Documentation

HLTPerformanceInfo::HLTPerformanceInfo ( )

Definition at line 7 of file HLTPerformanceInfo.cc.

References modules_, and paths_.

                                       {
  paths_.clear(); modules_.clear();
}

Member Function Documentation

void HLTPerformanceInfo::addModule ( const Module m) [inline]

Definition at line 122 of file HLTPerformanceInfo.h.

References modules_.

                                    {
    modules_.push_back(m);
  } 
void HLTPerformanceInfo::addModuleToPath ( const size_t  mod,
const size_t  path 
) [inline]

Definition at line 147 of file HLTPerformanceInfo.h.

References modules_, path(), and paths_.

                                                            {
    assert(( path <paths_.size()) && (mod < modules_.size()) );
    paths_[path].addModuleRef(mod);
  }
void HLTPerformanceInfo::addModuleToPath ( const char *  mod,
const char *  path 
) [inline]

Definition at line 126 of file HLTPerformanceInfo.h.

References endModules(), findModule(), i, j, m, modules_, and paths_.

                                                           {
     // first make sure module exists
     Modules::iterator m = findModule(mod);
     if ( m == endModules() ) {
       // new module - create it and stick it on the end
       Module newMod(mod, 0, 0); // time (wall and cpu) = 0 since it wasn't run  
       modules_.push_back(newMod);
     }

     for ( size_t i = 0; i < paths_.size(); ++i ) {
       if ( !( paths_[i] == path ) ) continue;
       // we found the path, add module to the end
       for ( size_t j = 0; j < modules_.size(); ++j ) {
         if ( !(modules_[j] == mod) ) continue;
         paths_[i].addModuleRef(j);
         break;
       }
       break;
     }
   }
void HLTPerformanceInfo::addPath ( const Path p) [inline]

Definition at line 119 of file HLTPerformanceInfo.h.

References paths_.

                               {
    paths_.push_back(p);
  }
Modules::const_iterator HLTPerformanceInfo::beginModules ( ) const [inline]

Definition at line 188 of file HLTPerformanceInfo.h.

References modules_.

                                             {
    return modules_.begin();
  }
PathList::iterator HLTPerformanceInfo::beginPaths ( ) [inline]

Definition at line 181 of file HLTPerformanceInfo.h.

References paths_.

                                 {
       return paths_.begin();
  }
void HLTPerformanceInfo::clear ( void  ) [inline]

Definition at line 152 of file HLTPerformanceInfo.h.

References modules_, and paths_.

               {
    modules_.clear(); paths_.clear();
  }
void HLTPerformanceInfo::clearModules ( ) [inline]

Definition at line 155 of file HLTPerformanceInfo.h.

References i, and modules_.

                      {
    for ( size_t i = 0; i < modules_.size(); ++i ) {
      modules_[i].clear();
    }
  }
Modules::const_iterator HLTPerformanceInfo::endModules ( ) const [inline]

Definition at line 192 of file HLTPerformanceInfo.h.

References modules_.

Referenced by addModuleToPath().

                                           {
    return modules_.end();
  }
PathList::iterator HLTPerformanceInfo::endPaths ( ) [inline]

Definition at line 184 of file HLTPerformanceInfo.h.

References paths_.

Referenced by moduleIndexInPath(), and setStatusOfModulesFromPath().

                               {
    return paths_.end();
  }
HLTPerformanceInfo::Modules::iterator HLTPerformanceInfo::findModule ( const char *  moduleInstanceName)

Definition at line 19 of file HLTPerformanceInfo.cc.

References spr::find(), and modules_.

Referenced by addModuleToPath().

                                                             {
  return std::find(modules_.begin(), modules_.end(),
                   moduleInstanceName);
}
HLTPerformanceInfo::PathList::iterator HLTPerformanceInfo::findPath ( const char *  pathName)

Definition at line 12 of file HLTPerformanceInfo.cc.

References spr::find(), prof2calltree::l, pathName(), and paths_.

Referenced by moduleIndexInPath(), and setStatusOfModulesFromPath().

                                                 {
  PathList::iterator l = std::find(paths_.begin(), paths_.end(),
                                         pathName);
  return l; 
}
const Module& HLTPerformanceInfo::getModule ( size_t  m) const [inline]

Definition at line 163 of file HLTPerformanceInfo.h.

References modules_.

{ return modules_.at(m); }
const HLTPerformanceInfo::Module & HLTPerformanceInfo::getModuleOnPath ( size_t  m,
size_t  p 
) const

Definition at line 130 of file HLTPerformanceInfo.cc.

References j, modules_, L1TEmulatorMonitor_cff::p, and paths_.

{
  // well if this doesn't get your attention....
  assert(p<paths_.size()&& m<paths_[p].numberOfModules());
  size_t j = paths_[p].getModuleIndex(m);
  return modules_.at(j);
}
const Path& HLTPerformanceInfo::getPath ( size_t  p) const [inline]

Definition at line 164 of file HLTPerformanceInfo.h.

References paths_.

{ return paths_.at(p); }
double HLTPerformanceInfo::longestModuleCPUTime ( ) const

Definition at line 79 of file HLTPerformanceInfo.cc.

References i, max(), modules_, and matplotRender::t.

                                                      {
  double t = -1;
  for ( Modules::const_iterator i = modules_.begin();
        i != modules_.end(); ++i ) {
    t = std::max(i->cputime(),t);
  }
  return t;
}
const char * HLTPerformanceInfo::longestModuleCPUTimeName ( ) const

Definition at line 102 of file HLTPerformanceInfo.cc.

References i, modules_, and matplotRender::t.

{
  double t = -1;
  std::string slowpoke("unknown");
  for ( Modules::const_iterator i = modules_.begin();
        i != modules_.end(); ++i ) {
    if ( i->cputime() > t ) {
      slowpoke = i->name();
      t = i->cputime();
    }
  }
  return slowpoke.c_str();
}
double HLTPerformanceInfo::longestModuleTime ( ) const

Definition at line 70 of file HLTPerformanceInfo.cc.

References i, max(), modules_, and matplotRender::t.

                                                   {
  double t = -1;
  for ( Modules::const_iterator i = modules_.begin();
        i != modules_.end(); ++i ) {
    t = std::max(i->time(),t);
  }
  return t;
}
const char * HLTPerformanceInfo::longestModuleTimeName ( ) const

Definition at line 88 of file HLTPerformanceInfo.cc.

References i, modules_, and matplotRender::t.

{
  double t = -1;
  std::string slowpoke("unknown");
  for ( Modules::const_iterator i = modules_.begin();
        i != modules_.end(); ++i ) {
    if ( i->time() > t ) {
      slowpoke = i->name();
      t = i->time();
    }
  }
  return slowpoke.c_str();
}
int HLTPerformanceInfo::moduleIndexInPath ( const char *  mod,
const char *  path 
)

Definition at line 156 of file HLTPerformanceInfo.cc.

References endPaths(), findPath(), j, mod(), modules_, and L1TEmulatorMonitor_cff::p.

{
  PathList::iterator p = findPath(path);
  if ( p == endPaths() ) return -1; // Path doesn't exist
  int ctr = 0 ; 
  for ( ModulesInPath::const_iterator j = p->begin(); j != p->end(); ++j ) {
      if ( modules_.at(*j) == mod ) return ctr ; 
      ctr++ ; 
  }
  return -2; // module not found on path
}
size_t HLTPerformanceInfo::numberOfModules ( ) const [inline]

Definition at line 177 of file HLTPerformanceInfo.h.

References modules_.

                                 {
    return modules_.size();
  }
size_t HLTPerformanceInfo::numberOfPaths ( ) const [inline]

Definition at line 174 of file HLTPerformanceInfo.h.

References paths_.

                               {
    return paths_.size();
  }
void HLTPerformanceInfo::setStatusOfModulesFromPath ( const char *  pathName)

Definition at line 172 of file HLTPerformanceInfo.cc.

References endPaths(), findPath(), j, mod(), modules_, L1TEmulatorMonitor_cff::p, Pass, Ready, HLTPerformanceInfo::Module::setStatus(), HLTPerformanceInfo::Module::status(), and edm::HLTPathStatus::wasrun().

{
  PathList::iterator p = findPath(pathName);
  if ( p == endPaths() ) {
    return; // do nothing
  }
  unsigned int ctr = 0;
  for ( ModulesInPath::const_iterator j = p->begin(); j != p->end(); ++j ) {
    edm::hlt::HLTState modState = edm::hlt::Ready ; 
    unsigned int modIndex = 0 ; 

    // get module in the master list
    Module & mod = modules_.at(*j);
    
    if ( ! mod.status().wasrun() ) {
        if (p->status().accept()) {
            modState = edm::hlt::Pass ;
        } else {
            if ( p->status().index() > ctr ) {
                modState = edm::hlt::Pass ; 
            } else if ( p->status().index() == ctr ) {
                modState = p->status().state() ; 
            }
        }
        mod.setStatus(edm::HLTPathStatus(modState,modIndex)) ;
    }
    ctr++ ; 
  }
  
}
double HLTPerformanceInfo::totalCPUTime ( ) const

Definition at line 34 of file HLTPerformanceInfo.cc.

References i, modules_, and matplotRender::t.

                                              {
  double t = 0;
  for ( size_t i = 0; i < modules_.size(); ++i ) {
    t += modules_[i].cputime();
  }
  return t;
}
double HLTPerformanceInfo::totalPathCPUTime ( const size_t  path)

Definition at line 55 of file HLTPerformanceInfo.cc.

References i, modules_, paths_, ntuplemaker::status, and matplotRender::t.

{
  double t = 0;
  unsigned int cnt = 0;
  ModulesInPath::const_iterator i = paths_[pathnumber].begin();
  for ( ; i != paths_[pathnumber].end(); ++i ) {
    if ( cnt > paths_[pathnumber].status().index()) break;
    ++cnt;
    t += modules_[*i].cputime();
  }
  return t;
}
double HLTPerformanceInfo::totalPathTime ( const size_t  path)

Definition at line 42 of file HLTPerformanceInfo.cc.

References i, modules_, paths_, ntuplemaker::status, and matplotRender::t.

{
  double t = 0;
  unsigned int cnt = 0;
  ModulesInPath::const_iterator i = paths_[pathnumber].begin();
  for ( ; i != paths_[pathnumber].end(); ++i ) {
    if ( cnt > paths_[pathnumber].status().index()) break;
    ++cnt;
    t += modules_[*i].time();
  }
  return t;
}
double HLTPerformanceInfo::totalTime ( ) const

Definition at line 26 of file HLTPerformanceInfo.cc.

References i, modules_, and matplotRender::t.

                                           {
  double t = 0;
  for ( size_t i = 0; i < modules_.size(); ++i ) {
    t += modules_[i].time();
  }
  return t;
}
bool HLTPerformanceInfo::uniqueModule ( const char *  mod) const

Definition at line 140 of file HLTPerformanceInfo.cc.

References funct::false, m, modules_, mergeVDriftHistosByStation::name, L1TEmulatorMonitor_cff::p, paths_, and funct::true.

                                                           {
  int mCtr = 0 ;
  for ( size_t p = 0; p < paths_.size(); ++p ) {
    for ( size_t m = 0; m < paths_[p].numberOfModules(); ++m ) {
      size_t modIndex = paths_[p].getModuleIndex(m);
      if ( modules_[modIndex].name() == std::string(mod) ) 
        ++mCtr;
      if ( mCtr > 1 ) 
        return false;
    }
  }

  if (mCtr == 0) return false ;
  return true ;
}

Member Data Documentation