00001 #ifndef MDCTUNNINGSVC_H_
00002 #define MDCTUNNINGSVC_H_
00003
00004 #include "GaudiKernel/IInterface.h"
00005 #include "GaudiKernel/Kernel.h"
00006 #include "GaudiKernel/Service.h"
00007 #include "GaudiKernel/IIncidentListener.h"
00008 #include "GaudiKernel/IDataProviderSvc.h"
00009 #include "BesMdcRes.hh"
00010 #include "MdcTunningSvc/IMdcTunningSvc.h"
00011
00012 #include "DatabaseSvc/IDatabaseSvc.h"
00013 #include <map>
00014 #include <vector>
00015
00016 class MdcTunningSvc: public Service, virtual public IMdcTunningSvc,
00017 virtual public IIncidentListener{
00018 public:
00019 MdcTunningSvc( const std::string& name, ISvcLocator* svcloc );
00020 ~MdcTunningSvc();
00021
00022 virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown);
00023 virtual StatusCode initialize();
00024 virtual StatusCode finalize();
00025
00026
00027 void handle(const Incident&);
00028 bool initTuningConst();
00029
00030 bool setMcEff(std::string eff_con);
00031 bool setMcRes();
00032
00033 bool setMcRes2(std::string res_con);
00034 bool setMcRes3(std::string res_con);
00035 StatusCode getMdcTuningTableInfo();
00036
00037 BesMdcRes* getMdcRes();
00038 void setMdcRes(std::string path);
00039 double NewSig(int layerId, double driftD);
00040 double DeldriftD(int layerId,double driftD);
00041 double Delcostta(int layerId,double costta);
00042 double GetEff(int layerId,int cellId,double driftD,double cosTheta,int posFlag);
00043 double GetRes(int layerId,int cellId,double driftD,double cosTheta,int posFlag,double entranceAngle,double& mean,double& sigma);
00044 double GetRes2(int layerId,int cellId,double driftD,double cosTheta,int posFlag,double entranceAngle,double& f,double& mean1,double& sigma1,double& mean2,double& sigma2);
00045 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);
00046 double ResvEntr(int layerId,double enterA,int ilr,double driftD);
00047 double DelEtr_Sig(int lay,double enterA,int ilr,double driftD);
00048
00049 double get_docaEff(int i,int j){ return docaEff[i][j];};
00050 double get_thetaEff(int i,int j){ return thetaEff[i][j];};
00051 double get_cellEff(int i,int j){return cellEff[i][j];}
00052
00053 private:
00054
00055 static const int docaNo=60;
00056 static const int thetaNo=40;
00057 int cellNo[43];
00058 double docaEff[43][docaNo];
00059 double thetaEff[43][thetaNo];
00060 double cellEff[43][288];
00061 double docaRes[43][docaNo][2][2];
00062 double docaF[43][docaNo][2];
00063 double docaMean1[43][docaNo][2];
00064 double docaSigma1[43][docaNo][2];
00065 double docaMean2[43][docaNo][2];
00066 double docaSigma2[43][docaNo][2];
00067
00068
00069 double resLargest[43][docaNo][2];
00070 double resSmallest[43][docaNo][2];
00071 double resRatio[43][docaNo][2];
00072 double resLargest_2[43][docaNo][2];
00073 double resSmallest_2[43][docaNo][2];
00074 double resRatio_2[43][docaNo][2];
00075
00076 double docaEff_2[43][docaNo];
00077 double thetaEff_2[43][thetaNo];
00078 double cellEff_2[43][288];
00079 double docaRes_2[43][docaNo][2][2];
00080 double docaF_2[43][docaNo][2];
00081 double docaMean1_2[43][docaNo][2];
00082 double docaSigma1_2[43][docaNo][2];
00083 double docaMean2_2[43][docaNo][2];
00084 double docaSigma2_2[43][docaNo][2];
00085
00086 std::string m_ParBossVer;
00087 double dD[18];
00088 int m_EndcapTuning;
00089 bool m_dbFlag;
00090 std::string m_effFile;
00091 std::string m_resFile;
00092 std::string m_effFile_endcap;
00093 std::string m_resFile_endcap;
00094 std::string m_path;
00095 BesMdcRes* m_BesMdcRes;
00096
00097 bool m_fromDB;
00098 IDataProviderSvc* m_eventSvc;
00099
00100 std::string host;
00101 std::string dbName;
00102 std::string table;
00103 std::string userName;
00104 std::string password;
00105 unsigned int serialNo;
00106
00107 IDatabaseSvc* m_dbsvc;
00108 };
00109
00110 #endif