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() override;
33 
34  void startingNewLoop(unsigned int iIteration) override;
35  Status duringLoop(Event const& ev, EventSetup const& es, ProcessingController& pc) override;
36  Status endOfLoop(EventSetup const& es, unsigned int iCounter) override;
37 
38  private:
39  NavigateEventsLooper(NavigateEventsLooper const&) = delete; // stop default
40  NavigateEventsLooper const& operator=(NavigateEventsLooper const&) = delete; // stop default
41 
42  int maxLoops_;
46  };
47 
49  : maxLoops_(pset.getUntrackedParameter<int>("maxLoops", -1)),
50  countLoops_(0),
51  shouldStopLoop_(false),
52  shouldStopProcess_(false) {}
53 
55 
56  void NavigateEventsLooper::startingNewLoop(unsigned int /*iIteration*/) {}
57 
59  if (!pc.lastOperationSucceeded()) {
60  std::cout << "Event could not be found. Nothing done. Try again.\n";
61  }
62 
63  std::cout << "\nWhat should we do next?\n";
64 
66  std::cout << "(0) process the next event\n";
68  std::cout << "(0) process the next event if it exists (at last event in the open file. there are more files)\n";
70  std::cout << "(0) will stop the loop because this is the last event\n";
72  std::cout << "(0) process the next event (if it exists)\n";
73  }
74 
75  if (pc.canRandomAccess()) {
77  std::cout << "(1) process the previous event\n";
79  std::cout << "(1) process the previous event if there are any (at first event in the open file. there are "
80  "previous files)\n";
82  std::cout << "(1) will stop the loop because this is the first event\n";
83  }
84 
85  std::cout << "(2) process a specific event\n";
86  }
87 
88  std::cout << "(3) stop loop\n";
89  std::cout << "(4) stop process" << std::endl;
90  long long int x;
91 
92  bool inputFailed = false;
93  do {
94  inputFailed = false;
95  if (!(std::cin >> x) || x < 0 || x > 4) {
96  inputFailed = true;
97  std::cin.clear();
98  std::cin.ignore(10000, '\n');
99  std::cout << "Please enter numeric characters only. The value must be in the range 0 to 4 (inclusive). Please "
100  "try again."
101  << std::endl;
102  }
103  if (!pc.canRandomAccess() && (x == 1 || x == 2)) {
104  inputFailed = true;
105  std::cout << "The source cannot do random access. 1 and 2 are illegal values. Please try again." << std::endl;
106  }
107  } while (inputFailed);
108 
109  shouldStopLoop_ = false;
110  shouldStopProcess_ = false;
111  if (x == 0) {
113  } else if (x == 1) {
115  } else if (x == 2) {
116  std::cout << "Which run?" << std::endl;
117  do {
118  inputFailed = false;
119  if (!(std::cin >> x)) {
120  inputFailed = true;
121  std::cin.clear();
122  std::cin.ignore(10000, '\n');
123  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
124  }
125  } while (inputFailed);
126  RunNumber_t run = x;
127  std::cout << "Which luminosity block?" << std::endl;
128  do {
129  inputFailed = false;
130  if (!(std::cin >> x)) {
131  inputFailed = true;
132  std::cin.clear();
133  std::cin.ignore(10000, '\n');
134  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
135  }
136  } while (inputFailed);
138  std::cout << "Which event?" << std::endl;
139  do {
140  inputFailed = false;
141  if (!(std::cin >> x)) {
142  inputFailed = true;
143  std::cin.clear();
144  std::cin.ignore(10000, '\n');
145  std::cout << "Please enter numeric characters only. Please try again." << std::endl;
146  }
147  } while (inputFailed);
148  EventNumber_t ev = x;
150  } else if (x == 3) {
152  shouldStopLoop_ = true;
153  } else if (x == 4) {
155  shouldStopLoop_ = true;
156  shouldStopProcess_ = true;
157  }
158  return shouldStopLoop_ ? kStop : kContinue;
159  }
160 
162  std::cout << "Ending loop" << std::endl;
163  if (shouldStopProcess_)
164  return kStop;
165  ++countLoops_;
166  return (maxLoops_ < 0 || countLoops_ < maxLoops_) ? kContinue : kStop;
167  }
168 } // namespace edm
169 
edm::RunNumber_t
unsigned int RunNumber_t
Definition: RunLumiEventNumber.h:14
edm::EDLooperBase::Status
Status
Definition: EDLooperBase.h:80
edm::ProcessingController::lastOperationSucceeded
bool lastOperationSucceeded() const
Definition: ProcessingController.cc:86
edm::NavigateEventsLooper::~NavigateEventsLooper
~NavigateEventsLooper() override
Definition: NavigateEventsLooper.cc:54
edm::ProcessingController::kAtLastEvent
Definition: ProcessingController.h:34
funct::false
false
Definition: Factorize.h:29
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::ProcessingController::forwardState
ForwardState forwardState() const
Returns the present state of processing.
Definition: ProcessingController.cc:76
edm::NavigateEventsLooper::NavigateEventsLooper
NavigateEventsLooper(ParameterSet const &pset)
Definition: NavigateEventsLooper.cc:48
edm::LuminosityBlockNumber_t
unsigned int LuminosityBlockNumber_t
Definition: RunLumiEventNumber.h:13
DEFINE_FWK_LOOPER
#define DEFINE_FWK_LOOPER(type)
Definition: LooperFactory.h:108
edm::ProcessingController
Definition: ProcessingController.h:29
edm::EDLooperBase::kStop
Definition: EDLooperBase.h:80
edm::ProcessingController::kNextFileExists
Definition: ProcessingController.h:33
edm::ProcessingController::kAtFirstEvent
Definition: ProcessingController.h:41
edm::EventNumber_t
unsigned long long EventNumber_t
Definition: RunLumiEventNumber.h:12
edm::NavigateEventsLooper::shouldStopLoop_
bool shouldStopLoop_
Definition: NavigateEventsLooper.cc:44
edm::NavigateEventsLooper::endOfLoop
Status endOfLoop(EventSetup const &es, unsigned int iCounter) override
Definition: NavigateEventsLooper.cc:161
edm::ProcessingController::kEventsAheadInFile
Definition: ProcessingController.h:32
edm::ProcessingController::reverseState
ReverseState reverseState() const
Definition: ProcessingController.cc:78
LooperFactory.h
ProcessingController.h
edm::ProcessingController::setTransitionToPreviousEvent
void setTransitionToPreviousEvent()
Definition: ProcessingController.cc:64
edm::ParameterSet
Definition: ParameterSet.h:47
EDLooperBase.h
edm::NavigateEventsLooper::maxLoops_
int maxLoops_
Definition: NavigateEventsLooper.cc:42
edm::ProcessingController::setTransitionToNextEvent
void setTransitionToNextEvent()
Definition: ProcessingController.cc:62
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSetup
Definition: EventSetup.h:58
edm::EDLooperBase::kContinue
Definition: EDLooperBase.h:80
edm::NavigateEventsLooper::duringLoop
Status duringLoop(Event const &ev, EventSetup const &es, ProcessingController &pc) override
Definition: NavigateEventsLooper.cc:58
edm::NavigateEventsLooper::shouldStopProcess_
bool shouldStopProcess_
Definition: NavigateEventsLooper.cc:45
edm::ProcessingController::kEventsBackwardsInFile
Definition: ProcessingController.h:39
writedatasetfile.run
run
Definition: writedatasetfile.py:27
edm::NavigateEventsLooper
Definition: NavigateEventsLooper.cc:29
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
edm::NavigateEventsLooper::operator=
NavigateEventsLooper const & operator=(NavigateEventsLooper const &)=delete
edm::ProcessingController::kUnknownForward
Definition: ProcessingController.h:35
edm::ProcessingController::kPreviousFileExists
Definition: ProcessingController.h:40
edm::ProcessingController::canRandomAccess
bool canRandomAccess() const
Returns 'true' if the job's source can randomly access.
Definition: ProcessingController.cc:80
edm::EDLooperBase
Definition: EDLooperBase.h:78
ParameterSet.h
edm::EventID
Definition: EventID.h:31
edm::Event
Definition: Event.h:73
edm::ProcessingController::setTransitionToEvent
void setTransitionToEvent(edm::EventID const &iID)
Definition: ProcessingController.cc:66
lumi
Definition: LumiSectionData.h:20
edm::NavigateEventsLooper::countLoops_
int countLoops_
Definition: NavigateEventsLooper.cc:43
edm::NavigateEventsLooper::startingNewLoop
void startingNewLoop(unsigned int iIteration) override
Definition: NavigateEventsLooper.cc:56
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27