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"
48 session->transaction().start();
49 std::cout <<
"connected succesfully to omds" << std::endl;
50 coral::ISchema& schema = session->nominalSchema();
86 std::cout <<
"entering readData" << std::endl;
88 session->transaction().start();
89 std::cout <<
"starting session " << std::endl;
90 coral::ISchema& schema = session->nominalSchema();
91 std::cout <<
" accessing schema " << std::endl;
94 coral::IQuery* query0 = schema.tableHandle(
"RUNSESSION_PARAMETER").newQuery();
95 std::cout <<
"table handling " << std::endl;
96 query0->addToOutputList(
"RUNSESSION_PARAMETER.STRING_VALUE",
"STRING_VALUE");
99 "RUNSESSION_PARAMETER.RUNNUMBER=:n_run AND RUNSESSION_PARAMETER.NAME='CMS.TRG:GTLumiSegInfo_format'";
100 coral::AttributeList conditionData0;
101 conditionData0.extend<
int>(
"n_run");
102 query0->setCondition(condition0, conditionData0);
103 conditionData0[0].data<
int>() = r_number;
104 coral::ICursor& cursor0 = query0->execute();
106 std::vector<L1TriggerScaler::Lumi> l1triggerscaler_array;
109 while (cursor0.next() != 0) {
110 const coral::AttributeList& row = cursor0.currentRow();
111 std::cout <<
" entering the query == " << std::endl;
112 string_format = row[
"STRING_VALUE"].data<
std::string>();
114 std::cout <<
" string value extracted == " << string_format << std::endl;
118 coral::IQuery* queryI = schema.tableHandle(
"RUNSESSION_PARAMETER").newQuery();
121 std::cout <<
"table handling " << std::endl;
124 queryI->addToOutputList(
"RUNSESSION_PARAMETER.ID",
"ID");
126 queryI->addToOutputList(
"RUNSESSION_PARAMETER.TIME",
"TIME");
130 "RUNSESSION_PARAMETER.RUNNUMBER=:n_run AND RUNSESSION_PARAMETER.NAME LIKE 'CMS.TRG:GTLumiSegInfo%' ORDER BY "
133 coral::AttributeList conditionData;
134 conditionData.extend<
int>(
"n_run");
135 queryI->setCondition(condition, conditionData);
136 conditionData[0].data<
int>() = r_number;
137 coral::ICursor& cursorI = queryI->execute();
139 std::vector<std::pair<int, long long> >
142 if (cursorI.next() == 0) {
143 std::cout <<
" run " << r_number <<
" not full " << std::endl;
145 while (cursorI.next() != 0) {
153 const coral::AttributeList& row = cursorI.currentRow();
154 std::cout <<
" entering the query == " << std::endl;
158 Itemp.
m_lumi_id = row[
"ID"].data<
long long>();
163 coral::TimeStamp st = row[
"TIME"].data<coral::TimeStamp>();
164 int year = st.year();
165 int month = st.month();
167 int hour = st.hour();
169 int minute = st.minute();
171 long nanosecond = st.nanosecond();
172 std::cout <<
" start time time extracted == "
173 <<
"-->year " << year <<
"-- month " << month <<
"-- day " <<
day <<
"-- hour " << hour <<
"-- minute "
174 << minute <<
"-- second " <<
second << std::endl;
175 boost::gregorian::date
dt(year, month,
day);
176 boost::posix_time::time_duration td(hour, minute,
second, nanosecond / 1000);
177 boost::posix_time::ptime
pt(
dt, td);
178 Itemp.
m_start_time = boost::posix_time::to_iso_extended_string(
pt);
181 coral::IQuery* queryII = schema.newQuery();
182 queryII->addToOutputList(
"RUNSESSION_VECTOR.VALUE_ID",
"VALUE_ID");
183 queryII->addToOutputList(
"RUNSESSION_VECTOR.VALUE_INDEX",
"VALUE_INDEX");
185 queryII->addToTableList(
"RUNSESSION_VECTOR");
186 std::string condition2 =
"RUNSESSION_VECTOR.PARENT_ID=:n_vid";
187 coral::AttributeList conditionData2;
188 conditionData2.extend<
long>(
"n_vid");
189 queryII->setCondition(condition2, conditionData2);
190 conditionData2[0].data<
long>() = Itemp.
m_lumi_id + 1;
191 coral::ICursor& cursorII = queryII->execute();
192 while (cursorII.next() != 0) {
193 const coral::AttributeList& row = cursorII.currentRow();
194 std::cout <<
" entering the queryII == " << std::endl;
195 long long vid_val = row[
"VALUE_ID"].data<
long long>();
196 int vid_id = (
int)row[
"VALUE_INDEX"].data<long long>();
197 v_vid.push_back(std::make_pair(vid_id, vid_val));
198 std::cout <<
" value_id index extracted == " << v_vid.back().first << std::endl;
199 std::cout <<
" value_id value extracted == " << v_vid.back().second << std::endl;
202 coral::AttributeList conditionData3;
203 conditionData3.extend<
int>(
"n_vid_val");
204 conditionData3[0].data<
int>() = vid_val;
208 coral::IQuery* queryIII = schema.newQuery();
209 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
210 queryIII->addToTableList(
"RUNSESSION_INTEGER");
211 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
212 queryIII->setCondition(condition3, conditionData3);
213 coral::ICursor& cursorIII = queryIII->execute();
215 while (cursorIII.next() != 0) {
216 const coral::AttributeList& row = cursorIII.currentRow();
218 Itemp.
m_rn = row[
"VALUE"].data<
long long>();
219 std::cout <<
" run extracted == " << Itemp.
m_rn << std::endl;
225 coral::IQuery* queryIII = schema.newQuery();
226 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
227 queryIII->addToTableList(
"RUNSESSION_INTEGER");
228 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
229 queryIII->setCondition(condition3, conditionData3);
230 coral::ICursor& cursorIII = queryIII->execute();
231 while (cursorIII.next() != 0) {
232 const coral::AttributeList& row = cursorIII.currentRow();
233 std::cout <<
" entering the queryIII " << std::endl;
279 coral::IQuery* queryIII = schema.newQuery();
280 queryIII->addToOutputList(
"RUNSESSION_DATE.VALUE",
"VALUE");
281 queryIII->addToTableList(
"RUNSESSION_DATE");
282 std::string condition3 =
"RUNSESSION_DATE.PARENT_ID=:n_vid_val";
283 queryIII->setCondition(condition3, conditionData3);
284 coral::ICursor& cursorIII = queryIII->execute();
285 if (cursorIII.next() != 0) {
286 const coral::AttributeList& row = cursorIII.currentRow();
287 std::cout <<
" entering the queryIII " << std::endl;
288 coral::TimeStamp ts = row[
"VALUE"].data<coral::TimeStamp>();
289 int year = ts.year();
290 int month = ts.month();
292 int hour = ts.hour();
294 int minute = ts.minute();
296 long nanosecond = ts.nanosecond();
297 std::cout <<
" start time time extracted == "
298 <<
"-->year " << year <<
"-- month " << month <<
"-- day " <<
day <<
"-- hour " << hour
299 <<
"-- minute " << minute <<
"-- second " <<
second << std::endl;
300 boost::gregorian::date
dt(year, month,
day);
301 boost::posix_time::time_duration td(hour, minute,
second, nanosecond / 1000);
302 boost::posix_time::ptime
pt(
dt, td);
303 Itemp.
m_date = boost::posix_time::to_iso_extended_string(
pt);
312 coral::IQuery* queryIII = schema.newQuery();
313 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
314 queryIII->addToTableList(
"RUNSESSION_INTEGER");
315 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
316 queryIII->setCondition(condition3, conditionData3);
317 coral::ICursor& cursorIII = queryIII->execute();
319 while (cursorIII.next() != 0) {
320 const coral::AttributeList& row = cursorIII.currentRow();
321 std::cout <<
" entering the queryIII " << std::endl;
322 int v = (
int)row[
"VALUE"].data<long long>();
335 coral::IQuery* queryIII = schema.newQuery();
336 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
337 queryIII->addToTableList(
"RUNSESSION_FLOAT");
338 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
339 queryIII->setCondition(condition3, conditionData3);
340 coral::ICursor& cursorIII = queryIII->execute();
342 while (cursorIII.next() != 0) {
343 const coral::AttributeList& row = cursorIII.currentRow();
344 std::cout <<
" entering the queryIII " << std::endl;
345 float v = (
float)row[
"VALUE"].data<double>();
359 coral::IQuery* queryIII = schema.newQuery();
360 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
361 queryIII->addToTableList(
"RUNSESSION_INTEGER");
362 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
363 queryIII->setCondition(condition3, conditionData3);
364 coral::ICursor& cursorIII = queryIII->execute();
366 while (cursorIII.next() != 0) {
367 const coral::AttributeList& row = cursorIII.currentRow();
368 std::cout <<
" entering the queryIII " << std::endl;
369 int v = (
int)row[
"VALUE"].data<long long>();
382 coral::IQuery* queryIII = schema.newQuery();
383 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
384 queryIII->addToTableList(
"RUNSESSION_INTEGER");
385 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
386 queryIII->setCondition(condition3, conditionData3);
387 coral::ICursor& cursorIII = queryIII->execute();
389 while (cursorIII.next() != 0) {
390 const coral::AttributeList& row = cursorIII.currentRow();
391 std::cout <<
" entering the queryIII " << std::endl;
392 int v = (
int)row[
"VALUE"].data<long long>();
405 coral::IQuery* queryIII = schema.newQuery();
406 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
407 queryIII->addToTableList(
"RUNSESSION_FLOAT");
408 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
409 queryIII->setCondition(condition3, conditionData3);
410 coral::ICursor& cursorIII = queryIII->execute();
412 while (cursorIII.next() != 0) {
413 const coral::AttributeList& row = cursorIII.currentRow();
414 std::cout <<
" entering the queryIII " << std::endl;
415 float v = (
float)row[
"VALUE"].data<double>();
428 coral::IQuery* queryIII = schema.newQuery();
429 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
430 queryIII->addToTableList(
"RUNSESSION_INTEGER");
431 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
432 queryIII->setCondition(condition3, conditionData3);
433 coral::ICursor& cursorIII = queryIII->execute();
435 while (cursorIII.next() != 0) {
436 const coral::AttributeList& row = cursorIII.currentRow();
437 std::cout <<
" entering the queryIII " << std::endl;
438 int v = (
int)row[
"VALUE"].data<long long>();
451 coral::IQuery* queryIII = schema.newQuery();
452 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
453 queryIII->addToTableList(
"RUNSESSION_INTEGER");
454 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
455 queryIII->setCondition(condition3, conditionData3);
456 coral::ICursor& cursorIII = queryIII->execute();
458 while (cursorIII.next() != 0) {
459 const coral::AttributeList& row = cursorIII.currentRow();
460 std::cout <<
" entering the queryIII " << std::endl;
461 int v = (
int)row[
"VALUE"].data<long long>();
474 coral::IQuery* queryIII = schema.newQuery();
475 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
476 queryIII->addToTableList(
"RUNSESSION_FLOAT");
477 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
478 queryIII->setCondition(condition3, conditionData3);
479 coral::ICursor& cursorIII = queryIII->execute();
481 while (cursorIII.next() != 0) {
482 const coral::AttributeList& row = cursorIII.currentRow();
483 std::cout <<
" entering the queryIII " << std::endl;
484 float v = (
float)row[
"VALUE"].data<double>();
497 coral::IQuery* queryIII = schema.newQuery();
498 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
499 queryIII->addToTableList(
"RUNSESSION_INTEGER");
500 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
501 queryIII->setCondition(condition3, conditionData3);
502 coral::ICursor& cursorIII = queryIII->execute();
504 while (cursorIII.next() != 0) {
505 const coral::AttributeList& row = cursorIII.currentRow();
506 std::cout <<
" entering the queryIII " << std::endl;
507 int v = (
int)row[
"VALUE"].data<long long>();
520 coral::IQuery* queryIII = schema.newQuery();
521 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
522 queryIII->addToTableList(
"RUNSESSION_FLOAT");
523 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
524 queryIII->setCondition(condition3, conditionData3);
525 coral::ICursor& cursorIII = queryIII->execute();
527 while (cursorIII.next() != 0) {
528 const coral::AttributeList& row = cursorIII.currentRow();
529 std::cout <<
" entering the queryIII " << std::endl;
530 float v = (
float)row[
"VALUE"].data<double>();
543 std::cout <<
"index out of range" << std::endl;
551 l1triggerscaler_array.push_back(Itemp);
556 session->transaction().commit();
561 return l1triggerscaler_array;