Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:40

0001 // Copyright 2024, Jefferson Science Associates, LLC.
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 
0004 #pragma once
0005 #include <JANA/JException.h>
0006 #include <ostream>
0007 #include <sstream>
0008 
0009 enum class JEventLevel { Run, Subrun, SlowControls, Timeslice, Block, PhysicsEvent, Subevent, Task, None };
0010 
0011 inline std::ostream& operator<<(std::ostream& os, JEventLevel level) {
0012     switch (level) {
0013         case JEventLevel::Run: os << "Run"; break;
0014         case JEventLevel::Subrun: os << "Subrun"; break;
0015         case JEventLevel::Timeslice: os << "Timeslice"; break;
0016         case JEventLevel::Block: os << "Block"; break;
0017         case JEventLevel::SlowControls: os << "SlowControls"; break;
0018         case JEventLevel::PhysicsEvent: os << "PhysicsEvent"; break;
0019         case JEventLevel::Subevent: os << "Subevent"; break;
0020         case JEventLevel::Task: os << "Task"; break;
0021         default: os << "None"; break;
0022     }
0023     return os;
0024 }
0025 
0026 inline std::string toString(JEventLevel level) {
0027     std::stringstream ss;
0028     ss << level;
0029     return ss.str();
0030 }
0031 
0032 inline JEventLevel parseEventLevel(const std::string& level) {
0033     if (level == "Run") return JEventLevel::Run;
0034     if (level == "Subrun") return JEventLevel::Subrun;
0035     if (level == "Timeslice") return JEventLevel::Timeslice;
0036     if (level == "Block") return JEventLevel::Block;
0037     if (level == "SlowControls") return JEventLevel::SlowControls;
0038     if (level == "PhysicsEvent") return JEventLevel::PhysicsEvent;
0039     if (level == "Subevent") return JEventLevel::Subevent;
0040     if (level == "Task") return JEventLevel::Task;
0041     if (level == "None") return JEventLevel::None;
0042     throw JException("Invalid JEventLevel '%s'", level.c_str());
0043 }
0044 
0045 
0046 inline JEventLevel next_level(JEventLevel current_level) {
0047     switch (current_level) {
0048         case JEventLevel::Run: return JEventLevel::Subrun;
0049         case JEventLevel::Subrun: return JEventLevel::Timeslice;
0050         case JEventLevel::Timeslice: return JEventLevel::Block;
0051         case JEventLevel::Block: return JEventLevel::SlowControls;
0052         case JEventLevel::SlowControls: return JEventLevel::PhysicsEvent;
0053         case JEventLevel::PhysicsEvent: return JEventLevel::Subevent;
0054         case JEventLevel::Subevent: return JEventLevel::Task;
0055         case JEventLevel::Task: return JEventLevel::None;
0056         default: return JEventLevel::None;
0057     }
0058 }