11 namespace statemachine {
13 int const INVALID_RUN_NUMBER = 0;
14 int const INVALID_LUMI = 0;
16 HandleLumis::LumiID
const InvalidLumiID = HandleLumis::LumiID(
edm::ProcessHistoryID(), INVALID_RUN_NUMBER, INVALID_LUMI);
20 processHistoryID_(phid),
31 emptyRunLumiMode_(emptyRunLumiMode) {
59 exitCalled_(
false) { }
74 message <<
"------------------------------------------------------------\n"
75 <<
"Another exception was caught while trying to clean up after the primary fatal exception.\n"
76 <<
" We give up trying to clean up at this point.\n";
77 std::string
msg(message.str());
142 if (context<HandleFiles>().shouldWeCloseOutput()) {
143 return transit<NewInputAndOutputFiles>();
146 return transit<HandleNewInputFile1>();
161 context<HandleFiles>().goToNewInputFile();
168 if (context<HandleFiles>().shouldWeCloseOutput()) {
169 return transit<NewInputAndOutputFiles>();
172 return transit<HandleNewInputFile1>();
187 if (context<HandleFiles>().shouldWeCloseOutput()) {
188 return transit<NewInputAndOutputFiles>();
191 return transit<HandleNewInputFile1>();
213 beginRunCalled_(
false),
214 currentRun_(INVALID_RUN),
215 runException_(
false) { }
230 message <<
"------------------------------------------------------------\n"
231 <<
"Another exception was caught while trying to clean up runs after\n"
232 <<
"the primary exception. We give up trying to clean up runs at\n"
233 <<
"this point. The description of this additional exception follows:\n"
234 <<
"cms::Exception\n"
236 std::string
msg(message.str());
239 catch (std::bad_alloc& e) {
241 message <<
"------------------------------------------------------------\n"
242 <<
"Another exception was caught while trying to clean up runs\n"
243 <<
"after the primary exception. We give up trying to clean up runs\n"
244 <<
"at this point. This additional exception was a\n"
245 <<
"std::bad_alloc exception thrown inside HandleRuns::finalizeRun.\n"
246 <<
"The job has probably exhausted the virtual memory available\n"
247 <<
"to the process.\n";
248 std::string
msg(message.str());
253 message <<
"------------------------------------------------------------\n"
254 <<
"Another exception was caught while trying to clean up runs after\n"
255 <<
"the primary exception. We give up trying to clean up runs at\n"
256 <<
"this point. This additional exception was a\n"
257 <<
"standard library exception thrown inside HandleRuns::finalizeRun\n"
259 std::string
msg(message.str());
264 message <<
"------------------------------------------------------------\n"
265 <<
"Another exception was caught while trying to clean up runs after\n"
266 <<
"the primary exception. We give up trying to clean up runs at\n"
267 <<
"this point. This additional exception was of unknown type and\n"
268 <<
"thrown inside HandleRuns::finalizeRun\n";
269 std::string
msg(message.str());
329 assert(context<HandleRuns>().currentRun() == INVALID_RUN);
330 context<HandleRuns>().setupCurrentRun();
335 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
342 if (run == context<HandleRuns>().currentRun()) {
343 return transit<ContinueRun1>();
345 context<HandleRuns>().finalizeRun();
346 return transit<NewRun>();
351 if (!context<HandleFiles>().shouldWeCloseOutput()) {
352 return transit<HandleNewInputFile2>();
354 return forward_event();
360 context<HandleFiles>().goToNewInputFile();
369 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
377 if (context<HandleRuns>().currentRun() != run) {
381 return transit<ContinueRun1>();
388 if (!context<HandleFiles>().shouldWeCloseOutput()) {
389 return transit<HandleNewInputFile2>();
391 return forward_event();
407 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
414 if (context<HandleRuns>().currentRun() != run) {
418 return transit<ContinueRun1>();
425 if (!context<HandleFiles>().shouldWeCloseOutput()) {
426 return transit<HandleNewInputFile2>();
428 return forward_event();
432 processHistoryID_(phid),
467 message <<
"------------------------------------------------------------\n"
468 <<
"Another exception was caught while trying to clean up lumis after\n"
469 <<
"the primary exception. We give up trying to clean up lumis at\n"
470 <<
"this point. The description of this additional exception follows:\n"
471 <<
"cms::Exception\n"
473 std::string
msg(message.str());
476 catch (std::bad_alloc& e) {
478 message <<
"------------------------------------------------------------\n"
479 <<
"Another exception was caught while trying to clean up lumis\n"
480 <<
"after the primary exception. We give up trying to clean up lumis\n"
481 <<
"at this point. This additional exception was a\n"
482 <<
"std::bad_alloc exception thrown inside HandleLumis::finalizeLumi.\n"
483 <<
"The job has probably exhausted the virtual memory available\n"
484 <<
"to the process.\n";
485 std::string
msg(message.str());
490 message <<
"------------------------------------------------------------\n"
491 <<
"Another exception was caught while trying to clean up lumis after\n"
492 <<
"the primary exception. We give up trying to clean up lumis at\n"
493 <<
"this point. This additional exception was a\n"
494 <<
"standard library exception thrown inside HandleLumis::finalizeLumi\n"
496 std::string
msg(message.str());
501 message <<
"------------------------------------------------------------\n"
502 <<
"Another exception was caught while trying to clean up lumis after\n"
503 <<
"the primary exception. We give up trying to clean up lumis at\n"
504 <<
"this point. This additional exception was of unknown type and\n"
505 <<
"thrown inside HandleLumis::finalizeLumi\n";
506 std::string
msg(message.str());
513 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
523 Run const&
run = context<HandleRuns>().currentRun();
524 assert (run != INVALID_RUN);
529 assert(context<HandleRuns>().beginRunCalled());
569 context<HandleLumis>().setupCurrentLumi();
578 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
579 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
580 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
581 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
582 assert(context<HandleLumis>().currentLumiEmpty() ==
true);
588 if (lumi.
id() == context<HandleLumis>().currentLumi().lumi()) {
589 return transit<ContinueLumi>();
591 return transit<AnotherLumi>();
597 if (!context<HandleFiles>().shouldWeCloseOutput()) {
598 return transit<HandleNewInputFile3>();
600 return forward_event();
606 context<HandleLumis>().finalizeLumi();
607 context<HandleLumis>().setupCurrentLumi();
616 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
617 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
618 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
619 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
620 assert(context<HandleLumis>().currentLumiEmpty() ==
true);
626 if (lumi.
id() == context<HandleLumis>().currentLumi().lumi()) {
627 return transit<ContinueLumi>();
629 return transit<AnotherLumi>();
635 if (!context<HandleFiles>().shouldWeCloseOutput()) {
636 return transit<HandleNewInputFile3>();
638 return forward_event();
654 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
655 assert(context<HandleRuns>().beginRunCalled());
656 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
657 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
658 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
659 assert(context<HandleLumis>().currentLumiEmpty() ==
false);
666 if (!context<HandleFiles>().shouldWeCloseOutput()) {
667 return transit<HandleNewInputFile3>();
669 return forward_event();
679 context<HandleRuns>().beginRunIfNotDoneAlready();
680 context<HandleLumis>().markLumiNonEmpty();
687 context<HandleFiles>().goToNewInputFile();
696 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
697 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
698 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
699 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
707 if (context<HandleRuns>().currentRun() == run) {
708 return transit<ContinueRun2>();
710 return forward_event();
716 if (!context<HandleFiles>().shouldWeCloseOutput()) {
717 return transit<HandleNewInputFile3>();
719 return forward_event();
735 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
736 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
737 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
738 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
745 if (context<HandleRuns>().currentRun() != run) {
746 return forward_event();
749 return transit<ContinueRun2>();
757 if (context<HandleLumis>().currentLumi().
lumi() != lumi.
id()) {
758 return transit<AnotherLumi>();
761 return transit<ContinueLumi>();
768 if (!context<HandleFiles>().shouldWeCloseOutput()) {
769 return transit<HandleNewInputFile3>();
771 return forward_event();
787 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
788 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
789 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
790 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
797 if (context<HandleLumis>().currentLumi().
lumi() != lumi.
id()) {
798 return transit<AnotherLumi>();
801 return transit<ContinueLumi>();
808 if (!context<HandleFiles>().shouldWeCloseOutput()) {
809 return transit<HandleNewInputFile3>();
811 return forward_event();
static const char runNumber_[]
HandleEvent(my_context ctx)
sc::result react(File const &file)
edm::IEventProcessor & ep_
FirstFile(my_context ctx)
virtual void respondToCloseOutputFiles()=0
edm::IEventProcessor * ep_
HandleFiles(my_context ctx)
HandleLumis(my_context ctx)
virtual void setExceptionMessageFiles(std::string &message)=0
virtual void writeLumi(ProcessHistoryID const &phid, int run, int lumi)=0
edm::IEventProcessor & ep_
bool currentLumiEmpty() const
edm::IEventProcessor & ep_
virtual int readAndCacheLumi()=0
virtual std::string explainSelf() const
FileMode fileMode() const
void endRun(Run const &run)
edm::IEventProcessor & ep_
sc::result react(File const &file)
virtual bool shouldWeStop() const =0
sc::result react(Lumi const &lumi)
ContinueLumi(my_context ctx)
edm::IEventProcessor & ep_
virtual void openOutputFiles()=0
virtual void readAndProcessEvent()=0
virtual void setExceptionMessageLumis(std::string &message)=0
virtual void rewindInput()=0
void readAndProcessEvent()
edm::IEventProcessor & ep_
void startingNewLoop(File const &file)
virtual void startingNewLoop()=0
FirstLumi(my_context ctx)
EmptyRunLumiMode emptyRunLumiMode_
virtual void readFile()=0
edm::IEventProcessor & ep() const
bool beginRunCalled() const
HandleRuns(my_context ctx)
edm::IEventProcessor & ep_
EndingLoop(my_context ctx)
virtual void deleteRunFromCache(statemachine::Run const &run)=0
ContinueRun2(my_context ctx)
LumiID const & currentLumi() const
virtual statemachine::Run readAndCacheRun()=0
virtual bool shouldWeCloseOutput() const =0
sc::result react(Run const &run)
virtual void closeOutputFiles()=0
virtual void respondToOpenOutputFiles()=0
Run const & currentRun() const
virtual void deleteLumiFromCache(ProcessHistoryID const &phid, int run, int lumi)=0
ContinueRun1(my_context ctx)
edm::IEventProcessor & ep_
edm::IEventProcessor & ep_
AnotherLumi(my_context ctx)
sc::result react(Lumi const &lumi)
virtual void respondToOpenInputFile()=0
virtual void respondToCloseInputFile()=0
virtual void closeInputFile()=0
bool shouldWeCloseOutput()
Machine(edm::IEventProcessor *ep, FileMode fileMode, EmptyRunLumiMode emptyRunLumiMode)
void rewindAndPrepareForNextLoop(Restart const &restart)
sc::result react(Lumi const &lumi)
sc::result react(Stop const &)
virtual bool alreadyHandlingException() const =0
virtual void endLumi(ProcessHistoryID const &phid, int run, int lumi)=0
edm::IEventProcessor & ep_
virtual void setExceptionMessageRuns(std::string &message)=0
void beginRun(Run const &run)
virtual bool endOfLoop()=0
edm::ProcessHistoryID const & processHistoryID() const
Run(edm::ProcessHistoryID const &phid, int runNumber)
sc::result react(Run const &run)
virtual void doErrorStuff()=0
virtual void beginRun(statemachine::Run const &run)=0
void beginRunIfNotDoneAlready()
sc::result react(Run const &run)
EmptyRunLumiMode emptyRunLumiMode() const
LumiID(edm::ProcessHistoryID const &phid, int run, int lumi)
bool runException() const
virtual void writeRun(statemachine::Run const &run)=0
virtual void endRun(statemachine::Run const &run)=0
virtual void beginLumi(ProcessHistoryID const &phid, int run, int lumi)=0
virtual void prepareForNextLoop()=0