CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Common/interface/LuminosityBlockBase.h

Go to the documentation of this file.
00001 #ifndef FWCore_Common_LuminosityBlockBase_h
00002 #define FWCore_Common_LuminosityBlockBase_h
00003 
00004 // -*- C++ -*-
00005 //
00006 // Package:     FWCore/Common
00007 // Class  :     LuminosityBlockBase
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 "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h"
00027 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00028 #include "DataFormats/Provenance/interface/RunID.h"
00029 #include "FWCore/Utilities/interface/InputTag.h"
00030 #include "DataFormats/Common/interface/BasicHandle.h"
00031 #include "DataFormats/Common/interface/Handle.h"
00032 
00033 //#include "FWCore/Framework/interface/PrincipalGetAdapter.h"
00034 //#include "FWCore/Framework/interface/Frameworkfwd.h"
00035 
00036 namespace edm {
00037 
00038   class LuminosityBlockBase {
00039   public:
00040     LuminosityBlockBase();
00041     virtual ~LuminosityBlockBase();
00042 
00043     // AUX functions.
00044     LuminosityBlockNumber_t luminosityBlock() const {
00045       return luminosityBlockAuxiliary().luminosityBlock();
00046     }
00047 
00048     RunNumber_t run() const {
00049       return luminosityBlockAuxiliary().run();
00050     }
00051 
00052     LuminosityBlockID id() const {
00053       return luminosityBlockAuxiliary().id();
00054     }
00055 
00056     Timestamp const& beginTime() const {
00057       return luminosityBlockAuxiliary().beginTime();
00058     }
00059     Timestamp const& endTime() const {
00060       return luminosityBlockAuxiliary().endTime();
00061     }
00062 
00063     virtual edm::LuminosityBlockAuxiliary const& luminosityBlockAuxiliary() const = 0;
00064 
00065 /*    template <typename PROD>
00066     bool
00067     get(SelectorBase const&, Handle<PROD>& result) const;
00068 
00069     template <typename PROD>
00070     bool
00071     getByLabel(std::string const& label, Handle<PROD>& result) const;
00072 
00073     template <typename PROD>
00074     bool
00075     getByLabel(std::string const& label,
00076                std::string const& productInstanceName,
00077                Handle<PROD>& result) const;
00078 */
00080     template <typename PROD>
00081     bool
00082     getByLabel(InputTag const& tag, Handle<PROD>& result) const;
00083 /*
00084     template <typename PROD>
00085     void
00086     getMany(SelectorBase const&, std::vector<Handle<PROD> >& results) const;
00087 
00088     template <typename PROD>
00089     bool
00090     getByType(Handle<PROD>& result) const;
00091 
00092     template <typename PROD>
00093     void
00094     getManyByType(std::vector<Handle<PROD> >& results) const;
00095 
00096     Run const&
00097     getRun() const {
00098       return *run_;
00099     }
00100 
00102     template <typename PROD>
00103     void
00104     put(std::auto_ptr<PROD> product) {put<PROD>(product, std::string());}
00105 
00107     template <typename PROD>
00108     void
00109     put(std::auto_ptr<PROD> product, std::string const& productInstanceName);
00110 
00111     Provenance
00112     getProvenance(BranchID const& theID) const;
00113 
00114     void
00115     getAllProvenance(std::vector<Provenance const*>& provenances) const;
00116 
00117     ProcessHistory const&
00118     processHistory() const;
00119 */
00120   private:
00121 /*    LuminosityBlockPrincipal const&
00122     luminosityBlockPrincipal() const;
00123 
00124     LuminosityBlockPrincipal&
00125     luminosityBlockPrincipal();
00126 
00127     typedef std::vector<std::pair<EDProduct*, ConstBranchDescription const*> > ProductPtrVec;
00128     ProductPtrVec& putProducts() {return putProducts_;}
00129     ProductPtrVec const& putProducts() const {return putProducts_;}
00130 
00131     // commit_() is called to complete the transaction represented by
00132     // this PrincipalGetAdapter. The friendships required seems gross, but any
00133     // alternative is not great either.  Putting it into the
00134     // public interface is asking for trouble
00135     friend class ConfigurableInputSource;
00136     friend class InputSource;
00137     friend class DaqSource;
00138     friend class RawInputSource;
00139     friend class EDFilter;
00140     friend class EDProducer;
00141 
00142     void commit_();
00143 
00144     PrincipalGetAdapter provRecorder_;
00145     ProductPtrVec putProducts_;
00146     LuminosityBlockAuxiliary const& aux_;
00147     boost::shared_ptr<Run const> const run_;
00148 */
00149     virtual BasicHandle getByLabelImpl(const std::type_info& iWrapperType, const std::type_info& iProductType, const InputTag& iTag) const = 0;
00150 
00151   };
00152 /*
00153   template <typename PROD>
00154   void
00155   LuminosityBlock::put(std::auto_ptr<PROD> product, std::string const& productInstanceName) {
00156     if (product.get() == 0) {                // null pointer is illegal
00157       TypeID typeID(typeid(PROD));
00158       principal_get_adapter_detail::throwOnPutOfNullProduct("LuminosityBlock", typeID, productInstanceName);
00159     }
00160 
00161     // The following will call post_insert if T has such a function,
00162     // and do nothing if T has no such function.
00163     typename boost::mpl::if_c<detail::has_postinsert<PROD>::value,
00164       DoPostInsert<PROD>,
00165       DoNotPostInsert<PROD> >::type maybe_inserter;
00166     maybe_inserter(product.get());
00167 
00168     ConstBranchDescription const& desc =
00169       provRecorder_.getBranchDescription(TypeID(*product), productInstanceName);
00170 
00171     Wrapper<PROD> *wp(new Wrapper<PROD>(product));
00172 
00173     putProducts().push_back(std::make_pair(wp, &desc));
00174 
00175     // product.release(); // The object has been copied into the Wrapper.
00176     // The old copy must be deleted, so we cannot release ownership.
00177   }
00178 
00179   template <typename PROD>
00180   bool
00181   LuminosityBlock::get(SelectorBase const& sel, Handle<PROD>& result) const {
00182     return provRecorder_.get(sel,result);
00183   }
00184 
00185   template <typename PROD>
00186   bool
00187   LuminosityBlock::getByLabel(std::string const& label, Handle<PROD>& result) const {
00188     return provRecorder_.getByLabel(label,result);
00189   }
00190 
00191   template <typename PROD>
00192   bool
00193   LuminosityBlock::getByLabel(std::string const& label,
00194                   std::string const& productInstanceName,
00195                   Handle<PROD>& result) const {
00196     return provRecorder_.getByLabel(label,productInstanceName,result);
00197   }
00198 
00200   template <typename PROD>
00201   bool
00202   LuminosityBlock::getByLabel(InputTag const& tag, Handle<PROD>& result) const {
00203     return provRecorder_.getByLabel(tag,result);
00204   }
00205 
00206   template <typename PROD>
00207   void
00208   LuminosityBlock::getMany(SelectorBase const& sel, std::vector<Handle<PROD> >& results) const {
00209     return provRecorder_.getMany(sel,results);
00210   }
00211 
00212   template <typename PROD>
00213   bool
00214   LuminosityBlock::getByType(Handle<PROD>& result) const {
00215     return provRecorder_.getByType(result);
00216   }
00217 
00218   template <typename PROD>
00219   void
00220   LuminosityBlock::getManyByType(std::vector<Handle<PROD> >& results) const {
00221     return provRecorder_.getManyByType(results);
00222   }
00223 */
00224    template <class T>
00225    bool
00226    LuminosityBlockBase::getByLabel(const InputTag& tag, Handle<T>& result) const {
00227       result.clear();
00228       BasicHandle bh = this->getByLabelImpl(typeid(edm::Wrapper<T>), typeid(T), tag);
00229       convert_handle(bh, result);  // throws on conversion error
00230       if (bh.failedToGet()) {
00231          return false;
00232       }
00233       return true;
00234    }
00235 
00236 
00237 }
00238 #endif 
00239 #endif