53 const boost::posix_time::ptime
time0 =
54 boost::posix_time::from_time_t(0);
56 temp_sum.
m_run = r_number;
57 std::cout <<
"entering readData" << std::endl;
61 session->transaction().start();
62 std::cout <<
"starting session " << std::endl;
63 coral::ISchema&
schema = session->schema(
"CMS_RUNINFO");
64 std::cout <<
" accessing schema " << std::endl;
67 long long id_start = 0;
69 coral::IQuery* queryI = schema.tableHandle(
m_tableToRead).newQuery();
71 queryI->addToOutputList(
m_tableToRead +
"." + m_columnToRead_id, m_columnToRead_id);
73 coral::AttributeList conditionData;
74 conditionData.extend<
int>(
"n_run" );
75 conditionData[0].data<
int>() = r_number;
77 queryI->setCondition(condition1, conditionData);
78 coral::ICursor& cursorI = queryI->execute();
79 if( cursorI.next() ) {
81 const coral::AttributeList& row = cursorI.currentRow();
82 id_start = row[m_columnToRead_id].data<
long long>();
94 coral::IQuery* queryII = schema.tableHandle(m_tableToRead_date).newQuery();
96 queryII->addToOutputList(m_tableToRead_date +
"." + m_columnToRead_val, m_columnToRead_val);
98 coral::AttributeList conditionData2;
99 conditionData2.extend<
long long>(
"n_id" );
100 conditionData2[0].data<
long long>() = id_start;
101 std::string condition2 = m_tableToRead_date +
".RUNSESSION_PARAMETER_ID=:n_id";
102 queryII->setCondition(condition2, conditionData2);
103 coral::ICursor& cursorII = queryII->execute();
104 coral::TimeStamp
start;
105 if( cursorII.next() ) {
107 const coral::AttributeList& row = cursorII.currentRow();
108 start = row[m_columnToRead_val].data<coral::TimeStamp>();
120 boost::posix_time::ptime start_ptime = start.time();
121 std::cout <<
"Posix time for run start: "<< start_ptime << std::endl;
122 boost::posix_time::time_duration startTimeFromEpoch = start_ptime -
time0;
123 temp_sum.
m_start_time_str = boost::posix_time::to_iso_extended_string(start_ptime);
135 coral::IQuery* queryIII = schema.tableHandle(m_tableToRead).newQuery();
137 queryIII->addToOutputList(m_tableToRead +
"." + m_columnToRead_id, m_columnToRead_id);
139 std::string condition3 = m_tableToRead +
".RUNNUMBER=:n_run AND " + m_tableToRead +
".NAME='CMS.LVL0:STOP_TIME_T'";
140 queryIII->setCondition(condition3, conditionData);
141 coral::ICursor& cursorIII = queryIII->execute();
142 long long id_stop = 0;
143 if( cursorIII.next() ) {
145 const coral::AttributeList& row = cursorIII.currentRow();
146 id_stop = row[m_columnToRead_id].data<
long long>();
155 coral::IQuery* queryIV = schema.tableHandle(m_tableToRead_date).newQuery();
157 queryIV->addToOutputList(m_tableToRead_date +
"." + m_columnToRead_val, m_columnToRead_val);
159 coral::AttributeList conditionData4;
160 conditionData4.extend<
long long>(
"n_id" );
161 conditionData4[0].data<
long long>() = id_stop;
162 std::string condition4 = m_tableToRead_date +
".RUNSESSION_PARAMETER_ID=:n_id";
163 queryIV->setCondition(condition4, conditionData4);
164 coral::ICursor& cursorIV = queryIV->execute();
165 coral::TimeStamp stop;
166 if( cursorIV.next() ) {
168 const coral::AttributeList& row = cursorIV.currentRow();
169 stop = row[m_columnToRead_val].data<coral::TimeStamp>();
181 boost::posix_time::ptime stop_ptime = stop.time();
182 std::cout <<
"Posix time for run stop: "<< stop_ptime << std::endl;
183 boost::posix_time::time_duration stopTimeFromEpoch = stop_ptime -
time0;
184 temp_sum.
m_stop_time_str = boost::posix_time::to_iso_extended_string(stop_ptime);
195 std::string m_tableToRead_fed =
"RUNSESSION_STRING";
196 coral::IQuery* queryV = schema.newQuery();
197 queryV->addToTableList(m_tableToRead);
198 queryV->addToTableList(m_tableToRead_fed);
199 queryV->addToOutputList(m_tableToRead_fed +
"." + m_columnToRead_val, m_columnToRead_val);
202 std::string condition5 = m_tableToRead +
".RUNNUMBER=:n_run AND " + m_tableToRead +
".NAME='CMS.LVL0:FED_ENABLE_MASK' AND RUNSESSION_PARAMETER.ID = RUNSESSION_STRING.RUNSESSION_PARAMETER_ID";
204 queryV->setCondition(condition5, conditionData);
205 coral::ICursor& cursorV = queryV->execute();
207 if ( cursorV.next() ) {
209 const coral::AttributeList& row = cursorV.currentRow();
219 std::stringstream
stream(fed);
222 if ( !(
stream >> word) ){
break;}
224 std::stringstream
ss(word);
227 ss >> fedNumber >> val;
230 if( (val & 0001) == 1 && (val != 5) && (val != 7) )
231 temp_sum.
m_fed_in.push_back(fedNumber);
242 coral::ISchema& schema2 = session->schema(
"CMS_DCS_ENV_PVSS_COND");
246 coral::IQuery* queryVI = schema2.tableHandle(m_tableToRead_cur).newQuery();
247 queryVI->addToOutputList(m_tableToRead_cur +
"." +
quoted(m_columnToRead_cur), m_columnToRead_cur);
248 queryVI->addToOutputList(m_tableToRead_cur +
"." + m_columnToRead_date, m_columnToRead_date);
250 coral::AttributeList conditionData6;
251 float last_current = -1;
253 conditionData6.extend<coral::TimeStamp>(
"runstart_time" );
254 conditionData6.extend<coral::TimeStamp>(
"runstop_time" );
255 conditionData6[
"runstart_time"].data<coral::TimeStamp>() = start;
256 conditionData6[
"runstop_time"].data<coral::TimeStamp>() = stop;
257 std::string conditionVI =
" NOT " + m_tableToRead_cur +
"." +
quoted(m_columnToRead_cur) +
" IS NULL AND "
258 + m_tableToRead_cur +
"." + m_columnToRead_date +
">:runstart_time AND "
259 + m_tableToRead_cur +
"." + m_columnToRead_date +
"<:runstop_time" ;
260 queryVI->setCondition(conditionVI, conditionData6);
261 queryVI->addToOrderList(m_tableToRead_cur +
"." + m_columnToRead_date +
" DESC");
263 std::cout <<
"run stop null" << std::endl;
264 conditionData6.extend<coral::TimeStamp>(
"runstart_time" );
265 conditionData6[
"runstart_time"].data<coral::TimeStamp>() = start;
266 std::string conditionVI =
" NOT " + m_tableToRead_cur +
"." +
quoted(m_columnToRead_cur) +
" IS NULL AND "
267 + m_tableToRead_cur +
"." + m_columnToRead_date +
"<:runstart_time" ;
268 queryVI->setCondition(conditionVI, conditionData6);
269 queryVI->addToOrderList(m_tableToRead_cur +
"." + m_columnToRead_date +
" DESC");
271 queryVI->limitReturnedRows(10000);
272 coral::ICursor& cursorVI = queryVI->execute();
273 coral::TimeStamp lastCurrentDate;
275 std::vector<double> time_curr;
276 if ( !cursorVI.next() ) {
279 coral::AttributeList conditionData6bis;
280 conditionData6bis.extend<coral::TimeStamp>(
"runstop_time" );
281 conditionData6bis[
"runstop_time"].data<coral::TimeStamp>() = stop;
282 std::string conditionVIbis =
" NOT " + m_tableToRead_cur +
"." +
quoted(m_columnToRead_cur) +
" IS NULL AND "
283 + m_tableToRead_cur +
"." + m_columnToRead_date +
" <:runstop_time" ;
284 coral::IQuery* queryVIbis = schema2.tableHandle(m_tableToRead_cur).newQuery();
285 queryVIbis->addToOutputList(m_tableToRead_cur +
"." +
quoted(m_columnToRead_cur), m_columnToRead_cur);
286 queryVIbis->setCondition(conditionVIbis, conditionData6bis);
287 queryVIbis->addToOrderList(m_tableToRead_cur +
"." + m_columnToRead_date +
" DESC");
288 coral::ICursor& cursorVIbis= queryVIbis->execute();
289 if( cursorVIbis.next() ) {
291 const coral::AttributeList& row = cursorVIbis.currentRow();
292 last_current = row[m_columnToRead_cur].data<
float>();
293 std::cout <<
"previos run(s) current, not changed in this run... " << last_current << std::endl;
301 while( cursorVI.next() ) {
303 const coral::AttributeList& row = cursorVI.currentRow();
304 lastCurrentDate = row[m_columnToRead_date].data<coral::TimeStamp>();
305 temp_sum.
m_current.push_back( row[m_columnToRead_cur].data<float>() );
318 boost::posix_time::ptime lastCurrentDate_ptime = lastCurrentDate.time();
319 std::cout <<
"Posix time for last current time: " << lastCurrentDate_ptime << std::endl;
320 boost::posix_time::time_duration lastCurrentDateTimeFromEpoch = lastCurrentDate_ptime -
time0;
321 last_date = boost::posix_time::to_iso_extended_string(lastCurrentDate_ptime);
322 std::cout <<
"last current time extracted == " << last_date << std::endl;
323 long long last_date_ll = lastCurrentDateTimeFromEpoch.total_microseconds();
324 time_curr.push_back(last_date_ll);
328 size_t csize = temp_sum.
m_current.size();
329 std::cout <<
"size of currents " << csize << std::endl;
330 size_t tsize = time_curr.size();
331 std::cout <<
"size of time " << tsize << std::endl;
333 std::cout<<
"current and time not filled correctly" << std::endl;
352 for(
size_t i = 0;
i < csize; ++
i) {
354 if( (tsize > 1) && (
i < csize - 1 ) ) {
355 wi = (time_curr[
i] - time_curr[
i+1]) ;
398 session->transaction().commit();
401 std::cout <<
"Exception: " << e.what() << std::endl;
tuple start
Check for commandline option errors.
const boost::posix_time::ptime time0
std::string m_tableToRead
std::vector< int > m_fed_in
std::string m_start_time_str
std::vector< float > m_current
std::string quoted(const std::string &s)
float m_run_intervall_micros
std::string m_columnToRead
std::string m_stop_time_str
std::string m_connectionString
std::vector< float > m_times_of_currents
long long m_start_time_ll
coral::ISession * connect(const std::string &connectionString, const std::string &user, const std::string &password)