Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-14 22:55:55

0001 #include "FWCore/ServiceRegistry/interface/GlobalContext.h"
0002 #include "FWCore/ServiceRegistry/interface/ProcessContext.h"
0003 
0004 #include <ostream>
0005 
0006 namespace edm {
0007 
0008   GlobalContext::GlobalContext(Transition transition,
0009                                LuminosityBlockID const& luminosityBlockID,
0010                                RunIndex const& runIndex,
0011                                LuminosityBlockIndex const& luminosityBlockIndex,
0012                                Timestamp const& timestamp,
0013                                ProcessContext const* processContext)
0014       : transition_(transition),
0015         luminosityBlockID_(luminosityBlockID),
0016         runIndex_(runIndex),
0017         luminosityBlockIndex_(luminosityBlockIndex),
0018         timestamp_(timestamp),
0019         processContext_(processContext) {}
0020 
0021   GlobalContext::GlobalContext(Transition transition, ProcessContext const* processContext)
0022       : transition_(transition),
0023         luminosityBlockID_(),
0024         runIndex_(RunIndex::invalidRunIndex()),
0025         luminosityBlockIndex_(LuminosityBlockIndex::invalidLuminosityBlockIndex()),
0026         timestamp_(),
0027         processContext_(processContext) {}
0028 
0029   std::ostream& operator<<(std::ostream& os, GlobalContext const& gc) {
0030     os << "GlobalContext: transition = ";
0031     switch (gc.transition()) {
0032       case GlobalContext::Transition::kBeginJob:
0033         os << "BeginJob";
0034         break;
0035       case GlobalContext::Transition::kBeginProcessBlock:
0036         os << "BeginProcessBlock";
0037         break;
0038       case GlobalContext::Transition::kAccessInputProcessBlock:
0039         os << "AccessInputProcessBlock";
0040         break;
0041       case GlobalContext::Transition::kBeginRun:
0042         os << "BeginRun";
0043         break;
0044       case GlobalContext::Transition::kBeginLuminosityBlock:
0045         os << "BeginLuminosityBlock";
0046         break;
0047       case GlobalContext::Transition::kEndLuminosityBlock:
0048         os << "EndLuminosityBlock";
0049         break;
0050       case GlobalContext::Transition::kEndRun:
0051         os << "EndRun";
0052         break;
0053       case GlobalContext::Transition::kEndProcessBlock:
0054         os << "EndProcessBlock";
0055         break;
0056       case GlobalContext::Transition::kEndJob:
0057         os << "EndJob";
0058         break;
0059       case GlobalContext::Transition::kWriteProcessBlock:
0060         os << "WriteProcessBlock";
0061         break;
0062       case GlobalContext::Transition::kWriteRun:
0063         os << "WriteRun";
0064         break;
0065       case GlobalContext::Transition::kWriteLuminosityBlock:
0066         os << "WriteLuminosityBlock";
0067         break;
0068     }
0069     os << "\n    " << gc.luminosityBlockID() << "\n    runIndex = " << gc.runIndex().value()
0070        << "  luminosityBlockIndex = " << gc.luminosityBlockIndex().value()
0071        << "  unixTime = " << gc.timestamp().unixTime() << " microsecondOffset = " << gc.timestamp().microsecondOffset()
0072        << "\n";
0073     if (gc.processContext()) {
0074       os << "    " << *gc.processContext();
0075     }
0076     return os;
0077   }
0078 
0079   void exceptionContext(std::ostream& os, GlobalContext const& gc) {
0080     os << "Processing ";
0081     switch (gc.transition()) {
0082       case GlobalContext::Transition::kBeginJob:
0083         os << "begin Job";
0084         break;
0085       case GlobalContext::Transition::kBeginProcessBlock:
0086         os << "begin ProcessBlock";
0087         break;
0088       case GlobalContext::Transition::kAccessInputProcessBlock:
0089         os << "access input ProcessBlock";
0090         break;
0091       case GlobalContext::Transition::kBeginRun:
0092         os << "global begin Run " << RunID(gc.luminosityBlockID().run());
0093         break;
0094       case GlobalContext::Transition::kBeginLuminosityBlock:
0095         os << "global begin LuminosityBlock " << gc.luminosityBlockID();
0096         break;
0097       case GlobalContext::Transition::kEndLuminosityBlock:
0098         os << "global end LuminosityBlock " << gc.luminosityBlockID();
0099         break;
0100       case GlobalContext::Transition::kEndRun:
0101         os << "global end Run " << RunID(gc.luminosityBlockID().run());
0102         break;
0103       case GlobalContext::Transition::kEndProcessBlock:
0104         os << "end ProcessBlock";
0105         break;
0106       case GlobalContext::Transition::kEndJob:
0107         os << "endJob";
0108         break;
0109       case GlobalContext::Transition::kWriteProcessBlock:
0110         os << "write ProcessBlock";
0111         break;
0112       case GlobalContext::Transition::kWriteRun:
0113         os << "write Run " << RunID(gc.luminosityBlockID().run());
0114         break;
0115       case GlobalContext::Transition::kWriteLuminosityBlock:
0116         os << "write LuminosityBlock " << gc.luminosityBlockID();
0117         break;
0118     }
0119   }
0120 
0121   std::string_view transitionName(GlobalContext::Transition iTrans) {
0122     switch (iTrans) {
0123       case GlobalContext::Transition::kBeginJob:
0124         return "begin Job";
0125       case GlobalContext::Transition::kBeginProcessBlock:
0126         return "begin ProcessBlock";
0127       case GlobalContext::Transition::kAccessInputProcessBlock:
0128         return "access input ProcessBlock";
0129       case GlobalContext::Transition::kBeginRun:
0130         return "global begin Run";
0131       case GlobalContext::Transition::kBeginLuminosityBlock:
0132         return "global begin LuminosityBlock";
0133       case GlobalContext::Transition::kEndLuminosityBlock:
0134         return "global end LuminosityBlock";
0135       case GlobalContext::Transition::kEndRun:
0136         return "global end Run";
0137       case GlobalContext::Transition::kEndProcessBlock:
0138         return "end ProcessBlock";
0139       case GlobalContext::Transition::kEndJob:
0140         return "endJob";
0141       case GlobalContext::Transition::kWriteProcessBlock:
0142         return "write ProcessBlock";
0143       case GlobalContext::Transition::kWriteRun:
0144         return "write Run";
0145       case GlobalContext::Transition::kWriteLuminosityBlock:
0146         return "write LuminosityBlock";
0147     }
0148     return "Unknown";
0149   }
0150 }  // namespace edm