![]() |
![]() |
00001 #ifndef FWCore_Common_RunBase_h 00002 #define FWCore_Common_RunBase_h 00003 00004 // -*- C++ -*- 00005 // 00006 // Package: FWCore/Common 00007 // Class : RunBase 00008 // 00019 // 00020 // Original Author: Eric Vaandering 00021 // Created: Tue Jan 12 15:31:00 CDT 2010 00022 // 00023 00024 #if !defined(__CINT__) && !defined(__MAKECINT__) 00025 00026 #include "FWCore/Utilities/interface/InputTag.h" 00027 #include "DataFormats/Common/interface/BasicHandle.h" 00028 #include "DataFormats/Common/interface/Handle.h" 00029 #include "DataFormats/Common/interface/ConvertHandle.h" 00030 #include "DataFormats/Common/interface/Wrapper.h" 00031 00032 #include "DataFormats/Provenance/interface/RunAuxiliary.h" 00033 #include "DataFormats/Provenance/interface/RunID.h" 00034 00035 namespace edm { 00036 00037 class RunBase { 00038 public: 00039 RunBase(); 00040 virtual ~RunBase(); 00041 00042 // AUX functions. 00043 RunID const& id() const {return runAuxiliary().id();} 00044 RunNumber_t run() const {return runAuxiliary().run();} 00045 Timestamp const& beginTime() const {return runAuxiliary().beginTime();} 00046 Timestamp const& endTime() const {return runAuxiliary().endTime();} 00047 00048 00049 virtual edm::RunAuxiliary const& runAuxiliary() const = 0; 00050 00052 template <typename PROD> 00053 bool 00054 getByLabel(InputTag const& tag, Handle<PROD>& result) const; 00055 00056 private: 00057 00058 virtual BasicHandle getByLabelImpl(const std::type_info& iWrapperType, const std::type_info& iProductType, const InputTag& iTag) const = 0; 00059 00060 }; 00061 00062 template <class T> 00063 bool 00064 RunBase::getByLabel(const InputTag& tag, Handle<T>& result) const { 00065 result.clear(); 00066 BasicHandle bh = this->getByLabelImpl(typeid(edm::Wrapper<T>), typeid(T), tag); 00067 convert_handle(bh, result); // throws on conversion error 00068 if (bh.failedToGet()) { 00069 return false; 00070 } 00071 return true; 00072 } 00073 00074 00075 } 00076 #endif 00077 #endif