CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
FieldDBUtil::ConnectionDB Class Reference

#include <ConnectionDB.h>

Public Types

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

Public Member Functions

 ConnectionDB ()
 Constructor keeps track of table of interest.
 
 ~ConnectionDB ()
 
ConnectionDB::eRet getReadSC_MagnetInfo (std::vector< double > &current, int runNo)
 
ConnectionDB::eRet getBeamEnergy (std::vector< double > &beamE, int runNo)
 
 ConnectionDB ()
 Constructor keeps track of table of interest.
 
 ~ConnectionDB ()
 
ConnectionDB::eRet getReadSC_MagnetInfo (std::vector< double > &current, int runNo)
 
ConnectionDB::eRet getBeamEnergy (std::vector< double > &beamE, int runNo)
 

Detailed Description

Member Enumeration Documentation

◆ eLevel [1/2]

◆ eLevel [2/2]

Used to form bit masks for dbs queries.

Enumerator
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 
LEVELProd 
LEVELDev 
LEVELTest 
LEVELSuperseded 

Definition at line 36 of file MagneticField/MagneticField-00-01-38/MagneticField/ConnectionDB.h.

36 {
37 LEVELProd = 1,
38 LEVELDev = 2,
39 LEVELTest = 4,
41 };

◆ eRet [1/2]

Enumerator
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 

Definition at line 25 of file InstallArea/include/MagneticField/MagneticField/ConnectionDB.h.

◆ eRet [2/2]

Enumerator
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 
RETOk 
RETBadCnfFile 
RETBadHost 
RETNoConnect 
RETWrongState 
RETBadValue 
RETMySQLError 
RETNoSchemaMatch 

Definition at line 25 of file MagneticField/MagneticField-00-01-38/MagneticField/ConnectionDB.h.

25 {
26 RETOk = 0,
27 RETBadCnfFile = 1,
28 RETBadHost = 2,
29 RETNoConnect = 3,
30 RETWrongState = 4,
31 RETBadValue = 5,
32 RETMySQLError = 6,
34 };

Constructor & Destructor Documentation

◆ ConnectionDB() [1/2]

FieldDBUtil::ConnectionDB::ConnectionDB ( )

Constructor keeps track of table of interest.

Definition at line 24 of file ConnectionDB.cxx.

24 {
25 StatusCode sc = Gaudi::svcLocator()->service("DatabaseSvc", m_dbsvc, true);
26 if (sc .isFailure() ) {
27 std::cout << "ERROR: In ConnectionDB()--> Unable to find DatabaseSvc " << std::endl;
28 }
29 }

◆ ~ConnectionDB() [1/2]

FieldDBUtil::ConnectionDB::~ConnectionDB ( )
inline

◆ ConnectionDB() [2/2]

FieldDBUtil::ConnectionDB::ConnectionDB ( )

Constructor keeps track of table of interest.

◆ ~ConnectionDB() [2/2]

FieldDBUtil::ConnectionDB::~ConnectionDB ( )
inline

Member Function Documentation

◆ getBeamEnergy() [1/2]

ConnectionDB::eRet FieldDBUtil::ConnectionDB::getBeamEnergy ( std::vector< double > &  beamE,
int  runNo 
)

Definition at line 77 of file ConnectionDB.cxx.

77 {
78 //Read magnetic field map
79 char stmt1[200];
80 int run_No = std::abs(runNo);
81
82 sprintf(stmt1,"select BPR_PRB,BER_PRB from RunParams where run_number = %d ",run_No);
83
85 results.clear();
86 int status = m_dbsvc->query("run",stmt1,results);
87 if(status<0){
88 std::cout << "ERROR Read the beam energy from the Database" << endreq;
89 exit(1);
90 }
91
92 int RowNumber = results.size();
93
94 if(RowNumber == 0) {
95 beamE.push_back(1.843); // for positron
96 beamE.push_back(1.843); // for electron
97
98 return RETOk;
99 }
100
101 if(RowNumber!=1){
102 std::cout<<"ERROR:error searching beam energy in the database, check your selection criterions"<<std::endl;
103 return RETMySQLError;
104 }
105
106 beamE.push_back(atof((*results[0])["BPR_PRB"])); // for positron
107 beamE.push_back(atof((*results[0])["BER_PRB"])); // for electron
108
109 return RETOk;
110 }
int runNo
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0

Referenced by MagneticFieldSvc::init_params().

◆ getBeamEnergy() [2/2]

ConnectionDB::eRet FieldDBUtil::ConnectionDB::getBeamEnergy ( std::vector< double > &  beamE,
int  runNo 
)

◆ getReadSC_MagnetInfo() [1/2]

ConnectionDB::eRet FieldDBUtil::ConnectionDB::getReadSC_MagnetInfo ( std::vector< double > &  current,
int  runNo 
)

Definition at line 32 of file ConnectionDB.cxx.

32 {
33
34#ifdef BEAN
35 static DatabaseSvc* m_dbsvc = 0;
36
37 if( !m_dbsvc ) {
38 m_dbsvc = DatabaseSvc::instance();
39 }
40#endif
41
42 //Read magnetic field map
43 char stmt1[200];
44 int run_No = std::abs(runNo);
45
46 sprintf(stmt1,"select Magnet_Current,SCQL,SCQR from SC_magnet where run_number = %d ",run_No);
47
48 DatabaseRecordVector results;
49 results.clear();
50 int status = m_dbsvc->query("run",stmt1,results);
51
52 if(status<0){
53 std::cout << "ERROR Read the SSM and SCQ current from the Database" << endl;
54 exit(1);
55 }
56
57 int RowNumber = results.size();
58 if(RowNumber!=1){
59 std::cout<<"ERROR:error searching SC_Magnet Data in the database, check your selection criterions"<<std::endl;
60 return RETMySQLError;
61 }
62
63 DatabaseRecord& rec = *results[0];
64 double ssm_curr = rec.GetDouble("Magnet_Current");
65 double scql_curr = rec.GetDouble("SCQL");
66 double scqr_curr = rec.GetDouble("SCQR");
67
68 // save results in vector
69 current.resize(3);
70 current[0] = ssm_curr;
71 current[1] = scql_curr;
72 current[2] = scqr_curr;
73
74 return RETOk;
75 }
int query(const std::string &dbName, const std::string &sql)

Referenced by MagneticFieldSvc::init_params().

◆ getReadSC_MagnetInfo() [2/2]

ConnectionDB::eRet FieldDBUtil::ConnectionDB::getReadSC_MagnetInfo ( std::vector< double > &  current,
int  runNo 
)

The documentation for this class was generated from the following files: