00001 #ifndef Framework_LuminosityBlock_h 00002 #define Framework_LuminosityBlock_h 00003 00004 // -*- C++ -*- 00005 // 00006 // Package: Framework 00007 // Class : LuminosityBlock 00008 // 00017 /*---------------------------------------------------------------------- 00018 00019 $Id: LuminosityBlock.h,v 1.18 2008/08/22 01:44:37 wmtan Exp $ 00020 00021 ----------------------------------------------------------------------*/ 00022 00023 #include "boost/shared_ptr.hpp" 00024 00025 #include "DataFormats/Provenance/interface/LuminosityBlockAuxiliary.h" 00026 #include "DataFormats/Provenance/interface/LuminosityBlockID.h" 00027 #include "DataFormats/Provenance/interface/RunID.h" 00028 00029 #include "FWCore/Framework/interface/DataViewImpl.h" 00030 #include "FWCore/Framework/interface/Frameworkfwd.h" 00031 00032 namespace edm { 00033 00034 class LuminosityBlock : private DataViewImpl 00035 { 00036 public: 00037 LuminosityBlock(LuminosityBlockPrincipal& lbp, const ModuleDescription& md); 00038 ~LuminosityBlock() {} 00039 00040 typedef DataViewImpl Base; 00041 // AUX functions. 00042 LuminosityBlockNumber_t luminosityBlock() const {return aux_.luminosityBlock();} 00043 00044 RunNumber_t run() const { 00045 return aux_.run(); 00046 } 00047 00048 LuminosityBlockID id() const { 00049 return aux_.id(); 00050 } 00051 00052 Timestamp const& beginTime() const {return aux_.beginTime();} 00053 Timestamp const& endTime() const {return aux_.endTime();} 00054 00055 using Base::get; 00056 using Base::getByLabel; 00057 using Base::getByType; 00058 using Base::getMany; 00059 using Base::getManyByType; 00060 using Base::me; 00061 using Base::processHistory; 00062 00063 Run const& 00064 getRun() const { 00065 return *run_; 00066 } 00067 00069 template <typename PROD> 00070 void 00071 put(std::auto_ptr<PROD> product) {put<PROD>(product, std::string());} 00072 00074 template <typename PROD> 00075 void 00076 put(std::auto_ptr<PROD> product, std::string const& productInstanceName); 00077 00078 Provenance 00079 getProvenance(BranchID const& theID) const; 00080 00081 void 00082 getAllProvenance(std::vector<Provenance const*> &provenances) const; 00083 00084 private: 00085 LuminosityBlockPrincipal const& 00086 luminosityBlockPrincipal() const; 00087 00088 LuminosityBlockPrincipal & 00089 luminosityBlockPrincipal(); 00090 00091 // commit_() is called to complete the transaction represented by 00092 // this DataViewImpl. The friendships required seems gross, but any 00093 // alternative is not great either. Putting it into the 00094 // public interface is asking for trouble 00095 friend class ConfigurableInputSource; 00096 friend class InputSource; 00097 friend class DaqSource; 00098 friend class RawInputSource; 00099 friend class EDFilter; 00100 friend class EDProducer; 00101 00102 void commit_(); 00103 00104 LuminosityBlockAuxiliary const& aux_; 00105 boost::shared_ptr<Run const> const run_; 00106 }; 00107 00108 template <typename PROD> 00109 void 00110 LuminosityBlock::put(std::auto_ptr<PROD> product, std::string const& productInstanceName) 00111 { 00112 if (product.get() == 0) { // null pointer is illegal 00113 TypeID typeID(typeid(PROD)); 00114 throw edm::Exception(edm::errors::NullPointerError) 00115 << "LuminosityBlock::put: A null auto_ptr was passed to 'put'.\n" 00116 << "The pointer is of type " << typeID << ".\n" 00117 << "The specified productInstanceName was '" << productInstanceName << "'.\n"; 00118 } 00119 00120 // The following will call post_insert if T has such a function, 00121 // and do nothing if T has no such function. 00122 typename boost::mpl::if_c<detail::has_postinsert<PROD>::value, 00123 DoPostInsert<PROD>, 00124 DoNotPostInsert<PROD> >::type maybe_inserter; 00125 maybe_inserter(product.get()); 00126 00127 ConstBranchDescription const& desc = 00128 getBranchDescription(TypeID(*product), productInstanceName); 00129 00130 Wrapper<PROD> *wp(new Wrapper<PROD>(product)); 00131 00132 putProducts().push_back(std::make_pair(wp, &desc)); 00133 00134 // product.release(); // The object has been copied into the Wrapper. 00135 // The old copy must be deleted, so we cannot release ownership. 00136 } 00137 00138 } 00139 #endif