CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CondCore/ESSources/plugins/CondDBESSource.h

Go to the documentation of this file.
00001 #ifndef CondCore_ESSources_CondDBESSource_h
00002 #define CondCore_ESSources_CondDBESSource_h
00003 //
00004 // Package:    CondCore/ESSources
00005 // Class:      CondDBESSource
00006 //
00007 /*
00008  Description: EventSetup source module for serving data from offline database
00009 */
00010 //
00011 // Author:      Zhen Xie
00012 //
00013 // system include files
00014 #include <string>
00015 #include <map>
00016 #include <set>
00017 // user include files
00018 #include "CondCore/DBCommon/interface/DbConnection.h"
00019 
00020 #include "FWCore/Framework/interface/DataProxyProvider.h"
00021 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00022 #include "CondCore/DBCommon/interface/TagMetadata.h"
00023 #include "CondCore/DBCommon/interface/Time.h"
00024 
00025 namespace edm{
00026   class ParameterSet;
00027 }
00028 namespace cond{
00029   class DbSession;
00030   class BasePayloadProxy;
00031   class DataProxyWrapperBase;
00032 }
00033 
00034 class CondDBESSource : public edm::eventsetup::DataProxyProvider,
00035                        public edm::EventSetupRecordIntervalFinder{
00036  public:
00037   typedef boost::shared_ptr<cond::DataProxyWrapperBase > ProxyP;
00038   typedef std::multimap< std::string,  ProxyP> ProxyMap;
00039  
00040 
00041   explicit CondDBESSource( const edm::ParameterSet& );
00042   ~CondDBESSource();
00043   
00044  protected:
00045   virtual void setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
00046                               const edm::IOVSyncValue& , 
00047                               edm::ValidityInterval&) ;
00048 
00049   virtual void registerProxies(const edm::eventsetup::EventSetupRecordKey& iRecordKey, KeyedProxies& aProxyList) ;
00050 
00051   virtual void newInterval(const edm::eventsetup::EventSetupRecordKey& iRecordType, const edm::ValidityInterval& iInterval) ;
00052 
00053  private:
00054 
00055   // ----------member data ---------------------------
00056 
00057   cond::DbConnection m_connection;
00058 
00059   // Container of DataProxy, implemented as multi-map keyed by records
00060   ProxyMap m_proxies;
00061 
00062 
00063   typedef std::set< cond::TagMetadata > TagCollection;
00064   // the collections of tag, record/label used in this ESSource
00065   TagCollection m_tagCollection;
00066 
00067   struct Stats {
00068     int nData;
00069     int nSet;
00070     int nRun;
00071     int nLumi;
00072     int nRefresh;
00073     int nActualRefresh;
00074   };
00075 
00076   Stats stats;
00077 
00078   unsigned int lastRun;
00079   unsigned int lastLumi;
00080   bool doRefresh;
00081 
00082   bool doDump;
00083 
00084  private:
00085 
00086    void fillTagCollectionFromDB( const std::string & coraldb,
00087                                  const std::string & prefix,
00088                                  const std::string & postfix,
00089                                  const std::string& roottag,
00090                                  std::map<std::string,cond::TagMetadata>& replacement);
00091 };
00092 #endif