CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
DQMSummaryReader Class Reference

#include <DQMSummaryReader.h>

Inheritance diagram for DQMSummaryReader:
TestBase

Public Member Functions

 DQMSummaryReader (const std::string &connectionString, const std::string &user, const std::string &pass)
 
DQMSummary readData (const std::string &table, const long long r_number)
 
void run ()
 
virtual ~DQMSummaryReader ()
 
- Public Member Functions inherited from TestBase
void setVerbosityLevel (coral::MsgLevel level)
 
void setVerbosityLevel (coral::MsgLevel level)
 
void setVerbosityLevel (coral::MsgLevel level)
 
 TestBase ()
 
 TestBase ()
 
 TestBase ()
 
virtual ~TestBase ()
 
virtual ~TestBase ()
 
virtual ~TestBase ()
 

Private Attributes

std::string m_connectionString
 
std::string m_pass
 
std::string m_tableToRead
 
std::string m_user
 

Additional Inherited Members

- Protected Member Functions inherited from TestBase
coral::ISession * connect (const std::string &connectionString, const std::string &user, const std::string &password)
 
coral::ISession * connect (const std::string &connectionString, const std::string &user, const std::string &password)
 
coral::ISession * connect (const std::string &connectionString, const std::string &user, const std::string &password)
 

Detailed Description

Definition at line 8 of file DQMSummaryReader.h.

Constructor & Destructor Documentation

DQMSummaryReader::DQMSummaryReader ( const std::string &  connectionString,
const std::string &  user,
const std::string &  pass 
)

Definition at line 21 of file DQMSummaryReader.cc.

References m_tableToRead.

23  :
24  TestBase(), /*ReadBase(),*/
25  m_connectionString( connectionString ),
26  m_user( user ),
27  m_pass( pass ) {
28  m_tableToRead="";
29 }
std::string m_pass
std::string m_user
std::string m_connectionString
TestBase()
Definition: TestBase.cc:10
std::string m_tableToRead
DQMSummaryReader::~DQMSummaryReader ( )
virtual

Definition at line 31 of file DQMSummaryReader.cc.

31 {}

Member Function Documentation

DQMSummary DQMSummaryReader::readData ( const std::string &  table,
const long long  r_number 
)

Definition at line 35 of file DQMSummaryReader.cc.

References TestBase::connect(), gather_cfg::cout, alignCSCRings::e, cppFunctionSkipper::exception, edm::hlt::Exception, m_connectionString, m_pass, DQMSummary::m_run, DQMSummary::m_summary, m_tableToRead, m_user, o2o::query, python.IdGenerator::schema, python.CommonUtils::session, AlCaHLTBitMon_QueryRunRegistry::string, and table.

Referenced by popcon::DQMSummarySourceHandler::getNewObjects().

