44 base_class (name, svcloc){
46 declareProperty(
"Host" , host = std::string(
"bes3db2.ihep.ac.cn"));
47 declareProperty(
"DbName" , dbName = std::string(
"offlinedb"));
48 declareProperty(
"UserName" , userName = std::string(
"guest"));
49 declareProperty(
"Password" , password = std::string(
"guestpass"));
50 declareProperty(
"IsData" , m_isData = std::string(
"default"));
51 declareProperty(
"BossRelease",m_bossRelease = std::string(
"default"));
52 declareProperty(
"TofEnergyPar",m_calPar=
"default");
53 declareProperty(
"TofEnergyBossVer",m_bossVer=
"default");
120 std::string& CalParVer,
124 std::string BossRelease,
128 MsgStream log(
msgSvc(),
"TofEnergyCalibSvc" );
134 StatusCode sc=serviceLocator()->service(
"DatabaseSvc",
m_dbsvc,
true);
135 if (sc .isFailure() ) {
136 log << MSG::ERROR <<
" Unable to find DatabaseSvc " << endreq;
140 const char* bossRelease = BossRelease.c_str();
141 const char* dataType = DataType.c_str();
143 sprintf(stmt,
"select RunFrom,RunTo,SftVer,ParVer from CalVtxLumVer where BossRelease = '%s' and RunFrom <= %d and RunTo >= %d and DataType='%s' ",bossRelease,run_No,run_No,dataType);
147 std::cout<<
"ERROR:error searching with:"<<stmt<<std::endl;
152 runfrm=records1->
GetInt(
"RunFrom");
153 runto=records1->
GetInt(
"RunTo");
154 cout<<dataType<<
" runfrm,runto in getSftParVer is:"<<runfrm<<
"::::"<<runto<<endl;
159 cout<<
"ERROR: "<<dataType<<
" set overlapped run number in the table CalVtxLumVer"<<endl;
162 return StatusCode::SUCCESS;
165 MsgStream log(messageService(), name());
166 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
167 int run = eventHeader->runNumber();
178 cout <<
"This data is the MC sample with the Run Number: " << run << endl;
182 if(m_bossRelease==
"default") m_bossRelease = getenv(
"BES_RELEASE");
183 if(m_isData==
"default")
185 cout<<
"Please set the type of TofEnergy"<<endl;
188 if(m_isData==
"Data") cType=
"TofEnergyData";
189 if(m_isData==
"MC") cType=
"TofEnergyMC";
190 st1=
getSftParVer(m_bossVer,m_calPar,runfrm1,runto1,run,m_bossRelease,cType);
191 if(cType==
"TofEnergyData"){
192 sprintf(stmt1,
"select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergyCalib where BossVer = '%s' and RunFrom <= %d and RunTo >= %d and isData = '%s'", m_bossVer.c_str(), run, run, m_isData.c_str());}
193 else if(cType==
"TofEnergyMC"){
194 sprintf(stmt1,
"select CalibConst,Para1,Para2,Para3,Para4,Para5 from TofEnergySim where BossVer = '%s' and RunFrom <= %d and RunTo >= %d and isData = '%s'", m_bossVer.c_str(), run, run, m_isData.c_str());}
200 m_CalibConst = dbrec.
GetDouble(
"CalibConst");
207 cout<<
"BossReleaseVer="<<m_bossRelease.c_str()<<
"\t"<<
"TofEnergyBossVer="<<m_bossVer.c_str()<<endl;
208 cout<<
"m_CalibConst is:"<<m_CalibConst<<endl;
209 cout<<
"Para1="<<m_Para1<<
"\t"
210 <<
"Para2="<<m_Para2<<
"\t"
211 <<
"Para3="<<m_Para3<<
"\t"
212 <<
"Para4="<<m_Para4<<
"\t"
213 <<
"Para5="<<m_Para5<<endl;
214 cout <<
"Successfully fetch TofEnergyCalibSvc information for run: "
217 }
else if( row_no<=0 ) {
218 cout <<
" TofEnergyCalibSvc:: can not found TofEnergyCalibSvc information of run:"
219 << run <<
", boss version " << m_bossRelease << endl;
sprintf(cut,"kal_costheta0_em>-0.93&&kal_costheta0_em<0.93&&kal_pxy0_em>=0.05+%d*0.1&&kal_pxy0_em<0.15+%d*0.1&&NGch>=2", j, j)
StatusCode getSftParVer(std::string &SftVer, std::string &CalParVer, int &runfrm, int &runto, int RunNo, std::string BossRelease, std::string DataType)