#include <ConnectionProvider.h>
Definition at line 20 of file ConnectionProvider.h.
Used to form bit masks for dbs queries.
Definition at line 42 of file ConnectionProvider.h.
00042 { 00043 LEVELProd = 1, 00044 LEVELDev = 2, 00045 LEVELTest = 4, 00046 LEVELSuperseded = 8 00047 };
RETOk | |
RETBadCnfFile | |
RETBadHost | |
RETNoConnect | |
RETWrongState | |
RETBadValue | |
RETMySQLError | |
RETNoSchemaMatch |
Definition at line 31 of file ConnectionProvider.h.
00031 { 00032 RETOk = 0, 00033 RETBadCnfFile = 1, 00034 RETBadHost = 2, 00035 RETNoConnect = 3, 00036 RETWrongState = 4, 00037 RETBadValue = 5, 00038 RETMySQLError = 6, 00039 RETNoSchemaMatch = 7 00040 };
RealDBUtil::ConnectionProvider::ConnectionProvider | ( | ) |
Constructor keeps track of table of interest.
Definition at line 144 of file ConnectionProvider.cxx.
References m_dbsvc, m_tfee_fileid, and m_trgTpye.
00144 { 00145 StatusCode sc = Gaudi::svcLocator()->service("DatabaseSvc", m_dbsvc, true); 00146 if (sc .isFailure() ) { 00147 std::cout << "ERROR: In ConnectionProvider()--> Unable to find DatabaseSvc " << std::endl; 00148 } 00149 m_trgTpye = -1; 00150 m_tfee_fileid = -1; 00151 }
RealDBUtil::ConnectionProvider::~ConnectionProvider | ( | ) |
bool RealDBUtil::ConnectionProvider::getcal | ( | int | runNo, | |
std::string | ids | |||
) |
Definition at line 47 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), genRecEmupikp::i, id_num, iter(), ganga-rec::j, m_dbsvc, IDatabaseSvc::query(), split(), deljobs::string, and trgGain.
Referenced by getEmcGain().
00047 { 00048 00049 //Read Luminosity information 00050 char stmt1[1024]; 00051 int run_No =std::abs(runNo); 00052 sprintf(stmt1,"select EQM_fileid,EMCGain from RunParams where run_number = %d",run_No); 00053 00054 DatabaseRecordVector results; 00055 results.clear(); 00056 int rowNumber = m_dbsvc->query("run",stmt1,results); 00057 if(rowNumber <= 0){ 00058 std::cout << "ERROR Read EQM_fileid from the Database, exit." << endreq; 00059 exit(1); 00060 } 00061 00062 int fileid = std::atoi((*results[0])["EQM_fileid"]); 00063 00064 string gainnum((*results[0])["EMCGain"]); 00065 00066 sprintf(stmt1, "select OID,Position,Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,Channel11,Channel12,Channel13,Channel14,Channel15,Channel16,Channel17,Channel18,Channel19,Channel20,Channel21,Channel22,Channel23,Channel24,Channel25,Channel26,Channel27,Channel28,Channel29,Channel30,Channel31,Channel32 from EQM where FileId=%d", fileid); 00067 00068 results.clear(); 00069 rowNumber = m_dbsvc->query("run",stmt1,results); 00070 if(rowNumber <= 0){ 00071 std::cout << "ERROR Read EQM from the Database, exit." << endreq; 00072 exit(1); 00073 } 00074 00075 std::map<std::string, std::vector<std::string> > map_EQM; 00076 map_EQM.clear(); 00077 for(int i=0;i<rowNumber;i++) 00078 { for(int j=2;j<34;j++) 00079 { 00080 std::vector<std::string> vec_tmp; 00081 vec_tmp.clear(); 00082 vec_tmp.push_back(toString<int>(j-1)); 00083 vec_tmp.push_back((*results[i])["OID"]); 00084 vec_tmp.push_back((*results[i])["Position"]); 00085 typedef pair<std::string, std::vector<std::string> > vpair; 00086 map_EQM.insert(vpair((*results[i])["Channel"+toString<int>(j-1)], vec_tmp)); 00087 00088 } 00089 } 00090 00091 vector<string> id = split(ids, ",", "<null>"); 00092 id_num=id.size(); 00093 00094 for(unsigned int m=0;m<id.size();m++){ 00095 if(id[m] == "0") { std::cout << " error: No." << m+1 << " id=0,please delete it! " << std::endl; break; } 00096 if(id[m] == "NULL") { std::cout << " end of loop! " << std::endl; break; } 00097 string channelnum,oid,modu; 00098 bool if_found = false; 00099 for(std::map<std::string,std::vector<std::string> >::iterator iter = map_EQM.begin(); iter != map_EQM.end(); iter++) 00100 { 00101 if(iter->first == id[m]) { 00102 if_found = true; 00103 channelnum = iter->second[0]; 00104 oid = iter->second[1]; 00105 modu = iter->second[2]; 00106 } 00107 } 00108 00109 if(!if_found) { std::cout << "can not find id " << id[m] << " in EQM, exit." << std::endl; exit(1); } 00110 00111 string b="AAAA"; 00112 string trgcratenum; 00113 for(int i=0;i<4;i++){ 00114 b[i] =oid[i+4]; 00115 } 00116 00117 //change oid to cratenum 00118 string a[16][2]={{"E3_1","96"},{"E2_0","97"},{"E2_1","98"},{"E1_0","99"},{"E1_1","100"},{"E3_0","101"},{"E2_2","102"},{"E3_2","103"},{"W3_1","112"},{"W2_0","113"},{"W2_1","114"},{"W1_0","115"},{"W1_1","116"},{"W3_0","117"},{"W2_2","118"},{"W3_2","119"}}; 00119 string trgCrate[16]={"0x60","0x61","0x62","0x63","0x64","0x65","0x66","0x67","0x70","0x71","0x72","0x73","0x74","0x75","0x76","0x77"}; 00120 00121 for(int i=0;i<16;i++){ 00122 if(b.compare(a[i][0])) continue; 00123 else { 00124 trgcratenum = trgCrate[i]; 00125 } 00126 } 00127 00128 std::string query_name = "select gain from EMC_Gain where run_id="+gainnum+" and ppc_id=\""+trgcratenum+"\" and Qmodule_no="+modu+" and Qchannel_no="+channelnum; 00129 results.clear(); 00130 rowNumber = m_dbsvc->query("run",query_name.c_str(),results); 00131 if(rowNumber <= 0){ 00132 std::cout << "ERROR Read gain from EMC_Gain Database, exit." << endreq; 00133 exit(1); 00134 } 00135 00136 //std::cout << "run_id: " << gainnum << " ppc_id: " << trgcratenum << " Qmodule_no: " << modu << " Qchannel_no: " << channelnum << " m: " << m << std::endl; 00137 00138 trgGain[m] = new std::string((*results[0])["gain"]); 00139 //std::cout << "gain: " << *trgGain[m] << std::endl; 00140 } 00141 return true; 00142 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getEmcGain | ( | std::vector< double > & | emcGain, | |
int | runNo | |||
) |
Definition at line 484 of file ConnectionProvider.cxx.
References getcal(), IEmcCalibConstSvc::getPartID(), IEmcCalibConstSvc::getPhiIndex(), IEmcCalibConstSvc::getThetaIndex(), genRecEmupikp::i, id_num, RETOk, deljobs::string, and trgGain.
Referenced by RealizationSvc::readDB().
00484 { 00485 // Get EmcCalibConstSvc. 00486 IEmcCalibConstSvc *emcCalibConstSvc; 00487 ISvcLocator* svcLocator = Gaudi::svcLocator(); 00488 StatusCode sc = svcLocator->service("EmcCalibConstSvc",emcCalibConstSvc); 00489 if(sc!=StatusCode::SUCCESS) { 00490 cout << "ConnectionProvider Error: Can't get EmcCalibConstSvc." << endl; 00491 } 00492 00493 string ids="128005"; 00494 00495 ostringstream str; 00496 int idBegin=0; 00497 int idEnd=6240; 00498 00499 for(int i=idBegin;i<idEnd;i++) { 00500 unsigned int npart = emcCalibConstSvc->getPartID(i); 00501 unsigned int ntheta = emcCalibConstSvc->getThetaIndex(i); 00502 unsigned int nphi = emcCalibConstSvc->getPhiIndex(i); 00503 00504 int triPart,triTheta,triPhi; 00505 if(npart==0) { 00506 triPart=0; 00507 triTheta=23+ntheta; 00508 } else if(npart==1&&ntheta<22) { 00509 triPart=0; 00510 triTheta=22-ntheta; 00511 } else if(npart==1&&ntheta>=22) { 00512 triPart=1; 00513 triTheta=ntheta-21; 00514 } else { //npart==2 00515 triPart=1; 00516 triTheta=23+ntheta; 00517 } 00518 triPhi=nphi+1; 00519 00520 ostringstream ssTheta; 00521 if(triPart==1&&triTheta<10) { 00522 ssTheta<<"0"<<triTheta; 00523 } else { 00524 ssTheta<<triTheta; 00525 } 00526 00527 ostringstream ssPhi; 00528 if(triPhi<10) { 00529 ssPhi<<"00"<<triPhi; 00530 } else if(triPhi<100) { 00531 ssPhi<<"0"<<triPhi; 00532 } else { 00533 ssPhi<<triPhi; 00534 } 00535 00536 if(triPart==0) { 00537 str<<ssTheta.str()<<ssPhi.str(); 00538 } else { 00539 str<<triPart<<ssTheta.str()<<ssPhi.str(); 00540 } 00541 if(i!=idEnd-1) { 00542 str<<","; 00543 } 00544 00545 //cout<<npart<<"\t"<<ntheta<<"\t"<<nphi<<endl; 00546 00547 } 00548 00549 ids=str.str(); 00550 //cout<<ids<<endl; 00551 00552 getcal( runNo, ids); 00553 00554 emcGain.clear(); 00555 for(int i=0;i<id_num;i++) { 00556 istringstream isin(*trgGain[i]); 00557 double value; 00558 isin>>value; 00559 value = ((50./255.)*(value)/60.)*5*0.5; 00560 emcGain.push_back(value); 00561 delete trgGain[i]; 00562 } 00563 00564 return RETOk; 00565 }
int RealDBUtil::ConnectionProvider::getEtotDataSteps | ( | ) | [inline] |
Definition at line 67 of file ConnectionProvider.h.
References m_EtotDataSteps.
Referenced by RealizationSvc::readDB().
00067 { return m_EtotDataSteps; }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getLumCurvePar | ( | std::string & | runTotalTime, | |
std::string & | tau_value, | |||
int | runNo, | |||
std::string | SftVer, | |||
std::string | ParVer, | |||
std::string | BossRelease | |||
) |
Definition at line 239 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), DatabaseRecord::GetString(), genRecEmupikp::i, m_dbsvc, IDatabaseSvc::query(), and RETOk.
Referenced by RealizationSvc::readDB().
00239 { 00240 //Read Luminosity curve parameters 00241 char stmt1[200]; 00242 int run_No =std::abs(runNo); 00243 00244 if(SftVer == "default") { 00245 if(BossRelease == "default") { 00246 std::cout << "ERROR BossRelease must be set! Current value is " << BossRelease << "." << endreq; 00247 exit(1); 00248 } 00249 else { 00250 sprintf(stmt1, "select SftVer, ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType = 'LumVtx'", BossRelease.c_str(), run_No, run_No); 00251 00252 DatabaseRecordVector records; 00253 int rowNo = m_dbsvc->query("offlinedb",stmt1,records); 00254 if(rowNo == 0) { 00255 std::cout << "ERROR: can not find records for run = " << run_No << " and BossRelease = " << BossRelease << endreq; 00256 exit(1); 00257 } 00258 DatabaseRecord* recordst = records[0]; 00259 SftVer = recordst->GetString("SftVer"); 00260 ParVer = recordst->GetString("ParVer"); 00261 std::cout << "Using the new SftVer and ParVer (" << SftVer << ", " << ParVer << ") for run " << run_No << ". " << endreq; 00262 } 00263 } 00264 00265 sprintf(stmt1,"select runTime,Tau_Value,SftVer,ParVer from OfflineLum where RunNo = %d",run_No); 00266 00267 DatabaseRecordVector results; 00268 results.clear(); 00269 int status = m_dbsvc->query("offlinedb",stmt1,results); 00270 if(status<0){ 00271 std::cout << "ERROR Read the luminosity curve parameters from the Database" << endreq; 00272 exit(1); 00273 } 00274 00275 int RowNumber = results.size(); 00276 if(RowNumber == 0){ 00277 std::cout<<"ERROR: No Luminosity curve parameters in this run, aborted."<<std::endl; 00278 exit(1); 00279 } 00280 00281 int ParVerID = 0; 00282 int RecordNo = 0; 00283 if(std::atoi(ParVer.c_str()) == 0) { 00284 for(int i = 0; i < RowNumber; i++) { 00285 if((std::atoi((*results[i])["ParVer"]) > ParVerID)&&((*results[i])["SftVer"]==SftVer)) { 00286 runTotalTime = (*results[i])["runTime"]; 00287 tau_value = (*results[i])["Tau_Value"]; 00288 ParVerID = std::atoi((*results[i])["ParVer"]); 00289 RecordNo++; 00290 } 00291 } 00292 } 00293 else { 00294 RecordNo = 0; 00295 for(int i = 0; i < RowNumber; i++) { 00296 if((std::atoi((*results[i])["ParVer"]) == std::atoi(ParVer.c_str()))&&((*results[i])["SftVer"]==SftVer)) { 00297 runTotalTime = (*results[i])["runTime"]; 00298 tau_value = (*results[i])["Tau_Value"]; 00299 ParVerID = std::atoi((*results[i])["ParVer"]); 00300 RecordNo++; 00301 } 00302 } 00303 } 00304 if(RecordNo == 0) { 00305 std::cout<<"ERROR: No Luminosity curve parameters found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl; 00306 exit(1); 00307 } 00308 00309 if(RecordNo >= 2 && std::atoi(ParVer.c_str()) != 0) { 00310 std::cout<<"ERROR: More than two Lum. curve parameters records found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl; 00311 exit(1); 00312 } 00313 00314 return RETOk; 00315 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBackgroundInfo | ( | std::vector< std::string > & | fileInfor, | |
std::string | query | |||
) |
Definition at line 660 of file ConnectionProvider.cxx.
References DatabaseRecordVector::clear(), genRecEmupikp::i, m_dbsvc, IDatabaseSvc::query(), RETMySQLError, RETNoSchemaMatch, and RETOk.
00660 { 00661 //Read background file 00662 //char stmt1[200]; 00663 //int run_No =runNo; 00664 00665 //sprintf(stmt1,"select FilePath,FileName from RanTrgData where RunNo = %d ",run_No); 00666 00667 DatabaseRecordVector results; 00668 results.clear(); 00669 int status = m_dbsvc->query("offlinedb",stmt1,results); 00670 if(status<0){ 00671 std::cout << "ERROR Read the background file from the Database" << endreq; 00672 exit(1); 00673 } 00674 int RowNumber = results.size(); 00675 if(RowNumber == 0){ 00676 std::cout<<"ERROR:error searching background Data in the database, check your selection criterions"<<std::endl; 00677 return RETMySQLError; 00678 } 00679 //vRanTrgEvtNum.clear(); 00680 fileInfor.clear(); 00681 for(int i = 0; i < RowNumber; i++) { 00682 //int RanTrgEvtNum = 0; 00683 //RanTrgEvtNum = std::atoi((*results[i])["NumEvent"]); 00684 //if(RanTrgEvtNum != 0) vRanTrgEvtNum.push_back(RanTrgEvtNum); 00685 //if(RanTrgEvtNum != 0) { 00686 fileInfor.push_back((*results[i])["FilePath"]); 00687 fileInfor.push_back((*results[i])["FileName"]); 00688 //} 00689 } 00690 00691 if(fileInfor.size() == 0) { 00692 std::cout<<"WARNING: the total bg event number in your selected bg files is zero, it will abort after error message" << std::endl; 00693 return RETNoSchemaMatch; 00694 } 00695 00696 return RETOk; 00697 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBackgroundInfo | ( | std::vector< std::string > & | fileInfor, | |
int | runNo | |||
) |
Definition at line 618 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), genRecEmupikp::i, m_dbsvc, IDatabaseSvc::query(), RETNoSchemaMatch, and RETOk.
Referenced by RealizationSvc::getBgFileName(), and RealizationSvc::readDB().
00618 { 00619 //Read background file 00620 char stmt1[200]; 00621 int run_No =std::abs(runNo); 00622 00623 //sprintf(stmt1,"select FilePath,FileName,NumEvent from RanTrgData where RunNo = %d ",run_No); 00624 sprintf(stmt1,"select FilePath,FileName from RanTrgData where RunNo = %d ",run_No); 00625 00626 DatabaseRecordVector results; 00627 results.clear(); 00628 int status = m_dbsvc->query("offlinedb",stmt1,results); 00629 if(status<0){ 00630 std::cout << "ERROR Read the background file from the Database" << endreq; 00631 exit(1); 00632 } 00633 00634 int RowNumber = results.size(); 00635 if(RowNumber == 0){ 00636 std::cout<<"WARNING: No Bg infor. in this run!"<<std::endl; 00637 return RETNoSchemaMatch; 00638 } 00639 //vRanTrgEvtNum.clear(); 00640 fileInfor.clear(); 00641 for(int i = 0; i < RowNumber; i++) { 00642 //int RanTrgEvtNum = 0; 00643 //RanTrgEvtNum = std::atoi((*results[i])["NumEvent"]); 00644 //if(RanTrgEvtNum != 0) vRanTrgEvtNum.push_back(RanTrgEvtNum); 00645 //if(RanTrgEvtNum != 0) { 00646 fileInfor.push_back((*results[i])["FilePath"]); 00647 fileInfor.push_back((*results[i])["FileName"]); 00648 //} 00649 } 00650 00651 if(fileInfor.size() == 0) { 00652 std::cout<<"WARNING: the total bg event number in run " << runNo << " is zero, it will use other run's bg" << std::endl; 00653 return RETNoSchemaMatch; 00654 } 00655 00656 return RETOk; 00657 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBunchInfo | ( | std::vector< std::string > & | bunch, | |
int | runNo, | |||
std::string | SftVer, | |||
std::string | ParVer, | |||
std::string | BossRelease | |||
) |
Definition at line 317 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), DatabaseRecord::GetString(), genRecEmupikp::i, m_dbsvc, IDatabaseSvc::query(), RETNoSchemaMatch, and RETOk.
Referenced by RealizationSvc::readDB().
00317 { 00318 //Read bunch size information 00319 char stmt1[200]; 00320 int run_No =std::abs(runNo); 00321 00322 if(SftVer == "default") { 00323 if(BossRelease == "default") { 00324 std::cout << "ERROR BossRelease must be set! Current value is " << BossRelease << "." << endreq; 00325 exit(1); 00326 } 00327 else { 00328 sprintf(stmt1, "select SftVer, ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType = 'LumVtx'", BossRelease.c_str(), run_No, run_No); 00329 00330 DatabaseRecordVector records; 00331 int rowNo = m_dbsvc->query("offlinedb",stmt1,records); 00332 if(rowNo == 0) { 00333 std::cout << "ERROR: can not find records for run = " << run_No << " and BossRelease = " << BossRelease << endreq; 00334 exit(1); 00335 } 00336 DatabaseRecord* recordst = records[0]; 00337 SftVer = recordst->GetString("SftVer"); 00338 ParVer = recordst->GetString("ParVer"); 00339 std::cout << "Using the new SftVer and ParVer (" << SftVer << ", " << ParVer << ") for run " << run_No << ". " << endreq; 00340 } 00341 } 00342 00343 sprintf(stmt1,"select Vx,Vy,Vz,AcSigmaVx,AcSigmaVy,SigmaVz,SftVer,ParVer from BeamPar where runNo = %d",run_No); 00344 /* 00345 if(std::atoi(ParVer.c_str()) == 0) { 00346 sprintf(stmt1,"select Vx,Vy,Vz,AcSigmaVx,AcSigmaVy,SigmaVz,ParVer from BeamPar where runNo = %d && SftVer = \"%s\"",run_No,SftVer.c_str()); 00347 } 00348 else { 00349 sprintf(stmt1,"select Vx,Vy,Vz,AcSigmaVx,AcSigmaVy,SigmaVz from BeamPar where runNo = %d && SftVer = \"%s\" && ParVer = \"%s\"",run_No,SftVer.c_str(),ParVer.c_str()); 00350 } 00351 */ 00352 00353 DatabaseRecordVector results; 00354 results.clear(); 00355 int status = m_dbsvc->query("offlinedb",stmt1,results); 00356 if(status<0){ 00357 std::cout << "ERROR Read the bunch from the Database" << endreq; 00358 exit(1); 00359 } 00360 00361 int RowNumber = results.size(); 00362 if(RowNumber == 0){ 00363 std::cout<<"WARNING: No bunch Data in this run! Please check your selection criteria (runNo, SftVer, ParVer)"<<std::endl; 00364 return RETNoSchemaMatch; 00365 } 00366 00367 int ParVerID = 0; 00368 int RecordNo = 0; 00369 if(std::atoi(ParVer.c_str()) == 0) { 00370 for(int i = 0; i < RowNumber; i++) { 00371 if((std::atoi((*results[i])["ParVer"]) > ParVerID)&&((*results[i])["SftVer"]==SftVer)) { 00372 bunch.clear(); 00373 bunch.push_back((*results[i])["Vx"]); 00374 bunch.push_back((*results[i])["Vy"]); 00375 bunch.push_back((*results[i])["Vz"]); 00376 bunch.push_back((*results[i])["AcSigmaVx"]); 00377 bunch.push_back((*results[i])["AcSigmaVy"]); 00378 bunch.push_back((*results[i])["SigmaVz"]); 00379 ParVerID = std::atoi((*results[i])["ParVer"]); 00380 RecordNo++; 00381 } 00382 } 00383 } 00384 else { 00385 RecordNo = 0; 00386 for(int i = 0; i < RowNumber; i++) { 00387 if((std::atoi((*results[i])["ParVer"]) == std::atoi(ParVer.c_str()))&&((*results[i])["SftVer"]==SftVer)) { 00388 bunch.clear(); 00389 bunch.push_back((*results[i])["Vx"]); 00390 bunch.push_back((*results[i])["Vy"]); 00391 bunch.push_back((*results[i])["Vz"]); 00392 bunch.push_back((*results[i])["AcSigmaVx"]); 00393 bunch.push_back((*results[i])["AcSigmaVy"]); 00394 bunch.push_back((*results[i])["SigmaVz"]); 00395 RecordNo++; 00396 } 00397 } 00398 } 00399 00400 if(RecordNo == 0) { 00401 std::cout<<"WARNING: No bunch infor. found in this run, it will use other run's"<<std::endl; 00402 return RETNoSchemaMatch; 00403 } 00404 00405 if(RecordNo >= 2 && std::atoi(ParVer.c_str()) != 0) { 00406 std::cout<<"ERROR: More than two bunch records found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl; 00407 exit(1); 00408 } 00409 00410 return RETOk; 00411 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadLumInfo | ( | std::string & | Lum, | |
int | runNo, | |||
std::string | SftVer, | |||
std::string | ParVer, | |||
std::string | BossRelease | |||
) |
Definition at line 156 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), DatabaseRecord::GetString(), genRecEmupikp::i, m_dbsvc, IDatabaseSvc::query(), and RETOk.
Referenced by RealizationSvc::getLuminosity().
00156 { 00157 //Read Luminosity information 00158 char stmt1[200]; 00159 int run_No =std::abs(runNo); 00160 00161 00162 if(SftVer == "default") { 00163 if(BossRelease == "default") { 00164 std::cout << "ERROR BossRelease must be set! Current value is " << BossRelease << "." << endreq; 00165 exit(1); 00166 } 00167 else { 00168 sprintf(stmt1, "select SftVer, ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType = 'LumVtx'", BossRelease.c_str(), run_No, run_No); 00169 00170 DatabaseRecordVector records; 00171 int rowNo = m_dbsvc->query("offlinedb",stmt1,records); 00172 if(rowNo == 0) { 00173 std::cout << "ERROR: can not find records for run = " << run_No << " and BossRelease = " << BossRelease << endreq; 00174 exit(1); 00175 } 00176 DatabaseRecord* recordst = records[0]; 00177 SftVer = recordst->GetString("SftVer"); 00178 ParVer = recordst->GetString("ParVer"); 00179 std::cout << "Using the new SftVer and ParVer (" << SftVer << ", " << ParVer << ") for run " << run_No << ". " << endreq; 00180 } 00181 } 00182 00183 00184 sprintf(stmt1,"select OfflineTwoGam,SftVer,ParVer from OfflineLum where RunNo = %d",run_No); 00185 /* 00186 if(std::atoi(ParVer.c_str()) == 0) { 00187 sprintf(stmt1,"select OfflineTwoGam,ParVer from OfflineLum where RunNo = %d && SftVer = \"%s\"",run_No,SftVer.c_str()); 00188 } 00189 else { 00190 sprintf(stmt1,"select OfflineTwoGam from OfflineLum where RunNo = %d && SftVer = \"%s\" && ParVer = \"%s\"",run_No,SftVer.c_str(),ParVer.c_str()); 00191 } 00192 */ 00193 DatabaseRecordVector results; 00194 results.clear(); 00195 int status = m_dbsvc->query("offlinedb",stmt1,results); 00196 if(status<0){ 00197 std::cout << "ERROR Read the luminosity from the Database" << endreq; 00198 exit(1); 00199 } 00200 00201 int RowNumber = results.size(); 00202 if(RowNumber == 0){ 00203 std::cout<<"WARNING: No Luminosity Data in this run, return 0."<<std::endl; 00204 Lum = "0"; 00205 return RETOk; 00206 } 00207 00208 int ParVerID = 0; 00209 int RecordNo = 0; 00210 if(std::atoi(ParVer.c_str()) == 0) { 00211 for(int i = 0; i < RowNumber; i++) { 00212 if((std::atoi((*results[i])["ParVer"]) > ParVerID)&&((*results[i])["SftVer"]==SftVer)) { Lum = (*results[i])["OfflineTwoGam"]; ParVerID = std::atoi((*results[i])["ParVer"]); RecordNo++;} 00213 } 00214 } 00215 else { 00216 RecordNo = 0; 00217 for(int i = 0; i < RowNumber; i++) { 00218 if((std::atoi((*results[i])["ParVer"]) == std::atoi(ParVer.c_str()))&&((*results[i])["SftVer"]==SftVer)) { Lum = (*results[i])["OfflineTwoGam"]; ParVerID = std::atoi((*results[i])["ParVer"]); RecordNo++;} 00219 } 00220 } 00221 00222 if(RecordNo == 0) { 00223 //std::cout<<"ERROR: No Luminosity infor. found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl; 00224 //std::abort(); 00225 std::cout<<"WARNING: No Luminosity infor. found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl; 00226 Lum = "0"; 00227 return RETOk; 00228 00229 } 00230 00231 if(RecordNo >= 2 && std::atoi(ParVer.c_str()) != 0) { 00232 std::cout<<"ERROR: More than two Lum. records found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl; 00233 exit(1); 00234 } 00235 00236 return RETOk; 00237 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadTofThreshInfo | ( | std::vector< std::string > & | tofThresh, | |
int | runNo | |||
) |
Definition at line 699 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), genRecEmupikp::i, m_dbsvc, m_tfee_fileid, m_tofThresh, IDatabaseSvc::query(), RETMySQLError, RETNoSchemaMatch, and RETOk.
Referenced by RealizationSvc::readDB().
00699 { 00700 //Read tof FEE threshold 00701 char stmt1[200]; 00702 int run_No =std::abs(runNo); 00703 00704 sprintf(stmt1,"select TFEE_fileid from RunParams where run_number = %d ",run_No); 00705 00706 DatabaseRecordVector results; 00707 results.clear(); 00708 int status = m_dbsvc->query("run",stmt1,results); 00709 if(status<0){ 00710 std::cout << "ERROR Read the Tof threshold from the Database" << endreq; 00711 exit(1); 00712 } 00713 int RowNumber = results.size(); 00714 if(RowNumber!=1){ 00715 std::cout<<"ERROR:error searching TFEE_fileid Data in the database, check your selection criterions"<<std::endl; 00716 return RETMySQLError; 00717 } 00718 int i_tfee_fileid = std::atoi((*results[0])["TFEE_fileid"]); 00719 std::cout<<"TFEE file id is "<<i_tfee_fileid<<std::endl; 00720 results.clear(); 00721 00722 if(i_tfee_fileid == m_tfee_fileid) { 00723 std::cout<<"Don't need to update TOF FEE threshold, it is same with the last run!"<<std::endl; 00724 } 00725 else { 00726 m_tfee_fileid = i_tfee_fileid; 00727 m_tofThresh.clear(); 00728 00729 sprintf(stmt1,"select PhysAddress,BarrelEnd,HighThreshold,LowThreshold from TFEE where FileId = %d ",i_tfee_fileid); 00730 int status1 = m_dbsvc->query("run",stmt1,results); 00731 if(status1<0){ 00732 std::cout << "ERROR Read the Tof threshold from the Database 1" << endreq; 00733 exit(1); 00734 } 00735 int RowNumber = results.size(); 00736 if(RowNumber == 0){ 00737 std::cout<<"WARNING: No TFEE infor. in this run!"<<std::endl; 00738 return RETNoSchemaMatch; 00739 } 00740 for(int i = 0; i < RowNumber; i++) { 00741 m_tofThresh.push_back((*results[i])["PhysAddress"]); 00742 m_tofThresh.push_back((*results[i])["BarrelEnd"]); 00743 m_tofThresh.push_back((*results[i])["HighThreshold"]); 00744 m_tofThresh.push_back((*results[i])["LowThreshold"]); 00745 } 00746 results.clear(); 00747 } 00748 00749 tofThresh = m_tofThresh; 00750 00751 return RETOk; 00752 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadTrgTableInfo | ( | std::vector< std::string > & | trgTable, | |
int | runNo | |||
) |
Definition at line 413 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), genRecEmupikp::i, ganga-rec::j, m_dbsvc, m_trgTable, m_trgTpye, IDatabaseSvc::query(), RETMySQLError, and RETOk.
Referenced by RealizationSvc::readDB().
00413 { 00414 //Read trigger table used in trigger simulation 00415 char stmt1[200]; 00416 int run_No =std::abs(runNo); 00417 00418 sprintf(stmt1,"select trgtable_id from RunParams where run_number = %d ",run_No); 00419 00420 DatabaseRecordVector results; 00421 results.clear(); 00422 int status = m_dbsvc->query("run",stmt1,results); 00423 if(status<0){ 00424 std::cout << "ERROR Read the trigger table from the Database" << endreq; 00425 exit(1); 00426 } 00427 00428 int RowNumber = results.size(); 00429 if(RowNumber!=1){ 00430 std::cout<<"ERROR:error searching Trigger Type Data in the database, check your selection criteria"<<std::endl; 00431 return RETMySQLError; 00432 } 00433 int i_trgTpye = std::atoi((*results[0])["trgtable_id"]); 00434 std::cout<<"Obj_id is "<<i_trgTpye<<std::endl; 00435 results.clear(); 00436 00437 if(i_trgTpye == m_trgTpye) { 00438 std::cout<<"Don't need to update trigger table, it is same with the last run!"<<std::endl; 00439 } 00440 else { 00441 m_trgTpye = i_trgTpye; 00442 m_trgTable.clear(); 00443 //retrieve EventChannelEnableRegister from database 00444 sprintf(stmt1,"select EventChannelEnableRegister from TrgTable where Obj_id = %d ", i_trgTpye); 00445 int status1 = m_dbsvc->query("run",stmt1,results); 00446 if(status1<0){ 00447 std::cout << "ERROR Read the trigger table from the Database 1" << endreq; 00448 exit(1); 00449 } 00450 RowNumber = results.size(); 00451 if(RowNumber!=1){ 00452 std::cout<<"ERROR:error searching Trigger Type Data in the database, check your selection criterions"<<std::endl; 00453 return RETMySQLError; 00454 } 00455 m_trgTable.push_back((*results[0])["EventChannelEnableRegister"]); 00456 results.clear(); 00457 00458 //retrieve TrgTable_Channel from database 00459 for(int i = 1; i < 17; i++) 00460 for(int j = 1; j < 5; j++) { 00461 if(i < 10) sprintf(stmt1,"select TrgTable_CH0%d_%d from TrgTable where Obj_id = %d ", i, j, i_trgTpye); 00462 else sprintf(stmt1,"select TrgTable_CH%d_%d from TrgTable where Obj_id = %d ", i, j, i_trgTpye); 00463 int status2 = m_dbsvc->query("run",stmt1,results); 00464 if(status2<0){ 00465 std::cout << "ERROR Read the trigger table from the Database 2" << endreq; 00466 exit(1); 00467 } 00468 RowNumber = results.size(); 00469 if(RowNumber!=1){ 00470 std::cout<<"ERROR:error searching TrgTable Data in the database, check your selection criterions"<<std::endl; 00471 return RETMySQLError; 00472 } 00473 if(i<10) sprintf(stmt1,"TrgTable_CH0%d_%d", i, j); 00474 else sprintf(stmt1,"TrgTable_CH%d_%d", i, j); 00475 m_trgTable.push_back((*results[0])[stmt1]); 00476 results.clear(); 00477 } 00478 } 00479 trgTable = m_trgTable; 00480 00481 return RETOk; 00482 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getRunInfo | ( | std::vector< std::string > & | runInfo, | |
int | runNo | |||
) |
Definition at line 754 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), deljobs::end, genRecEmupikp::i, iter(), m_dbsvc, IDatabaseSvc::query(), RETNoSchemaMatch, and RETOk.
Referenced by RealizationSvc::readDB().
00754 { 00755 //Read run information 00756 char stmt1[500]; 00757 int run_No =std::abs(runNo); 00758 00759 sprintf(stmt1,"select R_TM_BPR_PatNum,R_TM_BER_PatNum,S_R3O_BI_DCCT_current,E_R3O_BI_DCCT_current,AV_R3O_BI_DCCT_current,S_R4O_BI_DCCT_current,E_R4O_BI_DCCT_current,AV_R4O_BI_DCCT_current,S_BPR_LIFE,E_BPR_LIFE,AV_BPR_LIFE,S_BER_LIFE,E_BER_LIFE,AV_BER_LIFE from RunParams where run_number = %d ",run_No); 00760 00761 DatabaseRecordVector results; 00762 results.clear(); 00763 int status = m_dbsvc->query("run",stmt1,results); 00764 if(status<0){ 00765 std::cout << "ERROR Read the run information from the Database" << endreq; 00766 exit(1); 00767 } 00768 int RowNumber = results.size(); 00769 if(RowNumber == 0){ 00770 std::cout<<"WARNING: No run information in this run!"<<std::endl; 00771 return RETNoSchemaMatch; 00772 } 00773 00774 for(int i = 0; i < RowNumber; i++) { 00775 for(std::map<std::string,char*>::iterator iter = (*results[i]).begin(); iter != (*results[i]).end(); iter++) { 00776 runInfo.push_back(iter->second); 00777 } 00778 } 00779 00780 return RETOk; 00781 }
ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getTrgConfigInfo | ( | int | runNo | ) |
Definition at line 568 of file ConnectionProvider.cxx.
References abs, DatabaseRecordVector::clear(), m_dbsvc, m_EtotDataSteps, m_VthBalBLK, m_VthBalEEMC, m_VthBEtotH, m_VthBLZ, m_VthDiffB, m_VthDiffE, m_VthDiffMin, m_VthEEtotH, m_VthEtotL, m_VthEtotM, IDatabaseSvc::query(), and RETOk.
Referenced by RealizationSvc::readDB().
00568 { 00569 //Read trigger configure information 00570 char stmt1[1024]; 00571 int run_No =std::abs(runNo); 00572 00573 sprintf(stmt1,"select Trg_fileid from RunParams where run_number = %d ",run_No); 00574 00575 DatabaseRecordVector results; 00576 results.clear(); 00577 int rowNumber = m_dbsvc->query("run",stmt1,results); 00578 if( rowNumber <= 0){ 00579 std::cout << "ERROR: Read the Trg_fileid from RunParams, exit." << endl; 00580 exit(1); 00581 } 00582 00583 if(rowNumber > 1){ 00584 std::cout<<"WARNNING: there are more than one record for Trg_fileid in run " << runNo << ", the first one will be selected."<<std::endl; 00585 } 00586 int trg_fileid = std::atoi((*results[0])["Trg_fileid"]); 00587 00588 sprintf(stmt1,"select EtotDataSteps,VthBEtotH,VthEEtotH,VthEtotL,VthEtotM,VthBLZ,VthDiffB,VthDiffE,VthBalBLK,VthBalEEMC,VthDiffMin from Trg_EACC where FileId = %d ", trg_fileid); 00589 00590 results.clear(); 00591 rowNumber = m_dbsvc->query("run",stmt1,results); 00592 if( rowNumber <= 0){ 00593 std::cout << "ERROR: Read the EACC config infor. from Trg_EACC, exit." << endl; 00594 exit(1); 00595 } 00596 00597 if(rowNumber > 1){ 00598 std::cout<<"WARNNING: there are more than one record for EACC in run " << runNo << ", the first one will be selected."<<std::endl; 00599 } 00600 00601 m_EtotDataSteps = std::atoi((*results[0])["EtotDataSteps"]); 00602 m_VthBEtotH = std::atoi((*results[0])["VthBEtotH"]); 00603 m_VthEEtotH = std::atoi((*results[0])["VthEEtotH"]); 00604 m_VthEtotL = std::atoi((*results[0])["VthEtotL"]); 00605 m_VthEtotM = std::atoi((*results[0])["VthEtotM"]); 00606 m_VthBLZ = std::atoi((*results[0])["VthBLZ"]); 00607 m_VthDiffB = std::atoi((*results[0])["VthDiffB"]); 00608 m_VthDiffE = std::atoi((*results[0])["VthDiffE"]); 00609 m_VthBalBLK = std::atoi((*results[0])["VthBalBLK"]); 00610 m_VthBalEEMC = std::atoi((*results[0])["VthBalEEMC"]); 00611 m_VthDiffMin = std::atoi((*results[0])["VthDiffMin"]); 00612 00613 return RETOk; 00614 }
int RealDBUtil::ConnectionProvider::getVthBalBLK | ( | ) | [inline] |
Definition at line 75 of file ConnectionProvider.h.
References m_VthBalBLK.
Referenced by RealizationSvc::readDB().
00075 { return m_VthBalBLK; }
int RealDBUtil::ConnectionProvider::getVthBalEEMC | ( | ) | [inline] |
Definition at line 76 of file ConnectionProvider.h.
References m_VthBalEEMC.
Referenced by RealizationSvc::readDB().
00076 { return m_VthBalEEMC; }
int RealDBUtil::ConnectionProvider::getVthBEtotH | ( | ) | [inline] |
Definition at line 68 of file ConnectionProvider.h.
References m_VthBEtotH.
Referenced by RealizationSvc::readDB().
00068 { return m_VthBEtotH; }
int RealDBUtil::ConnectionProvider::getVthBLZ | ( | ) | [inline] |
Definition at line 72 of file ConnectionProvider.h.
References m_VthBLZ.
Referenced by RealizationSvc::readDB().
00072 { return m_VthBLZ; }
int RealDBUtil::ConnectionProvider::getVthDiffB | ( | ) | [inline] |
Definition at line 73 of file ConnectionProvider.h.
References m_VthDiffB.
Referenced by RealizationSvc::readDB().
00073 { return m_VthDiffB; }
int RealDBUtil::ConnectionProvider::getVthDiffE | ( | ) | [inline] |
Definition at line 74 of file ConnectionProvider.h.
References m_VthDiffE.
Referenced by RealizationSvc::readDB().
00074 { return m_VthDiffE; }
int RealDBUtil::ConnectionProvider::getVthDiffMin | ( | ) | [inline] |
Definition at line 77 of file ConnectionProvider.h.
References m_VthDiffMin.
Referenced by RealizationSvc::readDB().
00077 { return m_VthDiffMin; }
int RealDBUtil::ConnectionProvider::getVthEEtotH | ( | ) | [inline] |
Definition at line 69 of file ConnectionProvider.h.
References m_VthEEtotH.
Referenced by RealizationSvc::readDB().
00069 { return m_VthEEtotH; }
int RealDBUtil::ConnectionProvider::getVthEtotL | ( | ) | [inline] |
Definition at line 70 of file ConnectionProvider.h.
References m_VthEtotL.
Referenced by RealizationSvc::readDB().
00070 { return m_VthEtotL; }
int RealDBUtil::ConnectionProvider::getVthEtotM | ( | ) | [inline] |
Definition at line 71 of file ConnectionProvider.h.
References m_VthEtotM.
Referenced by RealizationSvc::readDB().
00071 { return m_VthEtotM; }
std::vector< std::string > RealDBUtil::ConnectionProvider::split | ( | const std::string & | src, | |
std::string | delimit, | |||
std::string | null_subst = "" | |||
) |
Definition at line 27 of file ConnectionProvider.cxx.
References RealDBUtil::npos, deljobs::string, and v.
Referenced by getcal().
00028 { 00029 if( src.empty() || delimit.empty() ) throw "split: empty string\0"; 00030 vector<string> v; 00031 S_T deli_len = delimit.size(); 00032 long index = npos, last_search_position = 0; 00033 while( (index=src.find(delimit, last_search_position))!=npos ) 00034 { 00035 if(index==last_search_position) 00036 v.push_back(null_subst); 00037 else 00038 v.push_back( src.substr(last_search_position, index- 00039 last_search_position) ); 00040 last_search_position = index + deli_len; 00041 } 00042 string last_one = src.substr(last_search_position); 00043 v.push_back( last_one.empty()? null_subst:last_one ); 00044 return v; 00045 }
int RealDBUtil::ConnectionProvider::id_num [private] |
Definition at line 80 of file ConnectionProvider.h.
Referenced by ConnectionProvider(), getcal(), getLumCurvePar(), getReadBackgroundInfo(), getReadBunchInfo(), getReadLumInfo(), getReadTofThreshInfo(), getReadTrgTableInfo(), getRunInfo(), and getTrgConfigInfo().
int RealDBUtil::ConnectionProvider::m_EtotDataSteps [private] |
Definition at line 91 of file ConnectionProvider.h.
Referenced by getEtotDataSteps(), and getTrgConfigInfo().
int RealDBUtil::ConnectionProvider::m_tfee_fileid [private] |
Definition at line 83 of file ConnectionProvider.h.
Referenced by ConnectionProvider(), and getReadTofThreshInfo().
std::vector<std::string> RealDBUtil::ConnectionProvider::m_tofThresh [private] |
std::vector<std::string> RealDBUtil::ConnectionProvider::m_trgTable [private] |
int RealDBUtil::ConnectionProvider::m_trgTpye [private] |
Definition at line 82 of file ConnectionProvider.h.
Referenced by ConnectionProvider(), and getReadTrgTableInfo().
int RealDBUtil::ConnectionProvider::m_VthBalBLK [private] |
Definition at line 99 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthBalBLK().
int RealDBUtil::ConnectionProvider::m_VthBalEEMC [private] |
Definition at line 100 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthBalEEMC().
int RealDBUtil::ConnectionProvider::m_VthBEtotH [private] |
Definition at line 92 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthBEtotH().
int RealDBUtil::ConnectionProvider::m_VthBLZ [private] |
Definition at line 96 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthBLZ().
int RealDBUtil::ConnectionProvider::m_VthDiffB [private] |
Definition at line 97 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthDiffB().
int RealDBUtil::ConnectionProvider::m_VthDiffE [private] |
Definition at line 98 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthDiffE().
int RealDBUtil::ConnectionProvider::m_VthDiffMin [private] |
Definition at line 101 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthDiffMin().
int RealDBUtil::ConnectionProvider::m_VthEEtotH [private] |
Definition at line 93 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthEEtotH().
int RealDBUtil::ConnectionProvider::m_VthEtotL [private] |
Definition at line 94 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthEtotL().
int RealDBUtil::ConnectionProvider::m_VthEtotM [private] |
Definition at line 95 of file ConnectionProvider.h.
Referenced by getTrgConfigInfo(), and getVthEtotM().
std::string* RealDBUtil::ConnectionProvider::trgGain[6500] [private] |