CMS 3D CMS Logo

Public Member Functions

l1t::WriterProxyT< Record, Type > Class Template Reference

#include <WriterProxy.h>

Inheritance diagram for l1t::WriterProxyT< Record, Type >:
l1t::WriterProxy

List of all members.

Public Member Functions

virtual std::string save (const edm::EventSetup &setup) const
virtual ~WriterProxyT ()

Detailed Description

template<class Record, class Type>
class l1t::WriterProxyT< Record, Type >

Definition at line 48 of file WriterProxy.h.


Constructor & Destructor Documentation

template<class Record , class Type >
virtual l1t::WriterProxyT< Record, Type >::~WriterProxyT ( ) [inline, virtual]

Definition at line 51 of file WriterProxy.h.

{}

Member Function Documentation

template<class Record , class Type >
virtual std::string l1t::WriterProxyT< Record, Type >::save ( const edm::EventSetup setup) const [inline, virtual]

Implements l1t::WriterProxy.

Definition at line 54 of file WriterProxy.h.

References cond::classNameForTypeId(), cond::DbScopedTransaction::commit(), Exception, edm::EventSetup::get(), patZpeak::handle, edm::Service< T >::isAvailable(), edm::ESHandle< T >::product(), python::CommonUtils::session, cond::DbScopedTransaction::start(), and cond::DbSession::storeObject().

        {
            // load record and type from EventSetup and save them in db
            edm::ESHandle<Type> handle;

            try
              {
                setup.get<Record> ().get (handle);
              }
            catch( l1t::DataAlreadyPresentException& ex )
              {
                return std::string() ;
              }

            // If handle is invalid, then data is already in DB
       
            edm::Service<cond::service::PoolDBOutputService> poolDb;
            if (!poolDb.isAvailable())
              {
                throw cond::Exception( "DataWriter: PoolDBOutputService not available."
                                       ) ;
              }
            cond::DbSession session = poolDb->session();
            cond::DbScopedTransaction tr(session);
            // if throw transaction will unroll
            tr.start(false);

            boost::shared_ptr<Type> pointer(new Type (*(handle.product ())));
            std::string payloadToken =  session.storeObject( pointer.get(),
                                                             cond::classNameForTypeId(typeid(Type))
                                                             );
            tr.commit();
            return payloadToken ;
        }