Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

RealDBUtil::ConnectionProvider Class Reference

#include <ConnectionProvider.h>

List of all members.

Public Types

enum  eLevel { LEVELProd = 1, LEVELDev = 2, LEVELTest = 4, LEVELSuperseded = 8 }
 Used to form bit masks for dbs queries. More...
enum  eLevel { LEVELProd = 1, LEVELDev = 2, LEVELTest = 4, LEVELSuperseded = 8 }
 Used to form bit masks for dbs queries. More...
enum  eRet {
  RETOk = 0, RETBadCnfFile = 1, RETBadHost = 2, RETNoConnect = 3,
  RETWrongState = 4, RETBadValue = 5, RETMySQLError = 6, RETNoSchemaMatch = 7
}
enum  eRet {
  RETOk = 0, RETBadCnfFile = 1, RETBadHost = 2, RETNoConnect = 3,
  RETWrongState = 4, RETBadValue = 5, RETMySQLError = 6, RETNoSchemaMatch = 7
}

Public Member Functions

 ConnectionProvider ()
 Constructor keeps track of table of interest.
 ConnectionProvider ()
 Constructor keeps track of table of interest.
bool getcal (int runNo, std::string ids)
bool getcal (int runNo, std::string ids)
ConnectionProvider::eRet getEmcGain (std::vector< double > &emcGain, int runNo)
ConnectionProvider::eRet getEmcGain (std::vector< double > &emcGain, int runNo)
int getEtotDataSteps ()
int getEtotDataSteps ()
ConnectionProvider::eRet getLumCurvePar (std::string &runTotalTime, std::string &tau_value, int runNo, std::string SftVer, std::string ParVer)
ConnectionProvider::eRet getLumCurvePar (std::string &runTotalTime, std::string &tau_value, int runNo, std::string SftVer, std::string ParVer)
ConnectionProvider::eRet getReadBackgroundInfo (std::vector< std::string > &fileInfor, std::string query)
ConnectionProvider::eRet getReadBackgroundInfo (std::vector< std::string > &fileInfor, int runNo)
ConnectionProvider::eRet getReadBackgroundInfo (std::vector< std::string > &fileInfor, std::string query)
ConnectionProvider::eRet getReadBackgroundInfo (std::vector< std::string > &fileInfor, int runNo)
ConnectionProvider::eRet getReadBunchInfo (std::vector< std::string > &bunch, int runNo, std::string SftVer, std::string ParVer)
ConnectionProvider::eRet getReadBunchInfo (std::vector< std::string > &bunch, int runNo, std::string SftVer, std::string ParVer)
ConnectionProvider::eRet getReadLumInfo (std::string &Lum, int runNo, std::string SftVer, std::string ParVer)
ConnectionProvider::eRet getReadLumInfo (std::string &Lum, int runNo, std::string SftVer, std::string ParVer)
ConnectionProvider::eRet getReadTofThreshInfo (std::vector< std::string > &tofThresh, int runNo)
ConnectionProvider::eRet getReadTofThreshInfo (std::vector< std::string > &tofThresh, int runNo)
ConnectionProvider::eRet getReadTrgTableInfo (std::vector< std::string > &trgTable, int runNo)
ConnectionProvider::eRet getReadTrgTableInfo (std::vector< std::string > &trgTable, int runNo)
ConnectionProvider::eRet getRunInfo (std::vector< std::string > &runInfo, int runNo)
ConnectionProvider::eRet getRunInfo (std::vector< std::string > &runInfo, int runNo)
ConnectionProvider::eRet getTrgConfigInfo (int runNo)
ConnectionProvider::eRet getTrgConfigInfo (int runNo)
int getVthBalBLK ()
int getVthBalBLK ()
int getVthBalEEMC ()
int getVthBalEEMC ()
int getVthBEtotH ()
int getVthBEtotH ()
int getVthBLZ ()
int getVthBLZ ()
int getVthDiffB ()
int getVthDiffB ()
int getVthDiffE ()
int getVthDiffE ()
int getVthDiffMin ()
int getVthDiffMin ()
int getVthEEtotH ()
int getVthEEtotH ()
int getVthEtotL ()
int getVthEtotL ()
int getVthEtotM ()
int getVthEtotM ()
std::vector< std::string > split (const std::string &src, std::string delimit, std::string null_subst="")
std::vector< std::string > split (const std::string &src, std::string delimit, std::string null_subst="")
 ~ConnectionProvider ()
 ~ConnectionProvider ()

