CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTPerformanceInfo.cc
Go to the documentation of this file.
1 // $Id: HLTPerformanceInfo.cc,v 1.17 2009/01/30 23:32:35 elmer Exp $
2 
5 #include <algorithm>
6 
8  paths_.clear(); modules_.clear();
9 }
10 
11 HLTPerformanceInfo::PathList::iterator
13  PathList::iterator l = std::find(paths_.begin(), paths_.end(),
14  pathName);
15  return l;
16 }
17 
18 HLTPerformanceInfo::Modules::iterator
19 HLTPerformanceInfo::findModule(const char* moduleInstanceName) {
20  return std::find(modules_.begin(), modules_.end(),
21  moduleInstanceName);
22 }
23 
24 
25 
27  double t = 0;
28  for ( size_t i = 0; i < modules_.size(); ++i ) {
29  t += modules_[i].time();
30  }
31  return t;
32 }
33 
35  double t = 0;
36  for ( size_t i = 0; i < modules_.size(); ++i ) {
37  t += modules_[i].cputime();
38  }
39  return t;
40 }
41 
42 double HLTPerformanceInfo::totalPathTime(const size_t pathnumber)
43 {
44  double t = 0;
45  unsigned int cnt = 0;
46  ModulesInPath::const_iterator i = paths_[pathnumber].begin();
47  for ( ; i != paths_[pathnumber].end(); ++i ) {
48  if ( cnt > paths_[pathnumber].status().index()) break;
49  ++cnt;
50  t += modules_[*i].time();
51  }
52  return t;
53 }
54 
55 double HLTPerformanceInfo::totalPathCPUTime(const size_t pathnumber)
56 {
57  double t = 0;
58  unsigned int cnt = 0;
59  ModulesInPath::const_iterator i = paths_[pathnumber].begin();
60  for ( ; i != paths_[pathnumber].end(); ++i ) {
61  if ( cnt > paths_[pathnumber].status().index()) break;
62  ++cnt;
63  t += modules_[*i].cputime();
64  }
65  return t;
66 }
67 
68 
69 
71  double t = -1;
72  for ( Modules::const_iterator i = modules_.begin();
73  i != modules_.end(); ++i ) {
74  t = std::max(i->time(),t);
75  }
76  return t;
77 }
78 
80  double t = -1;
81  for ( Modules::const_iterator i = modules_.begin();
82  i != modules_.end(); ++i ) {
83  t = std::max(i->cputime(),t);
84  }
85  return t;
86 }
87 
89 {
90  double t = -1;
91  std::string slowpoke("unknown");
92  for ( Modules::const_iterator i = modules_.begin();
93  i != modules_.end(); ++i ) {
94  if ( i->time() > t ) {
95  slowpoke = i->name();
96  t = i->time();
97  }
98  }
99  return slowpoke.c_str();
100 }
101 
103 {
104  double t = -1;
105  std::string slowpoke("unknown");
106  for ( Modules::const_iterator i = modules_.begin();
107  i != modules_.end(); ++i ) {
108  if ( i->cputime() > t ) {
109  slowpoke = i->name();
110  t = i->cputime();
111  }
112  }
113  return slowpoke.c_str();
114 }
115 
116 
117 // I think we can no longer do this as it requires going from path -> modules
118 // int HLTPerformanceInfo::Module::indexInPath(Path path) const
119 // {
120 // int ctr = 0 ;
121 // ModulesInPath::const_iterator iter = path.begin();
122 // for ( ; iter != path.end(); ++iter ) {
123 // if (modules_[*iter].name() == this->name()) return ctr ;
124 // ctr++ ;
125 // }
126 // //--- Module not found in path ---
127 // return -1 ;
128 // }
129 
131  size_t p) const
132 {
133  // well if this doesn't get your attention....
134  assert(p<paths_.size()&& m<paths_[p].numberOfModules());
135  size_t j = paths_[p].getModuleIndex(m);
136  return modules_.at(j);
137 }
138 
139 
140 bool HLTPerformanceInfo::uniqueModule(const char *mod) const {
141  int mCtr = 0 ;
142  for ( size_t p = 0; p < paths_.size(); ++p ) {
143  for ( size_t m = 0; m < paths_[p].numberOfModules(); ++m ) {
144  size_t modIndex = paths_[p].getModuleIndex(m);
145  if ( modules_[modIndex].name() == std::string(mod) )
146  ++mCtr;
147  if ( mCtr > 1 )
148  return false;
149  }
150  }
151 
152  if (mCtr == 0) return false ;
153  return true ;
154 }
155 
156 int HLTPerformanceInfo::moduleIndexInPath(const char *mod, const char *path)
157 {
158  PathList::iterator p = findPath(path);
159  if ( p == endPaths() ) return -1; // Path doesn't exist
160  int ctr = 0 ;
161  for ( ModulesInPath::const_iterator j = p->begin(); j != p->end(); ++j ) {
162  if ( modules_.at(*j) == mod ) return ctr ;
163  ctr++ ;
164  }
165  return -2; // module not found on path
166 }
167 
168 
169 // Set the status of the module based on the path's status
170 // make sure not to wipe out ones that come after the last
171 // module run on the particular path
173 {
174  PathList::iterator p = findPath(pathName);
175  if ( p == endPaths() ) {
176  return; // do nothing
177  }
178  unsigned int ctr = 0;
179  for ( ModulesInPath::const_iterator j = p->begin(); j != p->end(); ++j ) {
180  edm::hlt::HLTState modState = edm::hlt::Ready ;
181  unsigned int modIndex = 0 ;
182 
183  // get module in the master list
184  Module & mod = modules_.at(*j);
185 
186  if ( ! mod.status().wasrun() ) {
187  if (p->status().accept()) {
188  modState = edm::hlt::Pass ;
189  } else {
190  if ( p->status().index() > ctr ) {
191  modState = edm::hlt::Pass ;
192  } else if ( p->status().index() == ctr ) {
193  modState = p->status().state() ;
194  }
195  }
196  mod.setStatus(edm::HLTPathStatus(modState,modIndex)) ;
197  }
198  ctr++ ;
199  }
200 
201 }
PathList::iterator findPath(const char *pathName)
int i
Definition: DBlmapReader.cc:9
not [yet] run
Definition: HLTenums.h:21
bool wasrun() const
was this path run?
Definition: HLTPathStatus.h:61
double longestModuleCPUTime() const
const Module & getModuleOnPath(size_t m, size_t p) const
HLTState
status of a trigger path
Definition: HLTenums.h:21
double totalPathTime(const size_t path)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
double longestModuleTime() const
edm::HLTPathStatus status() const
list path
Definition: scaleCards.py:51
bool uniqueModule(const char *mod) const
void setStatusOfModulesFromPath(const char *pathName)
accept
Definition: HLTenums.h:22
PathList::iterator endPaths()
const T & max(const T &a, const T &b)
int j
Definition: DBlmapReader.cc:9
list mod
Load physics model.
double totalTime() const
double totalPathCPUTime(const size_t path)
const char * longestModuleTimeName() const
Modules::iterator findModule(const char *moduleInstanceName)
const char * longestModuleCPUTimeName() const
void setStatus(edm::HLTPathStatus status)
tuple status
Definition: ntuplemaker.py:245
int moduleIndexInPath(const char *mod, const char *path)
double totalCPUTime() const