1 #ifndef RecoLuminosity_LumiProducer_LumiDummy2DB_H
2 #define RecoLuminosity_LumiProducer_LumiDummy2DB_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/AttributeList.h"
14 #include "CoralBase/Attribute.h"
15 #include "CoralBase/Blob.h"
16 #include "CoralBase/Exception.h"
31 virtual const std::string
dataType()
const;
45 coral::ConnectionService*
svc=
new coral::ConnectionService;
50 coral::ISessionProxy*
session=svc->connect(
m_dest,coral::Update);
51 coral::ITypeConverter& tpc=session->typeConverter();
52 tpc.setCppTypeForSqlType(
"unsigned int",
"NUMBER(10)");
54 unsigned int totallumils=35;
55 unsigned int totalcmsls=32;
56 session->transaction().start(
false);
57 coral::ISchema&
schema=session->nominalSchema();
61 coral::AttributeList summaryData;
62 summaryData.extend(
"LUMISUMMARY_ID",
typeid(
unsigned long long));
63 summaryData.extend(
"RUNNUM",
typeid(
unsigned int));
64 summaryData.extend(
"CMSLSNUM",
typeid(
unsigned int));
65 summaryData.extend(
"LUMILSNUM",
typeid(
unsigned int));
66 summaryData.extend(
"LUMIVERSION",
typeid(std::string));
67 summaryData.extend(
"DTNORM",
typeid(
float));
68 summaryData.extend(
"LHCNORM",
typeid(
float));
69 summaryData.extend(
"INSTLUMI",
typeid(
float));
70 summaryData.extend(
"INSTLUMIERROR",
typeid(
float));
71 summaryData.extend(
"INSTLUMIQUALITY",
typeid(
short));
72 summaryData.extend(
"LUMISECTIONQUALITY",
typeid(
short));
73 summaryData.extend(
"CMSALIVE",
typeid(
short));
74 summaryData.extend(
"STARTORBIT",
typeid(
unsigned int));
75 summaryData.extend(
"NUMORBIT",
typeid(
unsigned int));
76 summaryData.extend(
"BEAMENERGY",
typeid(
float));
77 summaryData.extend(
"BEAMSTATUS",
typeid(std::string));
79 coral::IBulkOperation* summaryInserter=summarytable.dataEditor().bulkInsert(summaryData,totallumils);
80 coral::AttributeList detailData;
81 detailData.extend(
"LUMIDETAIL_ID",
typeid(
unsigned long long));
82 detailData.extend(
"LUMISUMMARY_ID",
typeid(
unsigned long long));
83 detailData.extend(
"BXLUMIVALUE",
typeid(coral::Blob));
84 detailData.extend(
"BXLUMIERROR",
typeid(coral::Blob));
85 detailData.extend(
"BXLUMIQUALITY",
typeid(coral::Blob));
86 detailData.extend(
"ALGONAME",
typeid(std::string));
87 coral::IBulkOperation* detailInserter=detailtable.dataEditor().bulkInsert(detailData,totallumils*
N_LUMIALGO);
89 unsigned long long& lumisummary_id=summaryData[
"LUMISUMMARY_ID"].data<
unsigned long long>();
90 unsigned int& lumirunnum = summaryData[
"RUNNUM"].data<
unsigned int>();
91 unsigned int&
cmslsnum=summaryData[
"CMSLSNUM"].data<
unsigned int>();
92 unsigned int&
lumilsnum=summaryData[
"LUMILSNUM"].data<
unsigned int>();
93 std::string& lumiversion = summaryData[
"LUMIVERSION"].data<std::string>();
94 float& dtnorm = summaryData[
"DTNORM"].data<
float>();
95 float& lhcnorm = summaryData[
"LHCNORM"].data<
float>();
96 float& instlumi = summaryData[
"INSTLUMI"].data<
float>();
97 float& instlumierror = summaryData[
"INSTLUMIERROR"].data<
float>();
98 short& instlumiquality = summaryData[
"INSTLUMIQUALITY"].data<
short>();
99 short& lumisectionquality = summaryData[
"LUMISECTIONQUALITY"].data<
short>();
100 short& cmsalive = summaryData[
"CMSALIVE"].data<
short>();
101 unsigned int& startorbit=summaryData[
"STARTORBIT"].data<
unsigned int>();
102 unsigned int& numorbit= summaryData[
"NUMORBIT"].data<
unsigned int>();
103 float& beamenergy= summaryData[
"BEAMENERGY"].data<
float>();
104 std::string& beamstatus= summaryData[
"BEAMSTATUS"].data<std::string>();
106 unsigned long long& lumidetail_id=detailData[
"LUMIDETAIL_ID"].data<
unsigned long long>();
107 unsigned long long& d2lumisummary_id=detailData[
"LUMISUMMARY_ID"].data<
unsigned long long>();
108 coral::Blob& bxlumivalue=detailData[
"BXLUMIVALUE"].data<coral::Blob>();
109 coral::Blob& bxlumierror=detailData[
"BXLUMIERROR"].data<coral::Blob>();
110 coral::Blob& bxlumiquality=detailData[
"BXLUMIQUALITY"].data<coral::Blob>();
111 std::string& algoname=detailData[
"ALGONAME"].data<std::string>();
112 for(
unsigned int i=1;
i<=totallumils;++
i){
120 instlumierror = 0.01;
122 lumisectionquality = 16;
124 short iscmsalive = 0;
136 summaryInserter->processNextIteration();
137 summaryInserter->flush();
141 if(
j==0) algoname=std::string(
"ET");
142 if(
j==1) algoname=std::string(
"OCC1");
143 if(
j==2) algoname=std::string(
"OCC2");
144 float lumivalue[
N_BX];
145 std::memset((
void*)&lumivalue,0,
sizeof(
float)*
N_BX);
146 float lumierror[
N_BX];
147 std::memset((
void*)&lumierror,0,
sizeof(
float)*N_BX );
148 short lumiquality[
N_BX];
149 std::memset((
void*)&lumiquality,0,
sizeof(
short)*N_BX );
150 bxlumivalue.resize(
sizeof(
float)*N_BX);
151 bxlumierror.resize(
sizeof(
float)*N_BX);
152 bxlumiquality.resize(
sizeof(
short)*N_BX);
153 void* bxlumivalueStartAddress=bxlumivalue.startingAddress();
154 void* bxlumierrorStartAddress=bxlumierror.startingAddress();
155 void* bxlumiqualityStartAddress=bxlumiquality.startingAddress();
156 for(
unsigned int k=0;
k<
N_BX; ++
k ){
161 std::memmove(bxlumivalueStartAddress,lumivalue,
sizeof(
float)*N_BX);
162 std::memmove(bxlumierrorStartAddress,lumierror,
sizeof(
float)*N_BX);
163 std::memmove(bxlumiqualityStartAddress,lumiquality,
sizeof(
short)*N_BX);
164 detailInserter->processNextIteration();
167 detailInserter->flush();
168 delete summaryInserter;
169 delete detailInserter;
171 session->transaction().rollback();
177 session->transaction().commit();
virtual const std::string sourceType() const
const unsigned int N_LUMIALGO
LumiDummy2DB(const std::string &dest)
void setAuthentication(const std::string &authPath)
static const std::string lumisummaryTableName()
static const std::string lumidetailTableName()
virtual const std::string dataType() const
virtual void retrieveData(unsigned int)
unsigned long long generateNextIDForTable(const std::string &tableName, unsigned int interval=1)
#define DEFINE_EDM_PLUGIN(factory, type, name)