Private Attributes

int id_num
IDatabaseSvcm_dbsvc
IDatabaseSvcm_dbsvc
int m_EtotDataSteps
int m_tfee_fileid
std::vector< std::string > m_tofThresh
std::vector< std::string > m_tofThresh
std::vector< std::string > m_trgTable
std::vector< std::string > m_trgTable
int m_trgTpye
int m_VthBalBLK
int m_VthBalEEMC
int m_VthBEtotH
int m_VthBLZ
int m_VthDiffB
int m_VthDiffE
int m_VthDiffMin
int m_VthEEtotH
int m_VthEtotL
int m_VthEtotM
std::string * trgGain [6500]
std::string * trgGain [6500]


Member Enumeration Documentation

enum RealDBUtil::ConnectionProvider::eLevel
 

Used to form bit masks for dbs queries.

Enumeration values:
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 
00041                 {
00042       LEVELProd = 1,
00043       LEVELDev  = 2,
00044       LEVELTest = 4,
00045       LEVELSuperseded = 8
00046     };

enum RealDBUtil::ConnectionProvider::eLevel
 

Used to form bit masks for dbs queries.

Enumeration values:
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 
00041                 {
00042       LEVELProd = 1,
00043       LEVELDev  = 2,
00044       LEVELTest = 4,
00045       LEVELSuperseded = 8
00046     };

enum RealDBUtil::ConnectionProvider::eRet
 

Enumeration values:
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 
00030               {
00031       RETOk = 0,
00032       RETBadCnfFile = 1,
00033       RETBadHost = 2, 
00034       RETNoConnect = 3,
00035       RETWrongState = 4,
00036       RETBadValue = 5,
00037       RETMySQLError = 6,
00038       RETNoSchemaMatch = 7
00039     };

enum RealDBUtil::ConnectionProvider::eRet
 

Enumeration values:
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 
00030               {
00031       RETOk = 0,
00032       RETBadCnfFile = 1,
00033       RETBadHost = 2, 
00034       RETNoConnect = 3,
00035       RETWrongState = 4,
00036       RETBadValue = 5,
00037       RETMySQLError = 6,
00038       RETNoSchemaMatch = 7
00039     };


Constructor & Destructor Documentation

RealDBUtil::ConnectionProvider::ConnectionProvider  ) 
 

Constructor keeps track of table of interest.

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  ) 
 

00153                                           {
00154   }

RealDBUtil::ConnectionProvider::ConnectionProvider  ) 
 

Constructor keeps track of table of interest.

RealDBUtil::ConnectionProvider::~ConnectionProvider  ) 
 


Member Function Documentation

bool RealDBUtil::ConnectionProvider::getcal int  runNo,
std::string  ids
 

bool RealDBUtil::ConnectionProvider::getcal int  runNo,
std::string  ids
 

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
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getEmcGain std::vector< double > &  emcGain,
int  runNo
 

00422                               {
00423       cout << "ConnectionProvider Error: Can't get EmcCalibConstSvc." << endl;
00424     }
00425     
00426     string ids="128005";
00427     
00428     ostringstream str;
00429     int idBegin=0;
00430     int idEnd=6240;
00431 
00432     for(int i=idBegin;i<idEnd;i++) {
00433       unsigned int npart = emcCalibConstSvc->getPartID(i);
00434       unsigned int ntheta = emcCalibConstSvc->getThetaIndex(i);
00435       unsigned int nphi = emcCalibConstSvc->getPhiIndex(i);
00436       
00437       int triPart,triTheta,triPhi;
00438       if(npart==0) {
00439         triPart=0; 
00440         triTheta=23+ntheta;
00441       } else if(npart==1&&ntheta<22) {
00442         triPart=0;
00443         triTheta=22-ntheta;
00444       } else if(npart==1&&ntheta>=22) {
00445         triPart=1;
00446         triTheta=ntheta-21;
00447       } else {  //npart==2
00448         triPart=1;
00449         triTheta=23+ntheta;
00450       } 
00451       triPhi=nphi+1;
00452       
00453       ostringstream ssTheta;
00454       if(triPart==1&&triTheta<10) {
00455         ssTheta<<"0"<<triTheta;
00456       } else {
00457         ssTheta<<triTheta;
00458       } 
00459       
00460       ostringstream ssPhi;
00461       if(triPhi<10) {
00462         ssPhi<<"00"<<triPhi;
00463       } else if(triPhi<100) {
00464         ssPhi<<"0"<<triPhi; 
00465       } else {
00466         ssPhi<<triPhi;
00467       }
00468 
00469       if(triPart==0) {
00470         str<<ssTheta.str()<<ssPhi.str();
00471       } else {
00472         str<<triPart<<ssTheta.str()<<ssPhi.str();
00473       }
00474       if(i!=idEnd-1) {
00475         str<<",";
00476       }
00477 
00478       //cout<<npart<<"\t"<<ntheta<<"\t"<<nphi<<endl;
00479 
00480     }
00481 
00482     ids=str.str();
00483     //cout<<ids<<endl;
00484 
00485     getcal( runNo, ids);
00486 
00487     emcGain.clear();
00488     for(int i=0;i<id_num;i++) {
00489       istringstream isin(*trgGain[i]);
00490       double value;
00491       isin>>value;
00492       value = ((50./255.)*(value)/60.)*5*0.5;
00493       emcGain.push_back(value);
00494       delete trgGain[i];
00495     }
00496 
00497     return RETOk;
00498   }
00499 

