244{
245 MsgStream log(
msgSvc(), name());
246 log << MSG::INFO <<
"begin read database MeasuredEcmsSvc from " <<
m_runFrom <<
" to " <<
m_runTo << endreq;
247 m_dbRecordVector.
clear();
248
249 m_rowNo1 = 0;
250 m_rowNo2 = 0;
251 m_isRunNoValid = false;
252 char stmt[400];
253
254 if ((runFrom >= 23463 && runFrom <= 38140) || (runFrom >= 47543 && runFrom <= 51498)) {
255 if ((runTo >= 23463 && runTo <= 38140) || (runTo >= 47543 && runTo <= 51498)) {
256 log << MSG::INFO << "read table MeasuredEcms2 for " << runFrom <<":" << runTo << endreq;
257 snprintf(stmt, 1024, "select sample, RunFrom, RunTo, Ecms, Ecms_err, Ave_Ecms, Ave_Ecms_err from MeasuredEcms2 where RunFrom >= %d and RunTo <= %d", runFrom, runTo);
258 m_tableOption = 1;
259 }
260 }
261 else if ((runFrom >= 11414 && runFrom <= 23454) || (runFrom >= 43716 && runFrom <= 47066) || (runFrom >= 70522 && runFrom <= 73929) || (runFrom >= 74031 && runFrom <= 78536) || (runFrom >= 78615 && runFrom <= 81094) ) {
262 if ((runTo >= 11414 && runTo <= 23454) || (runTo >= 43716 && runTo <= 47066) || (runFrom >= 70522 && runFrom <= 73929) || (runFrom >= 74031 && runFrom <= 78536) || (runFrom >= 78615 && runFrom <= 81094) ) {
263 log << MSG::INFO << "read table RunParams for " << runFrom <<":" << runTo << endreq;
264 snprintf(stmt, 1024, "select run_number, beam_energy, px, py, pz, beam_energy_err from RunParams where run_number >= %d and run_number <= %d", runFrom, runTo);
265 m_tableOption = 2;
266 }
267 }
268 else {
269 m_tableOption = -1;
270 }
271
272 if (m_tableOption == 1 || m_tableOption == 2) {
273 int rowNo = m_dbSvc->
query(
"offlinedb", stmt, m_dbRecordVector);
274 if (rowNo == 0) {
275 log << MSG::ERROR << "RowNo can not be 0, failed to read DB for " << runFrom <<":" << runTo << endreq;
276 cout << "RowNo can not be 0, failed to read DB for " << runFrom <<":" << runTo << endl;
277 } else {
278 if (m_tableOption == 1) m_rowNo1 = 1;
279 if (m_tableOption == 2) m_rowNo2 = 1;
280 log << MSG::INFO << "initialize the DatabaseRecordVector OK for " << runFrom <<":" << runTo << endreq;
281 cout << "MeasuredEcmsSvc: initialize the DatabaseRecordVector OK for " << runFrom <<":" << runTo << ", Nrecord = " << rowNo << "." << endl;
282 m_isRunNoValid = true;
283 }
284 if (m_rowNo2==1) {
285 for ( int i=0; i<rowNo; i++ ) {
286 int runnumber = m_dbRecordVector[i]->GetInt("run_number");
288 }
289 }
290 if (m_rowNo1==1) {
291 for ( int i=0; i<rowNo; i++ ) {
292 int run0 = m_dbRecordVector[i]->GetInt("RunFrom");
293 int run1 = m_dbRecordVector[i]->GetInt("RunTo");
294 for ( int j = run0; j<=run1; j++) {
296 }
297 }
298 }
299 }
300}