Public Member Functions | |
virtual Status | duringLoop (Event const &ev, EventSetup const &es, ProcessingController &pc) |
virtual Status | endOfLoop (EventSetup const &es, unsigned int iCounter) |
NavigateEventsLooper (ParameterSet const &pset) | |
virtual void | startingNewLoop (unsigned int iIteration) |
virtual | ~NavigateEventsLooper () |
Private Member Functions | |
NavigateEventsLooper (NavigateEventsLooper const &) | |
NavigateEventsLooper const & | operator= (NavigateEventsLooper const &) |
Private Attributes | |
int | countLoops_ |
int | maxLoops_ |
bool | shouldStopLoop_ |
bool | shouldStopProcess_ |
Allows interactive navigation from event to event in cmsRun jobs. Just add the looper to the python configuration and then respond to the questions that show up on the display by typing a number followed by return.
This was originally written to test the looper interface used by the Fireworks event display. It might be useful by itself.
If you use this either do not use a PoolOutputModule or turn off fast cloning its configuration.
Definition at line 29 of file NavigateEventsLooper.cc.
edm::NavigateEventsLooper::NavigateEventsLooper | ( | ParameterSet const & | pset | ) |
Definition at line 49 of file NavigateEventsLooper.cc.
: maxLoops_(pset.getUntrackedParameter<int>("maxLoops", -1)), countLoops_(0), shouldStopLoop_(false), shouldStopProcess_(false) { }
edm::NavigateEventsLooper::~NavigateEventsLooper | ( | ) | [virtual] |
Definition at line 56 of file NavigateEventsLooper.cc.
{ }
edm::NavigateEventsLooper::NavigateEventsLooper | ( | NavigateEventsLooper const & | ) | [private] |
EDLooperBase::Status edm::NavigateEventsLooper::duringLoop | ( | Event const & | , |
EventSetup const & | , | ||
ProcessingController & | |||
) | [virtual] |
Called after all event modules have had a chance to process the Event.
Implements edm::EDLooperBase.
Definition at line 64 of file NavigateEventsLooper.cc.
References edm::ProcessingController::canRandomAccess(), gather_cfg::cout, edm::ProcessingController::forwardState(), edm::ProcessingController::kAtFirstEvent, edm::ProcessingController::kAtLastEvent, edm::EDLooperBase::kContinue, edm::ProcessingController::kEventsAheadInFile, edm::ProcessingController::kEventsBackwardsInFile, edm::ProcessingController::kNextFileExists, edm::ProcessingController::kPreviousFileExists, edm::EDLooperBase::kStop, edm::ProcessingController::kUnknownForward, edm::ProcessingController::lastOperationSucceeded(), fjr2json::lumi, edm::ProcessingController::reverseState(), DTTTrigCorrFirst::run, edm::ProcessingController::setTransitionToEvent(), edm::ProcessingController::setTransitionToNextEvent(), edm::ProcessingController::setTransitionToPreviousEvent(), shouldStopLoop_, shouldStopProcess_, and x.
{ if(!pc.lastOperationSucceeded()) { std::cout << "Event could not be found. Nothing done. Try again.\n"; } std::cout << "\nWhat should we do next?\n"; if(pc.forwardState() == ProcessingController::kEventsAheadInFile) { std::cout << "(0) process the next event\n"; } else if(pc.forwardState() == ProcessingController::kNextFileExists) { std::cout << "(0) process the next event if it exists (at last event in the open file. there are more files)\n"; } else if(pc.forwardState() == ProcessingController::kAtLastEvent) { std::cout << "(0) will stop the loop because this is the last event\n"; } else if(pc.forwardState() == ProcessingController::kUnknownForward) { std::cout << "(0) process the next event (if it exists)\n"; } if(pc.canRandomAccess()) { if(pc.reverseState() == ProcessingController::kEventsBackwardsInFile) { std::cout << "(1) process the previous event\n"; } else if(pc.reverseState() == ProcessingController::kPreviousFileExists) { std::cout << "(1) process the previous event if there are any (at first event in the open file. there are previous files)\n"; } else if(pc.reverseState() == ProcessingController::kAtFirstEvent) { std::cout << "(1) will stop the loop because this is the first event\n"; } std::cout << "(2) process a specific event\n"; } std::cout << "(3) stop loop\n"; std::cout << "(4) stop process" << std::endl; int x; bool inputFailed = false; do { inputFailed = false; if(!(std::cin >> x) || x < 0 || x > 4) { inputFailed = true; std::cin.clear(); std::cin.ignore(10000, '\n'); std::cout << "Please enter numeric characters only. The value must be in the range 0 to 4 (inclusive). Please try again." << std::endl; } if(!pc.canRandomAccess() && (x == 1 || x == 2)) { inputFailed = true; std::cout << "The source cannot do random access. 1 and 2 are illegal values. Please try again." << std::endl; } } while(inputFailed); shouldStopLoop_ = false; shouldStopProcess_ = false; if(x == 0) { pc.setTransitionToNextEvent(); } else if(x == 1) { pc.setTransitionToPreviousEvent(); } else if(x == 2) { std::cout << "Which run?" << std::endl; do { inputFailed = false; if(!(std::cin >> x)) { inputFailed = true; std::cin.clear(); std::cin.ignore(10000, '\n'); std::cout << "Please enter numeric characters only. Please try again." << std::endl; } } while(inputFailed); RunNumber_t run = x; std::cout << "Which luminosity block?" << std::endl; do { inputFailed = false; if(!(std::cin >> x)) { inputFailed = true; std::cin.clear(); std::cin.ignore(10000, '\n'); std::cout << "Please enter numeric characters only. Please try again." << std::endl; } } while(inputFailed); LuminosityBlockNumber_t lumi = x; std::cout << "Which event?" << std::endl; do { inputFailed = false; if(!(std::cin >> x)) { inputFailed = true; std::cin.clear(); std::cin.ignore(10000, '\n'); std::cout << "Please enter numeric characters only. Please try again." << std::endl; } } while(inputFailed); EventNumber_t ev = x; pc.setTransitionToEvent(EventID(run, lumi, ev)); } else if(x == 3) { pc.setTransitionToNextEvent(); shouldStopLoop_ = true; } else if(x == 4) { pc.setTransitionToNextEvent(); shouldStopLoop_ = true; shouldStopProcess_ = true; } return shouldStopLoop_ ? kStop : kContinue; }
EDLooperBase::Status edm::NavigateEventsLooper::endOfLoop | ( | EventSetup const & | , |
unsigned int | iCounter | ||
) | [virtual] |
Called after the system has finished one loop over the events. Thar argument is a count of how many loops have been processed before this loo. For the first time through the events the argument will be 0.
Implements edm::EDLooperBase.
Definition at line 166 of file NavigateEventsLooper.cc.
References countLoops_, gather_cfg::cout, edm::EDLooperBase::kContinue, edm::EDLooperBase::kStop, maxLoops_, and shouldStopProcess_.
{ std::cout << "Ending loop" << std::endl; if(shouldStopProcess_) return kStop; ++countLoops_; return(maxLoops_ < 0 || countLoops_ < maxLoops_) ? kContinue : kStop; }
NavigateEventsLooper const& edm::NavigateEventsLooper::operator= | ( | NavigateEventsLooper const & | ) | [private] |
void edm::NavigateEventsLooper::startingNewLoop | ( | unsigned int | int | ) | [virtual] |
Called before system starts to loop over the events. The argument is a count of how many loops have been processed. For the first time through the events the argument will be 0.
Implements edm::EDLooperBase.
Definition at line 60 of file NavigateEventsLooper.cc.
{ }
int edm::NavigateEventsLooper::countLoops_ [private] |
Definition at line 44 of file NavigateEventsLooper.cc.
Referenced by endOfLoop().
int edm::NavigateEventsLooper::maxLoops_ [private] |
Definition at line 43 of file NavigateEventsLooper.cc.
Referenced by endOfLoop().
bool edm::NavigateEventsLooper::shouldStopLoop_ [private] |
Definition at line 45 of file NavigateEventsLooper.cc.
Referenced by duringLoop().
bool edm::NavigateEventsLooper::shouldStopProcess_ [private] |
Definition at line 46 of file NavigateEventsLooper.cc.
Referenced by duringLoop(), and endOfLoop().