int RealDBUtil::ConnectionProvider::getEtotDataSteps  )  [inline]
 

00066 { return m_EtotDataSteps; }

int RealDBUtil::ConnectionProvider::getEtotDataSteps  )  [inline]
 

00066 { return m_EtotDataSteps; }

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getLumCurvePar std::string &  runTotalTime,
std::string &  tau_value,
int  runNo,
std::string  SftVer,
std::string  ParVer
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getLumCurvePar std::string &  runTotalTime,
std::string &  tau_value,
int  runNo,
std::string  SftVer,
std::string  ParVer
 

00224                 {
00225       std::cout << "ERROR Read the luminosity curve parameters from the Database" << endreq;
00226       exit(1);
00227     }
00228 
00229     int RowNumber = results.size();
00230     if(RowNumber == 0){
00231       std::cout<<"ERROR: No Luminosity curve parameters in this run, aborted."<<std::endl;
00232       exit(1); 
00233     }
00234 
00235     int ParVerID = 0;
00236     int RecordNo = 0;
00237     if(std::atoi(ParVer.c_str()) == 0) {
00238       for(int i = 0; i < RowNumber; i++) {
00239         if((std::atoi((*results[i])["ParVer"]) > ParVerID)&&((*results[i])["SftVer"]==SftVer)) {
00240           runTotalTime = (*results[i])["runTime"]; 
00241           tau_value = (*results[i])["Tau_Value"]; 
00242           ParVerID = std::atoi((*results[i])["ParVer"]);
00243           RecordNo++;
00244         }
00245       }
00246     }
00247     else {
00248       RecordNo = 0;
00249       for(int i = 0; i < RowNumber; i++) {
00250         if((std::atoi((*results[i])["ParVer"]) == std::atoi(ParVer.c_str()))&&((*results[i])["SftVer"]==SftVer)) { 
00251           runTotalTime = (*results[i])["runTime"]; 
00252           tau_value = (*results[i])["Tau_Value"]; 
00253           ParVerID = std::atoi((*results[i])["ParVer"]); 
00254           RecordNo++;
00255         }
00256       }
00257     }
00258     if(RecordNo == 0) {
00259        std::cout<<"ERROR: No Luminosity curve parameters found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl;
00260        exit(1);
00261      }
00262    
00263      if(RecordNo >= 2 && std::atoi(ParVer.c_str()) != 0) {
00264        std::cout<<"ERROR: More than two Lum. curve parameters records found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl;
00265        exit(1);
00266      } 
00267    
00268      return RETOk;
00269   }
00270 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBackgroundInfo std::vector< std::string > &  fileInfor,
std::string  query
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBackgroundInfo std::vector< std::string > &  fileInfor,
int  runNo
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBackgroundInfo std::vector< std::string > &  fileInfor,
std::string  query
 

