00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "psana/RunIter.h"
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "PSEvt/EventId.h"
00026 #include "psana/Exceptions.h"
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 namespace psana {
00037
00038
00039
00040
00041 RunIter::RunIter ()
00042 : m_evtLoop()
00043 {
00044 }
00045
00046
00047 RunIter::RunIter (const boost::shared_ptr<EventLoop>& evtLoop)
00048 : m_evtLoop(evtLoop)
00049 {
00050 try {
00051 _runIter = m_evtLoop->index().runs().begin();
00052 }
00053 catch (ExceptionAbort e) {
00054 }
00055 }
00056
00057
00058
00059
00060 RunIter::~RunIter ()
00061 {
00062 }
00063
00064
00065 std::pair<RunIter::value_type, boost::shared_ptr<PSEvt::Event> >
00066 RunIter::nextWithEvent()
00067 {
00068 std::pair<RunIter::value_type, boost::shared_ptr<PSEvt::Event> > result;
00069
00070 try {
00071 if (_runIter == m_evtLoop->index().runs().end()) return result;
00072 m_evtLoop->index().setrun(*_runIter);
00073 _runIter++;
00074 }
00075 catch (ExceptionAbort e) {
00076 }
00077
00078
00079 while (true) {
00080 EventLoop::value_type nxt = m_evtLoop->next();
00081 if (nxt.first == EventLoop::None) {
00082
00083 break;
00084 } else if (nxt.first == EventLoop::BeginRun) {
00085
00086 boost::shared_ptr<PSEvt::EventId> eid = nxt.second->get();
00087 int run = eid ? eid->run() : -1 ;
00088 result = std::pair<RunIter::value_type,
00089 boost::shared_ptr<PSEvt::Event> >(RunIter::value_type(m_evtLoop, run), nxt.second);
00090 break;
00091 }
00092 }
00093
00094 return result;
00095 }
00096
00097 RunIter::value_type
00098 RunIter::next()
00099 {
00100 return nextWithEvent().first;
00101 }
00102
00103 }