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();
318 while (cursorIII.next() != 0) {
319 const coral::AttributeList& row = cursorIII.currentRow();
320 std::cout <<
" entering the queryIII " << std::endl;
321 int v = (
int)row[
"VALUE"].data<long long>();
332 coral::IQuery* queryIII = schema.newQuery();
333 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
334 queryIII->addToTableList(
"RUNSESSION_FLOAT");
335 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
336 queryIII->setCondition(condition3, conditionData3);
337 coral::ICursor& cursorIII = queryIII->execute();
338 while (cursorIII.next() != 0) {
339 const coral::AttributeList& row = cursorIII.currentRow();
340 std::cout <<
" entering the queryIII " << std::endl;
341 float v = (
float)row[
"VALUE"].data<double>();
353 coral::IQuery* queryIII = schema.newQuery();
354 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
355 queryIII->addToTableList(
"RUNSESSION_INTEGER");
356 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
357 queryIII->setCondition(condition3, conditionData3);
358 coral::ICursor& cursorIII = queryIII->execute();
359 while (cursorIII.next() != 0) {
360 const coral::AttributeList& row = cursorIII.currentRow();
361 std::cout <<
" entering the queryIII " << std::endl;
362 int v = (
int)row[
"VALUE"].data<long long>();
373 coral::IQuery* queryIII = schema.newQuery();
374 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
375 queryIII->addToTableList(
"RUNSESSION_INTEGER");
376 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
377 queryIII->setCondition(condition3, conditionData3);
378 coral::ICursor& cursorIII = queryIII->execute();
379 while (cursorIII.next() != 0) {
380 const coral::AttributeList& row = cursorIII.currentRow();
381 std::cout <<
" entering the queryIII " << std::endl;
382 int v = (
int)row[
"VALUE"].data<long long>();
393 coral::IQuery* queryIII = schema.newQuery();
394 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
395 queryIII->addToTableList(
"RUNSESSION_FLOAT");
396 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
397 queryIII->setCondition(condition3, conditionData3);
398 coral::ICursor& cursorIII = queryIII->execute();
399 while (cursorIII.next() != 0) {
400 const coral::AttributeList& row = cursorIII.currentRow();
401 std::cout <<
" entering the queryIII " << std::endl;
402 float v = (
float)row[
"VALUE"].data<double>();
413 coral::IQuery* queryIII = schema.newQuery();
414 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
415 queryIII->addToTableList(
"RUNSESSION_INTEGER");
416 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
417 queryIII->setCondition(condition3, conditionData3);
418 coral::ICursor& cursorIII = queryIII->execute();
419 while (cursorIII.next() != 0) {
420 const coral::AttributeList& row = cursorIII.currentRow();
421 std::cout <<
" entering the queryIII " << std::endl;
422 int v = (
int)row[
"VALUE"].data<long long>();
433 coral::IQuery* queryIII = schema.newQuery();
434 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
435 queryIII->addToTableList(
"RUNSESSION_INTEGER");
436 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
437 queryIII->setCondition(condition3, conditionData3);
438 coral::ICursor& cursorIII = queryIII->execute();
439 while (cursorIII.next() != 0) {
440 const coral::AttributeList& row = cursorIII.currentRow();
441 std::cout <<
" entering the queryIII " << std::endl;
442 int v = (
int)row[
"VALUE"].data<long long>();
453 coral::IQuery* queryIII = schema.newQuery();
454 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
455 queryIII->addToTableList(
"RUNSESSION_FLOAT");
456 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
457 queryIII->setCondition(condition3, conditionData3);
458 coral::ICursor& cursorIII = queryIII->execute();
459 while (cursorIII.next() != 0) {
460 const coral::AttributeList& row = cursorIII.currentRow();
461 std::cout <<
" entering the queryIII " << std::endl;
462 float v = (
float)row[
"VALUE"].data<double>();
473 coral::IQuery* queryIII = schema.newQuery();
474 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE",
"VALUE");
475 queryIII->addToTableList(
"RUNSESSION_INTEGER");
476 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
477 queryIII->setCondition(condition3, conditionData3);
478 coral::ICursor& cursorIII = queryIII->execute();
479 while (cursorIII.next() != 0) {
480 const coral::AttributeList& row = cursorIII.currentRow();
481 std::cout <<
" entering the queryIII " << std::endl;
482 int v = (
int)row[
"VALUE"].data<long long>();
493 coral::IQuery* queryIII = schema.newQuery();
494 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE",
"VALUE");
495 queryIII->addToTableList(
"RUNSESSION_FLOAT");
496 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
497 queryIII->setCondition(condition3, conditionData3);
498 coral::ICursor& cursorIII = queryIII->execute();
499 while (cursorIII.next() != 0) {
500 const coral::AttributeList& row = cursorIII.currentRow();
501 std::cout <<
" entering the queryIII " << std::endl;
502 float v = (
float)row[
"VALUE"].data<double>();
513 std::cout <<
"index out of range" << std::endl;
521 l1triggerscaler_array.push_back(Itemp);
526 session->transaction().commit();
531 return l1triggerscaler_array;
std::vector< float > m_GTAlgoRates
L1TriggerScalerRead(const std::string &connectionString, const std::string &user, const std::string &pass)
std::vector< int > m_GTTechCounts
std::vector< float > m_GTTechRates
~L1TriggerScalerRead() override
std::string m_tableToDrop
std::vector< int > m_GTAlgoCounts
std::vector< int > m_GTTechPrescaling
U second(std::pair< T, U > const &p)
std::vector< float > m_GTPartition0DeadTimeRatio
std::vector< L1TriggerScaler::Lumi > readData(const int r_number)
std::vector< int > m_GTPartition0DeadTime
std::string m_connectionString
void dropTable(const std::string &table)
std::string m_string_format
std::vector< int > m_GTPartition0TriggerCounts
std::vector< float > m_GTPartition0TriggerRates
std::vector< int > m_GTAlgoPrescaling
coral::ISession * connect(const std::string &connectionString, const std::string &user, const std::string &password)