Go to the documentation of this file.00001 #ifndef CondTools_L1Trigger_DataWriter_h
00002 #define CondTools_L1Trigger_DataWriter_h
00003
00004
00005 #include "FWCore/Framework/interface/IOVSyncValue.h"
00006 #include "FWCore/Framework/interface/EventSetup.h"
00007 #include "FWCore/Framework/interface/DataKey.h"
00008
00009 #include "FWCore/ServiceRegistry/interface/Service.h"
00010 #include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
00011 #include "CondCore/DBCommon/interface/DbSession.h"
00012 #include "CondCore/DBCommon/interface/DbScopedTransaction.h"
00013
00014 #include "CondCore/MetaDataService/interface/MetaData.h"
00015
00016 #include "DataFormats/Provenance/interface/RunID.h"
00017
00018
00019 #include "CondFormats/L1TObjects/interface/L1TriggerKeyList.h"
00020 #include "CondFormats/L1TObjects/interface/L1TriggerKey.h"
00021
00022 #include "CondTools/L1Trigger/interface/WriterProxy.h"
00023
00024 #include <string>
00025 #include <map>
00026
00027 namespace l1t
00028 {
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class DataWriter
00040 {
00041 public:
00042 DataWriter();
00043 ~DataWriter();
00044
00045
00046
00047
00048
00049 std::string writePayload( const edm::EventSetup& setup,
00050 const std::string& recordType ) ;
00051
00052
00053
00054
00055
00056 bool updateIOV( const std::string& esRecordName,
00057 const std::string& payloadToken,
00058 edm::RunNumber_t sinceRun,
00059 bool logTransactions = false ) ;
00060
00061
00062 void writeKeyList( L1TriggerKeyList* keyList,
00063 edm::RunNumber_t sinceRun = 0,
00064 bool logTransactions = false ) ;
00065
00066
00067 template< class T >
00068 void readObject( const std::string& payloadToken,
00069 T& outputObject ) ;
00070
00071 std::string payloadToken( const std::string& recordName,
00072 edm::RunNumber_t runNumber ) ;
00073
00074 std::string lastPayloadToken( const std::string& recordName ) ;
00075
00076 bool fillLastTriggerKeyList( L1TriggerKeyList& output ) ;
00077
00078 protected:
00079 };
00080
00081 template< class T >
00082 void DataWriter::readObject( const std::string& payloadToken,
00083 T& outputObject )
00084 {
00085 edm::Service<cond::service::PoolDBOutputService> poolDb;
00086 if( !poolDb.isAvailable() )
00087 {
00088 throw cond::Exception( "DataWriter: PoolDBOutputService not available."
00089 ) ;
00090 }
00091
00092 cond::DbSession session = poolDb->session();
00093 cond::DbScopedTransaction tr(session);
00094 tr.start(true);
00095
00096
00097 boost::shared_ptr<T> ref = session.getTypedObject<T>(payloadToken) ;
00098 outputObject = *ref ;
00099 tr.commit ();
00100 }
00101
00102 }
00103
00104 #endif