00603               {
00604     std::cout << "ERROR Read the background file from the Database" << endreq;
00605     exit(1);
00606   }
00607      int RowNumber = results.size();
00608      if(RowNumber == 0){
00609          std::cout<<"ERROR:error searching background Data in the database, check your selection criterions"<<std::endl;
00610         return RETMySQLError;
00611      }
00612      //vRanTrgEvtNum.clear();
00613      fileInfor.clear();
00614      for(int i = 0; i < RowNumber; i++) {
00615        //int RanTrgEvtNum = 0;
00616        //RanTrgEvtNum = std::atoi((*results[i])["NumEvent"]);
00617        //if(RanTrgEvtNum != 0) vRanTrgEvtNum.push_back(RanTrgEvtNum);
00618        //if(RanTrgEvtNum != 0) {
00619          fileInfor.push_back((*results[i])["FilePath"]);
00620          fileInfor.push_back((*results[i])["FileName"]);
00621        //}
00622      }
00623 
00624     if(fileInfor.size() == 0) {
00625       std::cout<<"WARNING: the total bg event number in your selected bg files is zero, it will abort after error message" << std::endl;
00626       return RETNoSchemaMatch;
00627     }
00628 
00629     return RETOk;
00630   }
00631 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBackgroundInfo std::vector< std::string > &  fileInfor,
int  runNo
 

00562               {
00563     std::cout << "ERROR Read the background file from the Database" << endreq;
00564     exit(1);
00565   }
00566 
00567      int RowNumber = results.size();
00568      if(RowNumber == 0){
00569          std::cout<<"WARNING: No Bg infor. in this run!"<<std::endl;
00570         return RETNoSchemaMatch;
00571      }
00572      //vRanTrgEvtNum.clear();
00573      fileInfor.clear();
00574      for(int i = 0; i < RowNumber; i++) {
00575        //int RanTrgEvtNum = 0;
00576        //RanTrgEvtNum = std::atoi((*results[i])["NumEvent"]);
00577        //if(RanTrgEvtNum != 0) vRanTrgEvtNum.push_back(RanTrgEvtNum); 
00578        //if(RanTrgEvtNum != 0) {
00579          fileInfor.push_back((*results[i])["FilePath"]);
00580          fileInfor.push_back((*results[i])["FileName"]);
00581        //}
00582      }
00583    
00584     if(fileInfor.size() == 0) {
00585       std::cout<<"WARNING: the total bg event number in run " << runNo << " is zero, it will use other run's bg" << std::endl;
00586       return RETNoSchemaMatch;
00587     }
00588 
00589     return RETOk;
00590   }
00591 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBunchInfo std::vector< std::string > &  bunch,
int  runNo,
std::string  SftVer,
std::string  ParVer
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadBunchInfo std::vector< std::string > &  bunch,
int  runNo,
std::string  SftVer,
std::string  ParVer
 

00278                                    {
00279     sprintf(stmt1,"select Vx,Vy,Vz,AcSigmaVx,AcSigmaVy,SigmaVz,ParVer from BeamPar where runNo = %d && SftVer = \"%s\"",run_No,SftVer.c_str());
00280   }
00281   else {
00282     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());
00283   }
00284 */    
00285 
00286   DatabaseRecordVector results;
00287   results.clear();
00288   int status = m_dbsvc->query("offlinedb",stmt1,results);
00289   if(status<0){
00290     std::cout << "ERROR Read the bunch from the Database" << endreq;
00291     exit(1);
00292   }
00293 
00294      int RowNumber = results.size();
00295      if(RowNumber == 0){
00296          std::cout<<"WARNING: No bunch Data in this run! Please check your selection criteria (runNo, SftVer, ParVer)"<<std::endl;
00297         return RETNoSchemaMatch;
00298      }
00299 
00300      int ParVerID = 0; 
00301      int RecordNo = 0;
00302      if(std::atoi(ParVer.c_str()) == 0) {
00303        for(int i = 0; i < RowNumber; i++) {
00304          if((std::atoi((*results[i])["ParVer"]) > ParVerID)&&((*results[i])["SftVer"]==SftVer)) { 
00305            bunch.clear();
00306            bunch.push_back((*results[i])["Vx"]);
00307            bunch.push_back((*results[i])["Vy"]);
00308            bunch.push_back((*results[i])["Vz"]);
00309            bunch.push_back((*results[i])["AcSigmaVx"]);
00310            bunch.push_back((*results[i])["AcSigmaVy"]);
00311            bunch.push_back((*results[i])["SigmaVz"]);
00312            ParVerID = std::atoi((*results[i])["ParVer"]);
00313            RecordNo++;
00314          }
00315        }
00316      }
00317      else {
00318        RecordNo = 0;
00319        for(int i = 0; i < RowNumber; i++) {
00320          if((std::atoi((*results[i])["ParVer"]) == std::atoi(ParVer.c_str()))&&((*results[i])["SftVer"]==SftVer)) { 
00321            bunch.clear();
00322            bunch.push_back((*results[i])["Vx"]);
00323            bunch.push_back((*results[i])["Vy"]);
00324            bunch.push_back((*results[i])["Vz"]);
00325            bunch.push_back((*results[i])["AcSigmaVx"]);
00326            bunch.push_back((*results[i])["AcSigmaVy"]);
00327            bunch.push_back((*results[i])["SigmaVz"]);
00328            RecordNo++;
00329          }
00330        }
00331      }
00332 
00333      if(RecordNo == 0) {
00334        std::cout<<"WARNING: No bunch infor. found in this run, it will use other run's"<<std::endl;
00335        return RETNoSchemaMatch;
00336      }
00337 
00338      if(RecordNo >= 2 && std::atoi(ParVer.c_str()) != 0) {
00339        std::cout<<"ERROR: More than two bunch records found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl;
00340        exit(1);
00341      }
00342 
00343      return RETOk;
00344   }
00345 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadLumInfo std::string &  Lum,
int  runNo,
std::string  SftVer,
std::string  ParVer
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadLumInfo std::string &  Lum,
int  runNo,
std::string  SftVer,
std::string  ParVer
 

