CMS 3D CMS Logo

StreamContext.cc
Go to the documentation of this file.
4 
5 #include <ostream>
6 
7 namespace edm {
8 
9  StreamContext::StreamContext(StreamID const& streamID, ProcessContext const* processContext)
10  : streamID_(streamID),
11  transition_(Transition::kInvalid),
12  eventID_(EventID(0, 0, 0)),
13  runIndex_(RunIndex::invalidRunIndex()),
14  luminosityBlockIndex_(LuminosityBlockIndex::invalidLuminosityBlockIndex()),
15  timestamp_(),
16  processContext_(processContext) {}
17 
19  Transition transition,
20  EventID const& eventID,
21  RunIndex const& runIndex,
22  LuminosityBlockIndex const& luminosityBlockIndex,
23  Timestamp const& timestamp,
24  ProcessContext const* processContext)
25  : streamID_(streamID),
26  transition_(transition),
27  eventID_(eventID),
28  runIndex_(runIndex),
29  luminosityBlockIndex_(luminosityBlockIndex),
30  timestamp_(timestamp),
31  processContext_(processContext) {}
32 
33  std::ostream& operator<<(std::ostream& os, StreamContext const& sc) {
34  os << "StreamContext: StreamID = " << sc.streamID() << " transition = ";
35  switch (sc.transition()) {
37  os << "BeginStream";
38  break;
40  os << "BeginRun";
41  break;
43  os << "BeginLuminosityBlock";
44  break;
46  os << "Event";
47  break;
49  os << "EndLuminosityBlock";
50  break;
52  os << "EndRun";
53  break;
55  os << "EndStream";
56  break;
58  os << "Invalid";
59  break;
60  }
61  os << "\n " << sc.eventID() << "\n runIndex = " << sc.runIndex().value()
62  << " luminosityBlockIndex = " << sc.luminosityBlockIndex().value()
63  << " unixTime = " << sc.timestamp().unixTime() << " microsecondOffset = " << sc.timestamp().microsecondOffset()
64  << "\n";
65  if (sc.processContext()) {
66  os << " " << *sc.processContext();
67  }
68  return os;
69  }
70 
71  void exceptionContext(std::ostream& os, StreamContext const& sc) {
72  os << "Processing ";
73  auto id = sc.eventID();
74  switch (sc.transition()) {
76  os << "begin Stream";
77  break;
79  os << "stream begin Run " << RunID(id.run());
80  break;
82  os << "stream begin LuminosityBlock " << LuminosityBlockID(id.run(), id.luminosityBlock());
83  break;
85  os << "Event " << sc.eventID();
86  break;
88  os << "stream end LuminosityBlock " << LuminosityBlockID(id.run(), id.luminosityBlock());
89  break;
91  os << "stream end Run " << RunID(id.run());
92  break;
94  os << "end Stream";
95  break;
97  os << "Invalid";
98  break;
99  }
100  os << " stream: " << sc.streamID();
101  }
102 
103  std::string_view transitionName(StreamContext::Transition iTrans) {
104  switch (iTrans) {
106  return "begin Stream";
108  return "stream begin Run";
110  return "stream begin LuminosityBlock";
112  return "Event";
114  return "stream end LuminosityBlock";
116  return "stream end Run";
118  return "end Stream";
120  return "Invalid";
121  }
122  return "Unknown";
123  }
124 
125 } // namespace edm
std::string_view transitionName(GlobalContext::Transition)
void exceptionContext(cms::Exception &, ESModuleCallingContext const &)
Timestamp const & timestamp() const
Definition: StreamContext.h:63
unsigned int value() const
Definition: RunIndex.h:45
unsigned int value() const
StreamID const & streamID() const
Definition: StreamContext.h:55
StreamContext(StreamID const &streamID, ProcessContext const *processContext)
Definition: StreamContext.cc:9
unsigned int microsecondOffset() const
Microseconds offset within second.
Definition: Timestamp.h:36
ProcessContext const * processContext() const
Definition: StreamContext.h:64
Transition transition() const
Definition: StreamContext.h:56
LuminosityBlockIndex const & luminosityBlockIndex() const
Definition: StreamContext.h:62
HLT enums.
EventID const & eventID() const
Definition: StreamContext.h:60
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger table.
RunIndex const & runIndex() const
Definition: StreamContext.h:61
unsigned int unixTime() const
Time in seconds since January 1, 1970.
Definition: Timestamp.h:33