#include <MdcTunningSvc.h>
Inheritance diagram for MdcTunningSvc:
Public Member Functions | |
double | Delcostta (int layerId, double costta) |
double | Delcostta (int layerId, double costta) |
double | DeldriftD (int layerId, double driftD) |
double | DeldriftD (int layerId, double driftD) |
double | DelEtr_Sig (int lay, double enterA, int ilr, double driftD) |
double | DelEtr_Sig (int lay, double enterA, int ilr, double driftD) |
virtual StatusCode | finalize () |
virtual StatusCode | finalize () |
double | get_cellEff (int i, int j) |
double | get_cellEff (int i, int j) |
double | get_docaEff (int i, int j) |
double | get_docaEff (int i, int j) |
double | get_thetaEff (int i, int j) |
double | get_thetaEff (int i, int j) |
double | GetEff (int layerId, int cellId, double driftD, double cosTheta, int posFlag) |
double | GetEff (int layerId, int cellId, double driftD, double cosTheta, int posFlag) |
BesMdcRes * | getMdcRes () |
BesMdcRes * | getMdcRes () |
StatusCode | getMdcTuningTableInfo () |
StatusCode | getMdcTuningTableInfo () |
double | GetRes (int layerId, int cellId, double driftD, double cosTheta, int posFlag, double entranceAngle, double &mean, double &sigma) |
double | GetRes (int layerId, int cellId, double driftD, double cosTheta, int posFlag, double entranceAngle, double &mean, double &sigma) |
double | GetRes2 (int layerId, int cellId, double driftD, double cosTheta, int posFlag, double entranceAngle, double &f, double &mean1, double &sigma1, double &mean2, double &sigma2) |
double | GetRes2 (int layerId, int cellId, double driftD, double cosTheta, int posFlag, double entranceAngle, double &f, double &mean1, double &sigma1, double &mean2, double &sigma2) |
void | handle (const Incident &) |
void | handle (const Incident &) |
virtual StatusCode | initialize () |
virtual StatusCode | initialize () |
bool | initTuningConst () |
bool | initTuningConst () |
MdcTunningSvc (const std::string &name, ISvcLocator *svcloc) | |
MdcTunningSvc (const std::string &name, ISvcLocator *svcloc) | |
double | NewSig (int layerId, double driftD) |
double | NewSig (int layerId, double driftD) |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvUnknown) |
double | ResvEntr (int layerId, double enterA, int ilr, double driftD) |
double | ResvEntr (int layerId, double enterA, int ilr, double driftD) |
bool | setMcEff (std::string eff_con) |
bool | setMcEff (std::string eff_con) |
bool | setMcRes () |
bool | setMcRes () |
bool | setMcRes2 () |
bool | setMcRes2 () |
void | setMdcRes (std::string path) |
void | setMdcRes (std::string path) |
~MdcTunningSvc () | |
~MdcTunningSvc () | |
Static Public Member Functions | |
const InterfaceID & | interfaceID () |
const InterfaceID & | interfaceID () |
Private Attributes | |
double | cellEff [43][288] |
double | cellEff_2 [43][288] |
int | cellNo [43] |
MYSQL * | conn |
MYSQL * | conn |
std::string | dbName |
double | dD [18] |
double | docaEff [43][docaNo] |
double | docaEff_2 [43][docaNo] |
double | docaF [43][docaNo][2] |
double | docaF_2 [43][docaNo][2] |
double | docaMean1 [43][docaNo][2] |
double | docaMean1_2 [43][docaNo][2] |
double | docaMean2 [43][docaNo][2] |
double | docaMean2_2 [43][docaNo][2] |
double | docaRes [43][docaNo][2][2] |
double | docaRes_2 [43][docaNo][2][2] |
double | docaSigma1 [43][docaNo][2] |
double | docaSigma1_2 [43][docaNo][2] |
double | docaSigma2 [43][docaNo][2] |
double | docaSigma2_2 [43][docaNo][2] |
std::string | host |
BesMdcRes * | m_BesMdcRes |
BesMdcRes * | m_BesMdcRes |
bool | m_dbFlag |
std::string | m_effFile |
std::string | m_effFile_endcap |
int | m_EndcapTuning |
IDataProviderSvc * | m_eventSvc |
IDataProviderSvc * | m_eventSvc |
bool | m_fromDB |
std::string | m_path |
std::string | m_resFile |
std::string | m_resFile_endcap |
std::string | password |
unsigned int | serialNo |
std::string | table |
double | thetaEff [43][thetaNo] |
double | thetaEff_2 [43][thetaNo] |
std::string | userName |
Static Private Attributes | |
const int | docaNo = 60 |
const int | thetaNo = 40 |
|
00028 : 00029 Service (name, svcloc){ 00030 m_BesMdcRes=0; 00031 // declare properties 00032 declareProperty("UseDatabase",m_dbFlag=false); 00033 declareProperty("UseEndcapTuning",m_EndcapTuning=1); // 0:no endcap Tuning , 1: using endcap Tuning 00034 declareProperty("EffFile", m_effFile= std::string("no path")); 00035 declareProperty("ResFile", m_resFile= std::string("no path")); 00036 declareProperty("EffFile_endcap", m_effFile_endcap= std::string("no path")); 00037 declareProperty("ResFile_endcap", m_resFile_endcap= std::string("no path")); 00038 declareProperty("path_mdc", m_path= std::string("no path")); 00039 declareProperty("Host" , host = std::string("bes3db2.ihep.ac.cn")); 00040 declareProperty("DbName" , dbName = std::string("offlinedb")); 00041 declareProperty("UserName" , userName = std::string("guest")); 00042 declareProperty("Password" , password = std::string("guestpass")); 00043 declareProperty("SerialNo" , serialNo = 0); 00044 declareProperty("fromDB", m_fromDB= false); 00045 00046 int no[43]={40,44,48,56,64,72,80,80,76,76,88,88,100,100,112,112,128,128,140,140,160,160,160,160,176,176,176,176,208,208,208,208,240,240,240,240,256,256,256,256,288,288,288}; 00047 for(int i=0;i<43;i++){ 00048 cellNo[i]=no[i]; 00049 } 00050 }
|
|
00052 { 00053 if(m_BesMdcRes) delete m_BesMdcRes; 00054 }
|
|
|
|
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00350 { 00351 int binTa = 0; 00352 int maxTa = 15; 00353 double minCos = -0.8 ; 00354 double minCos2 = -0.7 ; 00355 double maxCos = 0.8 ; 00356 00357 for(int ii = 0; ii <16; ii++){ 00358 if((costta<minCos)||(costta>maxCos)){ 00359 binTa = maxTa; 00360 }else if((costta>=(minCos + ii*0.1))&&(costta<(minCos2 + ii*0.1))){ 00361 binTa = ii; 00362 } 00363 } 00364 00365 double y0D = (m_BesMdcRes -> getD_theta(layerId ,binTa)); 00366 double y1D = (m_BesMdcRes -> getD_theta(layerId ,binTa+1)); 00367 double y0M = (m_BesMdcRes -> getM_theta(layerId,binTa)); 00368 double y1M = (m_BesMdcRes -> getM_theta(layerId,binTa+1)); 00369 00370 double yD[16],yM[16],Del[16]; 00371 for(int ll =0;ll<16;ll++){ 00372 yD[ll] = y0D + (y1D - y0D)/0.1*(costta - (minCos + ll*0.1)); 00373 yM[ll] = y0M + (y1M - y0D)/0.1*(costta - (minCos + ll*0.1)); 00374 Del[ll] = yD[ll] - yM[ll] ; 00375 } 00376 00377 double delTha = 0; 00378 00379 if((binTa>=0)&&(binTa<=5)){ 00380 delTha = Del[binTa] * 0.118 ; 00381 }else if((binTa>5)&&(binTa<=10)){ 00382 delTha = Del[binTa] * 0.518 ; 00383 }else if((binTa>10)&&(binTa<=15)){ 00384 delTha = Del[binTa] * 0.218 ; 00385 } 00386 00387 return delTha ; 00388 00389 }
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00314 { 00315 int bindD = 0; 00316 int maxbin =8 ; 00317 double mindD = 0.0 ; 00318 double maxdD = 9.0 ; 00319 00320 for(int jj =0;jj<9;jj++){ 00321 if((driftD<mindD)||(driftD>maxdD)){ 00322 bindD = maxbin; 00323 }else if((driftD>=jj)&&(driftD<(jj+1))){ 00324 bindD = jj ; 00325 } 00326 } 00327 double y0D = (m_BesMdcRes -> getD_dD(layerId ,bindD)) ; 00328 double y1D = (m_BesMdcRes -> getD_dD(layerId, bindD+1)) ; 00329 double yD = y0D + (y1D-y0D)*(driftD - bindD); // calculate the data 00330 double y0M = (m_BesMdcRes -> getM_dD(layerId ,bindD)) ; 00331 double y1M = (m_BesMdcRes -> getM_dD(layerId ,bindD+1)); 00332 double yM = y0M + (y1M-y0M)*(driftD - bindD); // calculate the mc data 00333 double dely = yD - yM ; 00334 00335 00336 /*if((bindD>=1)&&(bindD<=4)){ 00337 // cout<<"layerId :"<<layerId<<" dritfD :"<<driftD<<" dely*0.618:"<<dely*0.618<<endl; 00338 return dely*0.618 ; 00339 }else if((bindD>=5)&&(bindD<7)||(bindD ==8)){ 00340 // cout<<"layerId :"<<layerId<<" dritfD :"<<driftD<<" dely*0.418:"<<dely*0.418<<endl; 00341 return dely*0.418 ; 00342 }else { 00343 // cout<<"layerId :"<<layerId<<" dritfD :"<<driftD<<" dely:"<<dely<<endl; 00344 return dely; 00345 }*/ 00346 return dely; 00347 00348 }
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00565 { 00566 int bindD = 0; 00567 int maxbin =17; 00568 int iEntr =0; 00569 int ll = -1; 00570 double mindD = -9.; 00571 double maxdD =9.0; 00572 double delsigE =0; 00573 00574 if(enterA < 0){ 00575 iEntr = 0; 00576 }else {iEntr = 1;} 00577 00578 if(ilr == 0 ){ 00579 driftD = -1.*driftD; 00580 }else{ driftD = driftD ;} 00581 00582 if( (driftD < mindD) || (driftD > maxdD) ){ 00583 bindD = maxbin; 00584 }else { 00585 for(double dd =-9.; dd<9.;dd++){ 00586 ll++; 00587 if( (driftD>=dd ) && (driftD < (dd+1.)) ){ 00588 bindD = ll; 00589 dD[bindD] = dd; 00590 } 00591 } 00592 } 00593 00594 double y0D = (m_BesMdcRes -> getD_iEntr(lay,iEntr,bindD) ); 00595 double y1D = (m_BesMdcRes -> getD_iEntr(lay,iEntr,bindD+1) ); 00596 double yD = y0D + (y1D-y0D)*(driftD - dD[bindD]); // calculate the data 00597 double y0M = (m_BesMdcRes -> getM_iEntr(lay,iEntr,bindD) ); 00598 double y1M = (m_BesMdcRes -> getM_iEntr(lay,iEntr,bindD+1)); 00599 double yM = y0M + (y1M-y0M)*(driftD - dD[bindD]); // calculate the mc data 00600 double dely = yD - yM ; 00601 00602 //cout<<"Svc lay:"<<lay<<" iEntr :"<<iEntr<<" bindD :"<<bindD 00603 // <<" dD["<<bindD<<"] : "<<dD[bindD] 00604 // <<" y0D : "<<y0D<<" y1D : "<<y1D<<" yD :"<<yD 00605 // <<" y0M : "<<y0M<<" y1M : "<<y1M<<" yM :"<<yM<<" dely : "<<dely<<endl; 00606 00607 return dely; 00608 00609 }
|
|
|
|
00107 { 00108 MsgStream log(messageService(), name()); 00109 log << MSG::INFO << "MdcTunningSvc::finalize()" << endreq; 00110 mysql_close(conn); 00111 return StatusCode::SUCCESS; 00112 }
|
|
Implements IMdcTunningSvc. 00047 {return cellEff[i][j];}
|
|
Implements IMdcTunningSvc. 00047 {return cellEff[i][j];}
|
|
Implements IMdcTunningSvc. 00045 { return docaEff[i][j];};
|
|
Implements IMdcTunningSvc. 00045 { return docaEff[i][j];};
|
|
Implements IMdcTunningSvc. 00046 { return thetaEff[i][j];};
|
|
Implements IMdcTunningSvc. 00046 { return thetaEff[i][j];};
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00391 { 00392 driftD=fabs(driftD); 00393 if(driftD>12){ 00394 //std::cout<<"MdcTuningSvc: driftD overflow "<<driftD<<std::endl; 00395 driftD=12; 00396 } 00397 if(posFlag==0)driftD *= -1; 00398 00399 if(layerId<0 || layerId>42)std::cout<<" MdcTuningSvc:wrong LayerId "<<layerId<<std::endl; 00400 if(cellId<0 || cellId>=cellNo[layerId])std::cout<<"MdcTuningSvc:wrong cellId "<<cellId<<std::endl; 00401 00402 if(fabs(cosTheta)>1){ 00403 std::cout<<"MdcTuningSvc:wrong coseTheta "<<cosTheta<<std::endl; 00404 cosTheta=1; 00405 } 00406 double eff; 00407 int thetaBin=(int)floor((cosTheta+1)*thetaNo/2.); 00408 //debug 00409 // std::cout<<"cosTheta "<<cosTheta<<" caled "<<(cosTheta+1)*thetaNo/2.<<" floor "<<thetaBin<<std::endl; 00410 int docaBin=(int)floor((driftD+12)*docaNo/24.); 00411 if(m_EndcapTuning==0) 00412 eff = docaEff[layerId][docaBin] * thetaEff[layerId][thetaBin] * cellEff[layerId][cellId]; 00413 else { 00414 if(fabs(cosTheta)<=0.83) 00415 eff = docaEff[layerId][docaBin] * thetaEff[layerId][thetaBin] * cellEff[layerId][cellId]; 00416 else 00417 eff = docaEff_2[layerId][docaBin] * thetaEff_2[layerId][thetaBin] * cellEff_2[layerId][cellId]; 00418 00419 } 00420 //debug 00421 //std::cout<<"tuning svc doca "<<docaBin<<" theta "<<thetaBin<<" eff "<<eff<<std::endl; 00422 00423 return eff; 00424 }
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00282 {
00283 return m_BesMdcRes;
00284 }
|
|
|
|
00610 { 00611 MsgStream log(messageService(), name()); 00612 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,"/Event/EventHeader"); 00613 int run=eventHeader->runNumber(); 00614 std::cout<<"run ="<< run<<std::endl; 00615 run = fabs(run); 00616 unsigned long *lengths; 00617 MYSQL_RES *res_set; 00618 MYSQL_ROW row; 00619 int j=0; 00620 int cnt=0; 00621 for(int i=0;i<1000;i++){ 00622 char stmt1[200]; 00623 cnt = i; 00624 int run1 = run+i; 00625 sprintf(stmt1,"select MdcRes,MdcEff,dEdxTuning from MdcTuning where RunFrom <= %d and RunTo >= %d ",run1,run1); 00626 std::cout<<"stmt1:"<<stmt1<<std::endl; 00627 int aaa = -1; 00628 aaa = mysql_real_query(conn, stmt1, strlen(stmt1)); 00629 std::cout<<" mysql_real_query: "<<aaa<<std::endl; 00630 if(aaa){ 00631 // if(mysql_real_query(conn, stmt1, strlen(stmt1))) { 00632 fprintf(stderr, "query error\n"); 00633 return StatusCode::FAILURE; 00634 } 00635 res_set = mysql_store_result (conn); 00636 row = mysql_fetch_row(res_set); 00637 int row_no = mysql_num_rows(res_set); 00638 std::cout<<"row_no="<<row_no<<std::endl; 00639 if (row_no) { 00640 j=1; 00641 break; 00642 } 00643 int run2 = run-i; 00644 char stmt2[200]; 00645 sprintf(stmt2,"select MdcRes,MdcEff.dEdxTuning from MdcTuning where RunFrom <= %d and RunTo >= %d ",run2,run2); 00646 mysql_real_query(conn, stmt2, strlen(stmt2)); 00647 res_set = mysql_store_result (conn); 00648 row = mysql_fetch_row(res_set); 00649 row_no = mysql_num_rows(res_set); 00650 std::cout<<"row_no="<<row_no<<std::endl; 00651 if (row_no) { 00652 j=-1; 00653 break; 00654 } 00655 } 00656 if(cnt!=0&&cnt!=1000) { 00657 log << MSG::INFO << "get MDC tuning data form run " <<run+cnt*j<<" instread of run"<< run<< endreq; 00658 std::cout<<"get MDC tuning data form run " <<run+cnt*j<<" instread of run"<< run<<std::endl; 00659 } 00660 std::cout<<"cnt ="<<cnt<<std::endl; 00661 if(cnt==1000){ 00662 log << MSG::ERROR << "can not read Data from DB"<< endreq; 00663 mysql_close(conn); 00664 return StatusCode::FAILURE; 00665 } 00666 mysql_field_seek (res_set, 0); 00667 00668 lengths = mysql_fetch_lengths(res_set); 00669 // string fff = std::string(row[0]); 00670 // m_BesMdcRes->setMdcRes(fff); 00671 string ggg = std::string(row[1]); 00672 bool st = setMcEff(ggg); 00673 if(!st) return StatusCode::FAILURE; 00674 return StatusCode::SUCCESS; 00675 }
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00426 { 00427 driftD=fabs(driftD); 00428 if(driftD>12){ 00429 //std::cout<<"MdcTuningSvc: driftD overflow "<<driftD<<std::endl; 00430 driftD=12; 00431 } 00432 if(posFlag==0)driftD *= -1; 00433 00434 if(layerId<0 || layerId>42)std::cout<<" MdcTuningSvc:wrong LayerId "<<layerId<<std::endl; 00435 if(cellId<0 || cellId>=cellNo[layerId])std::cout<<"MdcTuningSvc:wrong cellId "<<cellId<<std::endl; 00436 00437 if(fabs(cosTheta)>1){ 00438 std::cout<<"MdcTuningSvc:wrong cosTheta "<<cosTheta<<std::endl; 00439 cosTheta=1; 00440 } 00441 00442 int thetaBin=(int)floor((cosTheta+1)*thetaNo/2.); 00443 //debug 00444 // std::cout<<"cosTheta "<<cosTheta<<" caled "<<(cosTheta+1)*thetaNo/2.<<" floor "<<thetaBin<<std::endl; 00445 int docaBin=(int)floor((driftD+12)*docaNo/24.); 00446 if(entranceAngle<0){ 00447 mean=docaRes[layerId][docaBin][0][0]; 00448 sigma=docaRes[layerId][docaBin][0][1]; 00449 }else{ 00450 mean=docaRes[layerId][docaBin][1][0]; 00451 sigma=docaRes[layerId][docaBin][1][1]; 00452 } 00453 00454 //debug 00455 //std::cout<<"tuning svc layer "<<layerId<<" driftD "<<driftD<<" posFlag "<<posFlag<<" doca "<<docaBin<<" theta "<<thetaBin<<" angle "<<entranceAngle<<" mean "<<mean<<" sigma "<<sigma<<std::endl; 00456 00457 return 1; 00458 }
|
|
|
|
00460 { 00461 driftD=fabs(driftD); 00462 if(driftD>12){ 00463 //std::cout<<"MdcTuningSvc: driftD overflow "<<driftD<<std::endl; 00464 driftD=12; 00465 } 00466 if(posFlag==0)driftD *= -1; 00467 00468 if(layerId<0 || layerId>42)std::cout<<" MdcTuningSvc:wrong LayerId "<<layerId<<std::endl; 00469 if(cellId<0 || cellId>=cellNo[layerId])std::cout<<"MdcTuningSvc:wrong cellId "<<cellId<<std::endl; 00470 00471 if(fabs(cosTheta)>1){ 00472 std::cout<<"MdcTuningSvc:wrong cosTheta "<<cosTheta<<std::endl; 00473 cosTheta=1; 00474 } 00475 00476 int thetaBin=(int)floor((cosTheta+1)*thetaNo/2.); 00477 //debug 00478 // std::cout<<"cosTheta "<<cosTheta<<" caled "<<(cosTheta+1)*thetaNo/2.<<" floor "<<thetaBin<<std::endl; 00479 int docaBin=(int)floor((driftD+12)*docaNo/24.); 00480 if(m_EndcapTuning==0) { 00481 if(entranceAngle<0){ 00482 f=docaF[layerId][docaBin][0]; 00483 mean1=docaMean1[layerId][docaBin][0]; 00484 sigma1=docaSigma1[layerId][docaBin][0]; 00485 mean2=docaMean2[layerId][docaBin][0]; 00486 sigma2=docaSigma2[layerId][docaBin][0]; 00487 }else{ 00488 f=docaF[layerId][docaBin][1]; 00489 mean1=docaMean1[layerId][docaBin][1]; 00490 sigma1=docaSigma1[layerId][docaBin][1]; 00491 mean2=docaMean2[layerId][docaBin][1]; 00492 sigma2=docaSigma2[layerId][docaBin][1]; 00493 } 00494 }else { 00495 if(fabs(cosTheta)<=0.83) { 00496 if(entranceAngle<0){ 00497 f=docaF[layerId][docaBin][0]; 00498 mean1=docaMean1[layerId][docaBin][0]; 00499 sigma1=docaSigma1[layerId][docaBin][0]; 00500 mean2=docaMean2[layerId][docaBin][0]; 00501 sigma2=docaSigma2[layerId][docaBin][0]; 00502 }else{ 00503 f=docaF[layerId][docaBin][1]; 00504 mean1=docaMean1[layerId][docaBin][1]; 00505 sigma1=docaSigma1[layerId][docaBin][1]; 00506 mean2=docaMean2[layerId][docaBin][1]; 00507 sigma2=docaSigma2[layerId][docaBin][1]; 00508 } 00509 } else { 00510 if(entranceAngle<0){ 00511 f=docaF_2[layerId][docaBin][0]; 00512 mean1=docaMean1_2[layerId][docaBin][0]; 00513 sigma1=docaSigma1_2[layerId][docaBin][0]; 00514 mean2=docaMean2_2[layerId][docaBin][0]; 00515 sigma2=docaSigma2_2[layerId][docaBin][0]; 00516 }else{ 00517 f=docaF_2[layerId][docaBin][1]; 00518 mean1=docaMean1_2[layerId][docaBin][1]; 00519 sigma1=docaSigma1_2[layerId][docaBin][1]; 00520 mean2=docaMean2_2[layerId][docaBin][1]; 00521 sigma2=docaSigma2_2[layerId][docaBin][1]; 00522 } 00523 } 00524 } 00525 //debug 00526 //std::cout<<"tuning svc layer "<<layerId<<" driftD "<<driftD<<" posFlag "<<posFlag<<" doca "<<docaBin<<" theta "<<thetaBin<<" angle "<<entranceAngle<<" f "<<f<<" mean1 "<<mean1<<" sigma1 "<<sigma1<<" mean2 "<<mean2<<" sigma2 "<<sigma2<<std::endl; 00527 00528 return 1; 00529 }
|
|
|
|
00114 { 00115 MsgStream log( messageService(), name() ); 00116 log << MSG::DEBUG << "handle: " << inc.type() << endreq; 00117 00118 if ( inc.type() == "NewRun" ){ 00119 log << MSG::DEBUG << "NewRun" << endreq; 00120 if(m_fromDB=true) { 00121 StatusCode sc = getMdcTuningTableInfo(); 00122 if(sc.isFailure()) { 00123 log << MSG::ERROR << "can not get MdcTuning data from the database" << endreq; 00124 exit(1); 00125 } 00126 } 00127 } 00128 }
|
|
|
|
00065 { 00066 MsgStream log(messageService(), name()); 00067 log << MSG::INFO << "MdcTunningSvc::initialize()" << endreq; 00068 00069 StatusCode sc = Service::initialize(); 00070 if( sc.isFailure() ) return sc; 00071 00072 if(m_fromDB==true){ 00073 // MYSQL *conn; 00074 // char *opt_host_name = "202.122.33.53"; 00075 // char *opt_user_name = "maqm"; 00076 // char *opt_password = "maqm_offline"; 00077 unsigned int opt_port_num = 3306; 00078 char *opt_socket_name = NULL; 00079 // char *opt_db_name = "offlinedb"; 00080 conn = mysql_init(NULL); 00081 unsigned int opt_flags = 0; 00082 mysql_real_connect(conn, host.c_str(), userName.c_str(), password.c_str(), 00083 dbName.c_str(), opt_port_num, opt_socket_name, opt_flags); 00084 // mysql_real_connect(conn, opt_host_name, opt_user_name, opt_password, 00085 // opt_db_name, opt_port_num, opt_socket_name, opt_flags); 00086 00087 IIncidentSvc* incsvc; 00088 sc = service("IncidentSvc", incsvc); 00089 int priority = 100; 00090 if( sc.isSuccess() ){ 00091 incsvc -> addListener(this, "NewRun", priority); 00092 } 00093 sc = serviceLocator()->service("EventDataSvc", m_eventSvc, true); 00094 if (sc .isFailure() ) { 00095 log << MSG::ERROR << "Unable to find EventDataSvc " << endreq; 00096 return sc; 00097 } 00098 } 00099 00100 if(m_fromDB!=true){ 00101 initTuningConst(); 00102 // if(m_path!=std::string("no path")) setMdcRes(m_path); 00103 } 00104 return StatusCode::SUCCESS; 00105 }
|
|
|
|
00129 { 00130 std::string FilePath = getenv("MDCTUNNINGSVCROOT"); 00131 if(m_effFile==std::string("no path")){ 00132 m_effFile=FilePath+"/dat/mc_eff.dat"; 00133 } 00134 setMcEff(m_effFile); 00135 if(m_resFile==std::string("no path")){ 00136 m_resFile=FilePath+"/dat/mc_res.dat"; 00137 } 00138 setMcRes2(); 00139 return true; 00140 }
|
|
00013 { return IID_IMdcTunningSvc; }
|
|
00013 { return IID_IMdcTunningSvc; }
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00291 { 00292 int bindD = 0; 00293 double mindD = 0.0 ; 00294 double maxdD = 9.0 ; 00295 int maxbin =8.0 ; 00296 00297 if((driftD<mindD)||(driftD>maxdD)){ 00298 bindD = maxbin ; 00299 }else { 00300 for(int kk = 0; kk < 9; kk++){ 00301 if((driftD>=(double)kk)&&(driftD<(double)(kk+1))){ 00302 bindD = kk ; } 00303 } 00304 } 00305 00306 double sigma1 = 0 ; 00307 00308 sigma1 = (m_BesMdcRes -> getD_dD(layerId ,bindD)) ; 00309 00310 return sigma1; 00311 }
|
|
|
|
00056 { 00057 if( IID_IMdcTunningSvc.versionMatch(riid) ){ 00058 *ppvInterface = static_cast<IMdcTunningSvc*> (this); 00059 } else{ 00060 return Service::queryInterface(riid, ppvInterface); 00061 } 00062 return StatusCode::SUCCESS; 00063 }
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00531 { 00532 int bindD =0; 00533 int maxbin = 17; 00534 int iEntr = 0; 00535 int ll = -1; 00536 double mindD = -9.; 00537 double maxdD = 9.; 00538 double sigmaE = 0.0; 00539 00540 if(enterA < 0){ 00541 iEntr = 0 ; 00542 }else{ iEntr = 1 ;} 00543 00544 if(ilr == 0 ){ 00545 driftD = -1.*driftD; 00546 }else{ driftD = driftD ;} 00547 00548 if( (driftD < mindD) || (driftD > maxdD) ){ 00549 bindD = maxbin ; 00550 }else{ 00551 for(double dd=-9.;dd<9.;dd++){ 00552 ll++; 00553 if( (driftD>= dd ) && (driftD < (dd+1.)) ){ 00554 bindD = ll ; 00555 } 00556 } 00557 } 00558 00559 sigmaE = (m_BesMdcRes -> getD_iEntr(layerId,iEntr,bindD) ); 00560 00561 //cout<<"Svc lay : "<<layerId<<" iEntr : "<<iEntr<<" bindD : "<<bindD<<" sigmaE :"<<sigmaE<<endl; 00562 return sigmaE; 00563 }
|
|
|
|
00141 { 00142 int i,j; 00143 string line; 00144 double lay,bin,expect,hit; 00145 //ifstream readMCEff(eff_con.c_str()); 00146 std::istringstream readMCEff; 00147 // (eff_con); 00148 if(m_fromDB){ 00149 readMCEff.str(eff_con); 00150 } 00151 if(!m_fromDB){ 00152 ifstream in(eff_con.c_str()); 00153 //char ch; 00154 //string hhh; 00155 //while(ift.get(ch)) hhh.putback(ch); 00156 //std::cout<<"hhh:"<<hhh<<std::endl; 00157 // stringstream strBuf ; 00158 istreambuf_iterator<char> iter(in) ; 00159 string strCache = string( iter, (istreambuf_iterator<char>()) ); 00160 readMCEff.str(strCache); 00161 //std::cout<<"strCache:"<<strCache<<std::endl; 00162 } 00163 // ifstream readMCEff(eff_con); 00164 if(!readMCEff.good()){ 00165 std::cout<<" Error , mdc tuning file: "<<m_effFile<<" not exist "<<std::endl; 00166 return false; 00167 }else{ 00168 std::cout<<" Open mdc tuning file: "<<m_effFile<<std::endl; 00169 for(i=0;i<43;i++){ 00170 readMCEff>>lay; 00171 getline(readMCEff,line); 00172 for(j=0;j<docaNo;j++){ 00173 readMCEff>>bin>>docaEff[i][j]>>expect>>hit; 00174 } 00175 readMCEff>>lay; 00176 getline(readMCEff,line); 00177 for(j=0;j<thetaNo;j++){ 00178 readMCEff>>bin>>thetaEff[i][j]>>expect>>hit; 00179 } 00180 readMCEff>>lay; 00181 getline(readMCEff,line); 00182 for(j=0;j<cellNo[i];j++){ 00183 readMCEff>>bin>>cellEff[i][j]>>expect>>hit; 00184 } 00185 } 00186 for(i=0;i<43;i++){ 00187 readMCEff>>lay; 00188 getline(readMCEff,line); 00189 for(j=0;j<docaNo;j++){ 00190 readMCEff>>bin>>docaEff_2[i][j]>>expect>>hit; 00191 } 00192 readMCEff>>lay; 00193 getline(readMCEff,line); 00194 for(j=0;j<thetaNo;j++){ 00195 readMCEff>>bin>>thetaEff_2[i][j]>>expect>>hit; 00196 } 00197 readMCEff>>lay; 00198 getline(readMCEff,line); 00199 for(j=0;j<cellNo[i];j++){ 00200 readMCEff>>bin>>cellEff_2[i][j]>>expect>>hit; 00201 } 00202 } 00203 } 00204 return true; 00205 }
|
|
|
|
00207 { 00208 int i,j; 00209 string line; 00210 double lay,bin; 00211 ifstream readMCRes(m_resFile.c_str()); 00212 if(!readMCRes.good()){ 00213 std::cout<<" Error , mdc tuning file: "<<m_resFile<<" not exist "<<std::endl; 00214 return false; 00215 }else{ 00216 std::cout<<" Open mdc tuning file: "<<m_resFile<<std::endl; 00217 for(i=0;i<43;i++){ 00218 readMCRes>>lay; 00219 getline(readMCRes,line); 00220 getline(readMCRes,line); 00221 for(j=0;j<docaNo;j++){ 00222 readMCRes>>bin>>docaRes[i][j][0][0]>>docaRes[i][j][0][1]; //entranceAngle<0 00223 } 00224 readMCRes>>lay; 00225 getline(readMCRes,line); 00226 getline(readMCRes,line); 00227 for(j=0;j<docaNo;j++){ 00228 readMCRes>>bin>>docaRes[i][j][1][0]>>docaRes[i][j][1][1]; //entranceAngle>0 00229 /* 00230 if(i==0||i==42){ 00231 cout<<"lay "<<i<<" docaNo "<<j<<" <0 mean "<<docaRes[i][j][0][0]<<" sigma "<<docaRes[i][j][0][1]<<" >0 mean "<<docaRes[i][j][1][0]<<" sigma "<<docaRes[i][j][1][1]<<endl; 00232 } 00233 */ 00234 } 00235 } 00236 } 00237 return true; 00238 }
|
|
|
|
00240 { 00241 int i,j; 00242 string line; 00243 double lay,bin; 00244 ifstream readMCRes(m_resFile.c_str()); 00245 if(!readMCRes.good()){ 00246 std::cout<<" Error , mdc tuning file: "<<m_resFile<<" not exist "<<std::endl; 00247 return false; 00248 }else{ 00249 std::cout<<" Open mdc tuning file: "<<m_resFile<<std::endl; 00250 for(i=0;i<43;i++){ 00251 readMCRes>>lay; 00252 getline(readMCRes,line); 00253 getline(readMCRes,line); 00254 for(j=0;j<docaNo;j++){ 00255 readMCRes>>bin>>docaF[i][j][0]>>docaMean1[i][j][0]>>docaSigma1[i][j][0]>>docaMean2[i][j][0]>>docaSigma2[i][j][0]; //entranceAngle<0 00256 } 00257 readMCRes>>lay; 00258 getline(readMCRes,line); 00259 getline(readMCRes,line); 00260 for(j=0;j<docaNo;j++){ 00261 readMCRes>>bin>>docaF[i][j][1]>>docaMean1[i][j][1]>>docaSigma1[i][j][1]>>docaMean2[i][j][1]>>docaSigma2[i][j][1]; //entranceAngle>0 00262 } 00263 } 00264 for(i=0;i<43;i++){ 00265 readMCRes>>lay; 00266 getline(readMCRes,line); 00267 getline(readMCRes,line); 00268 for(j=0;j<docaNo;j++){ 00269 readMCRes>>bin>>docaF_2[i][j][0]>>docaMean1_2[i][j][0]>>docaSigma1_2[i][j][0]>>docaMean2_2[i][j][0]>>docaSigma2_2[i][j][0]; //entranceAngle<0 00270 } 00271 readMCRes>>lay; 00272 getline(readMCRes,line); 00273 getline(readMCRes,line); 00274 for(j=0;j<docaNo;j++){ 00275 readMCRes>>bin>>docaF_2[i][j][1]>>docaMean1_2[i][j][1]>>docaSigma1_2[i][j][1]>>docaMean2_2[i][j][1]>>docaSigma2_2[i][j][1]; //entranceAngle>0 00276 } 00277 } 00278 } 00279 return true; 00280 }
|
|
Implements IMdcTunningSvc. |
|
Implements IMdcTunningSvc. 00286 { 00287 if(m_BesMdcRes) delete m_BesMdcRes; 00288 m_BesMdcRes = new BesMdcRes(path); 00289 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|