CMS 3D CMS Logo

NavigateEventsLooper.cc
Go to the documentation of this file.
1 
24 
25 #include <iostream>
26 
27 namespace edm {
28 
30  public:
32  NavigateEventsLooper(NavigateEventsLooper const&) = delete; // stop default
33  NavigateEventsLooper const& operator=(NavigateEventsLooper const&) = delete; // stop default
34  ~NavigateEventsLooper() override;
35 
36  void startingNewLoop(unsigned int iIteration) override;
37  Status duringLoop(Event const& ev, EventSetup const& es, ProcessingController& pc) override;
38  Status endOfLoop(EventSetup const& es, unsigned int iCounter) override;
39 
40  private:
41  int maxLoops_;
45  };
46 
48  : maxLoops_(pset.getUntrackedParameter<int>("maxLoops", -1)),
49  countLoops_(0),
50  shouldStopLoop_(false),
51  shouldStopProcess_(false) {}
52 
54 
55  void NavigateEventsLooper::startingNewLoop(unsigned int /*iIteration*/) {}
56 
58  if (!pc.lastOperationSucceeded()) {
59  std::cout << "Event could not be found. Nothing done. Try again.\n";
60  }
61 
62  std::cout << "\nWhat should we do next?\n";
63 
65  std::cout << "(0) process the next event\n";
67  std::cout << "(0) process the next event if it exists (at last event in the open file. there are more files)\n";
69  std::cout << "(0) will stop the loop because this is the last event\n";
71  std::cout << "(0) process the next event (if it exists)\n";
72  }
73 
74  if (pc.canRandomAccess()) {
76  std::cout << "(1) process the previous event\n";
78  std::cout << "(1) process the previous event if there are any (at first event in the open file. there are "
79  "previous files)\n";
81  std::cout << "(1) will stop the loop because this is the first event\n";
82  }
83 
84  std::cout << "(2) process a specific event\n";
85  }
86 
87  std::cout << "(3) stop loop\n";
88  std::cout << "(4) stop process" << std::endl;
89  long long int x;
90 
91  bool inputFailed = false;
92  do {
93  inputFailed = false;
94  if (!(std::cin >> x) || x < 0 || x > 4) {
95  inputFailed = true;
96  std::cin.clear();
97  std::cin.ignore(10000, '\n');
98  std::cout << "Please enter numeric characters only. The value must be in the range 0 to 4 (inclusive). Please "
99  "try again."
100  << std::endl;
101  }
102  if (!pc.canRandomAccess() && (x == 1 || x == 2)) {
103  inputFailed = true;
104  std::cout << "The source cannot do random access. 1 and 2 are illegal values. Please try again." << std::endl;
105  }
106  } while (inputFailed);
107 
108  shouldStopLoop_ = false;
109  shouldStopProcess_ = false;
110  if (x == 0) {
112  } else if (x == 1) {
114  } else if (x == 2) {
115  std::cout << "Which run?" << std::endl;
116  do {
117  inputFailed = false;
118  if (!(std::cin >> x)) {
119  inputFailed = true;
120  std::cin.clear();
121  std::cin.ignore(10000, '\n');
122  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
123  }
124  } while (inputFailed);
125  RunNumber_t run = x;
126  std::cout << "Which luminosity block?" << std::endl;
127  do {
128  inputFailed = false;
129  if (!(std::cin >> x)) {
130  inputFailed = true;
131  std::cin.clear();
132  std::cin.ignore(10000, '\n');
133  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
134  }
135  } while (inputFailed);
137  std::cout << "Which event?" << std::endl;
138  do {
139  inputFailed = false;
140  if (!(std::cin >> x)) {
141  inputFailed = true;
142  std::cin.clear();
143  std::cin.ignore(10000, '\n');
144  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
145  }
146  } while (inputFailed);
147  EventNumber_t ev = x;
149  } else if (x == 3) {
151  shouldStopLoop_ = true;
152  } else if (x == 4) {
154  shouldStopLoop_ = true;
155  shouldStopProcess_ = true;
156  }
157  return shouldStopLoop_ ? kStop : kContinue;
158  }
159 
161  std::cout << "Ending loop" << std::endl;
162  if (shouldStopProcess_)
163  return kStop;
164  ++countLoops_;
165  return (maxLoops_ < 0 || countLoops_ < maxLoops_) ? kContinue : kStop;
166  }
167 } // namespace edm
168 
NavigateEventsLooper const & operator=(NavigateEventsLooper const &)=delete
unsigned long long EventNumber_t
#define DEFINE_FWK_LOOPER(type)
ReverseState reverseState() const
void startingNewLoop(unsigned int iIteration) override
unsigned int LuminosityBlockNumber_t
void setTransitionToEvent(edm::EventID const &iID)
bool canRandomAccess() const
Returns &#39;true&#39; if the job&#39;s source can randomly access.
ForwardState forwardState() const
Returns the present state of processing.
Status endOfLoop(EventSetup const &es, unsigned int iCounter) override
HLT enums.
float x
unsigned int RunNumber_t
NavigateEventsLooper(ParameterSet const &pset)
Status duringLoop(Event const &ev, EventSetup const &es, ProcessingController &pc) override