8#include "GaudiKernel/Kernel.h"
9#include "GaudiKernel/IInterface.h"
10#include "GaudiKernel/StatusCode.h"
11#include "GaudiKernel/SvcFactory.h"
12#include "GaudiKernel/MsgStream.h"
14#include "GaudiKernel/IIncidentSvc.h"
15#include "GaudiKernel/Incident.h"
16#include "GaudiKernel/IIncidentListener.h"
18#include "GaudiKernel/ISvcLocator.h"
19#include "GaudiKernel/Bootstrap.h"
25#include "GaudiKernel/SmartDataPtr.h"
32 Service (name, svcloc){
35 declareProperty(
"UseDatabase",m_dbFlag =
false);
36 declareProperty(
"UseEndcapTuning",m_EndcapTuning = 1);
37 declareProperty(
"EffFile", m_effFile = std::string(
"no path"));
38 declareProperty(
"ResFile", m_resFile = std::string(
"no path"));
39 declareProperty(
"EffFile_endcap", m_effFile_endcap = std::string(
"no path"));
40 declareProperty(
"ResFile_endcap", m_resFile_endcap = std::string(
"no path"));
41 declareProperty(
"path_mdc", m_path = std::string(
"no path"));
42 declareProperty(
"Host" , host = std::string(
"bes3db2.ihep.ac.cn"));
43 declareProperty(
"DbName" , dbName = std::string(
"offlinedb"));
44 declareProperty(
"UserName" , userName = std::string(
"guest"));
45 declareProperty(
"Password" , password = std::string(
"guestpass"));
46 declareProperty(
"SerialNo" , serialNo = 0);
47 declareProperty(
"fromDB", m_fromDB =
true);
48 declareProperty(
"ParBossVer", m_ParBossVer = std::string(
"unknown"));
50 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};
52 for(
int i=0;i<43;i++){
59 if(m_BesMdcRes)
delete m_BesMdcRes;
63 if( IID_IMdcTunningSvc.versionMatch(riid) ){
66 return Service::queryInterface(riid, ppvInterface);
68 return StatusCode::SUCCESS;
73 MsgStream log(messageService(), name());
74 log << MSG::INFO <<
"========== MdcTunningSvc::initialize() ==========" << endreq;
76 m_ParBossVer=getenv(
"BES_RELEASE");
78 StatusCode sc = Service::initialize();
79 if( sc.isFailure() )
return sc;
82 cout <<
" MdcTunningSvc read from database. " << endl;
84 cout <<
" MdcTunningSvc read from localfile. " << endl;
88 sc = serviceLocator()->service(
"DatabaseSvc", m_dbsvc,
true);
89 if (sc .isFailure() ) {
90 log << MSG::ERROR <<
" ERROR: unable to find DatabaseSvc " << endreq;
109 IIncidentSvc* incsvc;
110 sc = service(
"IncidentSvc", incsvc);
112 if( sc.isSuccess() ){
113 incsvc -> addListener(
this,
"NewRun", priority);
115 sc = serviceLocator()->service(
"EventDataSvc", m_eventSvc,
true);
116 if (sc .isFailure() ) {
117 log << MSG::ERROR <<
" ERROR: unable to find EventDataSvc " << endreq;
126 cout <<
"========== MdcTunningSvc::initialize() failure ! ==========" << endl;
127 return StatusCode::FAILURE;
131 return StatusCode::SUCCESS;
135 MsgStream log(messageService(), name());
136 log << MSG::INFO <<
"========== MdcTunningSvc::finalize() ==========" << endreq;
139 return StatusCode::SUCCESS;
143 cout <<
"========== MdcTunningSvc::handle() ==========" << endl;
145 MsgStream log( messageService(), name() );
146 log << MSG::DEBUG <<
"handle: " << inc.type() << endreq;
148 if ( inc.type() ==
"NewRun" ){
149 log << MSG::DEBUG <<
"NewRun" << endreq;
151 cout <<
" Start getMdcTuningTableInfo. " << endl;
154 cout <<
" ERROR: can not get MdcTuning data from the database. " << endl;
155 log << MSG::ERROR <<
" ERROR: can not get MdcTuning data from the database. " << endreq;
163 std::string FilePath = getenv(
"MDCTUNNINGSVCROOT");
165 if(m_effFile==std::string(
"no path")){
166 if(!m_fromDB) cout <<
" ERROR: no mdc tuning eff file, please check the input! " << endl;
171 bool setMcEffStat =
setMcEff(m_effFile);
173 if(m_resFile==std::string(
"no path")){
174 if(!m_fromDB) cout <<
" ERROR: no mdc tuning res file, please check the input! " << endl;
180 bool setMcRes3Stat =
setMcRes3(m_resFile);
182 if(!(setMcRes3Stat&&setMcEffStat))
191 double lay,
bin,expect,hit;
193 std::istringstream readMCEff;
196 readMCEff.str(eff_con);
199 ifstream in(eff_con.c_str());
205 istreambuf_iterator<char>
iter(in) ;
206 string strCache = string(
iter, (istreambuf_iterator<char>()) );
207 readMCEff.str(strCache);
212 ifstream fin(eff_con.c_str());
215 cout <<
" ERROR: the mdc tunning eff file " << m_effFile <<
" not exist, please check the input! " << endl;
219 if(!readMCEff.good()){
220 cout <<
" ERROR: mdc tuning eff file " << m_effFile <<
" not exist. " << endl;
225 cout <<
" Open mdc tuning eff file: " << m_effFile << endl;
228 getline(readMCEff,line);
229 for(j=0;j<docaNo;j++){
230 readMCEff>>
bin>>docaEff[i][j]>>expect>>hit;
233 getline(readMCEff,line);
234 for(j=0;j<thetaNo;j++){
235 readMCEff>>
bin>>thetaEff[i][j]>>expect>>hit;
238 getline(readMCEff,line);
239 for(j=0;j<cellNo[i];j++){
240 readMCEff>>
bin>>cellEff[i][j]>>expect>>hit;
246 getline(readMCEff,line);
247 for(j=0;j<docaNo;j++){
248 readMCEff>>
bin>>docaEff_2[i][j]>>expect>>hit;
251 getline(readMCEff,line);
252 for(j=0;j<thetaNo;j++){
253 readMCEff>>
bin>>thetaEff_2[i][j]>>expect>>hit;
257 getline(readMCEff,line);
258 for(j=0;j<cellNo[i];j++){
259 readMCEff>>
bin>>cellEff_2[i][j]>>expect>>hit;
273 ifstream readMCRes(m_resFile.c_str());
274 if(!readMCRes.good()){
275 cout <<
" ERROR: mdc tuning file: " << m_resFile <<
" not exist. " << endl;
278 cout <<
" Open mdc tuning file: " << m_resFile << endl;
281 getline(readMCRes,line);
282 getline(readMCRes,line);
283 for(j=0;j<docaNo;j++){
284 readMCRes>>
bin>>docaRes[i][j][0][0]>>docaRes[i][j][0][1];
287 getline(readMCRes,line);
288 getline(readMCRes,line);
289 for(j=0;j<docaNo;j++){
290 readMCRes>>
bin>>docaRes[i][j][1][0]>>docaRes[i][j][1][1];
308 std::istringstream readMCRes;
311 readMCRes.str(res_con);
315 ifstream in(res_con.c_str());
316 istreambuf_iterator<char>
iter(in) ;
317 string strCache = string(
iter, (istreambuf_iterator<char>()) );
318 readMCRes.str(strCache);
320 if(!readMCRes.good()){
321 cout <<
" ERROR: mdc tuning file: " << m_resFile <<
" not exist. " << endl;
324 cout <<
" MdcTunningSvc::setMcRes2() Open mdc tuning resfile " << m_resFile << endl;
327 getline(readMCRes,line);
328 getline(readMCRes,line);
329 for(j=0;j<docaNo;j++){
330 readMCRes>>
bin>>docaF[i][j][0]>>docaMean1[i][j][0]>>docaSigma1[i][j][0]>>docaMean2[i][j][0]>>docaSigma2[i][j][0];
333 getline(readMCRes,line);
334 getline(readMCRes,line);
335 for(j=0;j<docaNo;j++){
336 readMCRes>>
bin>>docaF[i][j][1]>>docaMean1[i][j][1]>>docaSigma1[i][j][1]>>docaMean2[i][j][1]>>docaSigma2[i][j][1];
341 getline(readMCRes,line);
342 getline(readMCRes,line);
343 for(j=0;j<docaNo;j++){
344 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];
347 getline(readMCRes,line);
348 getline(readMCRes,line);
349 for(j=0;j<docaNo;j++){
350 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];
363 std::istringstream readMCRes;
365 readMCRes.str(res_con);
368 ifstream in(res_con.c_str());
369 istreambuf_iterator<char>
iter(in) ;
370 string strCache = string(
iter, (istreambuf_iterator<char>()) );
371 readMCRes.str(strCache);
374 ifstream fin(res_con.c_str());
378 cout <<
" ERROR: the mdc tunning res file " << m_resFile <<
" not exist, please check the input!" << endl;
381 if(!readMCRes.good()){
382 cout <<
" ERROR: the mdc tuning res file: " << m_resFile <<
" not exist, please check the input! " << endl;
387 cout <<
" MdcTunningSvc::setMcRes3() Open mdc tuning resfile: " << m_resFile << endl;
390 getline(readMCRes,line);
391 getline(readMCRes,line);
392 for(j=0;j<docaNo;j++){
393 readMCRes>>
bin>>docaF[i][j][0]>>docaMean1[i][j][0]>>docaSigma1[i][j][0]>>docaMean2[i][j][0]>>docaSigma2[i][j][0]>>resLargest[i][j][0]>>resSmallest[i][j][0]>>resRatio[i][j][0];
396 getline(readMCRes,line);
397 getline(readMCRes,line);
398 for(j=0;j<docaNo;j++){
399 readMCRes>>
bin>>docaF[i][j][1]>>docaMean1[i][j][1]>>docaSigma1[i][j][1]>>docaMean2[i][j][1]>>docaSigma2[i][j][1]>>resLargest[i][j][1]>>resSmallest[i][j][1]>>resRatio[i][j][1];
405 getline(readMCRes,line);
406 getline(readMCRes,line);
407 for(j=0;j<docaNo;j++){
408 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]>>resLargest_2[i][j][0]>>resSmallest_2[i][j][0]>>resRatio_2[i][j][0];
411 getline(readMCRes,line);
412 getline(readMCRes,line);
413 for(j=0;j<docaNo;j++){
415 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]>>resLargest_2[i][j][1]>>resSmallest_2[i][j][1]>>resRatio_2[i][j][1];
432 if(m_BesMdcRes)
delete m_BesMdcRes;
442 if((driftD<mindD)||(driftD>maxdD)){
445 for(
int kk = 0; kk < 9; kk++){
446 if((driftD>=(
double)kk)&&(driftD<(
double)(kk+1))){
453 sigma1 = (m_BesMdcRes -> getD_dD(layerId ,bindD)) ;
465 for(
int jj =0;jj<9;jj++){
466 if((driftD<mindD)||(driftD>maxdD)){
468 }
else if((driftD>=jj)&&(driftD<(jj+1))){
472 double y0D = (m_BesMdcRes -> getD_dD(layerId ,bindD)) ;
473 double y1D = (m_BesMdcRes -> getD_dD(layerId, bindD+1)) ;
474 double yD = y0D + (y1D-y0D)*(driftD - bindD);
475 double y0M = (m_BesMdcRes -> getM_dD(layerId ,bindD)) ;
476 double y1M = (m_BesMdcRes -> getM_dD(layerId ,bindD+1));
477 double yM = y0M + (y1M-y0M)*(driftD - bindD);
478 double dely = yD - yM ;
498 double minCos = -0.8 ;
499 double minCos2 = -0.7 ;
500 double maxCos = 0.8 ;
502 for(
int ii = 0; ii <16; ii++){
503 if((costta<minCos)||(costta>maxCos)){
505 }
else if((costta>=(minCos + ii*0.1))&&(costta<(minCos2 + ii*0.1))){
510 double y0D = (m_BesMdcRes -> getD_theta(layerId ,binTa));
511 double y1D = (m_BesMdcRes -> getD_theta(layerId ,binTa+1));
512 double y0M = (m_BesMdcRes -> getM_theta(layerId,binTa));
513 double y1M = (m_BesMdcRes -> getM_theta(layerId,binTa+1));
515 double yD[16],yM[16],Del[16];
516 for(
int ll =0;ll<16;ll++){
517 yD[ll] = y0D + (y1D - y0D)/0.1*(costta - (minCos + ll*0.1));
518 yM[ll] = y0M + (y1M - y0D)/0.1*(costta - (minCos + ll*0.1));
519 Del[ll] = yD[ll] - yM[ll] ;
524 if((binTa>=0)&&(binTa<=5)){
525 delTha = Del[binTa] * 0.118 ;
526 }
else if((binTa>5)&&(binTa<=10)){
527 delTha = Del[binTa] * 0.518 ;
528 }
else if((binTa>10)&&(binTa<=15)){
529 delTha = Del[binTa] * 0.218 ;
543 if(posFlag==0)driftD *= -1;
545 if(layerId<0 || layerId>42)std::cout<<
" MdcTuningSvc:wrong LayerId "<<layerId<<std::endl;
546 if(cellId<0 || cellId>=cellNo[layerId])std::cout<<
"MdcTuningSvc:wrong cellId "<<cellId<<std::endl;
548 if(fabs(cosTheta)>1){
549 std::cout<<
"MdcTuningSvc:wrong coseTheta "<<cosTheta<<std::endl;
553 int thetaBin=(int)floor((cosTheta+1)*thetaNo/2.);
556 int docaBin=(int)floor((driftD+12)*docaNo/24.);
557 if(m_EndcapTuning==0)
558 eff = docaEff[layerId][docaBin] * thetaEff[layerId][thetaBin] * cellEff[layerId][cellId];
560 if(fabs(cosTheta)<=0.83)
561 eff = docaEff[layerId][docaBin] * thetaEff[layerId][thetaBin] * cellEff[layerId][cellId];
563 eff = docaEff_2[layerId][docaBin] * thetaEff_2[layerId][thetaBin] * cellEff_2[layerId][cellId];
574double MdcTunningSvc::GetRes(
int layerId,
int cellId,
double driftD,
double cosTheta,
int posFlag,
double entranceAngle,
double& mean,
double&
sigma){
581 if(posFlag==0)driftD *= -1;
583 if(layerId<0 || layerId>42)std::cout<<
" MdcTuningSvc:wrong LayerId "<<layerId<<std::endl;
584 if(cellId<0 || cellId>=cellNo[layerId])std::cout<<
"MdcTuningSvc:wrong cellId "<<cellId<<std::endl;
586 if(fabs(cosTheta)>1){
587 std::cout<<
"MdcTuningSvc:wrong cosTheta "<<cosTheta<<std::endl;
594 int docaBin=(int)floor((driftD+12)*docaNo/24.);
596 mean=docaRes[layerId][docaBin][0][0];
597 sigma=docaRes[layerId][docaBin][0][1];
599 mean=docaRes[layerId][docaBin][1][0];
600 sigma=docaRes[layerId][docaBin][1][1];
609double MdcTunningSvc::GetRes2(
int layerId,
int cellId,
double driftD,
double cosTheta,
int posFlag,
double entranceAngle,
double&
f,
double& mean1,
double& sigma1,
double& mean2,
double& sigma2){
616 if(posFlag==0)driftD *= -1;
618 if(layerId<0 || layerId>42)std::cout<<
" MdcTuningSvc:wrong LayerId "<<layerId<<std::endl;
619 if(cellId<0 || cellId>=cellNo[layerId])std::cout<<
"MdcTuningSvc:wrong cellId "<<cellId<<std::endl;
621 if(fabs(cosTheta)>1){
622 std::cout<<
"MdcTuningSvc:wrong cosTheta "<<cosTheta<<std::endl;
629 int docaBin=(int)floor((driftD+12)*docaNo/24.);
630 if(m_EndcapTuning==0) {
632 f=docaF[layerId][docaBin][0];
633 mean1=docaMean1[layerId][docaBin][0];
634 sigma1=docaSigma1[layerId][docaBin][0];
635 mean2=docaMean2[layerId][docaBin][0];
636 sigma2=docaSigma2[layerId][docaBin][0];
638 f=docaF[layerId][docaBin][1];
639 mean1=docaMean1[layerId][docaBin][1];
640 sigma1=docaSigma1[layerId][docaBin][1];
641 mean2=docaMean2[layerId][docaBin][1];
642 sigma2=docaSigma2[layerId][docaBin][1];
645 if(fabs(cosTheta)<=0.83) {
647 f=docaF[layerId][docaBin][0];
648 mean1=docaMean1[layerId][docaBin][0];
649 sigma1=docaSigma1[layerId][docaBin][0];
650 mean2=docaMean2[layerId][docaBin][0];
651 sigma2=docaSigma2[layerId][docaBin][0];
653 f=docaF[layerId][docaBin][1];
654 mean1=docaMean1[layerId][docaBin][1];
655 sigma1=docaSigma1[layerId][docaBin][1];
656 mean2=docaMean2[layerId][docaBin][1];
657 sigma2=docaSigma2[layerId][docaBin][1];
661 f=docaF_2[layerId][docaBin][0];
662 mean1=docaMean1_2[layerId][docaBin][0];
663 sigma1=docaSigma1_2[layerId][docaBin][0];
664 mean2=docaMean2_2[layerId][docaBin][0];
665 sigma2=docaSigma2_2[layerId][docaBin][0];
667 f=docaF_2[layerId][docaBin][1];
668 mean1=docaMean1_2[layerId][docaBin][1];
669 sigma1=docaSigma1_2[layerId][docaBin][1];
670 mean2=docaMean2_2[layerId][docaBin][1];
671 sigma2=docaSigma2_2[layerId][docaBin][1];
682double MdcTunningSvc::GetRes3(
int layerId,
int cellId,
double driftD,
double cosTheta,
int posFlag,
double entranceAngle,
double&
f,
double& mean1,
double& sigma1,
double& mean2,
double& sigma2,
double& ResLargest,
double& ResSmallest,
double& ResRatio){
689 if(posFlag==0)driftD *= -1;
691 if(layerId<0 || layerId>42)std::cout<<
" MdcTuningSvc:wrong LayerId "<<layerId<<std::endl;
692 if(cellId<0 || cellId>=cellNo[layerId])std::cout<<
"MdcTuningSvc:wrong cellId "<<cellId<<std::endl;
694 if(fabs(cosTheta)>1){
695 std::cout<<
"MdcTuningSvc:wrong cosTheta "<<cosTheta<<std::endl;
702 int docaBin=(int)floor((driftD+12)*docaNo/24.);
703 if(m_EndcapTuning==0) {
705 f=docaF[layerId][docaBin][0];
706 mean1=docaMean1[layerId][docaBin][0];
707 sigma1=docaSigma1[layerId][docaBin][0];
708 mean2=docaMean2[layerId][docaBin][0];
709 sigma2=docaSigma2[layerId][docaBin][0];
710 ResLargest=resLargest[layerId][docaBin][0];
711 ResSmallest=resSmallest[layerId][docaBin][0];
712 ResRatio=resRatio[layerId][docaBin][0];
715 f=docaF[layerId][docaBin][1];
716 mean1=docaMean1[layerId][docaBin][1];
717 sigma1=docaSigma1[layerId][docaBin][1];
718 mean2=docaMean2[layerId][docaBin][1];
719 sigma2=docaSigma2[layerId][docaBin][1];
720 ResLargest=resLargest[layerId][docaBin][1];
721 ResSmallest=resSmallest[layerId][docaBin][1];
722 ResRatio=resRatio[layerId][docaBin][1];
725 if(fabs(cosTheta)<=0.83) {
727 f=docaF[layerId][docaBin][0];
728 mean1=docaMean1[layerId][docaBin][0];
729 sigma1=docaSigma1[layerId][docaBin][0];
730 mean2=docaMean2[layerId][docaBin][0];
731 sigma2=docaSigma2[layerId][docaBin][0];
732 ResLargest=resLargest[layerId][docaBin][0];
733 ResSmallest=resSmallest[layerId][docaBin][0];
734 ResRatio=resRatio[layerId][docaBin][0];
736 f=docaF[layerId][docaBin][1];
737 mean1=docaMean1[layerId][docaBin][1];
738 sigma1=docaSigma1[layerId][docaBin][1];
739 mean2=docaMean2[layerId][docaBin][1];
740 sigma2=docaSigma2[layerId][docaBin][1];
741 ResLargest=resLargest[layerId][docaBin][1];
742 ResSmallest=resSmallest[layerId][docaBin][1];
743 ResRatio=resRatio[layerId][docaBin][1];
747 f=docaF_2[layerId][docaBin][0];
748 mean1=docaMean1_2[layerId][docaBin][0];
749 sigma1=docaSigma1_2[layerId][docaBin][0];
750 mean2=docaMean2_2[layerId][docaBin][0];
751 sigma2=docaSigma2_2[layerId][docaBin][0];
752 ResLargest=resLargest_2[layerId][docaBin][0];
753 ResSmallest=resSmallest_2[layerId][docaBin][0];
754 ResRatio=resRatio_2[layerId][docaBin][0];
756 f=docaF_2[layerId][docaBin][1];
757 mean1=docaMean1_2[layerId][docaBin][1];
758 sigma1=docaSigma1_2[layerId][docaBin][1];
759 mean2=docaMean2_2[layerId][docaBin][1];
760 sigma2=docaSigma2_2[layerId][docaBin][1];
761 ResLargest=resLargest_2[layerId][docaBin][1];
762 ResSmallest=resSmallest_2[layerId][docaBin][1];
763 ResRatio=resRatio_2[layerId][docaBin][1];
794 }
else{ driftD = driftD ;}
796 if( (driftD < mindD) || (driftD > maxdD) ){
799 for(
double dd=-9.;dd<9.;dd++){
801 if( (driftD>= dd ) && (driftD < (dd+1.)) ){
807 sigmaE = (m_BesMdcRes -> getD_iEntr(layerId,iEntr,bindD) );
827 }
else{ driftD = driftD ;}
829 if( (driftD < mindD) || (driftD > maxdD) ){
832 for(
double dd =-9.; dd<9.;dd++){
834 if( (driftD>=dd ) && (driftD < (dd+1.)) ){
841 double y0D = (m_BesMdcRes -> getD_iEntr(lay,iEntr,bindD) );
842 double y1D = (m_BesMdcRes -> getD_iEntr(lay,iEntr,bindD+1) );
843 double yD = y0D + (y1D-y0D)*(driftD - dD[bindD]);
844 double y0M = (m_BesMdcRes -> getM_iEntr(lay,iEntr,bindD) );
845 double y1M = (m_BesMdcRes -> getM_iEntr(lay,iEntr,bindD+1));
846 double yM = y0M + (y1M-y0M)*(driftD - dD[bindD]);
847 double dely = yD - yM ;
859 MsgStream log(messageService(), name());
860 SmartDataPtr<Event::EventHeader> eventHeader(m_eventSvc,
"/Event/EventHeader");
861 int run=eventHeader->runNumber();
863 log << MSG::INFO <<
"MdcTuningSvc::getMdcTuningTableInfo() run =" << run << endreq;
864 if(m_ParBossVer==std::string(
"unknown"))
865 cout <<
"MdcTuningSvc::getMdcTuningTableInfo() : ERROR: there is no ParBossVer " << endl;
866 else log << MSG::INFO <<
"MdcTuningSvc::getMdcTuningTableInfo() : ParBossVer = " << m_ParBossVer << endl;
875 for(
int i=0;i<1000;i++){
879 cout <<
" ==================== " << endl;
881 sprintf(stmt1,
"select MdcRes,MdcEff from MdcTuning where RunFrom <= %d and RunTo >= %d and SftVer = \"%s\"",run1,run1,m_ParBossVer.c_str());
882 cout <<
" stmt1: " << stmt1 << endl;
885 int status = m_dbsvc->
query(
"offlinedb",stmt1,result);
887 cout <<
" ERROR: can not read MdcRes, MdcEff from the MdcTuning table " << endl;
888 log << MSG::ERROR <<
" ERROR Read MdcRes, MdcEff from the MdcTuning table " << endreq;
889 return StatusCode::FAILURE;
892 if(result.size()>=1){
915 sprintf(stmt2,
"select MdcRes,MdcEff from MdcTuning where RunFrom <= %d and RunTo >= %d and SftVer = \"%s\"",run2,run2,m_ParBossVer.c_str());
918 status = m_dbsvc->
query(
"offlinedb",stmt2,result);
920 log << MSG::ERROR <<
" ERROR Read MdcRes, MdcEff.dEdxTuning from the MdcTuning table " << endreq;
921 return StatusCode::FAILURE;
925 if(result.size()>=1){
937 if(cnt!=0&&cnt!=1000) {
938 log << MSG::INFO <<
" get MDC tuning data from run " << run + cnt*j <<
" instead of run " << run<< endreq;
941 cout <<
" cnt = " << cnt << endl;
943 log << MSG::ERROR <<
" can not read Data from DB" << endreq;
945 return StatusCode::FAILURE;
957 int row = result.size()-1;
958 cout <<
" row = " << row << endl;
961 cout <<
" ERROR: can not read Data from DB, please check MdcTunningSvc Version. " << endl;
962 return StatusCode::FAILURE;
965 string ggg = result[row]->GetString(
"MdcEff");
966 string fff = result[row]->GetString(
"MdcRes");
968 log << MSG::DEBUG <<
" MdcTunning Data: MdcEff: " << ggg <<
" MdcRes: " << fff << endreq;
975 if(!stEff)
return StatusCode::FAILURE;
976 if(!stRes)
return StatusCode::FAILURE;
977 return StatusCode::SUCCESS;
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)
TFile f("ana_bhabha660a_dqa_mcPat_zy_old.root")
*******INTEGER m_nBinMax INTEGER m_NdiMax !No of bins in histogram for cell exploration division $ !Last vertex $ !Last active cell $ !Last cell in buffer $ !No of sampling when dividing cell $ !No of function total $ !Flag for random ceel for $ !Flag for type of for WtMax $ !Flag which decides whether vertices are included in the sampling $ entire domain is hyp !Maximum effective eevents per bin
virtual int query(const std::string &dbName, const std::string &sql, DatabaseRecordVector &res)=0
double DelEtr_Sig(int lay, double enterA, int ilr, double driftD)
void setMdcRes(std::string path)
bool setMcRes2(std::string res_con)
bool setMcRes3(std::string res_con)
StatusCode getMdcTuningTableInfo()
double Delcostta(int layerId, double costta)
void handle(const Incident &)
double ResvEntr(int layerId, double enterA, int ilr, double driftD)
bool setMcEff(std::string eff_con)
double NewSig(int layerId, double driftD)
double DeldriftD(int layerId, double driftD)
double GetRes(int layerId, int cellId, double driftD, double cosTheta, int posFlag, double entranceAngle, double &mean, double &sigma)
double GetEff(int layerId, int cellId, double driftD, double cosTheta, int posFlag)
MdcTunningSvc(const std::string &name, ISvcLocator *svcloc)
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode finalize()
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 GetRes3(int layerId, int cellId, double driftD, double cosTheta, int posFlag, double entranceAngle, double &f, double &mean1, double &sigma1, double &mean2, double &sigma2, double &ResLargest, double &ResSmallest, double &ResRatio)
virtual StatusCode initialize()