41 MsgStream log(messageService(), name());
42 log << MSG::INFO <<
"RealizationSvc::initialize()" << endreq;
44 StatusCode sc = Service::initialize();
45 if( sc.isFailure() )
return sc;
47 if(m_SftVer ==
"NONE") m_SftVer = getenv(
"BES_RELEASE");
49 for(
unsigned int i = 0; i < m_runNoList.size(); i++) {
50 if(m_runNoList[i] != 0) {
51 std::cout <<
"run id : " << m_runNoList[i] << std::endl;
52 if(find(m_runIdList.begin(),m_runIdList.end(),m_runNoList[i]) == m_runIdList.end()) m_runIdList.push_back(m_runNoList[i]);
53 else log << MSG::ALWAYS <<
"RunNo "<<m_runNoList[i]<<
" repeated in run list"<<endreq;
56 if(i == 0 || (i+1) >= m_runNoList.size()) log << MSG::ERROR <<
"Please check your run id list, it is wrong" << endreq;
57 if(m_runNoList[i+1] < m_runNoList[i-1]) {
58 for(
int j = m_runNoList[i+1]+1; j < m_runNoList[i-1]; j++) {
59 if(find(m_runIdList.begin(),m_runIdList.end(),j) == m_runIdList.end()) m_runIdList.push_back(j);
60 else log << MSG::ALWAYS <<
"RunNo "<<j<<
" repeated in run list"<<endreq;
64 for(
int j = m_runNoList[i-1]+1; j < m_runNoList[i+1]; j++) {
65 if(find(m_runIdList.begin(),m_runIdList.end(),j) == m_runIdList.end()) m_runIdList.push_back(j);
66 else log << MSG::ALWAYS <<
"RunNo "<<j<<
" repeated in run list"<<endreq;
71 m_runID = m_runIdList[0];
73 int runMin = m_runID, runMax = m_runID;
74 for (
unsigned int i = 1; i < m_runIdList.size(); ++i ) {
75 int _run = m_runIdList[i];
76 if ( _run < runMin ) {
79 else if ( _run > runMax ) {
84 sc = service(
"DetVerSvc", idvSvc);
86 if ( dvSvc->
fromRun(abs(runMin)) != dvSvc->
fromRun(abs(runMax)) ) {
87 log << MSG::ERROR <<
"wrong run range ["
88 << runMin <<
" to " << runMax <<
"], crossed detector configuration" << endreq;
89 return StatusCode::FAILURE;
94 log << MSG::ERROR <<
"Could not open connection to database" << endreq;
98 sc = service(
"IncidentSvc", incsvc);
100 if( sc.isSuccess() ){
101 incsvc -> addListener(
this,
"NewRun", priority);
104 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
105 if (sc.isFailure() ) {
106 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endreq;
110 return StatusCode::SUCCESS;
167 MsgStream log( messageService(), name() );
170 std::vector<std::string> Bgfilename;
173 std::vector<std::string> fileInfor;
176 log << MSG::ERROR <<
"Could not find background infor., exit." << endreq;
180 for(
unsigned int i = 0; i < fileInfor.size(); i+=2)
182 Bgfilename.push_back(fileInfor[i]+
"/"+fileInfor[i+1]);
186 for(
unsigned int i = 0; i < Bgfilename.size(); i++) {
187 log << MSG::INFO <<
"Background file name: " << Bgfilename[i] << endreq;
263 MsgStream log( messageService(), name() );
264 log << MSG::DEBUG <<
"In getCaliConst" << endreq;
271 if(m_ifReadBunch ==
true) {
272 std::vector<std::string> sbunch;
273 std::vector<double> bunchInfo;
274 ConnectionProvider::eRet e = m_connect->
getReadBunchInfo(sbunch,
runNo,m_SftVer,m_ParVer,m_bossRelease);
277 for(
int id = 1;
true;
id++) {
287 if(last ==
true) log << MSG::INFO <<
"Use Bunch infor. of run " <<
runNo+
id <<
" instead of run " <<
runNo << endreq;
288 if(last ==
false) log << MSG::INFO <<
"Use Bunch infor. of run " <<
runNo-
id <<
" instead of run " <<
runNo << endreq;
293 if(e != 0 && e != 7) {
294 log << MSG::ERROR <<
"Could not find Bunch infor., exit." << endreq;
297 for(
unsigned int i = 0; i < sbunch.size(); i++)
299 bunchInfo.push_back(atof(sbunch[i].c_str()));
303 if(bunchInfo.size() == 6)
306 m_bunch_x = 10*bunchInfo[0];
307 m_bunch_y = 10*bunchInfo[1];
308 m_bunch_z = 10*bunchInfo[2];
309 m_sigma_x = 10*bunchInfo[3];
310 m_sigma_y = 10*bunchInfo[4];
311 m_sigma_z = 10*bunchInfo[5];
312 log << MSG::INFO <<
"BunchPosX: " << m_bunch_x <<
" BunchPosY: " << m_bunch_y <<
" BunchPosZ: " << m_bunch_z <<
" in Run " <<
runNo << endreq;
313 log << MSG::INFO <<
"BunchSigmaX: " << m_sigma_x <<
" BunchSigmaY: " << m_sigma_y <<
" BunchSigmaZ: " << m_sigma_z <<
" in Run " <<
runNo << endreq;
316 log << MSG::ERROR <<
"Please check the bunch information, the size is " << bunchInfo.size() << endreq;
322 if(m_ifReadTrg ==
true) {
324 std::vector<std::string> strgTable;
327 log << MSG::ERROR <<
"Could not find TrgTable infor., exit." << endreq;
330 for(
unsigned int i = 0; i < strgTable.size(); i++)
333 for (
unsigned int j = 0; j < (strgTable[i]).length(); j++)
335 value = value*10 + (strgTable[i][j] -
'0');
337 m_trgTable.push_back(uint32_t(value));
340 if(m_trgTable.size() != 65) log << MSG::ERROR <<
"Please check the TrgTable information, the size is " << m_trgTable.size() << endreq;
342 std::vector<double> vtrgGain;
345 log << MSG::ERROR <<
"Could not find emc gain infor., exit." << endreq;
348 for(
unsigned int i = 0; i < vtrgGain.size(); i++) {
349 m_trgGain[i] = vtrgGain[i];
355 log << MSG::ERROR <<
"Could not find Trigger config infor., exit." << endreq;
372 if(m_ifReadRandTrg ==
true) {
373 std::vector<std::string> fileInfor;
377 for(
int id = 1;
true;
id++) {
387 if(last ==
true) log << MSG::INFO <<
"Use Bg files of run " <<
runNo+
id <<
" instead of run " <<
runNo << endreq;
388 if(last ==
false) log << MSG::INFO <<
"Use Bg files of run " <<
runNo-
id <<
" instead of run " <<
runNo << endreq;
393 if(e != 0 && e != 7) {
394 log << MSG::ERROR <<
"Could not find background infor., exit." << endreq;
397 m_bgfilename.clear();
398 for(
unsigned int i = 0; i < fileInfor.size(); i+=2)
400 m_bgfilename.push_back(fileInfor[i]+
"/"+fileInfor[i+1]);
403 for(
unsigned int i = 0; i < m_bgfilename.size(); i++) {
404 log << MSG::INFO <<
"Background file name: " << m_bgfilename[i] <<
" in run " <<
runNo << endreq;
408 std::string srunTime;
409 std::string stau_value;
410 e = m_connect->
getLumCurvePar(srunTime, stau_value,
runNo, m_SftVer, m_ParVer, m_bossRelease);
412 log << MSG::ERROR <<
"Could not find Luminosity curve parameters, exit." << endreq;
415 m_runTotalTime = std::atof(srunTime.c_str());
416 m_tauValue = std::atof(stau_value.c_str());
417 log << MSG::INFO <<
"Total time is " << m_runTotalTime <<
", tau is " << m_tauValue <<
" in run " <<
runNo <<
". " << endreq;
421 if(m_ifReadTFEE ==
true) {
425 log << MSG::ERROR <<
"Could not find TFEE infor., exit." << endreq;
429 for(
unsigned int i = 0; i < m_tfee.size(); i++) {
430 log << MSG::INFO <<
"TFEE ----> " << m_tfee[i] << endreq;
435 if(m_ifReadRunInfo ==
true) {
437 std::vector<std::string> srunInfo;
440 log << MSG::ERROR <<
"Could not find run infor., exit." << endreq;
443 for(
unsigned int i = 0; i < srunInfo.size(); i++)
445 m_runInfo.push_back(atof(srunInfo[i].c_str()));
449 for(
unsigned int i = 0; i < m_runInfo.size(); i++) {
450 log << MSG::INFO <<
"runInfo ----> " << m_runInfo[i] << endreq;