File indexing completed on 2024-04-06 12:12:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include "FWCore/Framework/interface/EDLooper.h"
0017 #include "FWCore/Framework/interface/LooperFactory.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019
0020 namespace edm {
0021
0022 class IterateNTimesLooper : public EDLooper {
0023 public:
0024 IterateNTimesLooper(ParameterSet const&);
0025 IterateNTimesLooper(IterateNTimesLooper const&) = delete;
0026 IterateNTimesLooper const& operator=(IterateNTimesLooper const&) = delete;
0027 ~IterateNTimesLooper() override;
0028
0029
0030
0031
0032
0033
0034 void startingNewLoop(unsigned int) override;
0035 Status duringLoop(Event const&, EventSetup const&) override;
0036 Status endOfLoop(EventSetup const&, unsigned int) override;
0037
0038 private:
0039
0040 unsigned int max_;
0041 unsigned int times_;
0042 bool shouldStop_;
0043 };
0044
0045
0046
0047
0048
0049 IterateNTimesLooper::IterateNTimesLooper(ParameterSet const& iConfig)
0050 : max_(iConfig.getParameter<unsigned int>("nTimes")), times_(0), shouldStop_(false) {}
0051
0052
0053
0054
0055
0056 IterateNTimesLooper::~IterateNTimesLooper() {}
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 void IterateNTimesLooper::startingNewLoop(unsigned int iIteration) {
0073 times_ = iIteration;
0074 if (iIteration >= max_) {
0075 shouldStop_ = true;
0076 }
0077 }
0078
0079 EDLooper::Status IterateNTimesLooper::duringLoop(Event const&, EventSetup const&) {
0080 return shouldStop_ ? kStop : kContinue;
0081 }
0082
0083 EDLooper::Status IterateNTimesLooper::endOfLoop(EventSetup const&, unsigned int ) {
0084 ++times_;
0085 return (times_ < max_) ? kContinue : kStop;
0086 }
0087 }
0088
0089 using edm::IterateNTimesLooper;
0090 DEFINE_FWK_LOOPER(IterateNTimesLooper);