3 #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" 25 m_connectionString( connectionString ),
39 dqmSummary.
m_run = r_number;
40 std::cout<<
"Entering readData" << std::endl;
48 session->transaction().start();
50 coral::ISchema&
schema = session->nominalSchema();
55 query->addToOutputList(
"count(*)",
"count");
58 coral::AttributeList conditionData;
59 conditionData.extend<
long long>(
"n_run" );
61 conditionData[0].data<
long long>() = r_number;
62 query->setCondition(condition, conditionData);
64 coral::ICursor& cursor = query->execute();
65 DQMSummary::DQMSummary::RunItem runItem;
66 DQMSummary::DQMSummary::RunItem::LumiItem lumiItem;
70 const coral::AttributeList& row = cursor.currentRow();
71 nRows = row[
"count"].data<
double>();
77 std::cout <<
"Rows for count query " << nRows << std::endl;
79 std::cout <<
"Starting to build DQMSummary" << std::endl;
81 coral::IQuery* queryI = schema.tableHandle(
m_tableToRead).newQuery();
82 queryI->setDistinct();
83 queryI->addToOutputList(
"lumisec");
86 coral::AttributeList conditionDataI;
87 conditionDataI.extend<
long long>(
"n_run" );
89 conditionDataI[0].data<
long long>() = r_number;
90 queryI->setCondition(conditionI, conditionDataI);
92 coral::ICursor& cursorI = queryI->execute();
95 while( cursorI.next() ) {
98 const coral::AttributeList& rowI = cursorI.currentRow();
99 runItem.m_lumisec = rowI[
"lumisec"].data<
long long>();
101 coral::IQuery* queryII = schema.tableHandle(
m_tableToRead).newQuery();
102 queryII->addToOutputList(
"subsystem");
103 queryII->addToOutputList(
"reportcontent");
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" );
110 conditionDataII[0].data<
long long>() = r_number;
111 conditionDataII.extend<
long long>(
"n_lumisec" );
113 conditionDataII[1].data<
long long>() = rowI[
"lumisec"].data<long long>();
114 queryII->setCondition(conditionII, conditionDataII);
116 coral::ICursor& cursorII = queryII->execute();
119 while( cursorII.next() ) {
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>();
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;
131 std::cout <<
"Returned rows for lumisection query " << nRowsII << std::endl;
133 std::cout <<
"DQMSummary::DQMSummary::RunItem filled" << std::endl;
136 std::cout <<
"Returned rows for run number query " << nRowsI << std::endl;
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
151 runItem.m_lumisummary.push_back(lumiItem);
153 std::cout <<
"No information in DQMSummary for run " 154 << r_number <<std::endl;
158 throw cms::Exception(
"UnconsistentData") <<
"What is wrong with you?" << std::endl;
159 std::cout <<
"DQMSummary built" << std::endl;
161 session->transaction().commit();
164 std::cout <<
"Exception: "<<e.what()<<std::endl;
std::vector< RunItem > m_summary
DQMSummary readData(const std::string &table, const long long r_number)
def query(query_str, verbose=False)
std::string m_connectionString
~DQMSummaryReader() override
std::string m_tableToRead
DQMSummaryReader(const std::string &connectionString, const std::string &user, const std::string &pass)
coral::ISession * connect(const std::string &connectionString, const std::string &user, const std::string &password)