CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
edm::NavigateEventsLooper Class Reference
Inheritance diagram for edm::NavigateEventsLooper:
edm::EDLooperBase

Public Member Functions

virtual Status duringLoop (Event const &ev, EventSetup const &es, ProcessingController &pc) override
 
virtual Status endOfLoop (EventSetup const &es, unsigned int iCounter) override
 
 NavigateEventsLooper (ParameterSet const &pset)
 
virtual void startingNewLoop (unsigned int iIteration) override
 
virtual ~NavigateEventsLooper ()
 
- Public Member Functions inherited from edm::EDLooperBase
virtual void attachTo (ActivityRegistry &)
 Override this method if you need to monitor the state of the processing. More...
 
virtual void beginOfJob (EventSetup const &)
 
virtual void beginOfJob ()
 
void copyInfo (ScheduleInfo const &)
 
void doBeginLuminosityBlock (LuminosityBlockPrincipal &, EventSetup const &, ProcessContext *)
 
void doBeginRun (RunPrincipal &, EventSetup const &, ProcessContext *)
 
Status doDuringLoop (EventPrincipal &eventPrincipal, EventSetup const &es, ProcessingController &, StreamContext *)
 
void doEndLuminosityBlock (LuminosityBlockPrincipal &, EventSetup const &, ProcessContext *)
 
Status doEndOfLoop (EventSetup const &es)
 
void doEndRun (RunPrincipal &, EventSetup const &, ProcessContext *)
 
void doStartingNewLoop ()
 
 EDLooperBase ()
 
 EDLooperBase (EDLooperBase const &)=delete
 
virtual void endOfJob ()
 
virtual std::set
< eventsetup::EventSetupRecordKey
modifyingRecords () const
 
EDLooperBaseoperator= (EDLooperBase const &)=delete
 
void prepareForNextLoop (eventsetup::EventSetupProvider *esp)
 
void setActionTable (ExceptionToActionTable const *actionTable)
 
void setModuleChanger (ModuleChanger const *)
 
virtual ~EDLooperBase ()
 

Private Member Functions

 NavigateEventsLooper (NavigateEventsLooper const &)
 
NavigateEventsLooper const & operator= (NavigateEventsLooper const &)
 

Private Attributes

int countLoops_
 
int maxLoops_
 
bool shouldStopLoop_
 
bool shouldStopProcess_
 

Additional Inherited Members

- Public Types inherited from edm::EDLooperBase
enum  Status { kContinue, kStop }
 
- Protected Member Functions inherited from edm::EDLooperBase
ModuleChanger const * moduleChanger () const
 This only returns a non-zero value during the call to endOfLoop. More...
 
ScheduleInfo const * scheduleInfo () const
 This returns a non-zero value after the constructor has been called. More...
 

Detailed Description

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.

Author
W. David Dagenhart, created 27 August, 2010

Definition at line 29 of file NavigateEventsLooper.cc.

Constructor & Destructor Documentation

edm::NavigateEventsLooper::NavigateEventsLooper ( ParameterSet const &  pset)

Definition at line 49 of file NavigateEventsLooper.cc.

49  :
50  maxLoops_(pset.getUntrackedParameter<int>("maxLoops", -1)),
51  countLoops_(0),
52  shouldStopLoop_(false),
53  shouldStopProcess_(false) {
54  }
edm::NavigateEventsLooper::~NavigateEventsLooper ( )
virtual

Definition at line 56 of file NavigateEventsLooper.cc.

56  {
57  }
edm::NavigateEventsLooper::NavigateEventsLooper ( NavigateEventsLooper const &  )
private

Member Function Documentation

EDLooperBase::Status edm::NavigateEventsLooper::duringLoop ( Event const &  ,
EventSetup const &  ,
ProcessingController  
)
overridevirtual

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, ev, 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.

