42 MsgStream log(
msgSvc(), name() );
43 log << MSG::INFO <<
"RealizationSvc::initialize()" << endmsg;
45 StatusCode sc = Service::initialize();
46 if ( sc.isFailure() )
return sc;
48 if ( m_SftVer ==
"NONE" ) m_SftVer = getenv(
"BES_RELEASE" );
50 if ( m_runNoList.size() == 0 )
52 log << MSG::ERROR <<
"Please set the run id list" << endmsg;
53 return StatusCode::FAILURE;
56 for (
unsigned int i = 0; i < m_runNoList.size(); i++ )
58 if ( m_runNoList[i] != 0 )
60 std::cout <<
"run id : " << m_runNoList[i] << std::endl;
61 if ( find( m_runIdList.begin(), m_runIdList.end(), m_runNoList[i] ) ==
63 { m_runIdList.push_back( m_runNoList[i] ); }
66 log << MSG::ALWAYS <<
"RunNo " << m_runNoList[i] <<
" repeated in run list" << endmsg;
71 if ( i == 0 || ( i + 1 ) >= m_runNoList.size() )
72 log << MSG::ERROR <<
"Please check your run id list, it is wrong" << endmsg;
73 if ( m_runNoList[i + 1] < m_runNoList[i - 1] )
75 for (
int j = m_runNoList[i + 1] + 1; j < m_runNoList[i - 1]; j++ )
77 if ( find( m_runIdList.begin(), m_runIdList.end(), j ) == m_runIdList.end() )
78 m_runIdList.push_back( j );
79 else log << MSG::ALWAYS <<
"RunNo " << j <<
" repeated in run list" << endmsg;
84 for (
int j = m_runNoList[i - 1] + 1; j < m_runNoList[i + 1]; j++ )
86 if ( find( m_runIdList.begin(), m_runIdList.end(), j ) == m_runIdList.end() )
87 m_runIdList.push_back( j );
88 else log << MSG::ALWAYS <<
"RunNo " << j <<
" repeated in run list" << endmsg;
94 m_runID = m_runIdList[0];
96 int runMin = m_runID, runMax = m_runID;
97 for (
unsigned int i = 1; i < m_runIdList.size(); ++i )
99 int _run = m_runIdList[i];
100 if ( _run < runMin ) { runMin = _run; }
101 else if ( _run > runMax ) { runMax = _run; }
104 sc = service(
"DetVerSvc", idvSvc );
107 log << MSG::ERROR <<
"wrong run range [" << runMin <<
" to " << runMax
108 <<
"], crossed detector configuration" << endmsg;
109 return StatusCode::FAILURE;
113 if ( !m_connect ) { log << MSG::ERROR <<
"Could not open connection to database" << endmsg; }
115 IIncidentSvc* incsvc;
116 sc = service(
"IncidentSvc", incsvc );
118 if ( sc.isSuccess() ) { incsvc->addListener(
this,
"NewRun", priority ); }
120 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true );
121 if ( sc.isFailure() )
123 log << MSG::ERROR <<
"Unable to find EventDataSvc " << endmsg;
127 return StatusCode::SUCCESS;
285 MsgStream log(
msgSvc(), name() );
286 log << MSG::DEBUG <<
"In getCaliConst" << endmsg;
293 if ( m_ifReadBunch ==
true )
295 std::vector<std::string> sbunch;
296 std::vector<double> bunchInfo;
297 ConnectionProvider::eRet e =
298 m_connect->getReadBunchInfo( sbunch,
runNo, m_SftVer, m_ParVer, m_bossRelease );
302 for (
int id = 1;
true;
id++ )
304 e = m_connect->getReadBunchInfo( sbunch,
runNo +
id, m_SftVer, m_ParVer,
309 if ( (
runNo -
id ) > 0 )
311 e = m_connect->getReadBunchInfo( sbunch,
runNo -
id, m_SftVer, m_ParVer,
319 log << MSG::INFO <<
"Use Bunch infor. of run " <<
runNo +
id <<
" instead of run "
322 log << MSG::INFO <<
"Use Bunch infor. of run " <<
runNo -
id <<
" instead of run "
328 if ( e != 0 && e != 7 )
330 log << MSG::ERROR <<
"Could not find Bunch infor., exit." << endmsg;
333 for (
unsigned int i = 0; i < sbunch.size(); i++ )
334 { bunchInfo.push_back( atof( sbunch[i].c_str() ) ); }
337 if ( bunchInfo.size() == 6 )
340 m_bunch_x = 10 * bunchInfo[0];
341 m_bunch_y = 10 * bunchInfo[1];
342 m_bunch_z = 10 * bunchInfo[2];
343 m_sigma_x = 10 * bunchInfo[3];
344 m_sigma_y = 10 * bunchInfo[4];
345 m_sigma_z = 10 * bunchInfo[5];
346 log << MSG::INFO <<
"BunchPosX: " << m_bunch_x <<
" BunchPosY: " << m_bunch_y
347 <<
" BunchPosZ: " << m_bunch_z <<
" in Run " <<
runNo << endmsg;
348 log << MSG::INFO <<
"BunchSigmaX: " << m_sigma_x <<
" BunchSigmaY: " << m_sigma_y
349 <<
" BunchSigmaZ: " << m_sigma_z <<
" in Run " <<
runNo << endmsg;
353 log << MSG::ERROR <<
"Please check the bunch information, the size is "
354 << bunchInfo.size() << endmsg;
360 if ( m_ifReadTrg ==
true )
363 std::vector<std::string> strgTable;
364 ConnectionProvider::eRet e = m_connect->getReadTrgTableInfo( strgTable,
runNo );
367 log << MSG::ERROR <<
"Could not find TrgTable infor., exit." << endmsg;
370 for (
unsigned int i = 0; i < strgTable.size(); i++ )
373 for (
unsigned int j = 0; j < ( strgTable[i] ).length(); j++ )
374 { value = value * 10 + ( strgTable[i][j] -
'0' ); }
375 m_trgTable.push_back( uint32_t( value ) );
378 if ( m_trgTable.size() != 65 )
379 log << MSG::ERROR <<
"Please check the TrgTable information, the size is "
380 << m_trgTable.size() << endmsg;
382 std::vector<double> vtrgGain;
383 e = m_connect->getEmcGain( vtrgGain,
runNo );
386 log << MSG::ERROR <<
"Could not find emc gain infor., exit." << endmsg;
389 for (
unsigned int i = 0; i < vtrgGain.size(); i++ ) { m_trgGain[i] = vtrgGain[i]; }
392 e = m_connect->getTrgConfigInfo(
runNo );
395 log << MSG::ERROR <<
"Could not find Trigger config infor., exit." << endmsg;
398 m_EtotDataSteps = m_connect->getEtotDataSteps();
399 m_VthBEtotH = m_connect->getVthBEtotH();
400 m_VthEEtotH = m_connect->getVthEEtotH();
401 m_VthEtotL = m_connect->getVthEtotL();
402 m_VthEtotM = m_connect->getVthEtotM();
403 m_VthBLZ = m_connect->getVthBLZ();
404 m_VthDiffB = m_connect->getVthDiffB();
405 m_VthDiffE = m_connect->getVthDiffE();
406 m_VthBalBLK = m_connect->getVthBalBLK();
407 m_VthBalEEMC = m_connect->getVthBalEEMC();
408 m_VthDiffMin = m_connect->getVthDiffMin();
412 if ( m_ifReadRandTrg ==
true )
414 std::vector<std::string> fileInfor;
415 ConnectionProvider::eRet e = m_connect->getReadBackgroundInfo( fileInfor,
runNo );
419 for (
int id = 1;
true;
id++ )
421 e = m_connect->getReadBackgroundInfo( fileInfor,
runNo +
id );
425 if ( (
runNo -
id ) > 0 )
427 e = m_connect->getReadBackgroundInfo( fileInfor,
runNo -
id );
434 log << MSG::INFO <<
"Use Bg files of run " <<
runNo +
id <<
" instead of run "
437 log << MSG::INFO <<
"Use Bg files of run " <<
runNo -
id <<
" instead of run "
443 if ( e != 0 && e != 7 )
445 log << MSG::ERROR <<
"Could not find background infor., exit." << endmsg;
448 m_bgfilename.clear();
449 for (
unsigned int i = 0; i < fileInfor.size(); i += 2 )
450 { m_bgfilename.push_back( fileInfor[i] +
"/" + fileInfor[i + 1] ); }
452 for (
unsigned int i = 0; i < m_bgfilename.size(); i++ )
454 log << MSG::INFO <<
"Background file name: " << m_bgfilename[i] <<
" in run " <<
runNo
459 std::string srunTime;
460 std::string stau_value;
461 e = m_connect->getLumCurvePar( srunTime, stau_value,
runNo, m_SftVer, m_ParVer,
465 log << MSG::ERROR <<
"Could not find Luminosity curve parameters, exit." << endmsg;
468 m_runTotalTime = std::atof( srunTime.c_str() );
469 m_tauValue = std::atof( stau_value.c_str() );
470 log << MSG::INFO <<
"Total time is " << m_runTotalTime <<
", tau is " << m_tauValue
471 <<
" in run " <<
runNo <<
". " << endmsg;
475 if ( m_ifReadTFEE ==
true )
478 ConnectionProvider::eRet e = m_connect->getReadTofThreshInfo( m_tfee,
runNo );
481 log << MSG::ERROR <<
"Could not find TFEE infor., exit." << endmsg;
485 for (
unsigned int i = 0; i < m_tfee.size(); i++ )
486 { log << MSG::INFO <<
"TFEE ----> " << m_tfee[i] << endmsg; }
490 if ( m_ifReadRunInfo ==
true )
493 std::vector<std::string> srunInfo;
494 ConnectionProvider::eRet e = m_connect->getRunInfo( srunInfo,
runNo );
497 log << MSG::ERROR <<
"Could not find run infor., exit." << endmsg;
500 for (
unsigned int i = 0; i < srunInfo.size(); i++ )
501 { m_runInfo.push_back( atof( srunInfo[i].c_str() ) ); }
504 for (
unsigned int i = 0; i < m_runInfo.size(); i++ )
505 { log << MSG::INFO <<
"runInfo ----> " << m_runInfo[i] << endmsg; }