00156                                                                                                                        {
00157     //Read Luminosity information
00158    char stmt1[200];
00159    int run_No =std::abs(runNo);
00160    sprintf(stmt1,"select OfflineTwoGam,SftVer,ParVer from OfflineLum where RunNo = %d",run_No);
00161 /*
00162   if(std::atoi(ParVer.c_str()) == 0) {
00163     sprintf(stmt1,"select OfflineTwoGam,ParVer from OfflineLum where RunNo = %d && SftVer = \"%s\"",run_No,SftVer.c_str());
00164   }
00165   else {
00166     sprintf(stmt1,"select OfflineTwoGam from OfflineLum where RunNo = %d && SftVer = \"%s\" && ParVer = \"%s\"",run_No,SftVer.c_str(),ParVer.c_str());
00167   }
00168 */  
00169   DatabaseRecordVector results;
00170   results.clear();
00171   int status = m_dbsvc->query("offlinedb",stmt1,results);
00172   if(status<0){
00173     std::cout << "ERROR Read the luminosity from the Database" << endreq;
00174     exit(1);
00175   }
00176 
00177   int RowNumber = results.size();
00178   if(RowNumber == 0){
00179     std::cout<<"WARNING: No Luminosity Data in this run, return 0."<<std::endl;
00180     Lum = "0";
00181     return RETOk;
00182   }
00183 
00184    int ParVerID = 0;
00185    int RecordNo = 0;
00186    if(std::atoi(ParVer.c_str()) == 0) {
00187      for(int i = 0; i < RowNumber; i++) {
00188        if((std::atoi((*results[i])["ParVer"]) > ParVerID)&&((*results[i])["SftVer"]==SftVer)) { Lum = (*results[i])["OfflineTwoGam"]; ParVerID = std::atoi((*results[i])["ParVer"]); RecordNo++;}
00189      }
00190    }
00191    else {
00192      RecordNo = 0;
00193      for(int i = 0; i < RowNumber; i++) {
00194        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++;}
00195      }
00196    }
00197 
00198    if(RecordNo == 0) {
00199      //std::cout<<"ERROR: No Luminosity infor. found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl;
00200      //std::abort();
00201      std::cout<<"WARNING: No Luminosity infor. found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl;
00202      Lum = "0";
00203      return RETOk;
00204                      
00205    }
00206 
00207    if(RecordNo >= 2 && std::atoi(ParVer.c_str()) != 0) {
00208      std::cout<<"ERROR: More than two Lum. records found by your selection criteria, please check it (SftVer, ParVer)"<<std::endl;
00209      exit(1);
00210    }
00211 
00212    return RETOk;
00213 }

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadTofThreshInfo std::vector< std::string > &  tofThresh,
int  runNo
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadTofThreshInfo std::vector< std::string > &  tofThresh,
int  runNo
 

