test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NavigateEventsLooper.cc
Go to the documentation of this file.
1 
24 
25 #include <iostream>
26 
27 namespace edm {
28 
30 
31  public:
33  virtual ~NavigateEventsLooper();
34 
35  virtual void startingNewLoop(unsigned int iIteration) override;
36  virtual Status duringLoop(Event const& ev, EventSetup const& es, ProcessingController& pc) override;
37  virtual Status endOfLoop(EventSetup const& es, unsigned int iCounter) override;
38 
39  private:
40  NavigateEventsLooper(NavigateEventsLooper const&); // stop default
41  NavigateEventsLooper const& operator=(NavigateEventsLooper const&); // stop default
42 
43  int maxLoops_;
47  };
48 
50  maxLoops_(pset.getUntrackedParameter<int>("maxLoops", -1)),
51  countLoops_(0),
52  shouldStopLoop_(false),
53  shouldStopProcess_(false) {
54  }
55 
57  }
58 
59  void
60  NavigateEventsLooper::startingNewLoop(unsigned int /*iIteration*/) {
61  }
62 
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 
73  std::cout << "(0) process the next event\n";
75  std::cout << "(0) process the next event if it exists (at last event in the open file. there are more files)\n";
77  std::cout << "(0) will stop the loop because this is the last event\n";
79  std::cout << "(0) process the next event (if it exists)\n";
80  }
81 
82  if(pc.canRandomAccess()) {
84  std::cout << "(1) process the previous event\n";
86  std::cout << "(1) process the previous event if there are any (at first event in the open file. there are previous files)\n";
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) {
117  } else if(x == 1) {
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) {
156  shouldStopLoop_ = true;
157  } else if(x == 4) {
159  shouldStopLoop_ = true;
160  shouldStopProcess_ = true;
161  }
162  return shouldStopLoop_ ? kStop : kContinue;
163  }
164 
166  NavigateEventsLooper::endOfLoop(EventSetup const&, unsigned int /*iCounter*/) {
167  std::cout << "Ending loop" << std::endl;
168  if(shouldStopProcess_) return kStop;
169  ++countLoops_;
170  return(maxLoops_ < 0 || countLoops_ < maxLoops_) ? kContinue : kStop;
171  }
172 }
173 
bool canRandomAccess() const
Returns &#39;true&#39; if the job&#39;s source can randomly access.
unsigned int EventNumber_t
Definition: EventID.h:30
NavigateEventsLooper const & operator=(NavigateEventsLooper const &)
tuple lumi
Definition: fjr2json.py:35
#define DEFINE_FWK_LOOPER(type)
bool ev
virtual void startingNewLoop(unsigned int iIteration) override
unsigned int LuminosityBlockNumber_t
Definition: EventID.h:31
void setTransitionToEvent(edm::EventID const &iID)
ForwardState forwardState() const
Returns the present state of processing.
virtual Status endOfLoop(EventSetup const &es, unsigned int iCounter) override
tuple cout
Definition: gather_cfg.py:121
unsigned int RunNumber_t
Definition: EventRange.h:32
volatile std::atomic< bool > shutdown_flag false
Definition: DDAxes.h:10
NavigateEventsLooper(ParameterSet const &pset)
ReverseState reverseState() const
virtual Status duringLoop(Event const &ev, EventSetup const &es, ProcessingController &pc) override