35  {
36  m_tableToRead = table; // to be CMS_DQM_SUMMARY.summarycontent
37  //m_columnToRead = column; // to be run, lumisec
38  DQMSummary dqmSummary;
39  dqmSummary.m_run = r_number;
40  std::cout<< "Entering readData" << std::endl;
41  coral::ISession* session = this->connect(m_connectionString,
42  m_user, m_pass);
43  //coral::ISessionProxy* session = this->connect(m_connectionString,
44  // m_user, m_pass);
45  try{
46  //session->typeConverter().setCppTypeForSqlType(coral::AttributeSpecification::typeNameForId(typeid(std::string)), "VARCHAR2(20)");
47  //session->typeConverter().setCppTypeForSqlType(coral::AttributeSpecification::typeNameForId(typeid(std::string)), "VARCHAR2(40)");
48  session->transaction().start();
49  std::cout<< "Starting session on the connection " << m_connectionString << std::endl;
50  coral::ISchema& schema = session->nominalSchema();
51  std::cout<< "--- accessing schema for user " << m_user << std::endl;
52  std::cout<< "------ trying to handle table " << m_tableToRead << std::endl;
53  //defining count query
54  coral::IQuery* query = schema.tableHandle(m_tableToRead).newQuery();
55  query->addToOutputList("count(*)", "count");
56  //condition for the WHERE clause in the count query
57  std::string condition = "run=:n_run";
58  coral::AttributeList conditionData;
59  conditionData.extend<long long>( "n_run" );
60  //conditionData[0].setValue<long long>(r_number);
61  conditionData[0].data<long long>() = r_number;
62  query->setCondition(condition, conditionData);
63  //performing count query
64  coral::ICursor& cursor = query->execute();
65  DQMSummary::DQMSummary::RunItem runItem;
66  DQMSummary::DQMSummary::RunItem::LumiItem lumiItem;
67  double nRows = 0;
68  if( cursor.next() ) {
69  //cursor.currentRow().toOutputStream(std::cout) << std::endl;
70  const coral::AttributeList& row = cursor.currentRow();
71  nRows = row["count"].data<double>();
72  /*const coral::Attribute& count = cursor.currentRow()["count"];
73  if(count.specification().type() == typeid(double))
74  nRows = count.data<double>();
75  else
76  nRows = count.data<float>();*/
77  std::cout << "Rows for count query " << nRows << std::endl;
78  if( nRows != 0 ) {
79  std::cout << "Starting to build DQMSummary" << std::endl;
80  //defining first query
81  coral::IQuery* queryI = schema.tableHandle(m_tableToRead).newQuery();
82  queryI->setDistinct();
83  queryI->addToOutputList("lumisec");
84  //condition for the WHERE clause in the first query
85  std::string conditionI = "run=:n_run";
86  coral::AttributeList conditionDataI;
87  conditionDataI.extend<long long>( "n_run" );
88  //conditionDataI[0].setValue<long long>(r_number);
89  conditionDataI[0].data<long long>() = r_number;
90  queryI->setCondition(conditionI, conditionDataI);
91  //performing query
92  coral::ICursor& cursorI = queryI->execute();
93  //a little printout, then filling DQMSummary
94  int nRowsI = 0;
95  while( cursorI.next() ) {
96  //cursorI.currentRow().toOutputStream(std::cout) << std::endl;
97  ++nRowsI;
98  const coral::AttributeList& rowI = cursorI.currentRow();
99  runItem.m_lumisec = rowI["lumisec"].data<long long>();
100  //defining second query
101  coral::IQuery* queryII = schema.tableHandle(m_tableToRead).newQuery();
102  queryII->addToOutputList("subsystem");
103  queryII->addToOutputList("reportcontent");
104  //queryII->addToOutputList("type"); // when implemented in OMDS
105  queryII->addToOutputList("status");
106  std::string conditionII = "run= :n_run AND lumisec= :n_lumisec";
107  coral::AttributeList conditionDataII;
108  conditionDataII.extend<long long>( "n_run" );
109  //conditionDataII[0].setValue<long long>(r_number);
110  conditionDataII[0].data<long long>() = r_number;
111  conditionDataII.extend<long long>( "n_lumisec" );
112  //conditionDataII[1].setValue<long long>(rowI["lumisec"].data<long long>());
113  conditionDataII[1].data<long long>() = rowI["lumisec"].data<long long>();
114  queryII->setCondition(conditionII, conditionDataII);
115  //performing query
116  coral::ICursor& cursorII = queryII->execute();
117  //a little printout, then filling DQMSummary
118  int nRowsII = 0;
119  while( cursorII.next() ) {
120  //cursorII.currentRow().toOutputStream(std::cout) << std::endl;
121  ++nRowsII;
122  const coral::AttributeList& rowII = cursorII.currentRow();
123  lumiItem.m_subsystem = rowII["subsystem"].data<std::string>();
124  lumiItem.m_reportcontent = rowII["reportcontent"].data<std::string>();
125  //lumiItem.m_type = rowII["type"].data<std::string>(); // when implemented in OMDS
126  lumiItem.m_type = "reportSummary";
127  lumiItem.m_status = rowII["status"].data<double>();
128  runItem.m_lumisummary.push_back(lumiItem);
129  std::cout << "DQMSummary::DQMSummary::RunItem::LumiItem filled" << std::endl;
130  }
131  std::cout << "Returned rows for lumisection query " << nRowsII << std::endl;
132  dqmSummary.m_summary.push_back(runItem);
133  std::cout << "DQMSummary::DQMSummary::RunItem filled" << std::endl;
134  delete queryII;
135  }
136  std::cout << "Returned rows for run number query " << nRowsI << std::endl;
137  delete queryI;
138  }
139  else {
140  runItem.m_lumisec = 0;
141  lumiItem.m_subsystem = " ";
142  lumiItem.m_reportcontent = " ";
143  lumiItem.m_type = " ";
144  lumiItem.m_status = -2;
145  std::cout << "[lumisec (long long) : " << runItem.m_lumisec
146  << "], [subsystem (string) : " << lumiItem.m_subsystem
147  << "], [reportcontent (string) : " << lumiItem.m_reportcontent
148  << "], [type (string) : " << lumiItem.m_type
149  << "], [status (double) : " << lumiItem.m_status
150  << "]" << std::endl;
151  runItem.m_lumisummary.push_back(lumiItem);
152  dqmSummary.m_summary.push_back(runItem);
153  std::cout << "No information in DQMSummary for run "
154  << r_number <<std::endl;
155  }
156  }
157  else
158  throw cms::Exception("UnconsistentData") << "What is wrong with you?" << std::endl;
159  std::cout << "DQMSummary built" << std::endl;
160  delete query;
161  session->transaction().commit();
162  }
163  catch (const std::exception& e) {
164  std::cout << "Exception: "<<e.what()<<std::endl;
165  }
166  delete session;
167  return dqmSummary;
168 }
std::vector< RunItem > m_summary
Definition: DQMSummary.h:38
std::string m_pass
std::string m_user
std::string m_connectionString
long long m_run
Definition: DQMSummary.h:21
#define table(NAME)
Definition: DbCore.h:49
std::string m_tableToRead
tuple query
Definition: o2o.py:269
tuple cout
Definition: gather_cfg.py:121
coral::ISession * connect(const std::string &connectionString, const std::string &user, const std::string &password)
Definition: TestBase.cc:24
void DQMSummaryReader::run ( )
virtual

Implements TestBase.

Definition at line 33 of file DQMSummaryReader.cc.

Referenced by Types.EventID::cppID(), and Types.LuminosityBlockID::cppID().

33 {}

Member Data Documentation

std::string DQMSummaryReader::m_connectionString
private

Definition at line 19 of file DQMSummaryReader.h.

Referenced by readData().

std::string DQMSummaryReader::m_pass
private

Definition at line 21 of file DQMSummaryReader.h.

Referenced by readData().

std::string DQMSummaryReader::m_tableToRead
private

Definition at line 17 of file DQMSummaryReader.h.

Referenced by DQMSummaryReader(), and readData().

std::string DQMSummaryReader::m_user
private

Definition at line 20 of file DQMSummaryReader.h.

Referenced by readData().