File indexing completed on 2024-04-06 12:11:55
0001 #ifndef FWCore_Common_RunBase_h
0002 #define FWCore_Common_RunBase_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "DataFormats/Common/interface/BasicHandle.h"
0025 #include "DataFormats/Common/interface/ConvertHandle.h"
0026 #include "DataFormats/Common/interface/Handle.h"
0027 #include "DataFormats/Provenance/interface/RunAuxiliary.h"
0028 #include "DataFormats/Provenance/interface/RunID.h"
0029 #include "FWCore/Utilities/interface/InputTag.h"
0030
0031 namespace edm {
0032
0033 class RunBase {
0034 public:
0035 RunBase();
0036 virtual ~RunBase();
0037
0038
0039 RunID const& id() const { return runAuxiliary().id(); }
0040 RunNumber_t run() const { return runAuxiliary().run(); }
0041 Timestamp const& beginTime() const { return runAuxiliary().beginTime(); }
0042 Timestamp const& endTime() const { return runAuxiliary().endTime(); }
0043
0044 virtual edm::RunAuxiliary const& runAuxiliary() const = 0;
0045
0046
0047 template <typename PROD>
0048 bool getByLabel(InputTag const& tag, Handle<PROD>& result) const;
0049
0050 private:
0051 virtual BasicHandle getByLabelImpl(std::type_info const& iWrapperType,
0052 std::type_info const& iProductType,
0053 InputTag const& iTag) const = 0;
0054 };
0055
0056 template <typename T>
0057 bool RunBase::getByLabel(InputTag const& tag, Handle<T>& result) const {
0058 result.clear();
0059 BasicHandle bh = this->getByLabelImpl(typeid(Wrapper<T>), typeid(T), tag);
0060 result = convert_handle<T>(std::move(bh));
0061 if (result.failedToGet()) {
0062 return false;
0063 }
0064 return true;
0065 }
0066
0067 }
0068 #endif