LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
Tracer_service.cc
Go to the documentation of this file.
1 // ======================================================================
2 //
3 // Package: Services
4 // Class : Tracer
5 //
6 // ======================================================================
7 
20 #include "fhiclcpp/types/Atom.h"
21 #include "fhiclcpp/types/Name.h"
22 
23 #include <cassert>
24 #include <iostream>
25 #include <string>
26 
27 using namespace std::string_literals;
28 
29 namespace art {
30  class Tracer;
31 }
32 
33 // ======================================================================
34 class art::Tracer {
35 public:
36  struct Config {
37  fhicl::Atom<std::string> indentation{fhicl::Name{"indentation"}, "++"};
38  };
39 
42 
43  void postBeginJob();
44  void postEndJob();
45 
46  void preBeginRun(Run const& run);
47  void postBeginRun(Run const& run);
48 
49  void preBeginSubRun(SubRun const& subRun);
50  void postBeginSubRun(SubRun const& subRun);
51 
52  void preEvent(Event const& ev);
53  void postEvent(Event const& ev);
54 
55  void preEndSubRun(SubRunID const& id, Timestamp const& ts);
56  void postEndSubRun(SubRun const& run);
57 
58  void preEndRun(RunID const& id, Timestamp const& ts);
59  void postEndRun(Run const& run);
60 
61  void preModuleConstruction(ModuleDescription const& md);
62  void postModuleConstruction(ModuleDescription const& md);
63 
64  void preModuleBeginJob(ModuleDescription const& md);
65  void postModuleBeginJob(ModuleDescription const& md);
66 
67  void preModuleBeginRun(ModuleDescription const& md);
68  void postModuleBeginRun(ModuleDescription const& md);
69 
70  void preModuleBeginSubRun(ModuleDescription const& md);
71  void postModuleBeginSubRun(ModuleDescription const& md);
72 
73  void preModuleEvent(ModuleDescription const& md);
74  void postModuleEvent(ModuleDescription const& md);
75 
76  void preModuleEndSubRun(ModuleDescription const& md);
77  void postModuleEndSubRun(ModuleDescription const& md);
78 
79  void preModuleEndRun(ModuleDescription const& md);
80  void postModuleEndRun(ModuleDescription const& md);
81 
82  void preModuleEndJob(ModuleDescription const& md);
83  void postModuleEndJob(ModuleDescription const& md);
84 
85  void preSourceEvent();
86  void postSourceEvent(Event const&);
87 
88  void preSourceSubRun();
89  void postSourceSubRun(SubRun const&);
90 
91  void preSourceRun();
92  void postSourceRun(Run const&);
93 
94  void preOpenFile();
95  void postOpenFile(std::string const& fn);
96 
97  void preCloseFile();
98  void postCloseFile();
99 
100  void postOpenOutputFile(std::string const& label);
101  void preCloseOutputFile(std::string const& label);
102  void postCloseOutputFile(OutputFileInfo const& info);
103 
104  void prePathBeginRun(std::string const& s);
105  void postPathBeginRun(std::string const& s, HLTPathStatus const& hlt);
106 
107  void prePathBeginSubRun(std::string const& s);
108  void postPathBeginSubRun(std::string const& s, HLTPathStatus const& hlt);
109 
110  void prePathEvent(std::string const& s);
111  void postPathEvent(std::string const& s, HLTPathStatus const& hlt);
112 
113  void prePathEndSubRun(std::string const& s);
114  void postPathEndSubRun(std::string const& s, HLTPathStatus const& hlt);
115 
116  void prePathEndRun(std::string const& s);
117  void postPathEndRun(std::string const& s, HLTPathStatus const& hlt);
118 
119 private:
120  std::string indentation_;
121  unsigned int depth_{};
122 
123  std::ostream&
124  indent(unsigned n = 1u) const
125  {
126  for (; n != 0u; --n)
127  std::cout << indentation_;
128  return std::cout;
129  }
130 
131 }; // Tracer
132 
133 // ======================================================================
134 // constructors and destructor
135 
137  ActivityRegistry& iRegistry)
138  : indentation_{config().indentation()}
139 {
140  iRegistry.sPostBeginJob.watch(this, &Tracer::postBeginJob);
141  iRegistry.sPostEndJob.watch(this, &Tracer::postEndJob);
142 
143  iRegistry.sPreModule.watch(this, &Tracer::preModuleEvent);
144  iRegistry.sPostModule.watch(this, &Tracer::postModuleEvent);
145 
146  iRegistry.sPreModuleConstruction.watch(this, &Tracer::preModuleConstruction);
147  iRegistry.sPostModuleConstruction.watch(this,
149 
150  iRegistry.sPreModuleBeginJob.watch(this, &Tracer::preModuleBeginJob);
151  iRegistry.sPostModuleBeginJob.watch(this, &Tracer::postModuleBeginJob);
152 
153  iRegistry.sPreModuleEndJob.watch(this, &Tracer::preModuleEndJob);
154  iRegistry.sPostModuleEndJob.watch(this, &Tracer::postModuleEndJob);
155 
156  iRegistry.sPreModuleBeginRun.watch(this, &Tracer::preModuleBeginRun);
157  iRegistry.sPostModuleBeginRun.watch(this, &Tracer::postModuleBeginRun);
158 
159  iRegistry.sPreModuleEndRun.watch(this, &Tracer::preModuleEndRun);
160  iRegistry.sPostModuleEndRun.watch(this, &Tracer::postModuleEndRun);
161 
162  iRegistry.sPreModuleBeginSubRun.watch(this, &Tracer::preModuleBeginSubRun);
163  iRegistry.sPostModuleBeginSubRun.watch(this, &Tracer::postModuleBeginSubRun);
164 
165  iRegistry.sPreModuleEndSubRun.watch(this, &Tracer::preModuleEndSubRun);
166  iRegistry.sPostModuleEndSubRun.watch(this, &Tracer::postModuleEndSubRun);
167 
168  iRegistry.sPreProcessPath.watch(this, &Tracer::prePathEvent);
169  iRegistry.sPostProcessPath.watch(this, &Tracer::postPathEvent);
170 
171  iRegistry.sPrePathBeginRun.watch(this, &Tracer::prePathBeginRun);
172  iRegistry.sPostPathBeginRun.watch(this, &Tracer::postPathBeginRun);
173 
174  iRegistry.sPrePathEndRun.watch(this, &Tracer::prePathEndRun);
175  iRegistry.sPostPathEndRun.watch(this, &Tracer::postPathEndRun);
176 
177  iRegistry.sPrePathBeginSubRun.watch(this, &Tracer::prePathBeginSubRun);
178  iRegistry.sPostPathBeginSubRun.watch(this, &Tracer::postPathBeginSubRun);
179 
180  iRegistry.sPrePathEndSubRun.watch(this, &Tracer::prePathEndSubRun);
181  iRegistry.sPostPathEndSubRun.watch(this, &Tracer::postPathEndSubRun);
182 
183  iRegistry.sPreProcessEvent.watch(this, &Tracer::preEvent);
184  iRegistry.sPostProcessEvent.watch(this, &Tracer::postEvent);
185 
186  iRegistry.sPreBeginRun.watch(this, &Tracer::preBeginRun);
187  iRegistry.sPostBeginRun.watch(this, &Tracer::postBeginRun);
188 
189  iRegistry.sPreEndRun.watch(this, &Tracer::preEndRun);
190  iRegistry.sPostEndRun.watch(this, &Tracer::postEndRun);
191 
192  iRegistry.sPreBeginSubRun.watch(this, &Tracer::preBeginSubRun);
193  iRegistry.sPostBeginSubRun.watch(this, &Tracer::postBeginSubRun);
194 
195  iRegistry.sPreEndSubRun.watch(this, &Tracer::preEndSubRun);
196  iRegistry.sPostEndSubRun.watch(this, &Tracer::postEndSubRun);
197 
198  iRegistry.sPreSourceEvent.watch(this, &Tracer::preSourceEvent);
199  iRegistry.sPostSourceEvent.watch(this, &Tracer::postSourceEvent);
200 
201  iRegistry.sPreOpenFile.watch(this, &Tracer::preOpenFile);
202  iRegistry.sPostOpenFile.watch(this, &Tracer::postOpenFile);
203 
204  iRegistry.sPreCloseFile.watch(this, &Tracer::preCloseFile);
205  iRegistry.sPostCloseFile.watch(this, &Tracer::postCloseFile);
206 
207  iRegistry.sPostOpenOutputFile.watch(this, &Tracer::postOpenOutputFile);
208  iRegistry.sPreCloseOutputFile.watch(this, &Tracer::preCloseOutputFile);
209  iRegistry.sPostCloseOutputFile.watch(this, &Tracer::postCloseOutputFile);
210 
211  iRegistry.sPreSourceRun.watch(this, &Tracer::preSourceRun);
212  iRegistry.sPostSourceRun.watch(this, &Tracer::postSourceRun);
213 
214  iRegistry.sPreSourceSubRun.watch(this, &Tracer::preSourceSubRun);
215  iRegistry.sPostSourceSubRun.watch(this, &Tracer::postSourceSubRun);
216 }
217 
218 // ======================================================================
219 // member functions
220 
221 void
223 {
224  indent(1) << " Job started" << std::endl;
225 }
226 
227 void
229 {
230  indent(1) << " Job ended" << std::endl;
231 }
232 
233 void
235 {
236  indent(2) << "source event" << std::endl;
237 }
238 
239 void
241 {
242  indent(2) << "finished: source event" << std::endl;
243 }
244 
245 void
247 {
248  indent(2) << "source subRun" << std::endl;
249 }
250 
251 void
253 {
254  indent(2) << "finished: source subRun" << std::endl;
255 }
256 
257 void
259 {
260  indent(2) << "source run" << std::endl;
261 }
262 
263 void
265 {
266  indent(2) << "finished: source run" << std::endl;
267 }
268 
269 void
271 {
272  indent(2) << "open input file" << std::endl;
273 }
274 
275 void
276 art::Tracer::postOpenFile(std::string const& fn)
277 {
278  indent(2) << "finished: open input file" << fn << std::endl;
279 }
280 
281 void
283 {
284  indent(2) << "close input file" << std::endl;
285 }
286 
287 void
289 {
290  indent(2) << "finished: close input file" << std::endl;
291 }
292 
293 void
294 art::Tracer::postOpenOutputFile(std::string const& label)
295 {
296  indent(2) << "opened output file from " << label << std::endl;
297 }
298 
299 void
300 art::Tracer::preCloseOutputFile(std::string const& label)
301 {
302  indent(2) << "close output file from " << label << std::endl;
303 }
304 
305 void
307 {
308  std::string const fn{info.fileName().empty() ? "<none>"s : info.fileName()};
309  indent(2) << "finished close output file " << fn << " from "
310  << info.moduleLabel() << std::endl;
311 }
312 
313 void
315 {
316  depth_ = 0;
317  indent(2) << " processing event:" << ev.id() << " time:" << ev.time().value()
318  << std::endl;
319 }
320 
321 void
323 {
324  indent(2) << " finished event:" << std::endl;
325 }
326 
327 void
328 art::Tracer::prePathEvent(std::string const& iName)
329 {
330  indent(3) << " processing path for event:" << iName << std::endl;
331 }
332 
333 void
334 art::Tracer::postPathEvent(std::string const& /*iName*/, HLTPathStatus const&)
335 {
336  indent(3) << " finished path for event:" << std::endl;
337 }
338 
339 void
341 {
342  ++depth_;
343  indent(3 + depth_) << " module for event:" << iDescription.moduleLabel()
344  << std::endl;
345 }
346 
347 void
349 {
350  --depth_;
351  indent(4 + depth_) << " finished for event:" << iDescription.moduleLabel()
352  << std::endl;
353 }
354 
355 void
357 {
358  depth_ = 0;
359  indent(2) << " processing begin run:" << run.id()
360  << " time:" << run.beginTime().value() << std::endl;
361 }
362 
363 void
365 {
366  indent(2) << " finished begin run:" << std::endl;
367 }
368 
369 void
370 art::Tracer::prePathBeginRun(std::string const& iName)
371 {
372  indent(3) << " processing path for begin run:" << iName << std::endl;
373 }
374 
375 void
376 art::Tracer::postPathBeginRun(std::string const& /*iName*/,
377  HLTPathStatus const&)
378 {
379  indent(3) << " finished path for begin run:" << std::endl;
380 }
381 
382 void
384 {
385  ++depth_;
386  indent(3 + depth_) << " module for begin run:" << iDescription.moduleLabel()
387  << std::endl;
388 }
389 
390 void
392 {
393  --depth_;
394  indent(4 + depth_) << " finished for begin run:" << iDescription.moduleLabel()
395  << std::endl;
396 }
397 
398 void
399 art::Tracer::preEndRun(RunID const& iID, Timestamp const& iTime)
400 {
401  depth_ = 0;
402  indent(2) << " processing end run:" << iID << " time:" << iTime.value()
403  << std::endl;
404 }
405 
406 void
408 {
409  indent(2) << " finished end run:" << std::endl;
410 }
411 
412 void
413 art::Tracer::prePathEndRun(std::string const& iName)
414 {
415  indent(3) << " processing path for end run:" << iName << std::endl;
416 }
417 
418 void
419 art::Tracer::postPathEndRun(std::string const& /*iName*/, HLTPathStatus const&)
420 {
421  indent(3) << " finished path for end run:" << std::endl;
422 }
423 
424 void
426 {
427  ++depth_;
428  indent(3 + depth_) << " module for end run:" << iDescription.moduleLabel()
429  << std::endl;
430 }
431 
432 void
434 {
435  --depth_;
436  indent(4 + depth_) << " finished for end run:" << iDescription.moduleLabel()
437  << std::endl;
438 }
439 
440 void
442 {
443  depth_ = 0;
444  indent(2) << " processing begin subRun:" << subRun.id()
445  << " time:" << subRun.beginTime().value() << std::endl;
446 }
447 
448 void
450 {
451  indent(2) << " finished begin subRun:" << std::endl;
452 }
453 
454 void
455 art::Tracer::prePathBeginSubRun(std::string const& iName)
456 {
457  indent(3) << " processing path for begin subRun:" << iName << std::endl;
458 }
459 
460 void
461 art::Tracer::postPathBeginSubRun(std::string const& /*iName*/,
462  HLTPathStatus const&)
463 {
464  indent(3) << " finished path for begin subRun:" << std::endl;
465 }
466 
467 void
469 {
470  ++depth_;
471  indent(3 + depth_) << " module for begin subRun:"
472  << iDescription.moduleLabel() << std::endl;
473 }
474 void
476 {
477  --depth_;
478  indent(4) << " finished for begin subRun:" << iDescription.moduleLabel()
479  << std::endl;
480 }
481 
482 void
484 {
485  depth_ = 0;
486  indent(2) << " processing end subRun:" << iID << " time:" << iTime.value()
487  << std::endl;
488 }
489 void
491 {
492  indent(2) << " finished end subRun:" << std::endl;
493 }
494 
495 void
496 art::Tracer::prePathEndSubRun(std::string const& iName)
497 {
498  indent(3) << " processing path for end subRun:" << iName << std::endl;
499 }
500 
501 void
502 art::Tracer::postPathEndSubRun(std::string const& /*iName*/,
503  HLTPathStatus const&)
504 {
505  indent(3) << " finished path for end subRun:" << std::endl;
506 }
507 
508 void
510 {
511  ++depth_;
512  indent(3 + depth_) << " module for end subRun:" << iDescription.moduleLabel()
513  << std::endl;
514 }
515 
516 void
518 {
519  --depth_;
520  indent(4 + depth_) << " finished for end subRun:"
521  << iDescription.moduleLabel() << std::endl;
522 }
523 
524 void
526 {
527  indent(1) << " constructing module:" << iDescription.moduleLabel()
528  << std::endl;
529 }
530 
531 void
533 {
534  indent(1) << " construction finished:" << iDescription.moduleLabel()
535  << std::endl;
536 }
537 
538 void
540 {
541  indent(1) << " beginJob module:" << iDescription.moduleLabel() << std::endl;
542 }
543 
544 void
546 {
547  indent(1) << " beginJob finished:" << iDescription.moduleLabel() << std::endl;
548 }
549 
550 void
552 {
553  indent(1) << " endJob module:" << iDescription.moduleLabel() << std::endl;
554 }
555 
556 void
558 {
559  indent(1) << " endJob finished:" << iDescription.moduleLabel() << std::endl;
560 }
561 
562 // ======================================================================
void prePathEndRun(std::string const &s)
std::string indentation_
void preCloseOutputFile(std::string const &label)
Float_t s
Definition: plot.C:23
void prePathEndSubRun(std::string const &s)
void postSourceSubRun(SubRun const &)
void prePathEvent(std::string const &s)
void postSourceRun(Run const &)
void preModuleConstruction(ModuleDescription const &md)
void postOpenOutputFile(std::string const &label)
void postModuleConstruction(ModuleDescription const &md)
#define DEFINE_ART_SERVICE(svc)
Definition: ServiceMacros.h:93
void postPathBeginRun(std::string const &s, HLTPathStatus const &hlt)
void preEndRun(RunID const &id, Timestamp const &ts)
#define DECLARE_ART_SERVICE(svc, scope)
Definition: ServiceMacros.h:91
void postModuleBeginJob(ModuleDescription const &md)
void postModuleBeginSubRun(ModuleDescription const &md)
void preBeginRun(Run const &run)
void prePathBeginRun(std::string const &s)
Timestamp const & beginTime() const
Definition: SubRun.h:59
std::string const & moduleLabel() const
constexpr TimeValue_t value() const
Definition: Timestamp.h:24
Definition: Run.h:30
void preBeginSubRun(SubRun const &subRun)
std::ostream & indent(unsigned n=1u) const
void postEndSubRun(SubRun const &run)
void preSourceEvent()
void postModuleBeginRun(ModuleDescription const &md)
std::string const & fileName() const
void postEvent(Event const &ev)
void postBeginRun(Run const &run)
void preModuleEndJob(ModuleDescription const &md)
void preCloseFile()
void postSourceEvent(Event const &)
RunID const & id() const
Definition: Run.h:41
void postPathBeginSubRun(std::string const &s, HLTPathStatus const &hlt)
void postEndRun(Run const &run)
void preModuleBeginSubRun(ModuleDescription const &md)
void postOpenFile(std::string const &fn)
std::string const & moduleLabel() const
void postModuleEvent(ModuleDescription const &md)
void preModuleEndRun(ModuleDescription const &md)
void postModuleEndJob(ModuleDescription const &md)
void preModuleBeginJob(ModuleDescription const &md)
void postBeginJob()
unsigned int depth_
void preEvent(Event const &ev)
void prePathBeginSubRun(std::string const &s)
void preSourceRun()
SubRunID id() const
Definition: SubRun.h:53
void preModuleEndSubRun(ModuleDescription const &md)
void preSourceSubRun()
Timestamp time() const
Definition: Event.h:61
HLT enums.
void preModuleBeginRun(ModuleDescription const &md)
void preModuleEvent(ModuleDescription const &md)
Char_t n[5]
void postModuleEndSubRun(ModuleDescription const &md)
void postPathEndRun(std::string const &s, HLTPathStatus const &hlt)
Timestamp const & beginTime() const
Definition: Run.h:51
void postCloseFile()
Tracer(ServiceTable< Config > const &, ActivityRegistry &)
void preEndSubRun(SubRunID const &id, Timestamp const &ts)
void preOpenFile()
void postCloseOutputFile(OutputFileInfo const &info)
EventID id() const
Definition: Event.h:56
void postPathEndSubRun(std::string const &s, HLTPathStatus const &hlt)
void postBeginSubRun(SubRun const &subRun)
void postModuleEndRun(ModuleDescription const &md)
void postPathEvent(std::string const &s, HLTPathStatus const &hlt)