1 #ifndef RecoLuminosity_LumiProducer_TRGDummy2DB_h
2 #define RecoLuminosity_LumiProducer_TRGDummy2DB_h
3 #include "RelationalAccess/ConnectionService.h"
4 #include "RelationalAccess/ISessionProxy.h"
5 #include "RelationalAccess/ITransaction.h"
6 #include "RelationalAccess/ISchema.h"
7 #include "RelationalAccess/ITable.h"
8 #include "RelationalAccess/ITableDataEditor.h"
9 #include "RelationalAccess/IBulkOperation.h"
10 #include "RelationalAccess/ITypeConverter.h"
11 #include "CoralBase/AttributeList.h"
12 #include "CoralBase/AttributeSpecification.h"
13 #include "CoralBase/Attribute.h"
14 #include "CoralBase/Exception.h"
41 coral::ConnectionService* svc =
new coral::ConnectionService;
47 coral::ISessionProxy*
session = svc->connect(
m_dest, coral::Update);
48 coral::ITypeConverter& tpc = session->typeConverter();
49 tpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(7)");
50 tpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)");
51 tpc.setCppTypeForSqlType(
"unsigned long long",
"NUMBER(20)");
53 unsigned int totalcmsls = 32;
54 session->transaction().start(
false);
55 coral::ISchema& schema = session->nominalSchema();
58 coral::AttributeList trgData;
59 trgData.extend(
"TRG_ID",
typeid(
unsigned long long));
60 trgData.extend(
"RUNNUM",
typeid(
unsigned int));
61 trgData.extend(
"CMSLSNUM",
typeid(
unsigned int));
62 trgData.extend(
"BITNUM",
typeid(
unsigned int));
64 trgData.extend(
"TRGCOUNT",
typeid(
unsigned int));
65 trgData.extend(
"DEADTIME",
typeid(
unsigned long long));
66 trgData.extend(
"PRESCALE",
typeid(
unsigned int));
67 coral::IBulkOperation* trgInserter =
70 unsigned long long& trg_id = trgData[
"TRG_ID"].data<
unsigned long long>();
71 unsigned int& trgrunnum = trgData[
"RUNNUM"].data<
unsigned int>();
72 unsigned int& cmslsnum = trgData[
"CMSLSNUM"].data<
unsigned int>();
73 unsigned int& bitnum = trgData[
"BITNUM"].data<
unsigned int>();
75 unsigned int&
count = trgData[
"TRGCOUNT"].data<
unsigned int>();
76 unsigned long long& deadtime = trgData[
"DEADTIME"].data<
unsigned long long>();
77 unsigned int& prescale = trgData[
"PRESCALE"].data<
unsigned int>();
79 for (
unsigned int i = 1;
i <= totalcmsls; ++
i) {
90 ::sprintf(c,
"%d",
j);
96 trgInserter->processNextIteration();
102 std::cout <<
"database problem " << er.what() << std::endl;
103 session->transaction().rollback();
109 session->transaction().commit();
static const std::string trgTableName()
const edm::EventSetup & c
TRGDummy2DB(const std::string &dest)
unsigned long long retrieveData(unsigned int) override
const unsigned int N_TRGTECHBIT
const std::string sourceType() const override
void setAuthentication(const std::string &authPath)
const std::string dataType() const override
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
#define DEFINE_EDM_PLUGIN(factory, type, name)
const unsigned int N_TRGALGOBIT