64  {
65 
66  if(!pc.lastOperationSucceeded()) {
67  std::cout << "Event could not be found. Nothing done. Try again.\n";
68  }
69 
70  std::cout << "\nWhat should we do next?\n";
71 
72  if(pc.forwardState() == ProcessingController::kEventsAheadInFile) {
73  std::cout << "(0) process the next event\n";
74  } else if(pc.forwardState() == ProcessingController::kNextFileExists) {
75  std::cout << "(0) process the next event if it exists (at last event in the open file. there are more files)\n";
76  } else if(pc.forwardState() == ProcessingController::kAtLastEvent) {
77  std::cout << "(0) will stop the loop because this is the last event\n";
78  } else if(pc.forwardState() == ProcessingController::kUnknownForward) {
79  std::cout << "(0) process the next event (if it exists)\n";
80  }
81 
82  if(pc.canRandomAccess()) {
83  if(pc.reverseState() == ProcessingController::kEventsBackwardsInFile) {
84  std::cout << "(1) process the previous event\n";
85  } else if(pc.reverseState() == ProcessingController::kPreviousFileExists) {
86  std::cout << "(1) process the previous event if there are any (at first event in the open file. there are previous files)\n";
87  } else if(pc.reverseState() == ProcessingController::kAtFirstEvent) {
88  std::cout << "(1) will stop the loop because this is the first event\n";
89  }
90 
91  std::cout << "(2) process a specific event\n";
92  }
93 
94  std::cout << "(3) stop loop\n";
95  std::cout << "(4) stop process" << std::endl;
96  int x;
97 
98  bool inputFailed = false;
99  do {
100  inputFailed = false;
101  if(!(std::cin >> x) || x < 0 || x > 4) {
102  inputFailed = true;
103  std::cin.clear();
104  std::cin.ignore(10000, '\n');
105  std::cout << "Please enter numeric characters only. The value must be in the range 0 to 4 (inclusive). Please try again." << std::endl;
106  }
107  if(!pc.canRandomAccess() && (x == 1 || x == 2)) {
108  inputFailed = true;
109  std::cout << "The source cannot do random access. 1 and 2 are illegal values. Please try again." << std::endl;
110  }
111  } while(inputFailed);
112 
113  shouldStopLoop_ = false;
114  shouldStopProcess_ = false;
115  if(x == 0) {
116  pc.setTransitionToNextEvent();
117  } else if(x == 1) {
118  pc.setTransitionToPreviousEvent();
119  } else if(x == 2) {
120  std::cout << "Which run?" << std::endl;
121  do {
122  inputFailed = false;
123  if(!(std::cin >> x)) {
124  inputFailed = true;
125  std::cin.clear();
126  std::cin.ignore(10000, '\n');
127  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
128  }
129  } while(inputFailed);
130  RunNumber_t run = x;
131  std::cout << "Which luminosity block?" << std::endl;
132  do {
133  inputFailed = false;
134  if(!(std::cin >> x)) {
135  inputFailed = true;
136  std::cin.clear();
137  std::cin.ignore(10000, '\n');
138  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
139  }
140  } while(inputFailed);
142  std::cout << "Which event?" << std::endl;
143  do {
144  inputFailed = false;
145  if(!(std::cin >> x)) {
146  inputFailed = true;
147  std::cin.clear();
148  std::cin.ignore(10000, '\n');
149  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
150  }
151  } while(inputFailed);
152  EventNumber_t ev = x;
153  pc.setTransitionToEvent(EventID(run, lumi, ev));
154  } else if(x == 3) {
155  pc.setTransitionToNextEvent();
156  shouldStopLoop_ = true;
157  } else if(x == 4) {
158  pc.setTransitionToNextEvent();
159  shouldStopLoop_ = true;
160  shouldStopProcess_ = true;
161  }
162  return shouldStopLoop_ ? kStop : kContinue;
163  }
unsigned int EventNumber_t
Definition: EventID.h:30
tuple lumi
Definition: fjr2json.py:35
bool ev
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
tuple cout
Definition: gather_cfg.py:121
unsigned int RunNumber_t
Definition: EventRange.h:32
Definition: DDAxes.h:10
EDLooperBase::Status edm::NavigateEventsLooper::endOfLoop ( EventSetup const &  ,
unsigned int  iCounter 
)
overridevirtual

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_.

NavigateEventsLooper const& edm::NavigateEventsLooper::operator= ( NavigateEventsLooper const &  )
private
void edm::NavigateEventsLooper::startingNewLoop ( unsigned int  int)
overridevirtual

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.

60  {
61  }

Member Data Documentation

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().