/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Mdc/MdcCalibFunSvc/MdcCalibFunSvc-00-03-16/MdcCalibFunSvc/MdcCalibFunSvc.h

Go to the documentation of this file.
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      // Incident handler
00032      void handle(const Incident&);
00033 
00034      int m_run;
00035 
00036      /* Access by users */
00037 
00038      /* propagation velocity of the signal in the wire. unit: mm/ns */
00039      double getVprop(int lay) const;
00040 
00041      /* get propagation time. the unit of z is mm */
00042      double getTprop(int lay, double z) const;
00043 
00044      /* DriftTime is real drift time, that is 
00045         DriftTime = Tdc - TOF - T0 - TimeWalk */
00046      /* the unit of distance is mm */
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      /* Sigma1 and Sigma2 are the smaller and the bigger sigma of
00053         the two gaussian distribution, respectively.
00054         Sigma = sqrt( F*Sigma1^2 + (1-F)*Sigma2^2 ) */
00055      /* the unit of distance is mm */
00056      double getSigma(int layid, int lr, double dist,
00057                      double entrance = 0.0, double tanlam = 0.0,
00058                      double z = 0.0, double Q = 1000.0) const ;
00059      double getSigmaLR(int layid, int lr, double dist,
00060                        double entrance = 0.0, double tanlam = 0.0,
00061                        double z = 0.0, double Q = 1000.0) const ;
00062      double getSigma1(int layid, int lr, double dist,
00063                       double entrance = 0.0, double tanlam = 0.0,
00064                       double z = 0.0, double Q = 1000.0) const ;
00065      double getSigma2(int layid, int lr, double dist,
00066                       double entrance = 0.0, double tanlam = 0.0,
00067                       double z = 0.0, double Q = 1000.0) const ;
00068      double getF(int layid, int lr, double dist,
00069                  double entrance = 0.0, double tanlam = 0.0,
00070                  double z = 0.0, double Q = 1000.0) const ;
00071 
00072      double getSigmaToT(int layid, int lr, double tdr,
00073                         double entrance = 0.0, double tanlam = 0.0,
00074                         double z = 0.0, double Q = 1000.0) const ;
00075      double getSigmaToTLR(int layid, int lr, double tdr,
00076                           double entrance = 0.0, double tanlam = 0.0,
00077                           double z = 0.0, double Q = 1000.0) const ;
00078 
00079      void   setXtBegin() { m_xtiter = m_xtmap.begin(); }
00080      int    getNextXtpar(int& key, double& par);
00081      void   getXtpar(int layid, int entr, int lr, double par[]) const;
00082      bool   getNewXtpar() ;
00083      TTree* getNewXtparTree(int layid, int entr, int lr) const;
00084 
00085      double getT0(int layid, int cellid) const ;
00086      double getT0(int wireid) const { return m_t0[wireid]; }
00087      double getDelT0(int wireid) const { return m_delt0[wireid]; }
00088 
00089      double getTimeWalk(int layid, double Q) const ;
00090      double getQtpar(int layid, int ord) const;
00091 
00092      double getWireEff(int layid, int cellid) const ;
00093      double getWireEff(int wireid) const { return m_wireEff[wireid]; }
00094 
00095      void setSdBegin() { m_sditer = m_sdmap.begin(); }
00096      int  getNextSdpar(int& key, double& par);
00097      void getSdpar(int layid, int entr, int lr, double par[]) const;
00098      bool   getR2tpar() ;
00099      TTree* getR2tTree(int layid) const;
00100      
00101      int getXtEntrIndex(double entrance) const;
00102      int getSdEntrIndex(double entrance) const;
00103 
00104 /*      std::string getCalibDataFile() { return m_pRootSvc->getrootfile(); } */
00105 
00106 private:
00107      static const int NWIRE = 6796;
00108      static const int NLAYER = 43;
00109      static const int NXTENTR = 18;
00110      static const int NXTPAR = 8;
00111      static const int NXTORD = 6;
00112      static const int NSDBIN = 24;
00113 
00114      /* initial calib const */
00115      bool initCalibConst();
00116 
00117      double t2dPoly(double drifttime, int layid, int cellid, int lr, 
00118                     double entrance = 0.0) const ;
00119      double t2dInter(double drifttime, int layid, int cellid, int lr, 
00120                      double entrance = 0.0) const ;
00121 
00122 /*      bool   getNewXtpar() ; */
00123 /*      TTree* getNewXtparTree(int layid, int entr, int lr) const; */
00124 
00125 /*      bool   getR2tpar() ; */
00126 /*      TTree* getR2tTree(int layid) const; */
00127 
00128      int  getXtKey(int layid, int entr, int lr, int ord) const;
00129      int getSdKey(int layid, int entr, int lr, int bin) const;
00130      int getXtparId(int layid, int entr, int lr, int ord) const;
00131      int getSdparId(int layid, int entr, int lr, int bin) const;
00132 
00133      void checkConst();
00134      int m_updateNum;
00135      bool m_checkConst;
00136 
00137      int m_layInfSig;           /* the layer with infinite sigma for reconstruction */
00138      int m_xtMode;              /* 0: polynomial, 1: interpretation */
00139      std::string m_xtfile;
00140      bool m_fgR2t;
00141      bool m_linearXT;           /* 1: v=0.03um/ns, 0: read xt from database */
00142      bool m_readWireEffDb;      /* 1: read from DB, 0: read from file */
00143      std::string m_wireEffFile;
00144      bool m_outputXtMode;
00145      bool m_fixSigma;
00146      double m_fixSigmaValue;
00147 
00148      IMdcGeomSvc*       m_pMdcGeomSvc;
00149      IDataProviderSvc*  m_pCalDataSvc;
00150      ICalibRootSvc*     m_pRootSvc;
00151 
00152      /* for calculation Tprop */
00153      double m_zst[43];
00154 
00155      /* calibration constants */
00156      std::map<int, double> m_xtmap;
00157      std::vector<double>   m_xtpar;
00158 
00159      std::vector<double>   m_t0;
00160      std::vector<double>   m_delt0;
00161 
00162      std::vector<double>   m_qtpar0;
00163      std::vector<double>   m_qtpar1;
00164 
00165      std::map<int, double> m_sdmap;
00166      std::vector<double>   m_sdpar;
00167 
00168      std::map<int, double>::iterator m_xtiter;
00169      std::map<int, double>::iterator m_sditer;
00170 
00171      double m_wireEff[6796];
00172 
00173      int m_nNewXt[NLAYER][NXTENTR][2];
00174      double m_vt[NLAYER][NXTENTR][2][200];
00175      double m_vd[NLAYER][NXTENTR][2][200];
00176 
00177      int m_nR2t[NLAYER][NXTENTR][2];
00178      double m_tR2t[NLAYER][NXTENTR][2][200];
00179      double m_sR2t[NLAYER][NXTENTR][2][200];
00180 
00181      static const int XTLAYER_INDEX    = 11;
00182      static const int XTLAYER_MASK     = 0x1F800;
00183      static const int XTLAYER_DECO     = 0x3F;
00184 
00185      static const int XTENTRA_INDEX    = 6;
00186      static const int XTENTRA_MASK     = 0x7C0;
00187      static const int XTENTRA_DECO     = 0x1F;
00188 
00189      static const int XTLR_INDEX       = 4;
00190      static const int XTLR_MASK        = 0x30;
00191      static const int XTLR_DECO        = 0x3;
00192 
00193      static const int XTORDER_INDEX    = 0;
00194      static const int XTORDER_MASK     = 0xF;
00195      static const int XTORDER_DECO     = 0xF;
00196 
00197 
00198      static const int SDLAYER_INDEX    = 10;
00199      static const int SDLAYER_MASK     = 0xFC00;
00200      static const int SDLAYER_DECO     = 0x3F;
00201 
00202      static const int SDENTRA_INDEX    = 7;
00203      static const int SDENTRA_MASK     = 0x380;
00204      static const int SDENTRA_DECO     = 0x7;
00205 
00206      static const int SDLR_INDEX       = 5;
00207      static const int SDLR_MASK        = 0x60;
00208      static const int SDLR_DECO        = 0x3;
00209 
00210      static const int SDBIN_INDEX      = 0;
00211      static const int SDBIN_MASK       = 0x1F;
00212      static const int SDBIN_DECO       = 0x1F;
00213 };
00214 
00215 inline double MdcCalibFunSvc::getVprop(int lay) const{
00216      if(lay<8) return 220.0;
00217      else return 240.0;
00218 }
00219 
00220 inline int MdcCalibFunSvc::getXtparId(int layid, int entr, int lr,
00221                                       int ord) const{
00222      int parId = (layid * 432) + (entr * 24) + (lr * 8) + ord;
00223      return parId;
00224 }
00225 
00226 inline int MdcCalibFunSvc::getSdparId(int layid, int entr, int lr,
00227                                       int bin) const{
00228      int parId = (layid * 288) + (entr * 48) + (lr * 24) + bin;
00229      return parId;
00230 }
00231 
00232 #endif /* MDCCALIBFUNSVC_H_ */

Generated on Tue Nov 29 23:12:52 2016 for BOSS_7.0.2 by  doxygen 1.4.7