Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:01:49

0001 #ifndef FWCore_Common_LuminosityBlockBase_h
0002 #define FWCore_Common_LuminosityBlockBase_h
0003 
0004 // -*- C++ -*-
0005 //
0006 // Package:     FWCore/Common
0007 // Class  :     LuminosityBlockBase
0008 //
0009 /**\class LuminosityBlockBase LuminosityBlockBase.h FWCore/Common/interface/LuminosityBlockBase.h
0010 
0011  Description: Base class for LuminosityBlocks in both the full and light framework
0012 
0013  Usage:
0014     One can use this class for code which needs to work in both the full and the
0015  light (i.e. FWLite) frameworks.  Data can be accessed using the same getByLabel
0016  interface which is available in the full framework.
0017 
0018 */
0019 //
0020 // Original Author:  Eric Vaandering
0021 //         Created:  Tue Jan 12 15:31:00 CDT 2010
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/LuminosityBlockAuxiliary.h"
0028 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
0029 #include "DataFormats/Provenance/interface/RunID.h"
0030 #include "FWCore/Utilities/interface/InputTag.h"
0031 
0032 namespace edm {
0033 
0034   class LuminosityBlockBase {
0035   public:
0036     LuminosityBlockBase();
0037     virtual ~LuminosityBlockBase();
0038 
0039     // AUX functions.
0040     LuminosityBlockNumber_t luminosityBlock() const { return luminosityBlockAuxiliary().luminosityBlock(); }
0041 
0042     RunNumber_t run() const { return luminosityBlockAuxiliary().run(); }
0043 
0044     LuminosityBlockID id() const { return luminosityBlockAuxiliary().id(); }
0045 
0046     Timestamp const& beginTime() const { return luminosityBlockAuxiliary().beginTime(); }
0047     Timestamp const& endTime() const { return luminosityBlockAuxiliary().endTime(); }
0048 
0049     virtual edm::LuminosityBlockAuxiliary const& luminosityBlockAuxiliary() const = 0;
0050 
0051     /// same as above, but using the InputTag class
0052     template <typename PROD>
0053     bool getByLabel(InputTag const& tag, Handle<PROD>& result) const;
0054 
0055   private:
0056     virtual BasicHandle getByLabelImpl(std::type_info const& iWrapperType,
0057                                        std::type_info const& iProductType,
0058                                        const InputTag& iTag) const = 0;
0059   };
0060 
0061   template <class T>
0062   bool LuminosityBlockBase::getByLabel(const InputTag& tag, Handle<T>& result) const {
0063     result.clear();
0064     BasicHandle bh = this->getByLabelImpl(typeid(Wrapper<T>), typeid(T), tag);
0065     result = convert_handle<T>(std::move(bh));
0066     if (result.failedToGet()) {
0067       return false;
0068     }
0069     return true;
0070   }
0071 
0072 }  // namespace edm
0073 #endif