3 #include "RelationalAccess/ISession.h"
4 #include "RelationalAccess/ITransaction.h"
5 #include "RelationalAccess/ISchema.h"
6 #include "RelationalAccess/ITable.h"
7 #include "RelationalAccess/ITableDataEditor.h"
8 #include "RelationalAccess/TableDescription.h"
9 #include "RelationalAccess/IQuery.h"
10 #include "RelationalAccess/ICursor.h"
11 #include "CoralBase/AttributeList.h"
12 #include "CoralBase/Attribute.h"
13 #include "CoralBase/AttributeSpecification.h"
18 #include "CoralBase/TimeStamp.h"
20 #include "boost/date_time/posix_time/posix_time.hpp"
21 #include "boost/date_time.hpp"
77 temp_sum.
m_run = r_number;
79 std::cout <<
"entering readData" << std::endl;
81 session->transaction().start();
82 std::cout <<
"starting session " << std::endl;
83 coral::ISchema& schema = session->nominalSchema();
84 std::cout <<
" accessing schema " << std::endl;
87 coral::IQuery* queryI = schema.tableHandle(
m_tableToRead).newQuery();
92 coral::AttributeList conditionData;
93 conditionData.extend<
int>(
"n_run");
94 conditionData[0].data<
int>() = r_number;
98 queryI->setCondition(condition1, conditionData);
99 coral::ICursor& cursorI = queryI->execute();
101 if (cursorI.next() != 0) {
102 const coral::AttributeList& row = cursorI.currentRow();
112 long long id_start = 0;
114 coral::IQuery* queryII = schema.tableHandle(
m_tableToRead).newQuery();
117 queryII->addToOutputList(
m_tableToRead +
"." + m_columnToRead_id, m_columnToRead_id);
120 queryII->setCondition(condition2, conditionData);
121 coral::ICursor& cursorII = queryII->execute();
123 if (cursorII.next() != 0) {
124 const coral::AttributeList& row = cursorII.currentRow();
125 id_start = row[m_columnToRead_id].data<
long long>();
126 std::cout <<
" id for start time time extracted == " << id_start << std::endl;
129 std::cout <<
" id for start time time extracted == " << id_start << std::endl;
135 std::string m_tableToRead_date =
"RUNSESSION_DATE";
138 coral::IQuery* queryIII = schema.tableHandle(m_tableToRead_date).newQuery();
141 queryIII->addToOutputList(m_tableToRead_date +
"." + m_columnToRead_val, m_columnToRead_val);
143 coral::AttributeList conditionData3;
144 conditionData3.extend<
long long>(
"n_id");
145 conditionData3[0].data<
long long>() = id_start;
146 std::string condition3 = m_tableToRead_date +
".runsession_parameter_id=:n_id";
147 queryIII->setCondition(condition3, conditionData3);
148 coral::ICursor& cursorIII = queryIII->execute();
150 if (cursorIII.next() != 0) {
151 const coral::AttributeList& row = cursorIII.currentRow();
152 coral::TimeStamp ts = row[m_columnToRead_val].data<coral::TimeStamp>();
153 int year = ts.year();
154 int month = ts.month();
156 int hour = ts.hour();
157 int minute = ts.minute();
159 long nanosecond = ts.nanosecond();
164 std::cout <<
" start time time extracted == "
165 <<
"-->year " << year <<
"-- month " << month <<
"-- day " <<
day <<
"-- hour " << hour <<
"-- minute "
166 << minute <<
"-- second " <<
second <<
"-- nanosecond " << nanosecond << std::endl;
169 boost::posix_time::time_duration td(hour - 1, minute,
second, nanosecond / 1000);
171 boost::posix_time::ptime
pt(
dt, td);
183 boost::posix_time::time_duration time_diff = (
pt - time_at_epoch);
193 coral::IQuery* queryIV = schema.tableHandle(
m_tableToRead).newQuery();
196 queryIV->addToOutputList(
m_tableToRead +
"." + m_columnToRead_id, m_columnToRead_id);
200 queryIV->setCondition(condition4, conditionData);
202 coral::ICursor& cursorIV = queryIV->execute();
204 long long id_stop = 0;
205 if (cursorIV.next() != 0) {
206 const coral::AttributeList& row = cursorIV.currentRow();
208 id_stop = row[m_columnToRead_id].data<
long long>();
209 std::cout <<
" id for stop time time extracted == " << id_stop << std::endl;
217 coral::IQuery* queryIVbis = schema.tableHandle(m_tableToRead_date).newQuery();
220 queryIVbis->addToOutputList(m_tableToRead_date +
"." + m_columnToRead_val, m_columnToRead_val);
222 coral::AttributeList conditionData4bis;
223 conditionData4bis.extend<
long long>(
"n_id");
224 conditionData4bis[0].data<
long long>() = id_stop;
225 std::string condition4bis = m_tableToRead_date +
".runsession_parameter_id=:n_id";
226 queryIVbis->setCondition(condition4bis, conditionData4bis);
227 coral::ICursor& cursorIVbis = queryIVbis->execute();
228 if (cursorIVbis.next() != 0) {
229 const coral::AttributeList& row = cursorIVbis.currentRow();
230 coral::TimeStamp ts = row[m_columnToRead_val].data<coral::TimeStamp>();
231 int year = ts.year();
232 int month = ts.month();
234 int hour = ts.hour();
235 int minute = ts.minute();
237 long nanosecond = ts.nanosecond();
238 std::cout <<
" stop time time extracted == "
239 <<
"-->year " << year <<
"-- month " << month <<
"-- day " <<
day <<
"-- hour " << hour <<
"-- minute "
240 << minute <<
"-- second " <<
second <<
"-- nanosecond " << nanosecond << std::endl;
243 boost::posix_time::time_duration td(hour - 1, minute,
second, nanosecond / 1000);
244 boost::posix_time::ptime
pt(
dt, td);
250 boost::posix_time::time_duration time_diff = (
pt - time_at_epoch);
260 const std::string m_tableToRead_ls =
"HLT_SUPERVISOR_LUMISECTIONS_V2";
263 coral::IQuery* queryV = schema.tableHandle(m_tableToRead_ls).newQuery();
264 queryV->addToOutputList(
"MAX(" + m_tableToRead_ls +
"." + m_columnToRead_ls +
")", m_columnToRead_ls);
265 std::string condition5 = m_tableToRead_ls +
".runnr=:n_run ";
268 queryV->setCondition(condition5, conditionData);
271 coral::ICursor& cursorV = queryV->execute();
272 if (cursorV.next() != 0) {
273 const coral::AttributeList& row = cursorV.currentRow();
274 double lumisections = row[m_columnToRead_ls].data<
double>();
280 std::cout <<
" leaving the query " << std::endl;
285 coral::IQuery* queryVIPIXEL = schema.tableHandle(
m_tableToRead).newQuery();
289 queryVIPIXEL->setCondition(condition6PIXEL, conditionData);
290 coral::ICursor& cursorVIPIXEL = queryVIPIXEL->execute();
292 if (cursorVIPIXEL.next() != 0) {
293 const coral::AttributeList& row = cursorVIPIXEL.currentRow();
302 coral::IQuery* queryVITRACKER = schema.tableHandle(
m_tableToRead).newQuery();
306 queryVITRACKER->setCondition(condition6TRACKER, conditionData);
307 coral::ICursor& cursorVITRACKER = queryVITRACKER->execute();
309 if (cursorVITRACKER.next() != 0) {
310 const coral::AttributeList& row = cursorVITRACKER.currentRow();
318 delete queryVITRACKER;
320 coral::IQuery* queryVIECAL = schema.tableHandle(
m_tableToRead).newQuery();
324 queryVIECAL->setCondition(condition6ECAL, conditionData);
325 coral::ICursor& cursorVIECAL = queryVIECAL->execute();
327 if (cursorVIECAL.next() != 0) {
328 const coral::AttributeList& row = cursorVIECAL.currentRow();
338 coral::IQuery* queryVIHCAL = schema.tableHandle(
m_tableToRead).newQuery();
342 queryVIHCAL->setCondition(condition6HCAL, conditionData);
343 coral::ICursor& cursorVIHCAL = queryVIHCAL->execute();
345 if (cursorVIHCAL.next() != 0) {
346 const coral::AttributeList& row = cursorVIHCAL.currentRow();
356 coral::IQuery* queryVIDT = schema.tableHandle(
m_tableToRead).newQuery();
360 queryVIDT->setCondition(condition6DT, conditionData);
361 coral::ICursor& cursorVIDT = queryVIDT->execute();
363 if (cursorVIDT.next() != 0) {
364 const coral::AttributeList& row = cursorVIDT.currentRow();
374 coral::IQuery* queryVICSC = schema.tableHandle(
m_tableToRead).newQuery();
378 queryVICSC->setCondition(condition6CSC, conditionData);
379 coral::ICursor& cursorVICSC = queryVICSC->execute();
381 if (cursorVICSC.next() != 0) {
382 const coral::AttributeList& row = cursorVICSC.currentRow();
392 coral::IQuery* queryVIRPC = schema.tableHandle(
m_tableToRead).newQuery();
396 queryVIRPC->setCondition(condition6RPC, conditionData);
397 coral::ICursor& cursorVIRPC = queryVIRPC->execute();
399 if (cursorVIRPC.next() != 0) {
400 const coral::AttributeList& row = cursorVIRPC.currentRow();
415 coral::IQuery* queryVII = schema.tableHandle(
m_tableToRead).newQuery();
420 coral::AttributeList conditionData7;
421 conditionData7.extend<
int>(
"n_run");
422 conditionData7[0].data<
int>() = r_number;
427 queryVII->setCondition(condition7, conditionData7);
428 coral::ICursor& cursorVII = queryVII->execute();
430 if (cursorVII.next() != 0) {
431 const coral::AttributeList& row = cursorVII.currentRow();
441 coral::IQuery* queryVIII = schema.tableHandle(
m_tableToRead).newQuery();
446 coral::AttributeList conditionData8;
447 conditionData8.extend<
int>(
"n_run");
448 conditionData8[0].data<
int>() = r_number;
453 queryVIII->setCondition(condition8, conditionData8);
454 coral::ICursor& cursorVIII = queryVIII->execute();
456 if (cursorVIII.next() != 0) {
457 const coral::AttributeList& row = cursorVIII.currentRow();
469 coral::IQuery* queryIX = schema.tableHandle(
m_tableToRead).newQuery();
474 coral::AttributeList conditionData9;
475 conditionData9.extend<
int>(
"n_run");
476 conditionData9[0].data<
int>() = r_number;
482 queryIX->setCondition(condition9, conditionData9);
483 coral::ICursor& cursorIX = queryIX->execute();
485 if (cursorIX.next() != 0) {
486 const coral::AttributeList& row = cursorIX.currentRow();
497 session->transaction().commit();