00001 #ifndef MDCCALIBFUNSVC_H_
00002 #define MDCCALIBFUNSVC_H_
00003
00004 #include "GaudiKernel/IInterface.h"
00005 #include "GaudiKernel/Kernel.h"
00006 #include "GaudiKernel/Service.h"
00007 #include "GaudiKernel/IIncidentListener.h"
00008
00009 #include "GaudiKernel/IDataProviderSvc.h"
00010 #include "GaudiKernel/SmartDataPtr.h"
00011 #include "GaudiKernel/DataSvc.h"
00012 #include "CalibData/CalibModel.h"
00013 #include "CalibData/Mdc/MdcCalibData.h"
00014 #include "CalibDataSvc/ICalibRootSvc.h"
00015
00016 #include "MdcCalibFunSvc/IMdcCalibFunSvc.h"
00017
00018 #include <map>
00019 #include <vector>
00020
00021 class MdcCalibFunSvc: public Service, virtual public IMdcCalibFunSvc,
00022 virtual public IIncidentListener{
00023 public:
00024 MdcCalibFunSvc( const std::string& name, ISvcLocator* svcloc );
00025 ~MdcCalibFunSvc();
00026
00027 virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvUnknown);
00028 virtual StatusCode initialize();
00029 virtual StatusCode finalize();
00030
00031
00032 void handle(const Incident&);
00033
00034 int m_run;
00035
00036
00037
00038
00039 double getVprop(int lay) const;
00040
00041
00042 double getTprop(int lay, double z) const;
00043
00044
00045
00046
00047 double driftTimeToDist(double drifttime, int layid, int cellid, int lr,
00048 double entrance = 0.0) const ;
00049 double distToDriftTime(double dist, int layid, int cellid, int lr,
00050 double entrance = 0.0) const ;
00051
00052
00053 double rawTimeNoTOFToDist(double rawtimeNoTOF, int layid, int cellid, int lr,
00054 double entrance = 0.0, double Q = 1000.0) const ;
00055 double distToRawTimeNoTOF(double dist, int layid, int cellid, int lr,
00056 double entrance = 0.0, double Q = 1000.0) const ;
00057
00058
00059 double rawTimeToDriftT(double rawtime, int layid,
00060 int cellid, double Q) const;
00061
00062
00063
00064
00065
00066 double getSigma(int layid, int lr, double dist,
00067 double entrance = 0.0, double tanlam = 0.0,
00068 double z = 0.0, double Q = 1000.0) const ;
00069 double getSigmaLR(int layid, int lr, double dist,
00070 double entrance = 0.0, double tanlam = 0.0,
00071 double z = 0.0, double Q = 1000.0) const ;
00072 double getSigma1(int layid, int lr, double dist,
00073 double entrance = 0.0, double tanlam = 0.0,
00074 double z = 0.0, double Q = 1000.0) const ;
00075 double getSigma2(int layid, int lr, double dist,
00076 double entrance = 0.0, double tanlam = 0.0,
00077 double z = 0.0, double Q = 1000.0) const ;
00078 double getF(int layid, int lr, double dist,
00079 double entrance = 0.0, double tanlam = 0.0,
00080 double z = 0.0, double Q = 1000.0) const ;
00081
00082 void setXtBegin() { m_xtiter = m_xtmap.begin(); }
00083 int getNextXtpar(int& key, double& par);
00084 void getXtpar(int layid, int entr, int lr, double par[]) const;
00085
00086 double getT0(int layid, int cellid) const ;
00087 double getT0(int wireid) const { return m_t0[wireid]; }
00088 double getDelT0(int wireid) const { return m_delt0[wireid]; }
00089
00090 double getTimeWalk(int layid, double Q) const ;
00091 double getQtpar(int layid, int ord) const;
00092
00093 void setSdBegin() { m_sditer = m_sdmap.begin(); }
00094 int getNextSdpar(int& key, double& par);
00095 void getSdpar(int layid, int entr, int lr, double par[]) const;
00096
00097 int getXtEntrIndex(double entrance) const;
00098 int getSdEntrIndex(double entrance) const;
00099
00100
00101
00102 private:
00103
00104 bool initCalibConst();
00105
00106 int getXtKey(int layid, int entr, int lr, int ord) const;
00107
00108 int getSdKey(int layid, int entr, int lr, int bin) const;
00109
00110 int getXtparId(int layid, int entr, int lr, int ord) const;
00111 int getSdparId(int layid, int entr, int lr, int bin) const;
00112
00113 int m_layInfSig;
00114
00115 IMdcGeomSvc* m_pMdcGeomSvc;
00116 IDataProviderSvc* m_pCalDataSvc;
00117 ICalibRootSvc* m_pRootSvc;
00118
00119
00120 double m_zst[43];
00121
00122
00123 std::map<int, double> m_xtmap;
00124 std::vector<double> m_xtpar;
00125
00126 std::vector<double> m_t0;
00127 std::vector<double> m_delt0;
00128
00129 std::vector<double> m_qtpar0;
00130 std::vector<double> m_qtpar1;
00131
00132 std::map<int, double> m_sdmap;
00133 std::vector<double> m_sdpar;
00134
00135 std::map<int, double>::iterator m_xtiter;
00136 std::map<int, double>::iterator m_sditer;
00137
00138
00139 static const int NWIRE = 6796;
00140 static const int NLAYER = 43;
00141 static const int NXTPAR = 8;
00142 static const int NXTORD = 6;
00143 static const int NSDBIN = 24;
00144
00145 static const int XTLAYER_INDEX = 11;
00146 static const int XTLAYER_MASK = 0x1F800;
00147 static const int XTLAYER_DECO = 0x3F;
00148
00149 static const int XTENTRA_INDEX = 6;
00150 static const int XTENTRA_MASK = 0x7C0;
00151 static const int XTENTRA_DECO = 0x1F;
00152
00153 static const int XTLR_INDEX = 4;
00154 static const int XTLR_MASK = 0x30;
00155 static const int XTLR_DECO = 0x3;
00156
00157 static const int XTORDER_INDEX = 0;
00158 static const int XTORDER_MASK = 0xF;
00159 static const int XTORDER_DECO = 0xF;
00160
00161
00162 static const int SDLAYER_INDEX = 10;
00163 static const int SDLAYER_MASK = 0xFC00;
00164 static const int SDLAYER_DECO = 0x3F;
00165
00166 static const int SDENTRA_INDEX = 7;
00167 static const int SDENTRA_MASK = 0x380;
00168 static const int SDENTRA_DECO = 0x7;
00169
00170 static const int SDLR_INDEX = 5;
00171 static const int SDLR_MASK = 0x60;
00172 static const int SDLR_DECO = 0x3;
00173
00174 static const int SDBIN_INDEX = 0;
00175 static const int SDBIN_MASK = 0x1F;
00176 static const int SDBIN_DECO = 0x1F;
00177 };
00178
00179 inline double MdcCalibFunSvc::getVprop(int lay) const{
00180 if(lay<8) return 220.0;
00181 else return 240.0;
00182 }
00183
00184 inline int MdcCalibFunSvc::getXtparId(int layid, int entr, int lr,
00185 int ord) const{
00186 int parId = (layid * 432) + (entr * 24) + (lr * 8) + ord;
00187 return parId;
00188 }
00189
00190 inline int MdcCalibFunSvc::getSdparId(int layid, int entr, int lr,
00191 int bin) const{
00192 int parId = (layid * 288) + (entr * 48) + (lr * 24) + bin;
00193 return parId;
00194 }
00195
00196 #endif