CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/DataFormats/HLTReco/interface/ModuleTiming.h

Go to the documentation of this file.
00001 #ifndef Edm_Module_Timing_h
00002 #define Edm_Module_Timing_h
00003 
00004 #include <vector>
00005 #include <string>
00006 
00007 /* Original version: July 2006, Christos Leonidopoulos */
00008 
00009 namespace edm
00010 {
00011 
00012   // structure holding the processing time (per event) and name of a module
00013   class ModuleTime
00014   {
00015   public:
00016     ModuleTime(): name_(""), time_(-1) {}
00017     ModuleTime(std::string Name, double Time): name_(Name), time_(Time) {}
00018       ~ModuleTime(){}
00019       
00020       std::string name() const {return name_;} // module name ("label")
00021       double time() const {return time_;} // processing time for event (secs)
00022   private:
00023     std::string name_;
00024     double time_;
00025   };
00026 
00027   // structure holding processing info for all modules in event (+total time)
00028   class EventTime
00029   {
00030   private:
00031     std::vector<ModuleTime> moduleSet;    
00032     double tot_time_; // total time in event for all modules (in secs)
00033 
00034   public:
00035     EventTime() {reset();}
00036     ~EventTime() {}
00037 
00038     // # of modules contained in event
00039     unsigned size() const{return moduleSet.size();} 
00040     // get hold of ModuleTime structure for module #i, where 0 <= i < size() 
00041     const ModuleTime & moduleTime(unsigned i)
00042       {
00043         return moduleSet.at(i);
00044       }
00045     // get total processing time for event (secs)
00046     double tot_time() const {return tot_time_;}
00047     // get name for module #i, where 0 <= i < size() 
00048     std::string name(unsigned i) const
00049     {
00050       return moduleSet.at(i).name();
00051     }
00052     // get processing time for module #i (secs), where 0 <= i < size() 
00053     double time(unsigned i) const
00054     {
00055       return moduleSet.at(i).time();
00056     }
00057     // add module structure to event
00058     void addModuleTime(const ModuleTime & m)
00059     {
00060       moduleSet.push_back(m); 
00061       tot_time_ += m.time();
00062     }
00063 
00064     // reset all info (ie. from previous event)
00065    void reset()
00066     {moduleSet.clear(); tot_time_ = 0;}
00067     
00068   };
00069 
00070 
00071 }
00072 
00073 #endif // #define Edm_Module_Timing_h