00642               {
00643     std::cout << "ERROR Read the Tof threshold from the Database" << endreq;
00644     exit(1);
00645   }
00646      int RowNumber = results.size();
00647      if(RowNumber!=1){
00648          std::cout<<"ERROR:error searching TFEE_fileid Data in the database, check your selection criterions"<<std::endl;
00649         return RETMySQLError;
00650      }
00651      int i_tfee_fileid = std::atoi((*results[0])["TFEE_fileid"]);
00652      std::cout<<"TFEE file id is "<<i_tfee_fileid<<std::endl;
00653      results.clear();
00654 
00655      if(i_tfee_fileid == m_tfee_fileid) {
00656       std::cout<<"Don't need to update TOF FEE threshold, it is same with the last run!"<<std::endl;
00657     }
00658     else {
00659       m_tfee_fileid = i_tfee_fileid;
00660       m_tofThresh.clear();
00661 
00662       sprintf(stmt1,"select PhysAddress,BarrelEnd,HighThreshold,LowThreshold from TFEE where FileId = %d ",i_tfee_fileid);
00663       int status1 = m_dbsvc->query("run",stmt1,results);
00664       if(status1<0){
00665         std::cout << "ERROR Read the Tof threshold from the Database 1" << endreq;
00666         exit(1);
00667      }
00668      int RowNumber = results.size();
00669      if(RowNumber == 0){
00670          std::cout<<"WARNING: No TFEE infor. in this run!"<<std::endl;
00671         return RETNoSchemaMatch;
00672      }  
00673      for(int i = 0; i < RowNumber; i++) {
00674        m_tofThresh.push_back((*results[i])["PhysAddress"]); 
00675        m_tofThresh.push_back((*results[i])["BarrelEnd"]); 
00676        m_tofThresh.push_back((*results[i])["HighThreshold"]); 
00677        m_tofThresh.push_back((*results[i])["LowThreshold"]); 
00678      }
00679      results.clear();
00680    }
00681  
00682    tofThresh = m_tofThresh;
00683 
00684     return RETOk;
00685   }
00686 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadTrgTableInfo std::vector< std::string > &  trgTable,
int  runNo
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getReadTrgTableInfo std::vector< std::string > &  trgTable,
int  runNo
 

00356               {
00357     std::cout << "ERROR Read the trigger table from the Database" << endreq;
00358     exit(1);
00359   }
00360 
00361      int RowNumber = results.size();
00362      if(RowNumber!=1){
00363          std::cout<<"ERROR:error searching Trigger Type Data in the database, check your selection criteria"<<std::endl;
00364         return RETMySQLError;
00365      }
00366      int i_trgTpye = std::atoi((*results[0])["trgtable_id"]);
00367      std::cout<<"Obj_id is "<<i_trgTpye<<std::endl;
00368      results.clear();
00369 
00370     if(i_trgTpye == m_trgTpye) {
00371       std::cout<<"Don't need to update trigger table, it is same with the last run!"<<std::endl;
00372     }
00373     else {
00374       m_trgTpye = i_trgTpye;
00375       m_trgTable.clear();
00376       //retrieve EventChannelEnableRegister from database
00377       sprintf(stmt1,"select EventChannelEnableRegister from TrgTable where Obj_id = %d ", i_trgTpye);
00378       int status1 = m_dbsvc->query("run",stmt1,results);
00379       if(status1<0){
00380         std::cout << "ERROR Read the trigger table from the Database 1" << endreq;
00381         exit(1);
00382       }
00383        RowNumber = results.size();
00384        if(RowNumber!=1){
00385            std::cout<<"ERROR:error searching Trigger Type Data in the database, check your selection criterions"<<std::endl;
00386           return RETMySQLError;
00387        }  
00388        m_trgTable.push_back((*results[0])["EventChannelEnableRegister"]);
00389        results.clear(); 
00390 
00391       //retrieve TrgTable_Channel from database
00392       for(int i = 1; i < 17; i++)
00393         for(int j = 1; j < 5; j++) {
00394           if(i < 10) sprintf(stmt1,"select TrgTable_CH0%d_%d from TrgTable where Obj_id = %d ", i, j, i_trgTpye);
00395           else  sprintf(stmt1,"select TrgTable_CH%d_%d from TrgTable where Obj_id = %d ", i, j, i_trgTpye);
00396           int status2 = m_dbsvc->query("run",stmt1,results);
00397          if(status2<0){
00398             std::cout << "ERROR Read the trigger table from the Database 2" << endreq;
00399             exit(1);
00400           }
00401            RowNumber = results.size();
00402            if(RowNumber!=1){
00403                std::cout<<"ERROR:error searching TrgTable Data in the database, check your selection criterions"<<std::endl;
00404               return RETMySQLError;
00405            }
00406           if(i<10) sprintf(stmt1,"TrgTable_CH0%d_%d", i, j);
00407           else sprintf(stmt1,"TrgTable_CH%d_%d", i, j);
00408           m_trgTable.push_back((*results[0])[stmt1]);
00409           results.clear();
00410       }
00411     }
00412     trgTable = m_trgTable;
00413 
00414     return RETOk;
00415   }
00416 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getRunInfo std::vector< std::string > &  runInfo,
int  runNo
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getRunInfo std::vector< std::string > &  runInfo,
int  runNo
 

