5 #include "RelationalAccess/ISession.h"
6 #include "RelationalAccess/ITransaction.h"
7 #include "RelationalAccess/ISchema.h"
8 #include "RelationalAccess/ITable.h"
9 #include "RelationalAccess/ITableDataEditor.h"
10 #include "RelationalAccess/TableDescription.h"
11 #include "RelationalAccess/IQuery.h"
12 #include "RelationalAccess/ICursor.h"
13 #include "CoralBase/AttributeList.h"
14 #include "CoralBase/Attribute.h"
15 #include "CoralBase/AttributeSpecification.h"
20 #include "CoralBase/TimeStamp.h"
22 #include "boost/date_time/posix_time/posix_time.hpp"
23 #include "boost/date_time.hpp"
41 m_connectionString( connectionString ),
66 session->transaction().start( );
67 std::cout <<
"connected succesfully to omds" <<std::endl;
68 coral::ISchema&
schema = session->nominalSchema();
76 std::vector<L1TriggerScaler::Lumi>
113 std::cout<<
"entering readData" << std::endl;
116 session->transaction().start( );
117 std::cout<<
"starting session " << std::endl;
118 coral::ISchema&
schema = session->nominalSchema();
119 std::cout<<
" accessing schema " << std::endl;
122 coral::IQuery* query0 = schema.tableHandle(
"RUNSESSION_PARAMETER").newQuery();
123 std::cout<<
"table handling " << std::endl;
124 query0->addToOutputList(
"RUNSESSION_PARAMETER.STRING_VALUE" ,
"STRING_VALUE");
126 std::string condition0 =
"RUNSESSION_PARAMETER.RUNNUMBER=:n_run AND RUNSESSION_PARAMETER.NAME='CMS.TRG:GTLumiSegInfo_format'";
127 coral::AttributeList conditionData0;
128 conditionData0.extend<
int>(
"n_run" );
129 query0->setCondition( condition0, conditionData0 );
130 conditionData0[0].data<
int>() = r_number;
131 coral::ICursor& cursor0 = query0->execute();
133 std::vector<L1TriggerScaler::Lumi> l1triggerscaler_array;
136 while ( cursor0.next()!=0 )
139 const coral::AttributeList& row = cursor0.currentRow();
140 std::cout<<
" entering the query == " << std::endl;
141 string_format= row[
"STRING_VALUE"].data<
std::string>();
143 std::cout<<
" string value extracted == " << string_format << std::endl;
153 coral::IQuery* queryI = schema.tableHandle(
"RUNSESSION_PARAMETER").newQuery();
156 std::cout<<
"table handling " << std::endl;
159 queryI->addToOutputList(
"RUNSESSION_PARAMETER.ID" ,
"ID");
161 queryI->addToOutputList(
"RUNSESSION_PARAMETER.TIME" ,
"TIME");
164 std::string condition =
"RUNSESSION_PARAMETER.RUNNUMBER=:n_run AND RUNSESSION_PARAMETER.NAME LIKE 'CMS.TRG:GTLumiSegInfo%' ORDER BY TIME ";
166 coral::AttributeList conditionData;
167 conditionData.extend<
int>(
"n_run" );
168 queryI->setCondition( condition, conditionData );
169 conditionData[0].data<
int>() = r_number;
170 coral::ICursor& cursorI = queryI->execute();
172 std::vector<std::pair<int, long long> > v_vid;
174 if (cursorI.next()==0)
177 std::cout<<
" run " <<r_number <<
" not full " << std::endl;
179 while ( cursorI.next()!=0 )
188 const coral::AttributeList& row = cursorI.currentRow();
189 std::cout<<
" entering the query == " << std::endl;
193 Itemp.
m_lumi_id=row[
"ID"].data<
long long>();
197 coral::TimeStamp st=row[
"TIME"].data<coral::TimeStamp>();
199 int month= st.month();
203 int minute= st.minute();
205 long nanosecond = st.nanosecond();
206 std::cout<<
" start time time extracted == " <<
"-->year " << year
207 <<
"-- month " << month
209 <<
"-- hour " << hour
210 <<
"-- minute " << minute
211 <<
"-- second " << second <<std::endl;
212 boost::gregorian::date
dt(year,month,day);
213 boost::posix_time::time_duration td(hour,minute,second,nanosecond/1000);
214 boost::posix_time::ptime pt( dt, td);
215 Itemp.
m_start_time = boost::posix_time::to_iso_extended_string(pt);
220 coral::IQuery* queryII = schema.newQuery();
221 queryII->addToOutputList(
"RUNSESSION_VECTOR.VALUE_ID" ,
"VALUE_ID");
222 queryII->addToOutputList(
"RUNSESSION_VECTOR.VALUE_INDEX" ,
"VALUE_INDEX");
224 queryII->addToTableList(
"RUNSESSION_VECTOR");
225 std::string condition2 =
"RUNSESSION_VECTOR.PARENT_ID=:n_vid";
226 coral::AttributeList conditionData2;
227 conditionData2.extend<
long>(
"n_vid" );
228 queryII->setCondition( condition2, conditionData2 );
229 conditionData2[0].data<
long>() =Itemp.
m_lumi_id +1 ;
230 coral::ICursor& cursorII = queryII->execute();
231 while ( cursorII.next()!=0 )
233 const coral::AttributeList& row = cursorII.currentRow();
234 std::cout<<
" entering the queryII == " << std::endl;
235 long long vid_val = row[
"VALUE_ID"].data<
long long>();
236 int vid_id = (int)row[
"VALUE_INDEX"].data<long long>();
237 v_vid.push_back(std::make_pair(vid_id, vid_val));
238 std::cout<<
" value_id index extracted == " << v_vid.back().first << std::endl;
239 std::cout<<
" value_id value extracted == " << v_vid.back().second << std::endl;
242 coral::AttributeList conditionData3;
243 conditionData3.extend<
int>(
"n_vid_val" );
244 conditionData3[0].data<
int>() =vid_val ;
248 coral::IQuery* queryIII = schema.newQuery();
249 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
250 queryIII->addToTableList(
"RUNSESSION_INTEGER");
251 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
252 queryIII->setCondition( condition3, conditionData3 );
253 coral::ICursor& cursorIII = queryIII->execute();
256 while ( cursorIII.next()!=0 ) {
257 const coral::AttributeList& row = cursorIII.currentRow();
259 Itemp.
m_rn = row[
"VALUE"].data<
long long>();
267 coral::IQuery* queryIII = schema.newQuery();
268 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
269 queryIII->addToTableList(
"RUNSESSION_INTEGER");
270 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
271 queryIII->setCondition( condition3, conditionData3 );
272 coral::ICursor& cursorIII = queryIII->execute();
273 while ( cursorIII.next()!=0 ) {
274 const coral::AttributeList& row = cursorIII.currentRow();
275 std::cout<<
" entering the queryIII " << std::endl;
324 coral::IQuery* queryIII = schema.newQuery();
325 queryIII->addToOutputList(
"RUNSESSION_DATE.VALUE" ,
"VALUE");
326 queryIII->addToTableList(
"RUNSESSION_DATE");
327 std::string condition3 =
"RUNSESSION_DATE.PARENT_ID=:n_vid_val";
328 queryIII->setCondition( condition3, conditionData3 );
329 coral::ICursor& cursorIII = queryIII->execute();
330 if ( cursorIII.next()!=0 ) {
331 const coral::AttributeList& row = cursorIII.currentRow();
332 std::cout<<
" entering the queryIII " << std::endl;
333 coral::TimeStamp ts = row[
"VALUE"].data<coral::TimeStamp>();
335 int month= ts.month();
339 int minute= ts.minute();
340 int second = ts.second();
341 long nanosecond = ts.nanosecond();
342 std::cout<<
" start time time extracted == " <<
"-->year " << year
343 <<
"-- month " << month
345 <<
"-- hour " << hour
346 <<
"-- minute " << minute
347 <<
"-- second " << second <<std::endl;
348 boost::gregorian::date
dt(year,month,day);
349 boost::posix_time::time_duration td(hour,minute,second,nanosecond/1000);
350 boost::posix_time::ptime pt( dt, td);
351 Itemp.
m_date = boost::posix_time::to_iso_extended_string(pt);
363 coral::IQuery* queryIII = schema.newQuery();
364 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
365 queryIII->addToTableList(
"RUNSESSION_INTEGER");
366 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
367 queryIII->setCondition( condition3, conditionData3 );
368 coral::ICursor& cursorIII = queryIII->execute();
370 while ( cursorIII.next()!=0 ) {
371 const coral::AttributeList& row = cursorIII.currentRow();
372 std::cout<<
" entering the queryIII " << std::endl;
373 int v = (int)row[
"VALUE"].data<long long>();
387 coral::IQuery* queryIII = schema.newQuery();
388 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
389 queryIII->addToTableList(
"RUNSESSION_FLOAT");
390 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
391 queryIII->setCondition( condition3, conditionData3 );
392 coral::ICursor& cursorIII = queryIII->execute();
394 while ( cursorIII.next()!=0 ) {
395 const coral::AttributeList& row = cursorIII.currentRow();
396 std::cout<<
" entering the queryIII " << std::endl;
397 float v = (float)row[
"VALUE"].data<double>();
412 coral::IQuery* queryIII = schema.newQuery();
413 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
414 queryIII->addToTableList(
"RUNSESSION_INTEGER");
415 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
416 queryIII->setCondition( condition3, conditionData3 );
417 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>();
436 coral::IQuery* queryIII = schema.newQuery();
437 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
438 queryIII->addToTableList(
"RUNSESSION_INTEGER");
439 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
440 queryIII->setCondition( condition3, conditionData3 );
441 coral::ICursor& cursorIII = queryIII->execute();
443 while ( cursorIII.next()!=0 ) {
444 const coral::AttributeList& row = cursorIII.currentRow();
445 std::cout<<
" entering the queryIII " << std::endl;
446 int v = (int)row[
"VALUE"].data<long long>();
460 coral::IQuery* queryIII = schema.newQuery();
461 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
462 queryIII->addToTableList(
"RUNSESSION_FLOAT");
463 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
464 queryIII->setCondition( condition3, conditionData3 );
465 coral::ICursor& cursorIII = queryIII->execute();
467 while ( cursorIII.next()!=0 ) {
468 const coral::AttributeList& row = cursorIII.currentRow();
469 std::cout<<
" entering the queryIII " << std::endl;
470 float v = (float)row[
"VALUE"].data<double>();
484 coral::IQuery* queryIII = schema.newQuery();
485 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
486 queryIII->addToTableList(
"RUNSESSION_INTEGER");
487 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
488 queryIII->setCondition( condition3, conditionData3 );
489 coral::ICursor& cursorIII = queryIII->execute();
491 while ( cursorIII.next()!=0 ) {
492 const coral::AttributeList& row = cursorIII.currentRow();
493 std::cout<<
" entering the queryIII " << std::endl;
494 int v = (int)row[
"VALUE"].data<long long>();
508 coral::IQuery* queryIII = schema.newQuery();
509 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
510 queryIII->addToTableList(
"RUNSESSION_INTEGER");
511 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
512 queryIII->setCondition( condition3, conditionData3 );
513 coral::ICursor& cursorIII = queryIII->execute();
515 while ( cursorIII.next()!=0 ) {
516 const coral::AttributeList& row = cursorIII.currentRow();
517 std::cout<<
" entering the queryIII " << std::endl;
518 int v = (int)row[
"VALUE"].data<long long>();
532 coral::IQuery* queryIII = schema.newQuery();
533 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
534 queryIII->addToTableList(
"RUNSESSION_FLOAT");
535 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
536 queryIII->setCondition( condition3, conditionData3 );
537 coral::ICursor& cursorIII = queryIII->execute();
539 while ( cursorIII.next()!=0 ) {
540 const coral::AttributeList& row = cursorIII.currentRow();
541 std::cout<<
" entering the queryIII " << std::endl;
542 float v = (float)row[
"VALUE"].data<double>();
556 coral::IQuery* queryIII = schema.newQuery();
557 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
558 queryIII->addToTableList(
"RUNSESSION_INTEGER");
559 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
560 queryIII->setCondition( condition3, conditionData3 );
561 coral::ICursor& cursorIII = queryIII->execute();
563 while ( cursorIII.next()!=0 ) {
564 const coral::AttributeList& row = cursorIII.currentRow();
565 std::cout<<
" entering the queryIII " << std::endl;
566 int v = (int)row[
"VALUE"].data<long long>();
580 coral::IQuery* queryIII = schema.newQuery();
581 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
582 queryIII->addToTableList(
"RUNSESSION_FLOAT");
583 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
584 queryIII->setCondition( condition3, conditionData3 );
585 coral::ICursor& cursorIII = queryIII->execute();
587 while ( cursorIII.next()!=0 ) {
588 const coral::AttributeList& row = cursorIII.currentRow();
589 std::cout<<
" entering the queryIII " << std::endl;
590 float v = (float)row[
"VALUE"].data<double>();
603 std::cout<<
"index out of range" << std::endl;
615 l1triggerscaler_array.push_back(Itemp);
622 session->transaction().commit();
628 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
std::string m_tableToDrop
std::vector< int > m_GTAlgoCounts
std::vector< int > m_GTTechPrescaling
virtual ~L1TriggerScalerRead()
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)