CMS 3D CMS Logo

ThrowingSource.cc
Go to the documentation of this file.
8 
9 namespace edm {
11  public:
12  explicit ThrowingSource(ParameterSet const&, InputSourceDescription const&);
13  ~ThrowingSource() noexcept(false) override;
14 
15  void beginJob() override;
16  void endJob() override;
18  void beginRun(edm::Run&) override;
19  std::shared_ptr<edm::FileBlock> readFile_() override;
20  void closeFile_() override;
21  std::shared_ptr<edm::RunAuxiliary> readRunAuxiliary_() override;
22  std::shared_ptr<edm::LuminosityBlockAuxiliary> readLuminosityBlockAuxiliary_() override;
23  void readEvent_(edm::EventPrincipal&) override;
24 
25  private:
26  enum {
29  kBeginJob = 2,
30  kBeginRun = 3,
32  kEndLumi = 5,
33  kEndRun = 6,
34  kEndJob = 7,
39  kReadFile = 12,
40  kCloseFile = 13,
42  };
44  void produce(Event&) override;
45 
46  // To test exception throws from sources
48  };
49 
52  whenToThrow_(pset.getUntrackedParameter<int>("whenToThrow", kDoNotThrow)) {
54  throw cms::Exception("TestThrow") << "ThrowingSource constructor";
55  }
56 
59  throw cms::Exception("TestThrow") << "ThrowingSource destructor";
60  }
61 
63 
65 
67  if (whenToThrow_ == kBeginJob)
68  throw cms::Exception("TestThrow") << "ThrowingSource::beginJob";
69  }
70 
72  if (whenToThrow_ == kEndJob)
73  throw cms::Exception("TestThrow") << "ThrowingSource::endJob";
74  }
75 
77  if (whenToThrow_ == kBeginLumi)
78  throw cms::Exception("TestThrow") << "ThrowingSource::beginLuminosityBlock";
79  }
80 
82  if (whenToThrow_ == kBeginRun)
83  throw cms::Exception("TestThrow") << "ThrowingSource::beginRun";
84  }
85 
86  std::shared_ptr<FileBlock> ThrowingSource::readFile_() {
87  if (whenToThrow_ == kReadFile)
88  throw cms::Exception("TestThrow") << "ThrowingSource::readFile_";
89  return std::make_shared<FileBlock>();
90  }
91 
93  if (whenToThrow_ == kCloseFile)
94  throw cms::Exception("TestThrow") << "ThrowingSource::closeFile_";
95  }
96 
97  std::shared_ptr<RunAuxiliary> ThrowingSource::readRunAuxiliary_() {
99  throw cms::Exception("TestThrow") << "ThrowingSource::readRunAuxiliary_";
101  resetNewRun();
102  return std::make_shared<RunAuxiliary>(eventID().run(), ts, Timestamp::invalidTimestamp());
103  }
104 
105  std::shared_ptr<LuminosityBlockAuxiliary> ThrowingSource::readLuminosityBlockAuxiliary_() {
107  throw cms::Exception("TestThrow") << "ThrowingSource::readLuminosityBlockAuxiliary_";
108  if (processingMode() == Runs)
109  return std::shared_ptr<LuminosityBlockAuxiliary>();
111  resetNewLumi();
112  return std::make_shared<LuminosityBlockAuxiliary>(
114  }
115 
117  if (whenToThrow_ == kReadEvent)
118  throw cms::Exception("TestThrow") << "ThrowingSource::readEvent_";
121  auto history = processHistoryRegistry().getMapped(aux.processHistoryID());
122  eventPrincipal.fillEventPrincipal(aux, history);
123  }
124 } // namespace edm
125 
126 using edm::ThrowingSource;
void readEvent_(edm::EventPrincipal &) override
static Timestamp invalidTimestamp()
Definition: Timestamp.h:75
std::shared_ptr< edm::RunAuxiliary > readRunAuxiliary_() override
assert(be >=bs)
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:39
void produce(Event &) override
#define DEFINE_FWK_INPUT_SOURCE(type)
std::string const & processGUID() const
Accessor for global process identifier.
Definition: InputSource.h:226
void closeFile_() override
void endJob() override
bool eventCached() const
Definition: InputSource.h:389
unsigned long long TimeValue_t
Definition: Timestamp.h:21
ProcessHistoryRegistry const & processHistoryRegistry() const
Accessors for process history registry.
Definition: InputSource.h:168
RunNumber_t run() const
Definition: EventID.h:38
bool getMapped(ProcessHistoryID const &key, ProcessHistory &value) const
void fillEventPrincipal(EventAuxiliary const &aux, ProcessHistory const *processHistory, DelayedReader *reader=nullptr)
HLT enums.
bool setRunAndEventInfo(EventID &id, TimeValue_t &time, edm::EventAuxiliary::ExperimentType &eType) override
void beginLuminosityBlock(edm::LuminosityBlock &) override
~ThrowingSource() noexcept(false) override
std::shared_ptr< edm::LuminosityBlockAuxiliary > readLuminosityBlockAuxiliary_() override
void beginJob() override
Begin protected makes it easier to do template programming.
std::shared_ptr< edm::FileBlock > readFile_() override
void beginRun(edm::Run &) override
Definition: Run.h:45
ThrowingSource(ParameterSet const &, InputSourceDescription const &)
ProcessingMode processingMode() const
RunsLumisAndEvents (default), RunsAndLumis, or Runs.
Definition: InputSource.h:255