CMS 3D CMS Logo

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