CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/RecoLuminosity/LumiProducer/plugins/CMSRunSummaryDummy2DB.cc

Go to the documentation of this file.
00001 #ifndef RecoLuminosity_LumiProducer_CMSRunSummaryDummy2DB_H 
00002 #define RecoLuminosity_LumiProducer_CMSRunSummaryDummy2DB_H 
00003 #include "RelationalAccess/ConnectionService.h"
00004 #include "RelationalAccess/ISessionProxy.h"
00005 #include "RelationalAccess/ITransaction.h"
00006 #include "RelationalAccess/ITypeConverter.h"
00007 #include "RelationalAccess/ISchema.h"
00008 #include "RelationalAccess/ITable.h"
00009 #include "RelationalAccess/ITableDataEditor.h"
00010 #include "CoralBase/TimeStamp.h"
00011 #include "CoralBase/AttributeList.h"
00012 #include "CoralBase/AttributeSpecification.h"
00013 #include "CoralBase/Attribute.h"
00014 #include "CoralBase/Exception.h"
00015 #include "RecoLuminosity/LumiProducer/interface/DataPipe.h"
00016 #include "RecoLuminosity/LumiProducer/interface/LumiNames.h"
00017 #include "RecoLuminosity/LumiProducer/interface/Exception.h"
00018 #include "RecoLuminosity/LumiProducer/interface/DBConfig.h"
00019 #include <iostream>
00020 namespace lumi{
00021   class CMSRunSummaryDummy2DB : public DataPipe{
00022   public:
00023     CMSRunSummaryDummy2DB(const std::string& dest);
00024     virtual unsigned long long retrieveData( unsigned int );
00025     virtual const std::string dataType() const;
00026     virtual const std::string sourceType() const;
00027     virtual ~CMSRunSummaryDummy2DB();
00028   };//cl CMSRunSummaryDummy2DB
00029   //
00030   //implementation
00031   //
00032   CMSRunSummaryDummy2DB::CMSRunSummaryDummy2DB( const std::string& dest):DataPipe(dest){}
00033   unsigned long long CMSRunSummaryDummy2DB::retrieveData( unsigned int runnum){
00034     //
00035     //generate dummy data of run summary for the given run and write data to LumiDB
00036     //
00037     std::string fakehltkey("/cdaq/Cosmic/V12");
00038     coral::ConnectionService* svc=new coral::ConnectionService;
00039     lumi::DBConfig dbconf(*svc);
00040     if(!m_authpath.empty()){
00041       dbconf.setAuthentication(m_authpath);
00042     }
00043     coral::ISessionProxy* session=svc->connect(m_dest,coral::Update);
00044     coral::ITypeConverter& tpc=session->typeConverter();
00045     tpc.setCppTypeForSqlType("unsigned int","NUMBER(10)");
00046     try{
00047       session->transaction().start(false);
00048       coral::ISchema& schema=session->nominalSchema();
00049       coral::ITable& runtable=schema.tableHandle(LumiNames::cmsrunsummaryTableName());
00050       coral::AttributeList runData;
00051       runtable.dataEditor().rowBuffer(runData);
00052       runData["RUNNUM"].data<unsigned int>()=runnum;
00053       runData["FILLNUM"].data<unsigned int>()=8973344;
00054       runData["SEQUENCE"].data<std::string>()="run sequence key";
00055       runData["HLTKEY"].data<std::string>()=fakehltkey;
00056       runData["STARTTIME"].data<coral::TimeStamp>()=coral::TimeStamp::now();
00057       runData["STOPTIME"].data<coral::TimeStamp>()=coral::TimeStamp::now();
00058       
00059       runtable.dataEditor().insertRow(runData);
00060     }catch( const coral::Exception& er){
00061       std::cout<<"database problem "<<er.what()<<std::endl;
00062       session->transaction().rollback();
00063       delete session;
00064       delete svc;
00065       throw er;
00066     }
00067     session->transaction().commit();
00068     delete session;
00069     delete svc;
00070     return 0;
00071   }
00072   const std::string CMSRunSummaryDummy2DB::dataType() const{
00073     return "CMSRUNSUMMARY";
00074   }
00075   const std::string CMSRunSummaryDummy2DB::sourceType() const{
00076     return "DUMMY";
00077   }
00078   CMSRunSummaryDummy2DB::~CMSRunSummaryDummy2DB(){}
00079 }//ns lumi
00080 #include "RecoLuminosity/LumiProducer/interface/DataPipeFactory.h"
00081 DEFINE_EDM_PLUGIN(lumi::DataPipeFactory,lumi::CMSRunSummaryDummy2DB,"CMSRunSummaryDummy2DB");
00082 #endif