CMS 3D CMS Logo

GlobalContext.cc
Go to the documentation of this file.
4 
5 #include <ostream>
6 #include <sstream>
7 
8 namespace edm {
9 
11  LuminosityBlockID const& luminosityBlockID,
12  RunIndex const& runIndex,
13  LuminosityBlockIndex const& luminosityBlockIndex,
14  Timestamp const& timestamp,
15  ProcessContext const* processContext)
16  : transition_(transition),
17  luminosityBlockID_(luminosityBlockID),
18  runIndex_(runIndex),
19  luminosityBlockIndex_(luminosityBlockIndex),
20  timestamp_(timestamp),
21  processContext_(processContext) {}
22 
23  GlobalContext::GlobalContext(Transition transition, ProcessContext const* processContext)
24  : transition_(transition),
25  luminosityBlockID_(),
26  runIndex_(RunIndex::invalidRunIndex()),
27  luminosityBlockIndex_(LuminosityBlockIndex::invalidLuminosityBlockIndex()),
28  timestamp_(),
29  processContext_(processContext) {}
30 
31  std::ostream& operator<<(std::ostream& os, GlobalContext const& gc) {
32  os << "GlobalContext: transition = ";
33  switch (gc.transition()) {
35  os << "BeginJob";
36  break;
38  os << "BeginProcessBlock";
39  break;
41  os << "AccessInputProcessBlock";
42  break;
44  os << "BeginRun";
45  break;
47  os << "BeginLuminosityBlock";
48  break;
50  os << "EndLuminosityBlock";
51  break;
53  os << "EndRun";
54  break;
56  os << "EndProcessBlock";
57  break;
59  os << "EndJob";
60  break;
62  os << "WriteProcessBlock";
63  break;
65  os << "WriteRun";
66  break;
68  os << "WriteLuminosityBlock";
69  break;
70  }
71  os << "\n " << gc.luminosityBlockID() << "\n runIndex = " << gc.runIndex().value()
72  << " luminosityBlockIndex = " << gc.luminosityBlockIndex().value()
73  << " unixTime = " << gc.timestamp().unixTime() << " microsecondOffset = " << gc.timestamp().microsecondOffset()
74  << "\n";
75  if (gc.processContext()) {
76  os << " " << *gc.processContext();
77  }
78  return os;
79  }
80 
81  void exceptionContext(std::ostream& os, GlobalContext const& gc) {
82  os << "Processing ";
83  switch (gc.transition()) {
85  os << "begin Job";
86  break;
88  os << "begin ProcessBlock";
89  break;
91  os << "access input ProcessBlock";
92  break;
94  os << "global begin Run " << RunID(gc.luminosityBlockID().run());
95  break;
97  os << "global begin LuminosityBlock " << gc.luminosityBlockID();
98  break;
100  os << "global end LuminosityBlock " << gc.luminosityBlockID();
101  break;
103  os << "global end Run " << RunID(gc.luminosityBlockID().run());
104  break;
106  os << "end ProcessBlock";
107  break;
109  os << "endJob";
110  break;
112  os << "write ProcessBlock";
113  break;
115  os << "write Run " << RunID(gc.luminosityBlockID().run());
116  break;
118  os << "write LuminosityBlock " << gc.luminosityBlockID();
119  break;
120  }
121  }
122 
123  void exceptionContext(cms::Exception& ex, GlobalContext const& globalContext, char const* context) {
124  std::ostringstream ost;
125  if (context && *context != '\0') {
126  ex.addContext(context);
127  }
128  exceptionContext(ost, globalContext);
129  ex.addContext(ost.str());
130  }
131 
132  std::string_view transitionName(GlobalContext::Transition iTrans) {
133  switch (iTrans) {
135  return "begin Job";
137  return "begin ProcessBlock";
139  return "access input ProcessBlock";
141  return "global begin Run";
143  return "global begin LuminosityBlock";
145  return "global end LuminosityBlock";
147  return "global end Run";
149  return "end ProcessBlock";
151  return "endJob";
153  return "write ProcessBlock";
155  return "write Run";
157  return "write LuminosityBlock";
158  }
159  return "Unknown";
160  }
161 } // namespace edm
std::string_view transitionName(GlobalContext::Transition)
void exceptionContext(cms::Exception &, ESModuleCallingContext const &)
unsigned int value() const
Definition: RunIndex.h:45
unsigned int value() const
GlobalContext(Transition transition, LuminosityBlockID const &luminosityBlockID, RunIndex const &runIndex, LuminosityBlockIndex const &luminosityBlockIndex, Timestamp const &timestamp, ProcessContext const *processContext)
unsigned int microsecondOffset() const
Microseconds offset within second.
Definition: Timestamp.h:36
LuminosityBlockIndex const & luminosityBlockIndex() const
Definition: GlobalContext.h:68
ProcessContext const * processContext() const
Definition: GlobalContext.h:70
LuminosityBlockID const & luminosityBlockID() const
Definition: GlobalContext.h:66
Timestamp const & timestamp() const
Definition: GlobalContext.h:69
RunNumber_t run() const
void addContext(std::string const &context)
Definition: Exception.cc:169
Transition transition() const
Definition: GlobalContext.h:59
RunIndex const & runIndex() const
Definition: GlobalContext.h:67
HLT enums.
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
unsigned int unixTime() const
Time in seconds since January 1, 1970.
Definition: Timestamp.h:33