00697               {
00698     std::cout << "ERROR Read the run information from the Database" << endreq;
00699     exit(1);
00700   } 
00701      int RowNumber = results.size();
00702      if(RowNumber == 0){
00703          std::cout<<"WARNING: No run information in this run!"<<std::endl;
00704         return RETNoSchemaMatch;
00705      }  
00706     
00707      for(int i = 0; i < RowNumber; i++) {
00708        for(std::map<std::string,char*>::iterator iter = (*results[i]).begin(); iter != (*results[i]).end(); iter++) {
00709          runInfo.push_back(iter->second);
00710        }
00711      }
00712 
00713      return RETOk; 
00714   }
00715 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getTrgConfigInfo int  runNo  ) 
 

ConnectionProvider::eRet RealDBUtil::ConnectionProvider::getTrgConfigInfo int  runNo  ) 
 

00511                        {
00512       std::cout << "ERROR: Read the Trg_fileid from RunParams, exit." << endl;
00513       exit(1);
00514     }
00515 
00516     if(rowNumber > 1){
00517       std::cout<<"WARNNING: there are more than one record for Trg_fileid in run " << runNo << ", the first one will be selected."<<std::endl;
00518     }
00519     int trg_fileid = std::atoi((*results[0])["Trg_fileid"]);
00520 
00521     sprintf(stmt1,"select EtotDataSteps,VthBEtotH,VthEEtotH,VthEtotL,VthEtotM,VthBLZ,VthDiffB,VthDiffE,VthBalBLK,VthBalEEMC,VthDiffMin from Trg_EACC where FileId = %d ", trg_fileid);
00522 
00523     results.clear();
00524     rowNumber = m_dbsvc->query("run",stmt1,results);
00525     if( rowNumber <= 0){
00526       std::cout << "ERROR: Read the EACC config infor. from Trg_EACC, exit." << endl;
00527       exit(1);
00528     }
00529 
00530     if(rowNumber > 1){
00531       std::cout<<"WARNNING: there are more than one record for EACC in run " << runNo << ", the first one will be selected."<<std::endl;
00532     }
00533 
00534     m_EtotDataSteps = std::atoi((*results[0])["EtotDataSteps"]);
00535     m_VthBEtotH = std::atoi((*results[0])["VthBEtotH"]);
00536     m_VthEEtotH = std::atoi((*results[0])["VthEEtotH"]);
00537     m_VthEtotL = std::atoi((*results[0])["VthEtotL"]);
00538     m_VthEtotM = std::atoi((*results[0])["VthEtotM"]);
00539     m_VthBLZ = std::atoi((*results[0])["VthBLZ"]);
00540     m_VthDiffB = std::atoi((*results[0])["VthDiffB"]);
00541     m_VthDiffE = std::atoi((*results[0])["VthDiffE"]);
00542     m_VthBalBLK = std::atoi((*results[0])["VthBalBLK"]);
00543     m_VthBalEEMC = std::atoi((*results[0])["VthBalEEMC"]);
00544     m_VthDiffMin = std::atoi((*results[0])["VthDiffMin"]);
00545     
00546     return RETOk;
00547   }
00548 

int RealDBUtil::ConnectionProvider::getVthBalBLK  )  [inline]
 

00074 { return m_VthBalBLK; }

int RealDBUtil::ConnectionProvider::getVthBalBLK  )  [inline]
 

00074 { return m_VthBalBLK; }

int RealDBUtil::ConnectionProvider::getVthBalEEMC  )  [inline]
 

00075 { return m_VthBalEEMC; }

int RealDBUtil::ConnectionProvider::getVthBalEEMC  )  [inline]
 

00075 { return m_VthBalEEMC; }

