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;
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;
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);
362 coral::IQuery* queryIII = schema.newQuery();
363 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
364 queryIII->addToTableList(
"RUNSESSION_INTEGER");
365 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
366 queryIII->setCondition( condition3, conditionData3 );
367 coral::ICursor& cursorIII = queryIII->execute();
369 while ( cursorIII.next()!=0 ) {
370 const coral::AttributeList& row = cursorIII.currentRow();
371 std::cout<<
" entering the queryIII " << std::endl;
372 int v = (
int)row[
"VALUE"].data<long long>();
386 coral::IQuery* queryIII = schema.newQuery();
387 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
388 queryIII->addToTableList(
"RUNSESSION_FLOAT");
389 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
390 queryIII->setCondition( condition3, conditionData3 );
391 coral::ICursor& cursorIII = queryIII->execute();
393 while ( cursorIII.next()!=0 ) {
394 const coral::AttributeList& row = cursorIII.currentRow();
395 std::cout<<
" entering the queryIII " << std::endl;
396 float v = (
float)row[
"VALUE"].data<double>();
411 coral::IQuery* queryIII = schema.newQuery();
412 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
413 queryIII->addToTableList(
"RUNSESSION_INTEGER");
414 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
415 queryIII->setCondition( condition3, conditionData3 );
416 coral::ICursor& cursorIII = queryIII->execute();
418 while ( cursorIII.next()!=0 ) {
419 const coral::AttributeList& row = cursorIII.currentRow();
420 std::cout<<
" entering the queryIII " << std::endl;
421 int v = (
int)row[
"VALUE"].data<long long>();
435 coral::IQuery* queryIII = schema.newQuery();
436 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
437 queryIII->addToTableList(
"RUNSESSION_INTEGER");
438 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
439 queryIII->setCondition( condition3, conditionData3 );
440 coral::ICursor& cursorIII = queryIII->execute();
442 while ( cursorIII.next()!=0 ) {
443 const coral::AttributeList& row = cursorIII.currentRow();
444 std::cout<<
" entering the queryIII " << std::endl;
445 int v = (
int)row[
"VALUE"].data<long long>();
459 coral::IQuery* queryIII = schema.newQuery();
460 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
461 queryIII->addToTableList(
"RUNSESSION_FLOAT");
462 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
463 queryIII->setCondition( condition3, conditionData3 );
464 coral::ICursor& cursorIII = queryIII->execute();
466 while ( cursorIII.next()!=0 ) {
467 const coral::AttributeList& row = cursorIII.currentRow();
468 std::cout<<
" entering the queryIII " << std::endl;
469 float v = (
float)row[
"VALUE"].data<double>();
483 coral::IQuery* queryIII = schema.newQuery();
484 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
485 queryIII->addToTableList(
"RUNSESSION_INTEGER");
486 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
487 queryIII->setCondition( condition3, conditionData3 );
488 coral::ICursor& cursorIII = queryIII->execute();
490 while ( cursorIII.next()!=0 ) {
491 const coral::AttributeList& row = cursorIII.currentRow();
492 std::cout<<
" entering the queryIII " << std::endl;
493 int v = (
int)row[
"VALUE"].data<long long>();
507 coral::IQuery* queryIII = schema.newQuery();
508 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
509 queryIII->addToTableList(
"RUNSESSION_INTEGER");
510 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
511 queryIII->setCondition( condition3, conditionData3 );
512 coral::ICursor& cursorIII = queryIII->execute();
514 while ( cursorIII.next()!=0 ) {
515 const coral::AttributeList& row = cursorIII.currentRow();
516 std::cout<<
" entering the queryIII " << std::endl;
517 int v = (
int)row[
"VALUE"].data<long long>();
531 coral::IQuery* queryIII = schema.newQuery();
532 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
533 queryIII->addToTableList(
"RUNSESSION_FLOAT");
534 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
535 queryIII->setCondition( condition3, conditionData3 );
536 coral::ICursor& cursorIII = queryIII->execute();
538 while ( cursorIII.next()!=0 ) {
539 const coral::AttributeList& row = cursorIII.currentRow();
540 std::cout<<
" entering the queryIII " << std::endl;
541 float v = (
float)row[
"VALUE"].data<double>();
555 coral::IQuery* queryIII = schema.newQuery();
556 queryIII->addToOutputList(
"RUNSESSION_INTEGER.VALUE" ,
"VALUE");
557 queryIII->addToTableList(
"RUNSESSION_INTEGER");
558 std::string condition3 =
"RUNSESSION_INTEGER.PARENT_ID=:n_vid_val";
559 queryIII->setCondition( condition3, conditionData3 );
560 coral::ICursor& cursorIII = queryIII->execute();
562 while ( cursorIII.next()!=0 ) {
563 const coral::AttributeList& row = cursorIII.currentRow();
564 std::cout<<
" entering the queryIII " << std::endl;
565 int v = (
int)row[
"VALUE"].data<long long>();
579 coral::IQuery* queryIII = schema.newQuery();
580 queryIII->addToOutputList(
"RUNSESSION_FLOAT.VALUE" ,
"VALUE");
581 queryIII->addToTableList(
"RUNSESSION_FLOAT");
582 std::string condition3 =
"RUNSESSION_FLOAT.PARENT_ID=:n_vid_val";
583 queryIII->setCondition( condition3, conditionData3 );
584 coral::ICursor& cursorIII = queryIII->execute();
586 while ( cursorIII.next()!=0 ) {
587 const coral::AttributeList& row = cursorIII.currentRow();
588 std::cout<<
" entering the queryIII " << std::endl;
589 float v = (
float)row[
"VALUE"].data<double>();
602 std::cout<<
"index out of range" << std::endl;
614 l1triggerscaler_array.push_back(Itemp);
621 session->transaction().commit();
627 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)