10 namespace statemachine {
12 int const INVALID_RUN_NUMBER = 0;
13 int const INVALID_LUMI = 0;
15 HandleLumis::LumiID
const InvalidLumiID = HandleLumis::LumiID(
edm::ProcessHistoryID(), INVALID_RUN_NUMBER, INVALID_LUMI);
19 processHistoryID_(phid),
30 emptyRunLumiMode_(emptyRunLumiMode) {
58 exitCalled_(
false) { }
72 std::string
message(
"Another exception was caught while trying to clean up files after the primary fatal exception.");
132 if(context<HandleFiles>().shouldWeCloseOutput()) {
133 return transit<NewInputAndOutputFiles>();
135 return transit<HandleNewInputFile1>();
149 context<HandleFiles>().goToNewInputFile();
155 if(context<HandleFiles>().shouldWeCloseOutput()) {
156 return transit<NewInputAndOutputFiles>();
158 return transit<HandleNewInputFile1>();
171 if(context<HandleFiles>().shouldWeCloseOutput()) {
172 return transit<NewInputAndOutputFiles>();
174 return transit<HandleNewInputFile1>();
196 beginRunCalled_(
false),
197 currentRun_(INVALID_RUN),
198 runException_(
false) { }
212 std::string
message(
"Another exception was caught while trying to clean up runs after the primary fatal exception.");
245 ep_.
endRun(run, cleaningUpAfterException);
271 assert(context<HandleRuns>().currentRun() == INVALID_RUN);
272 context<HandleRuns>().setupCurrentRun();
277 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
283 if(run == context<HandleRuns>().currentRun()) {
284 return transit<ContinueRun1>();
286 context<HandleRuns>().finalizeRun(
false);
287 return transit<NewRun>();
291 if(!context<HandleFiles>().shouldWeCloseOutput()) {
292 return transit<HandleNewInputFile2>();
294 return forward_event();
299 context<HandleFiles>().goToNewInputFile();
308 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
315 if(context<HandleRuns>().currentRun() != run) {
318 return transit<ContinueRun1>();
324 if(!context<HandleFiles>().shouldWeCloseOutput()) {
325 return transit<HandleNewInputFile2>();
327 return forward_event();
342 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
348 if(context<HandleRuns>().currentRun() != run) {
351 return transit<ContinueRun1>();
357 if(!context<HandleFiles>().shouldWeCloseOutput()) {
358 return transit<HandleNewInputFile2>();
360 return forward_event();
364 processHistoryID_(phid),
397 std::string
message(
"Another exception was caught while trying to clean up lumis after the primary fatal exception.");
404 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
414 Run const&
run = context<HandleRuns>().currentRun();
415 assert(run != INVALID_RUN);
420 assert(context<HandleRuns>().beginRunCalled());
459 context<HandleLumis>().setupCurrentLumi();
468 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
469 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
470 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
471 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
472 assert(context<HandleLumis>().currentLumiEmpty() ==
true);
477 if(lumi.
id() == context<HandleLumis>().currentLumi().lumi()) {
478 return transit<ContinueLumi>();
480 return transit<AnotherLumi>();
485 if(!context<HandleFiles>().shouldWeCloseOutput()) {
486 return transit<HandleNewInputFile3>();
488 return forward_event();
493 context<HandleLumis>().finalizeLumi(
false);
494 context<HandleLumis>().setupCurrentLumi();
503 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
504 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
505 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
506 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
507 assert(context<HandleLumis>().currentLumiEmpty() ==
true);
512 if(lumi.
id() == context<HandleLumis>().currentLumi().lumi()) {
513 return transit<ContinueLumi>();
515 return transit<AnotherLumi>();
520 if(!context<HandleFiles>().shouldWeCloseOutput()) {
521 return transit<HandleNewInputFile3>();
523 return forward_event();
538 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
539 assert(context<HandleRuns>().beginRunCalled());
540 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
541 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
542 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
543 assert(context<HandleLumis>().currentLumiEmpty() ==
false);
549 if(!context<HandleFiles>().shouldWeCloseOutput()) {
550 return transit<HandleNewInputFile3>();
552 return forward_event();
562 context<HandleRuns>().beginRunIfNotDoneAlready();
563 context<HandleLumis>().markLumiNonEmpty();
569 context<HandleFiles>().goToNewInputFile();
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);
588 if(context<HandleRuns>().currentRun() == run) {
589 return transit<ContinueRun2>();
591 return forward_event();
596 if(!context<HandleFiles>().shouldWeCloseOutput()) {
597 return transit<HandleNewInputFile3>();
599 return forward_event();
614 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
615 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
616 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
617 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
623 if(context<HandleRuns>().currentRun() != run) {
624 return forward_event();
626 return transit<ContinueRun2>();
633 if(context<HandleLumis>().currentLumi().
lumi() != lumi.
id()) {
634 return transit<AnotherLumi>();
636 return transit<ContinueLumi>();
642 if(!context<HandleFiles>().shouldWeCloseOutput()) {
643 return transit<HandleNewInputFile3>();
645 return forward_event();
660 assert(context<HandleRuns>().currentRun() != INVALID_RUN);
661 assert(context<HandleLumis>().currentLumi().processHistoryID() == context<HandleRuns>().currentRun().processHistoryID());
662 assert(context<HandleLumis>().currentLumi().
run() == context<HandleRuns>().currentRun().
runNumber());
663 assert(context<HandleLumis>().currentLumi().
lumi() != INVALID_LUMI);
669 if(context<HandleLumis>().currentLumi().
lumi() != lumi.
id()) {
670 return transit<AnotherLumi>();
672 return transit<ContinueLumi>();
678 if(!context<HandleFiles>().shouldWeCloseOutput()) {
679 return transit<HandleNewInputFile3>();
681 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_
virtual void endRun(statemachine::Run const &run, bool cleaningUpAfterException)=0
void endRun(Run const &run, bool cleaningUpAfterException)
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
virtual void endLumi(ProcessHistoryID const &phid, int run, int lumi, bool cleaningUpAfterException)=0
edm::IEventProcessor & ep_
bool currentLumiEmpty() const
edm::IEventProcessor & ep_
FileMode fileMode() const
edm::IEventProcessor & ep_
sc::result react(File const &file)
virtual int readAndCacheLumi(bool merge)=0
virtual bool shouldWeStop() const =0
sc::result react(Lumi const &lumi)
ContinueLumi(my_context ctx)
void closeFiles(bool cleaningUpAfterException)
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)
virtual statemachine::Run readAndCacheRun(bool merge)=0
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 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
void finalizeLumi(bool cleaningUpAfterException)
void finalizeRun(Run const &)
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
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)
virtual void closeInputFile(bool cleaningUpAfterException)=0
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 beginLumi(ProcessHistoryID const &phid, int run, int lumi)=0
virtual void prepareForNextLoop()=0