int RealDBUtil::ConnectionProvider::getVthBEtotH  )  [inline]
 

00067 { return m_VthBEtotH; }

int RealDBUtil::ConnectionProvider::getVthBEtotH  )  [inline]
 

00067 { return m_VthBEtotH; }

int RealDBUtil::ConnectionProvider::getVthBLZ  )  [inline]
 

00071 { return m_VthBLZ; }

int RealDBUtil::ConnectionProvider::getVthBLZ  )  [inline]
 

00071 { return m_VthBLZ; }

int RealDBUtil::ConnectionProvider::getVthDiffB  )  [inline]
 

00072 { return m_VthDiffB; }

int RealDBUtil::ConnectionProvider::getVthDiffB  )  [inline]
 

00072 { return m_VthDiffB; }

int RealDBUtil::ConnectionProvider::getVthDiffE  )  [inline]
 

00073 { return m_VthDiffE; }

int RealDBUtil::ConnectionProvider::getVthDiffE  )  [inline]
 

00073 { return m_VthDiffE; }

int RealDBUtil::ConnectionProvider::getVthDiffMin  )  [inline]
 

00076 { return m_VthDiffMin; }

int RealDBUtil::ConnectionProvider::getVthDiffMin  )  [inline]
 

00076 { return m_VthDiffMin; }

int RealDBUtil::ConnectionProvider::getVthEEtotH  )  [inline]
 

00068 { return m_VthEEtotH; }

int RealDBUtil::ConnectionProvider::getVthEEtotH  )  [inline]
 

00068 { return m_VthEEtotH; }

int RealDBUtil::ConnectionProvider::getVthEtotL  )  [inline]
 

00069 { return m_VthEtotL; }

int RealDBUtil::ConnectionProvider::getVthEtotL  )  [inline]
 

00069 { return m_VthEtotL; }

int RealDBUtil::ConnectionProvider::getVthEtotM  )  [inline]
 

00070 { return m_VthEtotM; }

int RealDBUtil::ConnectionProvider::getVthEtotM  )  [inline]
 

00070 { return m_VthEtotM; }

std::vector<std::string> RealDBUtil::ConnectionProvider::split const std::string &  src,
std::string  delimit,
std::string  null_subst = ""
 

std::vector< std::string > RealDBUtil::ConnectionProvider::split const std::string &  src,
std::string  delimit,
std::string  null_subst = ""
 

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   }


Member Data Documentation

int RealDBUtil::ConnectionProvider::id_num [private]
 

IDatabaseSvc* RealDBUtil::ConnectionProvider::m_dbsvc [private]
 

IDatabaseSvc* RealDBUtil::ConnectionProvider::m_dbsvc [private]
 

int RealDBUtil::ConnectionProvider::m_EtotDataSteps [private]
 

int RealDBUtil::ConnectionProvider::m_tfee_fileid [private]
 

std::vector<std::string> RealDBUtil::ConnectionProvider::m_tofThresh [private]
 

std::vector<std::string> RealDBUtil::ConnectionProvider::m_tofThresh [private]
 

std::vector<std::string> RealDBUtil::ConnectionProvider::m_trgTable [private]
 

std::vector<std::string> RealDBUtil::ConnectionProvider::m_trgTable [private]
 

int RealDBUtil::ConnectionProvider::m_trgTpye [private]
 

int RealDBUtil::ConnectionProvider::m_VthBalBLK [private]
 

int RealDBUtil::ConnectionProvider::m_VthBalEEMC [private]
 

int RealDBUtil::ConnectionProvider::m_VthBEtotH [private]
 

int RealDBUtil::ConnectionProvider::m_VthBLZ [private]
 

int RealDBUtil::ConnectionProvider::m_VthDiffB [private]
 

int RealDBUtil::ConnectionProvider::m_VthDiffE [private]
 

int RealDBUtil::ConnectionProvider::m_VthDiffMin [private]
 

int RealDBUtil::ConnectionProvider::m_VthEEtotH [private]
 

int RealDBUtil::ConnectionProvider::m_VthEtotL [private]
 

int RealDBUtil::ConnectionProvider::m_VthEtotM [private]
 

std::string* RealDBUtil::ConnectionProvider::trgGain[6500] [private]
 

std::string* RealDBUtil::ConnectionProvider::trgGain[6500] [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Feb 2 19:23:05 2011 for BOSS6.5.5 by  doxygen 1.3.9.1