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