MdcCalibFunSvc Class Reference

#include <MdcCalibFunSvc.h>

Inheritance diagram for MdcCalibFunSvc:

IMdcCalibFunSvc List of all members.

Public Member Functions

 MdcCalibFunSvc (const std::string &name, ISvcLocator *svcloc)
 ~MdcCalibFunSvc ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
void handle (const Incident &)
double getVprop (int lay) const
double getTprop (int lay, double z) const
double driftTimeToDist (double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
double distToDriftTime (double dist, int layid, int cellid, int lr, double entrance=0.0) const
double getSigma (int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getSigmaLR (int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getSigma1 (int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getSigma2 (int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getF (int layid, int lr, double dist, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getSigmaToT (int layid, int lr, double tdr, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
double getSigmaToTLR (int layid, int lr, double tdr, double entrance=0.0, double tanlam=0.0, double z=0.0, double Q=1000.0) const
void setXtBegin ()
int getNextXtpar (int &key, double &par)
void getXtpar (int layid, int entr, int lr, double par[]) const
bool getNewXtpar ()
TTree * getNewXtparTree (int layid, int entr, int lr) const
double getT0 (int layid, int cellid) const
double getT0 (int wireid) const
double getDelT0 (int wireid) const
double getTimeWalk (int layid, double Q) const
double getQtpar (int layid, int ord) const
double getWireEff (int layid, int cellid) const
double getWireEff (int wireid) const
void setSdBegin ()
int getNextSdpar (int &key, double &par)
void getSdpar (int layid, int entr, int lr, double par[]) const
bool getR2tpar ()
TTree * getR2tTree (int layid) const
int getXtEntrIndex (double entrance) const
int getSdEntrIndex (double entrance) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Public Attributes

int m_run

Private Member Functions

bool initCalibConst ()
double t2dPoly (double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
double t2dInter (double drifttime, int layid, int cellid, int lr, double entrance=0.0) const
int getXtKey (int layid, int entr, int lr, int ord) const
int getSdKey (int layid, int entr, int lr, int bin) const
int getXtparId (int layid, int entr, int lr, int ord) const
int getSdparId (int layid, int entr, int lr, int bin) const
void checkConst ()

Private Attributes

int m_updateNum
bool m_checkConst
int m_layInfSig
int m_xtMode
std::string m_xtfile
bool m_fgR2t
bool m_linearXT
bool m_readWireEffDb
std::string m_wireEffFile
bool m_outputXtMode
bool m_fixSigma
double m_fixSigmaValue
IMdcGeomSvcm_pMdcGeomSvc
IDataProviderSvc * m_pCalDataSvc
ICalibRootSvcm_pRootSvc
double m_zst [43]
std::map< int, double > m_xtmap
std::vector< double > m_xtpar
std::vector< double > m_t0
std::vector< double > m_delt0
std::vector< double > m_qtpar0
std::vector< double > m_qtpar1
std::map< int, double > m_sdmap
std::vector< double > m_sdpar
std::map< int, double >::iterator m_xtiter
std::map< int, double >::iterator m_sditer
double m_wireEff [6796]
int m_nNewXt [NLAYER][NXTENTR][2]
double m_vt [NLAYER][NXTENTR][2][200]
double m_vd [NLAYER][NXTENTR][2][200]
int m_nR2t [NLAYER][NXTENTR][2]
double m_tR2t [NLAYER][NXTENTR][2][200]
double m_sR2t [NLAYER][NXTENTR][2][200]

Static Private Attributes

static const int NWIRE = 6796
static const int NLAYER = 43
static const int NXTENTR = 18
static const int NXTPAR = 8
static const int NXTORD = 6
static const int NSDBIN = 24
static const int XTLAYER_INDEX = 11
static const int XTLAYER_MASK = 0x1F800
static const int XTLAYER_DECO = 0x3F
static const int XTENTRA_INDEX = 6
static const int XTENTRA_MASK = 0x7C0
static const int XTENTRA_DECO = 0x1F
static const int XTLR_INDEX = 4
static const int XTLR_MASK = 0x30
static const int XTLR_DECO = 0x3
static const int XTORDER_INDEX = 0
static const int XTORDER_MASK = 0xF
static const int XTORDER_DECO = 0xF
static const int SDLAYER_INDEX = 10
static const int SDLAYER_MASK = 0xFC00
static const int SDLAYER_DECO = 0x3F
static const int SDENTRA_INDEX = 7
static const int SDENTRA_MASK = 0x380
static const int SDENTRA_DECO = 0x7
static const int SDLR_INDEX = 5
static const int SDLR_MASK = 0x60
static const int SDLR_DECO = 0x3
static const int SDBIN_INDEX = 0
static const int SDBIN_MASK = 0x1F
static const int SDBIN_DECO = 0x1F

Detailed Description

Definition at line 21 of file MdcCalibFunSvc.h.


Constructor & Destructor Documentation

MdcCalibFunSvc::MdcCalibFunSvc ( const std::string name,
ISvcLocator *  svcloc 
)

MdcCalibFunSvc::~MdcCalibFunSvc (  ) 

Definition at line 54 of file MdcCalibFunSvc.cxx.

00054                                {
00055 }


Member Function Documentation

void MdcCalibFunSvc::checkConst (  )  [private]

Definition at line 824 of file MdcCalibFunSvc.cxx.

References bin, fname, genRecEmupikp::i, key, m_delt0, m_nNewXt, m_nR2t, m_qtpar0, m_qtpar1, m_sdmap, m_sdpar, m_sR2t, m_t0, m_tR2t, m_updateNum, m_vd, m_vt, m_xtmap, and m_xtpar.

Referenced by initCalibConst().

00824                                {
00825      char fname[200];
00826      sprintf(fname, "checkXt_%d.txt", m_updateNum);
00827      ofstream fxt(fname);
00828      unsigned mapsize = m_xtmap.size();
00829      unsigned vsize = m_xtpar.size();
00830      fxt << setw(10) << mapsize << setw(10) << vsize << endl << endl;
00831      int key;
00832      double par;
00833      std::map<int, double>::iterator xtiter = m_xtmap.begin();
00834      while(  xtiter != m_xtmap.end() ){
00835           key = (*xtiter).first;
00836           par = (*xtiter).second;
00837           fxt << setw(20) << key << setw(20) << par << endl;
00838           xtiter++;
00839      }
00840      fxt << endl;
00841      for(unsigned i=0; i<vsize; i++){
00842           fxt << setw(5) << i << setw(15) << m_xtpar[i] << endl;
00843      }
00844      fxt.close();
00845 
00846      sprintf(fname, "checkT0_%d.txt", m_updateNum);
00847      ofstream ft0(fname);
00848      ft0 << setw(10) << m_t0.size() << setw(10) << m_delt0.size() << endl;
00849      for(unsigned i=0; i<m_t0.size(); i++){
00850           ft0 << setw(5) << i << setw(15) << m_t0[i] << setw(15) << m_delt0[i] << endl;
00851      }
00852      ft0.close();
00853 
00854      sprintf(fname, "checkQt_%d.txt", m_updateNum);
00855      ofstream fqt(fname);
00856      fqt << setw(10) << m_qtpar0.size() << setw(10) << m_qtpar1.size() << endl;
00857      for(unsigned i=0; i<m_qtpar0.size(); i++){
00858           fqt << setw(5) << i << setw(15) << m_qtpar0[i] << setw(15) << m_qtpar1[i] << endl;
00859      }
00860      fqt.close();
00861 
00862      sprintf(fname, "checkSd_%d.txt", m_updateNum);
00863      ofstream fsd(fname);
00864      mapsize = m_sdmap.size();
00865      vsize = m_sdpar.size();
00866      fsd << setw(10) << mapsize << setw(10) << vsize << endl << endl;
00867      std::map<int, double>::iterator sditer = m_sdmap.begin();
00868      while(  sditer != m_sdmap.end() ){
00869           key = (*sditer).first;
00870           par = (*sditer).second;
00871           fsd << setw(20) << key << setw(20) << par << endl;
00872           sditer++;
00873      }
00874      fsd << endl;
00875      for(unsigned i=0; i<vsize; i++){
00876           fsd << setw(5) << i << setw(15) << m_sdpar[i] << endl;
00877      }
00878      fsd.close();
00879 
00880      sprintf(fname, "checkNewXt_%d.txt", m_updateNum);
00881      ofstream fnewxt(fname);
00882      for(int lay=0; lay<43; lay++){
00883           for(int iEntr=0; iEntr<18; iEntr++){
00884                for(int lr=0; lr<2; lr++){
00885                     fnewxt << setw(5) << lay << setw(5) << iEntr << setw(3) << lr
00886                            << setw(5) << m_nNewXt[lay][iEntr][lr] << endl;
00887                     for(int bin=0; bin<m_nNewXt[lay][iEntr][lr]; bin++){
00888                          fnewxt << setw(15) << m_vt[lay][iEntr][lr][bin]
00889                                 << setw(15) << m_vd[lay][iEntr][lr][bin] << endl;
00890                     }
00891                }
00892           }
00893      }
00894      fnewxt.close();
00895 
00896      sprintf(fname, "checkR2t_%d.txt", m_updateNum);
00897      ofstream fr2t(fname);
00898      for(int lay=0; lay<43; lay++){
00899           for(int iEntr=0; iEntr<18; iEntr++){
00900                for(int lr=0; lr<2; lr++){
00901                     fr2t << setw(5) << lay << setw(5) << iEntr << setw(3) << lr
00902                          << setw(5) << m_nR2t[lay][iEntr][lr] << endl;
00903                     for(int bin=0; bin<m_nR2t[lay][iEntr][lr]; bin++){
00904                          fr2t << setw(15) << m_tR2t[lay][iEntr][lr][bin]
00905                               << setw(15) << m_sR2t[lay][iEntr][lr][bin] << endl;
00906                     }
00907                }
00908           }
00909      }
00910      fr2t.close();
00911 }

double MdcCalibFunSvc::distToDriftTime ( double  dist,
int  layid,
int  cellid,
int  lr,
double  entrance = 0.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 214 of file MdcCalibFunSvc.cxx.

References driftTimeToDist(), getXtEntrIndex(), getXtpar(), genRecEmupikp::i, m_linearXT, and x.

Referenced by EsTimeAlg::execute().

00215                                                                       {
00216      int i = 0;
00217      double time;
00218      int ord;
00219      double xtpar[8];
00220      double dxdtpar[5];
00221      double x;
00222      double dxdt;
00223      double deltax;
00224 
00225      int entr = getXtEntrIndex(entrance);
00226      getXtpar(layid, entr, lr, xtpar);
00227 
00228      double tm1 = xtpar[6];
00229      double tm2 = 2000.0;
00230      double dm1 = driftTimeToDist(tm1, layid, cellid, lr, entrance);
00231      double dm2 = driftTimeToDist(tm2, layid, cellid, lr, entrance);
00232 
00233      if(dist < 0){
00234           cout << "Warning in MdcCalibFunSvc: driftDist < 0" << endl;
00235           time = 0.0;
00236      } else if(dist < xtpar[0]){
00237           time = 0.0;
00238      } else if(dist < dm1){
00239           for(ord=0; ord<5; ord++){
00240                dxdtpar[ord] = (double)(ord+1) * xtpar[ord+1];
00241           }
00242           time = dist / 0.03;
00243           while(1){
00244                if( i > 50 ){
00245                     cout << "Warning in MdcCalibFunSvc: "
00246                          << "can not get the exact value in the dist-to-time conversion." 
00247                          << endl;
00248                     time = dist / 0.03;
00249                     break;
00250                }
00251 
00252                x = 0.0;
00253                for(ord=0; ord<6; ord++)
00254                     x += xtpar[ord] * pow(time, ord);
00255 
00256                deltax = x - dist;
00257                if( fabs(deltax) < 0.001 ){
00258                     break;
00259                }
00260 
00261                dxdt = 0.0;
00262                for(ord=0; ord<5; ord++)
00263                     dxdt += dxdtpar[ord] * pow(time, ord);
00264 
00265                time = time - (deltax / dxdt);
00266                i++;
00267           }
00268      } else if(dist < dm2){
00269           time = (dist - dm1) * (tm2 - tm1) / (dm2 - dm1) + tm1;
00270      } else{
00271           time = tm2;
00272      }
00273 
00274      if(m_linearXT) time = dist / 0.03;
00275      return time;
00276 }

double MdcCalibFunSvc::driftTimeToDist ( double  drifttime,
int  layid,
int  cellid,
int  lr,
double  entrance = 0.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 149 of file MdcCalibFunSvc.cxx.

References check_raw_filter::dist, m_linearXT, m_xtMode, t2dInter(), and t2dPoly().

Referenced by MdcxHit::d(), distToDriftTime(), MdcHit::driftDist(), TrkReco::execute(), and KalFitTrack::getDriftDist().

00150                                                                       {
00151      double dist;
00152      if(0 == m_xtMode){
00153           dist = t2dPoly(drifttime, layid, cellid, lr, entrance);
00154      } else{
00155           if((0==lr) || (1==lr)) dist = t2dInter(drifttime, layid, cellid, lr, entrance);
00156           else{
00157                double dl = t2dInter(drifttime, layid, cellid, lr, entrance);
00158                double dr = t2dInter(drifttime, layid, cellid, lr, entrance);
00159                dist = (dl + dr) * 0.5;
00160           }
00161      }
00162 //      cout << setw(15) << drifttime << setw(15) << dist << endl;
00163      if(m_linearXT) dist = 0.03 * drifttime;
00164      return dist;
00165 }

StatusCode MdcCalibFunSvc::finalize (  )  [virtual]

Definition at line 106 of file MdcCalibFunSvc.cxx.

References Bes_Common::INFO, m_delt0, m_qtpar0, m_qtpar1, m_sdmap, m_t0, and m_xtmap.

00106                                    {
00107      MsgStream log(messageService(), name());
00108      log << MSG::INFO << "MdcCalibFunSvc::finalize()" << endreq;
00109 
00110      m_xtmap.clear();
00111      m_t0.clear();
00112      m_delt0.clear();
00113      m_qtpar0.clear();
00114      m_qtpar1.clear();
00115      m_sdmap.clear();
00116 
00117      return StatusCode::SUCCESS;
00118 }

double MdcCalibFunSvc::getDelT0 ( int  wireid  )  const [inline, virtual]

Implements IMdcCalibFunSvc.

Definition at line 87 of file MdcCalibFunSvc.h.

References m_delt0.

00087 { return m_delt0[wireid]; }

double MdcCalibFunSvc::getF ( int  layid,
int  lr,
double  dist,
double  entrance = 0.0,
double  tanlam = 0.0,
double  z = 0.0,
double  Q = 1000.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 352 of file MdcCalibFunSvc.cxx.

00354                                                       {
00355 
00356      return 1.0;
00357 }

bool MdcCalibFunSvc::getNewXtpar (  )  [virtual]

Implements IMdcCalibFunSvc.

Definition at line 416 of file MdcCalibFunSvc.cxx.

References calibUtil::ERROR, getNewXtparTree(), genRecEmupikp::i, Bes_Common::INFO, m_nNewXt, m_vd, m_vt, NLAYER, and NXTENTR.

Referenced by initCalibConst().

00416                                  {
00417      MsgStream log(messageService(), name());
00418      log << MSG::INFO << "read calib const from TCDS" << endreq;
00419 
00420      for(int layid=0; layid<NLAYER; layid++){
00421           for(int entr=0; entr<NXTENTR; entr++){
00422                for(int lr=0; lr<2; lr++){
00423                     double br_t,br_d;
00424                     TTree* newXtTree = getNewXtparTree(layid,entr,lr);
00425                     if(!newXtTree) return false;
00426                     newXtTree -> SetBranchAddress("t", &br_t);
00427                     newXtTree -> SetBranchAddress("d", &br_d);
00428                     int nEntries = newXtTree -> GetEntries();
00429                     if((nEntries<10) || (nEntries>=200)){
00430                          log << MSG::ERROR << "wrong X-T constants: layer " << layid
00431                              << ", iEntr " << entr << ", lr " << lr << endreq;
00432                          return false;
00433                     }
00434                     m_nNewXt[layid][entr][lr] = nEntries;
00435                     for(int i=0; i<nEntries; i++){
00436                          newXtTree->GetEntry(i);
00437                          m_vt[layid][entr][lr][i] = br_t;
00438                          m_vd[layid][entr][lr][i] = br_d;
00439                     }//end loop entries
00440                }//end lr
00441           }//end entr
00442      }//end layid
00443 
00444      return true;
00445 }

TTree * MdcCalibFunSvc::getNewXtparTree ( int  layid,
int  entr,
int  lr 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 447 of file MdcCalibFunSvc.cxx.

References calibUtil::ERROR, m_pCalDataSvc, and deljobs::string.

Referenced by getNewXtpar().

00447                                                                        {
00448      MsgStream log(messageService(), name());
00449      string fullPath = "/Calib/MdcCal";
00450      SmartDataPtr<CalibData::MdcCalibData> calConst(m_pCalDataSvc, fullPath);
00451      if( ! calConst ){
00452           log << MSG::ERROR << "can not get MdcCalibConst via SmartPtr" << endreq;
00453           return NULL;
00454      }
00455 
00456      TTree* newXtTree = calConst->getNewXtpar(layid,entr,lr);
00457      return newXtTree;
00458 }

int MdcCalibFunSvc::getNextSdpar ( int &  key,
double &  par 
) [virtual]

Implements IMdcCalibFunSvc.

Definition at line 556 of file MdcCalibFunSvc.cxx.

References m_sditer, and m_sdmap.

Referenced by initCalibConst().

00556                                                      {
00557      if( m_sditer != m_sdmap.end() ){
00558           key = (*m_sditer).first;
00559           par = (*m_sditer).second;
00560           m_sditer++;
00561           return 1;
00562      }
00563      else return 0;
00564 }

int MdcCalibFunSvc::getNextXtpar ( int &  key,
double &  par 
) [virtual]

Implements IMdcCalibFunSvc.

Definition at line 398 of file MdcCalibFunSvc.cxx.

References m_xtiter, and m_xtmap.

00398                                                      {
00399      if( m_xtiter != m_xtmap.end() ){
00400           key = (*m_xtiter).first;
00401           par = (*m_xtiter).second;
00402           m_xtiter++;
00403           return 1;
00404      }
00405      else return 0;
00406 }

double MdcCalibFunSvc::getQtpar ( int  layid,
int  ord 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 536 of file MdcCalibFunSvc.cxx.

References m_qtpar0, and m_qtpar1.

Referenced by getTimeWalk().

00536                                                         {
00537      if(0 == ord)       return m_qtpar0[layid];
00538      else if(1 == ord)  return m_qtpar1[layid];
00539      else {
00540           cout << "wrong order number" << endl;
00541           return 0.0;
00542      }
00543 }

bool MdcCalibFunSvc::getR2tpar (  )  [virtual]

Implements IMdcCalibFunSvc.

Definition at line 460 of file MdcCalibFunSvc.cxx.

References bin, getR2tTree(), genRecEmupikp::i, m_nR2t, m_sR2t, m_tR2t, NLAYER, and NXTENTR.

Referenced by initCalibConst().

00460                                {
00461      for(int layid=0; layid<NLAYER; layid++){
00462           int br_iEntr,br_lr;
00463           double br_s,br_t;
00464           TTree* r2tTree = getR2tTree(layid);
00465           if(!r2tTree) return false;
00466           r2tTree -> SetBranchAddress("iEntr", &br_iEntr);
00467           r2tTree -> SetBranchAddress("lr", &br_lr);
00468           r2tTree -> SetBranchAddress("s", &br_s);
00469           r2tTree -> SetBranchAddress("t", &br_t);
00470           int nEntries = r2tTree -> GetEntries();
00471           for(int i=0; i<nEntries; i++){
00472                r2tTree->GetEntry(i);
00473                int bin = m_nR2t[layid][br_iEntr][br_lr];
00474                if(bin>=200){
00475                     cout << "Error: number of sigma-time bins overflow" << endl;
00476                     return false;
00477                }
00478                m_tR2t[layid][br_iEntr][br_lr][bin] = br_t;
00479                m_sR2t[layid][br_iEntr][br_lr][bin] = br_s;
00480                m_nR2t[layid][br_iEntr][br_lr]++;
00481           }
00482      }
00483      for(int layid=0; layid<NLAYER; layid++){
00484           for(int iEntr=0; iEntr<NXTENTR; iEntr++){
00485                for(int lr=0; lr<2; lr++){
00486                     if((m_nR2t[layid][iEntr][lr]<10) || (m_nR2t[layid][iEntr][lr]>=200)) return false;
00487                }
00488           }
00489      }
00490      return true;
00491 }

TTree * MdcCalibFunSvc::getR2tTree ( int  layid  )  const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 493 of file MdcCalibFunSvc.cxx.

References calibUtil::ERROR, m_pCalDataSvc, and deljobs::string.

Referenced by getR2tpar().

00493                                                 {
00494      MsgStream log(messageService(), name());
00495      string fullPath = "/Calib/MdcCal";
00496      SmartDataPtr<CalibData::MdcCalibData> calConst(m_pCalDataSvc, fullPath);
00497      if( ! calConst ){
00498           log << MSG::ERROR << "can not get MdcCalibConst via SmartPtr" << endreq;
00499           return NULL;
00500      }
00501 
00502      TTree* r2tTree = calConst->getR2tpar(layid);
00503      return r2tTree;
00504 }

int MdcCalibFunSvc::getSdEntrIndex ( double  entrance  )  const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 597 of file MdcCalibFunSvc.cxx.

References genRecEmupikp::i, and Bes_Common::WARNING.

Referenced by getSigmaLR().

00597                                                         {
00598      int i;
00599      int index;
00600      int idmax = 5;
00601      double aglpi = 3.141592653;
00602      double aglmin = -1.570796327; // -90 degree
00603      double aglmax = 1.570796327; // 90 degree
00604      double delAngle = 0.523598776; // 30 degree
00605 
00606      MsgStream log(messageService(), name());
00607      if(entrance < aglmin){
00608           log << MSG::WARNING << "entrance angle < -pi/2" << endreq;
00609           while(1){
00610                entrance += aglpi;
00611                if(entrance >= aglmin) break;
00612           }
00613      } else if(entrance > aglmax){
00614           log << MSG::WARNING << "entrance angle > pi/2" << endreq;
00615           while(1){
00616                entrance -= aglpi;
00617                if(entrance <= aglmax) break;
00618           }
00619      }
00620 
00621      index = (int)((entrance-aglmin) / delAngle);
00622      if(index < 0) index = 0;
00623      else if(index > idmax) index = idmax;
00624 
00625      return index;
00626 }

int MdcCalibFunSvc::getSdKey ( int  layid,
int  entr,
int  lr,
int  bin 
) const [private]

Definition at line 815 of file MdcCalibFunSvc.cxx.

References key, SDBIN_INDEX, SDBIN_MASK, SDENTRA_INDEX, SDENTRA_MASK, SDLAYER_INDEX, SDLAYER_MASK, SDLR_INDEX, and SDLR_MASK.

00815                                                                        {
00816      int key = ( (layid << SDLAYER_INDEX) & SDLAYER_MASK ) |
00817           ( (entr << SDENTRA_INDEX) & SDENTRA_MASK ) |
00818           ( (lr << SDLR_INDEX) & SDLR_MASK ) |
00819           ( (ord << SDBIN_INDEX) & SDBIN_MASK );
00820 
00821      return key;
00822 }

void MdcCalibFunSvc::getSdpar ( int  layid,
int  entr,
int  lr,
double  par[] 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 545 of file MdcCalibFunSvc.cxx.

References bin, getSdparId(), m_sdpar, and NSDBIN.

Referenced by getSigmaLR().

00545                                                                             {
00546      int parId;
00547      if( (entr < 0) || (entr >= 18) ){
00548           entr = 17;
00549      }
00550      for(int bin=0; bin<NSDBIN; bin++){
00551           parId = getSdparId(layid, entr, lr, bin);
00552           par[bin] = m_sdpar[parId];
00553      }
00554 }

int MdcCalibFunSvc::getSdparId ( int  layid,
int  entr,
int  lr,
int  bin 
) const [inline, private]

Definition at line 226 of file MdcCalibFunSvc.h.

Referenced by getSdpar(), and initCalibConst().

00227                                                     {
00228      int parId = (layid * 288) + (entr * 48) + (lr * 24) + bin;
00229      return parId;
00230 }

double MdcCalibFunSvc::getSigma ( int  layid,
int  lr,
double  dist,
double  entrance = 0.0,
double  tanlam = 0.0,
double  z = 0.0,
double  Q = 1000.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 278 of file MdcCalibFunSvc.cxx.

References getSigmaLR(), m_fixSigma, m_fixSigmaValue, and m_layInfSig.

Referenced by TrkReco::execute(), MdcxHit::getSigma(), KalFitTrack::getSigma(), and getSigma1().

00280                                                           {
00281      double sigma;
00282      if( (0 == lr) || (1 == lr) ){
00283           sigma = getSigmaLR(layid, lr, dist, entrance, tanlam, z, Q);
00284      } else{
00285           double sl = getSigmaLR(layid, 0, dist, entrance, tanlam, z, Q);
00286           double sr = getSigmaLR(layid, 1, dist, entrance, tanlam, z, Q);
00287           sigma = (sl + sr) * 0.5;
00288      }
00289 
00290      if(m_fixSigma) sigma = 0.001 * m_fixSigmaValue;
00291      if(layid == m_layInfSig) sigma = 9999.0;
00292      return sigma;
00293 }

double MdcCalibFunSvc::getSigma1 ( int  layid,
int  lr,
double  dist,
double  entrance = 0.0,
double  tanlam = 0.0,
double  z = 0.0,
double  Q = 1000.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 338 of file MdcCalibFunSvc.cxx.

References getSigma().

00340                                                            {
00341      double sigma1 = getSigma(layid, lr, dist, entrance, tanlam, z, Q);
00342      return sigma1;
00343 }

double MdcCalibFunSvc::getSigma2 ( int  layid,
int  lr,
double  dist,
double  entrance = 0.0,
double  tanlam = 0.0,
double  z = 0.0,
double  Q = 1000.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 345 of file MdcCalibFunSvc.cxx.

00347                                                            {
00348 
00349      return 0.0;
00350 }

double MdcCalibFunSvc::getSigmaLR ( int  layid,
int  lr,
double  dist,
double  entrance = 0.0,
double  tanlam = 0.0,
double  z = 0.0,
double  Q = 1000.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 295 of file MdcCalibFunSvc.cxx.

References bin, dmin, getSdEntrIndex(), getSdpar(), and NSDBIN.

Referenced by getSigma().

00297                                                             {
00298 
00299      double sigma = 9999.0;
00300      double par[NSDBIN];
00301 
00302      int entr = getSdEntrIndex(entrance);
00303      getSdpar(layid, entr, lr, par);
00304 
00305      int nmaxBin;
00306      double dw = 0.5;           // width of each distance bin
00307      double dmin = 0.25;        // mm
00308      if(layid < 8){
00309           nmaxBin = 20; // 11->20 2011-12-10
00310      } else{
00311           nmaxBin = 20; // 15->20 2011-12-10
00312      }
00313 
00314      double dref[2];
00315      double distAbs = fabs(dist);
00316      if(distAbs < dmin){
00317           sigma = par[0];
00318      } else{
00319           int bin = (int)((distAbs - dmin) / dw);
00320           if(bin >= nmaxBin){
00321                sigma = par[nmaxBin];
00322           } else if(bin < 0){
00323                sigma = par[0];
00324           } else{
00325                dref[0] = (double)bin * dw + 0.25;
00326                dref[1] = (double)(bin+1) * dw + 0.25;
00327                if((dref[1] - dref[0]) <= 0){
00328                     sigma = 9999.0;
00329                } else{
00330                     sigma = (par[bin+1] - par[bin]) * (distAbs - dref[0]) /
00331                          (dref[1] - dref[0]) + par[bin];
00332                }
00333           }
00334      }
00335      return sigma;
00336 }

double MdcCalibFunSvc::getSigmaToT ( int  layid,
int  lr,
double  tdr,
double  entrance = 0.0,
double  tanlam = 0.0,
double  z = 0.0,
double  Q = 1000.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 359 of file MdcCalibFunSvc.cxx.

References getSigmaToTLR(), and m_fgR2t.

00360                                                                            {
00361      if(!m_fgR2t){
00362           cout << "ERROR: can not get sigma-time functions" << endl;
00363           return -999.0;
00364      } else if( (0 == lr) || (1 == lr) ){
00365           return getSigmaToTLR(layid, lr, tdr, entrance, tanlam, z, Q);
00366      } else{
00367           double sl = getSigmaToTLR(layid, 0, tdr, entrance, tanlam, z, Q);
00368           double sr = getSigmaToTLR(layid, 1, tdr, entrance, tanlam, z, Q);
00369           double sigma = (sl + sr) * 0.5;
00370           return sigma;
00371      }
00372 }

double MdcCalibFunSvc::getSigmaToTLR ( int  layid,
int  lr,
double  tdr,
double  entrance = 0.0,
double  tanlam = 0.0,
double  z = 0.0,
double  Q = 1000.0 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 374 of file MdcCalibFunSvc.cxx.

References getXtEntrIndex(), genRecEmupikp::i, m_nR2t, m_sR2t, and m_tR2t.

Referenced by getSigmaToT().

00375                                                                              {
00376      double sigma;
00377      int iEntr = getXtEntrIndex(entrance);
00378      int nBin = m_nR2t[layid][iEntr][lr];
00379      if(tdr < m_tR2t[layid][iEntr][lr][0]){
00380           sigma = m_sR2t[layid][iEntr][lr][0];
00381      } else if(tdr < m_tR2t[layid][iEntr][lr][nBin-1]){
00382           for(int i=0; i<(nBin-1); i++){
00383                if((tdr>=m_tR2t[layid][iEntr][lr][i]) && (tdr<m_tR2t[layid][iEntr][lr][i+1])){
00384                     double t1 = m_tR2t[layid][iEntr][lr][i];
00385                     double t2 = m_tR2t[layid][iEntr][lr][i+1];
00386                     double s1 = m_sR2t[layid][iEntr][lr][i];
00387                     double s2 = m_sR2t[layid][iEntr][lr][i+1];
00388                     sigma = (tdr-t1) * (s2-s1) / (t2-t1) + s1;
00389                     break;
00390                }
00391           }
00392      } else{
00393           sigma = m_sR2t[layid][iEntr][lr][nBin-1];
00394      }
00395      return sigma;
00396 }

double MdcCalibFunSvc::getT0 ( int  wireid  )  const [inline, virtual]

Implements IMdcCalibFunSvc.

Definition at line 86 of file MdcCalibFunSvc.h.

References m_t0.

00086 { return m_t0[wireid]; }

double MdcCalibFunSvc::getT0 ( int  layid,
int  cellid 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 507 of file MdcCalibFunSvc.cxx.

References MdcGeoWire::Id(), m_pMdcGeomSvc, and IMdcGeomSvc::Wire().

Referenced by MdcHoughFinder::digiToHots(), HoughValidUpdate::digiToHots(), MdcHoughFinder::digiToHots2(), HoughValidUpdate::digiToHots2(), TrkReco::execute(), EsTimeAlg::execute(), KalFitTrack::getDriftTime(), MdcxHit::process(), and MdcHit::setCalibSvc().

00507                                                         {
00508      int wireid = m_pMdcGeomSvc->Wire(layid, cellid)->Id();
00509      double t0 = getT0(wireid);
00510 
00511      return t0;
00512 }

double MdcCalibFunSvc::getTimeWalk ( int  layid,
double  Q 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 514 of file MdcCalibFunSvc.cxx.

References getQtpar(), and m_run.

Referenced by MdcHoughFinder::digiToHots(), HoughValidUpdate::digiToHots(), MdcHoughFinder::digiToHots2(), HoughValidUpdate::digiToHots2(), TrkReco::execute(), EsTimeAlg::execute(), KalFitTrack::getDriftTime(), MdcxHit::process(), and MdcHit::setCalibSvc().

00514                                                             {
00515      double tw = 0.0;
00516      double qtpar[2];
00517      int ord;
00518 
00519      if(Q < 0.0001) Q = 0.0001;
00520 
00521      for(ord=0; ord<2; ord++){
00522           qtpar[ord] = getQtpar(layid, ord);
00523      }
00524 
00525      tw = qtpar[0] + qtpar[1] / sqrt( Q );
00526      if(m_run < 0) tw = 0.0;    // for MC
00527 
00528      return tw;
00529 }

double MdcCalibFunSvc::getTprop ( int  lay,
double  z 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 143 of file MdcCalibFunSvc.cxx.

References getVprop(), and m_zst.

Referenced by MdcHit::driftTime(), and MdcxHit::tcor().

00143                                                       {
00144      double vp = getVprop(lay);
00145      double tp = fabs(z - m_zst[lay]) / vp;
00146      return tp;
00147 }

double MdcCalibFunSvc::getVprop ( int  lay  )  const [inline, virtual]

Implements IMdcCalibFunSvc.

Definition at line 215 of file MdcCalibFunSvc.h.

Referenced by getTprop().

00215                                                    {
00216      if(lay<8) return 220.0;
00217      else return 240.0;
00218 }

double MdcCalibFunSvc::getWireEff ( int  wireid  )  const [inline, virtual]

Implements IMdcCalibFunSvc.

Definition at line 93 of file MdcCalibFunSvc.h.

References m_wireEff.

00093 { return m_wireEff[wireid]; }

double MdcCalibFunSvc::getWireEff ( int  layid,
int  cellid 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 531 of file MdcCalibFunSvc.cxx.

References MdcGeoWire::Id(), m_pMdcGeomSvc, m_wireEff, and IMdcGeomSvc::Wire().

00531                                                              {
00532      int wireid = m_pMdcGeomSvc->Wire(layid, cellid)->Id();
00533      return m_wireEff[wireid];
00534 }

int MdcCalibFunSvc::getXtEntrIndex ( double  entrance  )  const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 566 of file MdcCalibFunSvc.cxx.

References genRecEmupikp::i, and Bes_Common::WARNING.

Referenced by distToDriftTime(), getSigmaToTLR(), t2dInter(), and t2dPoly().

00566                                                         {
00567      int i;
00568      int index;
00569      int idmax = 17;
00570      double aglpi = 3.141592653;
00571      double aglmin = -1.570796327; // -90 degree
00572      double aglmax = 1.570796327; // 90 degree
00573      double delAngle = 0.174532925; // 10 degree
00574 
00575      MsgStream log(messageService(), name());
00576      if(entrance < aglmin){
00577           log << MSG::WARNING << "entrance angle < -pi/2" << endreq;
00578           while(1){
00579                entrance += aglpi;
00580                if(entrance >= aglmin) break;
00581           }
00582      } else if(entrance > aglmax){
00583           log << MSG::WARNING << "entrance angle > pi/2" << endreq;
00584           while(1){
00585                entrance -= aglpi;
00586                if(entrance <= aglmax) break;
00587           }
00588      }
00589 
00590      index = (int)((entrance-aglmin) / delAngle);
00591      if(index < 0) index = 0;
00592      else if(index > idmax) index = idmax;
00593 
00594      return index;
00595 }

int MdcCalibFunSvc::getXtKey ( int  layid,
int  entr,
int  lr,
int  ord 
) const [private]

Definition at line 805 of file MdcCalibFunSvc.cxx.

References key, XTENTRA_INDEX, XTENTRA_MASK, XTLAYER_INDEX, XTLAYER_MASK, XTLR_INDEX, XTLR_MASK, XTORDER_INDEX, and XTORDER_MASK.

00805                                                                       {
00806 
00807      int key = ( (layid << XTLAYER_INDEX) & XTLAYER_MASK ) |
00808           ( (entr << XTENTRA_INDEX) & XTENTRA_MASK ) |
00809           ( (lr << XTLR_INDEX) & XTLR_MASK ) |
00810           ( (ord << XTORDER_INDEX) & XTORDER_MASK );
00811 
00812      return key;
00813 }

void MdcCalibFunSvc::getXtpar ( int  layid,
int  entr,
int  lr,
double  par[] 
) const [virtual]

Implements IMdcCalibFunSvc.

Definition at line 408 of file MdcCalibFunSvc.cxx.

References getXtparId(), and m_xtpar.

Referenced by distToDriftTime(), and t2dPoly().

00408                                                                             {
00409      int parId;
00410      for(int ord=0; ord<8; ord++){
00411           parId = getXtparId(layid, entr, lr, ord);
00412           par[ord] = m_xtpar[parId];
00413      }
00414 }

int MdcCalibFunSvc::getXtparId ( int  layid,
int  entr,
int  lr,
int  ord 
) const [inline, private]

Definition at line 220 of file MdcCalibFunSvc.h.

Referenced by getXtpar(), and initCalibConst().

00221                                                     {
00222      int parId = (layid * 432) + (entr * 24) + (lr * 8) + ord;
00223      return parId;
00224 }

void MdcCalibFunSvc::handle ( const Incident &   ) 

Definition at line 120 of file MdcCalibFunSvc.cxx.

References Bes_Common::DEBUG, calibUtil::ERROR, and initCalibConst().

00120                                               {
00121      MsgStream log( messageService(), name() );
00122      log << MSG::DEBUG << "handle: " << inc.type() << endreq;
00123 
00124      if ( inc.type() == "NewRun" ){
00125           log << MSG::DEBUG << "NewRun" << endreq;
00126 
00127           if( ! initCalibConst() ){
00128                log << MSG::ERROR 
00129                    << "can not initilize Mdc Calib Constants" << endl
00130                    << "  Please insert the following statement "
00131                    << "in your \"jobOption.txt\" "
00132                    << "before the include file of Mdc Reconstruction: "
00133                    << endl << "        "
00134                    << "#include \"$CALIBSVCROOT/share/job-CalibData.txt\""
00135                    << endl
00136                    << "  If still error, please contact with Wu Linghui "
00137                    << "(wulh@mail.ihep.ac.cn)."
00138                    << endreq;
00139           }
00140      } 
00141 }

bool MdcCalibFunSvc::initCalibConst (  )  [private, virtual]

Implements IMdcCalibFunSvc.

Definition at line 628 of file MdcCalibFunSvc.cxx.

References MdcGeoWire::Backward(), checkConst(), calibUtil::ERROR, Bes_Common::FATAL, MdcGeoWire::Forward(), getNewXtpar(), getNextSdpar(), getR2tpar(), getSdparId(), getXtparId(), genRecEmupikp::i, Bes_Common::INFO, key, m_checkConst, m_delt0, m_fgR2t, m_nR2t, m_outputXtMode, m_pCalDataSvc, m_pMdcGeomSvc, m_qtpar0, m_qtpar1, m_readWireEffDb, m_run, m_sdmap, m_sdpar, m_t0, m_updateNum, m_wireEff, m_wireEffFile, m_xtmap, m_xtMode, m_xtpar, m_zst, NLAYER, NWIRE, NXTENTR, SDBIN_DECO, SDBIN_INDEX, SDENTRA_DECO, SDENTRA_INDEX, SDLAYER_DECO, SDLAYER_INDEX, SDLR_DECO, SDLR_INDEX, setSdBegin(), setXtBegin(), deljobs::string, Bes_Common::WARNING, IMdcGeomSvc::Wire(), XTENTRA_DECO, XTENTRA_INDEX, XTLAYER_DECO, XTLAYER_INDEX, XTLR_DECO, XTLR_INDEX, XTORDER_DECO, and XTORDER_INDEX.

Referenced by handle().

00628                                    {
00629      MsgStream log(messageService(), name());
00630      log << MSG::INFO << "read calib const from TCDS" << endreq;
00631 
00632      IDataProviderSvc* eventSvc = NULL;
00633      Gaudi::svcLocator()->service("EventDataSvc", eventSvc);
00634      SmartDataPtr<Event::EventHeader> eventHeader(eventSvc,"/Event/EventHeader");
00635      if (!eventHeader) {
00636           log << MSG::FATAL << "Could not find Event Header" << endreq;
00637           return( StatusCode::FAILURE);
00638      }
00639      m_run = eventHeader->runNumber();
00640 
00641      // clear calibration constants vectors
00642      m_xtmap.clear();
00643      m_xtpar.clear();
00644      m_t0.clear();
00645      m_delt0.clear();
00646      m_qtpar0.clear();
00647      m_qtpar1.clear();
00648      m_sdmap.clear();
00649      m_sdpar.clear();
00650 
00651      string fullPath = "/Calib/MdcCal";
00652      SmartDataPtr<CalibData::MdcCalibData> calConst(m_pCalDataSvc, fullPath);
00653      if( ! calConst ){
00654           log << MSG::ERROR << "can not get MdcCalibConst via SmartPtr" 
00655               << endreq;
00656           return false;
00657      }
00658 
00659      // initialize XT parameter
00660      int layid;
00661      int entr;
00662      int lr;
00663      int ord;
00664      int key;
00665      double par;
00666      calConst -> setXtBegin();
00667      while( calConst->getNextXtpar(key, par) ){
00668           m_xtmap.insert( valType(key, par) );
00669      }
00670 
00671      int parId;
00672      unsigned mapsize = m_xtmap.size();
00673      m_xtpar.resize(mapsize);
00674      log << MSG::INFO << "size of xtmap: " << mapsize << endreq;
00675 
00676      calConst -> setXtBegin();
00677      while( calConst->getNextXtpar(key, par) ){
00678           layid = (key >> XTLAYER_INDEX) & XTLAYER_DECO;
00679           entr = (key >> XTENTRA_INDEX) & XTENTRA_DECO;
00680           lr = (key >> XTLR_INDEX) & XTLR_DECO;
00681           ord = (key >> XTORDER_INDEX) & XTORDER_DECO;
00682 
00683           parId = getXtparId(layid, entr, lr, ord);
00684           m_xtpar[parId] = par;
00685      }
00686 
00687      // initialize T0 parameter
00688      int wid;
00689      double t0;
00690      double delt0;
00691      for(wid=0; wid<NWIRE; wid++){
00692           t0 = calConst->getT0(wid);
00693           delt0 = calConst->getDelT0(wid);
00694 
00695           m_t0.push_back(t0);
00696           m_delt0.push_back(delt0);
00697      }
00698 
00699      // initialize QT parameter
00700      double qtpar0;
00701      double qtpar1;
00702      for(layid=0; layid<NLAYER; layid++){
00703           qtpar0 = calConst -> getQtpar0(layid);
00704           qtpar1 = calConst -> getQtpar1(layid);
00705 
00706           m_qtpar0.push_back(qtpar0);
00707           m_qtpar1.push_back(qtpar1);
00708      }
00709 
00710      // initialize resolution parameter
00711      calConst -> setSdBegin();
00712      while( calConst -> getNextSdpar(key, par) ){
00713           m_sdmap.insert( valType(key, par) );
00714 //        cout << setw(15) << key << setw(15) << par << endl;
00715      }
00716 
00717      mapsize = m_sdmap.size();
00718      m_sdpar.resize(mapsize);
00719      log << MSG::INFO << "size of sdmap: " << mapsize << endreq;
00720 
00721      calConst -> setSdBegin();
00722      while( calConst -> getNextSdpar(key, par) ){
00723           layid = (key >> SDLAYER_INDEX) & SDLAYER_DECO;
00724           entr = (key >> SDENTRA_INDEX) & SDENTRA_DECO;
00725           lr = (key >> SDLR_INDEX) & SDLR_DECO;
00726           ord = (key >> SDBIN_INDEX) & SDBIN_DECO;
00727 
00728           parId = getSdparId(layid, entr, lr, ord);
00729           m_sdpar[parId] = par;
00730      }
00731 
00732      double zeast;
00733      double zwest;
00734      for(layid=0; layid<NLAYER; layid++){
00735           zwest = m_pMdcGeomSvc->Wire(layid, 0)->Forward().z();
00736           zeast = m_pMdcGeomSvc->Wire(layid, 0)->Backward().z();
00737 
00738           if(0 == (layid % 2)) m_zst[layid] = zwest;    // west end
00739           else m_zst[layid] = zeast; // east end
00740      }
00741 
00742      // read new-XT
00743      log << MSG::INFO << "read new xt from TCDS" << endreq;
00744      if (!getNewXtpar()){
00745           log << MSG::WARNING << "can not get MDC New XT Trees" << endreq;
00746           m_xtMode = 0;
00747      }
00748      if(m_run < 0) m_xtMode = 0;
00749      if(0 == m_xtMode) log << MSG::INFO << "use old X-T functions " << endreq;
00750      else log << MSG::INFO << "use new X-T functions " << endreq;
00751      if(m_outputXtMode){
00752           if(0 == m_xtMode) cout << "use old X-T functions " << endl;
00753           else cout << "use new X-T functions " << endl;
00754           m_outputXtMode = false;
00755      }
00756 
00757      // read r-t
00758      for(layid=0; layid<NLAYER; layid++){
00759           for(entr=0; entr<NXTENTR; entr++){
00760                for(lr=0; lr<2; lr++) m_nR2t[layid][entr][lr] = 0;
00761           }
00762      }
00763      m_fgR2t = true;
00764      log << MSG::INFO << "read new sigma-time from TCDS" << endreq;
00765      if (!getR2tpar()){
00766           log << MSG::WARNING << "can not get sigma-time functions" << endreq;
00767           m_fgR2t = false;
00768      } else{
00769           log << MSG::INFO << "read sigma-time successfully " << endreq;
00770      }
00771 
00772      // read wire efficiency
00773      if(m_readWireEffDb){
00774           fullPath = "/Calib/MdcDataConst";
00775           log << MSG::INFO <<"Read Wire Eff from TCDS: "<< fullPath << endreq;
00776           log << MSG::INFO << "Read wire eff!" << endreq;
00777 
00778           SmartDataPtr<CalibData::MdcDataConst> dataConst(m_pCalDataSvc, fullPath);
00779           if(!dataConst){
00780                log << MSG::ERROR << "can not get MdcDataConst via SmartPtr" << endreq;
00781                return false; 
00782           }
00783           for(int wir=0; wir<NWIRE; wir++) {
00784                m_wireEff[wir] = dataConst->getWireEff(wir);
00785           }
00786      } else{
00787           log << MSG::INFO <<"Read Wire Eff from file: "<< m_wireEffFile << endreq;
00788           ifstream fEff(m_wireEffFile.c_str());
00789           if(!fEff.is_open()){
00790                log << MSG::ERROR << "can not open wire eff file: " << m_wireEffFile << endreq;
00791                return false;
00792           } else{
00793                string strtmp;
00794                for(int i=0; i<4; i++) fEff >> strtmp;
00795                for(int wir=0; wir<NWIRE; wir++) fEff >> strtmp >> strtmp >> strtmp >> m_wireEff[wir];
00796                fEff.close();
00797           }
00798      }
00799      if(m_checkConst) checkConst();
00800      m_updateNum++;
00801 
00802      return true;
00803 }

StatusCode MdcCalibFunSvc::initialize (  )  [virtual]

Definition at line 66 of file MdcCalibFunSvc.cxx.

References calibUtil::ERROR, Bes_Common::FATAL, Bes_Common::INFO, m_fixSigma, m_fixSigmaValue, m_nR2t, m_pCalDataSvc, m_pMdcGeomSvc, m_updateNum, m_wireEff, NLAYER, and NXTENTR.

00066                                      {
00067      MsgStream log(messageService(), name());
00068      log << MSG::INFO << "MdcCalibFunSvc::initialize()" << endreq;
00069 
00070      StatusCode sc = Service::initialize();
00071      if( sc.isFailure() ) return sc;
00072 
00073      IIncidentSvc* incsvc;
00074      sc = service("IncidentSvc", incsvc);
00075      int priority = 100;
00076      if( sc.isSuccess() ){
00077           incsvc -> addListener(this, "NewRun", priority);
00078      }
00079 
00080      sc = service("CalibDataSvc", m_pCalDataSvc, true);
00081      if( sc == StatusCode::SUCCESS ){
00082           log << MSG::INFO << "Retrieve IDataProviderSvc" << endreq;
00083      }else{
00084           log << MSG::FATAL << "can not get IDataProviderSvc" << endreq;
00085      }
00086 
00087      sc = service("MdcGeomSvc", m_pMdcGeomSvc);
00088      if( sc != StatusCode::SUCCESS ){
00089           log << MSG::ERROR << "can not use MdcGeomSvc" << endreq;
00090           return StatusCode::FAILURE;
00091      }
00092 
00093      if(m_fixSigma) cout << "Fix MDC sigma to " << m_fixSigmaValue << " micron." << endl;
00094 
00095      m_updateNum = 0;
00096      for(int wir=0; wir<6796; wir++) m_wireEff[wir] = 1.0;
00097      for(int lay=0; lay<NLAYER; lay++){
00098           for(int iEntr=0; iEntr<NXTENTR; iEntr++){
00099                for(int lr=0; lr<2; lr++) m_nR2t[lay][iEntr][lr] = 0;
00100           }
00101      }
00102 
00103      return StatusCode::SUCCESS;
00104 }

static const InterfaceID& IMdcCalibFunSvc::interfaceID (  )  [inline, static, inherited]

Definition at line 19 of file IMdcCalibFunSvc.h.

References IID_IMdcCalibFunSvc().

00019 { return IID_IMdcCalibFunSvc; }

StatusCode MdcCalibFunSvc::queryInterface ( const InterfaceID &  riid,
void **  ppvUnknown 
) [virtual]

Definition at line 57 of file MdcCalibFunSvc.cxx.

References IID_IMdcCalibFunSvc().

00057                                                                                      {
00058      if( IID_IMdcCalibFunSvc.versionMatch(riid) ){
00059           *ppvInterface = static_cast<IMdcCalibFunSvc*> (this);
00060      } else{
00061           return Service::queryInterface(riid, ppvInterface);
00062      }
00063      return StatusCode::SUCCESS;
00064 }

void MdcCalibFunSvc::setSdBegin (  )  [inline, virtual]

Implements IMdcCalibFunSvc.

Definition at line 95 of file MdcCalibFunSvc.h.

References m_sditer, and m_sdmap.

Referenced by initCalibConst().

00095 { m_sditer = m_sdmap.begin(); }

void MdcCalibFunSvc::setXtBegin (  )  [inline, virtual]

Implements IMdcCalibFunSvc.

Definition at line 79 of file MdcCalibFunSvc.h.

References m_xtiter, and m_xtmap.

Referenced by initCalibConst().

00079 { m_xtiter = m_xtmap.begin(); }

double MdcCalibFunSvc::t2dInter ( double  drifttime,
int  layid,
int  cellid,
int  lr,
double  entrance = 0.0 
) const [private]

Definition at line 190 of file MdcCalibFunSvc.cxx.

References check_raw_filter::dist, getXtEntrIndex(), genRecEmupikp::i, m_nNewXt, m_vd, and m_vt.

Referenced by driftTimeToDist().

00191                                                                {
00192      double dist;
00193      int iEntr = getXtEntrIndex(entrance);
00194      int nBin = m_nNewXt[layid][iEntr][lr];
00195      if(drifttime < m_vt[layid][iEntr][lr][0]){
00196           dist = m_vd[layid][iEntr][lr][0];
00197      } else if(drifttime < m_vt[layid][iEntr][lr][nBin-1]){
00198           for(int i=0; i<(nBin-1); i++){
00199                if((drifttime>=m_vt[layid][iEntr][lr][i]) && (drifttime<m_vt[layid][iEntr][lr][i+1])){
00200                     double t1 = m_vt[layid][iEntr][lr][i];
00201                     double t2 = m_vt[layid][iEntr][lr][i+1];
00202                     double d1 = m_vd[layid][iEntr][lr][i];
00203                     double d2 = m_vd[layid][iEntr][lr][i+1];
00204                     dist = (drifttime-t1) * (d2-d1) / (t2-t1) + d1;
00205                     break;
00206                }
00207           }
00208      } else{
00209           dist = m_vd[layid][iEntr][lr][nBin-1];
00210      }
00211      return dist;
00212 }

double MdcCalibFunSvc::t2dPoly ( double  drifttime,
int  layid,
int  cellid,
int  lr,
double  entrance = 0.0 
) const [private]

Definition at line 167 of file MdcCalibFunSvc.cxx.

References check_raw_filter::dist, getXtEntrIndex(), and getXtpar().

Referenced by driftTimeToDist().

00168                                                               {
00169      int ord;
00170      double xtpar[8];
00171      double dist = 0.0;
00172 
00173      int entr = getXtEntrIndex(entrance);
00174      getXtpar(layid, entr, lr, xtpar);
00175 
00176      if(drifttime < xtpar[6]){
00177           for(ord=0; ord<6; ord++){
00178                dist += xtpar[ord] * pow(drifttime, ord);
00179           }
00180      } else{
00181           for(ord=0; ord<6; ord++){
00182                dist += xtpar[ord] * pow(xtpar[6], ord);
00183           }
00184           dist += xtpar[7] * (drifttime - xtpar[6]);
00185      }
00186 
00187      return dist;
00188 }


Member Data Documentation

bool MdcCalibFunSvc::m_checkConst [private]

Definition at line 135 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

std::vector<double> MdcCalibFunSvc::m_delt0 [private]

Definition at line 160 of file MdcCalibFunSvc.h.

Referenced by checkConst(), finalize(), getDelT0(), and initCalibConst().

bool MdcCalibFunSvc::m_fgR2t [private]

Definition at line 140 of file MdcCalibFunSvc.h.

Referenced by getSigmaToT(), and initCalibConst().

bool MdcCalibFunSvc::m_fixSigma [private]

Definition at line 145 of file MdcCalibFunSvc.h.

Referenced by getSigma(), and initialize().

double MdcCalibFunSvc::m_fixSigmaValue [private]

Definition at line 146 of file MdcCalibFunSvc.h.

Referenced by getSigma(), and initialize().

int MdcCalibFunSvc::m_layInfSig [private]

Definition at line 137 of file MdcCalibFunSvc.h.

Referenced by getSigma().

bool MdcCalibFunSvc::m_linearXT [private]

Definition at line 141 of file MdcCalibFunSvc.h.

Referenced by distToDriftTime(), and driftTimeToDist().

int MdcCalibFunSvc::m_nNewXt[NLAYER][NXTENTR][2] [private]

Definition at line 173 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getNewXtpar(), and t2dInter().

int MdcCalibFunSvc::m_nR2t[NLAYER][NXTENTR][2] [private]

Definition at line 177 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getR2tpar(), getSigmaToTLR(), initCalibConst(), and initialize().

bool MdcCalibFunSvc::m_outputXtMode [private]

Definition at line 144 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

IDataProviderSvc* MdcCalibFunSvc::m_pCalDataSvc [private]

Definition at line 149 of file MdcCalibFunSvc.h.

Referenced by getNewXtparTree(), getR2tTree(), initCalibConst(), and initialize().

IMdcGeomSvc* MdcCalibFunSvc::m_pMdcGeomSvc [private]

Definition at line 148 of file MdcCalibFunSvc.h.

Referenced by getT0(), getWireEff(), initCalibConst(), and initialize().

ICalibRootSvc* MdcCalibFunSvc::m_pRootSvc [private]

Definition at line 150 of file MdcCalibFunSvc.h.

std::vector<double> MdcCalibFunSvc::m_qtpar0 [private]

Definition at line 162 of file MdcCalibFunSvc.h.

Referenced by checkConst(), finalize(), getQtpar(), and initCalibConst().

std::vector<double> MdcCalibFunSvc::m_qtpar1 [private]

Definition at line 163 of file MdcCalibFunSvc.h.

Referenced by checkConst(), finalize(), getQtpar(), and initCalibConst().

bool MdcCalibFunSvc::m_readWireEffDb [private]

Definition at line 142 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

int MdcCalibFunSvc::m_run

Definition at line 34 of file MdcCalibFunSvc.h.

Referenced by getTimeWalk(), and initCalibConst().

std::map<int, double>::iterator MdcCalibFunSvc::m_sditer [private]

Definition at line 169 of file MdcCalibFunSvc.h.

Referenced by getNextSdpar(), and setSdBegin().

std::map<int, double> MdcCalibFunSvc::m_sdmap [private]

Definition at line 165 of file MdcCalibFunSvc.h.

Referenced by checkConst(), finalize(), getNextSdpar(), initCalibConst(), and setSdBegin().

std::vector<double> MdcCalibFunSvc::m_sdpar [private]

Definition at line 166 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getSdpar(), and initCalibConst().

double MdcCalibFunSvc::m_sR2t[NLAYER][NXTENTR][2][200] [private]

Definition at line 179 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getR2tpar(), and getSigmaToTLR().

std::vector<double> MdcCalibFunSvc::m_t0 [private]

Definition at line 159 of file MdcCalibFunSvc.h.

Referenced by checkConst(), finalize(), getT0(), and initCalibConst().

double MdcCalibFunSvc::m_tR2t[NLAYER][NXTENTR][2][200] [private]

Definition at line 178 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getR2tpar(), and getSigmaToTLR().

int MdcCalibFunSvc::m_updateNum [private]

Definition at line 134 of file MdcCalibFunSvc.h.

Referenced by checkConst(), initCalibConst(), and initialize().

double MdcCalibFunSvc::m_vd[NLAYER][NXTENTR][2][200] [private]

Definition at line 175 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getNewXtpar(), and t2dInter().

double MdcCalibFunSvc::m_vt[NLAYER][NXTENTR][2][200] [private]

Definition at line 174 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getNewXtpar(), and t2dInter().

double MdcCalibFunSvc::m_wireEff[6796] [private]

Definition at line 171 of file MdcCalibFunSvc.h.

Referenced by getWireEff(), initCalibConst(), and initialize().

std::string MdcCalibFunSvc::m_wireEffFile [private]

Definition at line 143 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

std::string MdcCalibFunSvc::m_xtfile [private]

Definition at line 139 of file MdcCalibFunSvc.h.

std::map<int, double>::iterator MdcCalibFunSvc::m_xtiter [private]

Definition at line 168 of file MdcCalibFunSvc.h.

Referenced by getNextXtpar(), and setXtBegin().

std::map<int, double> MdcCalibFunSvc::m_xtmap [private]

Definition at line 156 of file MdcCalibFunSvc.h.

Referenced by checkConst(), finalize(), getNextXtpar(), initCalibConst(), and setXtBegin().

int MdcCalibFunSvc::m_xtMode [private]

Definition at line 138 of file MdcCalibFunSvc.h.

Referenced by driftTimeToDist(), and initCalibConst().

std::vector<double> MdcCalibFunSvc::m_xtpar [private]

Definition at line 157 of file MdcCalibFunSvc.h.

Referenced by checkConst(), getXtpar(), and initCalibConst().

double MdcCalibFunSvc::m_zst[43] [private]

Definition at line 153 of file MdcCalibFunSvc.h.

Referenced by getTprop(), and initCalibConst().

const int MdcCalibFunSvc::NLAYER = 43 [static, private]

Definition at line 108 of file MdcCalibFunSvc.h.

Referenced by getNewXtpar(), getR2tpar(), initCalibConst(), and initialize().

const int MdcCalibFunSvc::NSDBIN = 24 [static, private]

Definition at line 112 of file MdcCalibFunSvc.h.

Referenced by getSdpar(), and getSigmaLR().

const int MdcCalibFunSvc::NWIRE = 6796 [static, private]

Definition at line 107 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::NXTENTR = 18 [static, private]

Definition at line 109 of file MdcCalibFunSvc.h.

Referenced by getNewXtpar(), getR2tpar(), initCalibConst(), and initialize().

const int MdcCalibFunSvc::NXTORD = 6 [static, private]

Definition at line 111 of file MdcCalibFunSvc.h.

const int MdcCalibFunSvc::NXTPAR = 8 [static, private]

Definition at line 110 of file MdcCalibFunSvc.h.

const int MdcCalibFunSvc::SDBIN_DECO = 0x1F [static, private]

Definition at line 212 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::SDBIN_INDEX = 0 [static, private]

Definition at line 210 of file MdcCalibFunSvc.h.

Referenced by getSdKey(), and initCalibConst().

const int MdcCalibFunSvc::SDBIN_MASK = 0x1F [static, private]

Definition at line 211 of file MdcCalibFunSvc.h.

Referenced by getSdKey().

const int MdcCalibFunSvc::SDENTRA_DECO = 0x7 [static, private]

Definition at line 204 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::SDENTRA_INDEX = 7 [static, private]

Definition at line 202 of file MdcCalibFunSvc.h.

Referenced by getSdKey(), and initCalibConst().

const int MdcCalibFunSvc::SDENTRA_MASK = 0x380 [static, private]

Definition at line 203 of file MdcCalibFunSvc.h.

Referenced by getSdKey().

const int MdcCalibFunSvc::SDLAYER_DECO = 0x3F [static, private]

Definition at line 200 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::SDLAYER_INDEX = 10 [static, private]

Definition at line 198 of file MdcCalibFunSvc.h.

Referenced by getSdKey(), and initCalibConst().

const int MdcCalibFunSvc::SDLAYER_MASK = 0xFC00 [static, private]

Definition at line 199 of file MdcCalibFunSvc.h.

Referenced by getSdKey().

const int MdcCalibFunSvc::SDLR_DECO = 0x3 [static, private]

Definition at line 208 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::SDLR_INDEX = 5 [static, private]

Definition at line 206 of file MdcCalibFunSvc.h.

Referenced by getSdKey(), and initCalibConst().

const int MdcCalibFunSvc::SDLR_MASK = 0x60 [static, private]

Definition at line 207 of file MdcCalibFunSvc.h.

Referenced by getSdKey().

const int MdcCalibFunSvc::XTENTRA_DECO = 0x1F [static, private]

Definition at line 187 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::XTENTRA_INDEX = 6 [static, private]

Definition at line 185 of file MdcCalibFunSvc.h.

Referenced by getXtKey(), and initCalibConst().

const int MdcCalibFunSvc::XTENTRA_MASK = 0x7C0 [static, private]

Definition at line 186 of file MdcCalibFunSvc.h.

Referenced by getXtKey().

const int MdcCalibFunSvc::XTLAYER_DECO = 0x3F [static, private]

Definition at line 183 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::XTLAYER_INDEX = 11 [static, private]

Definition at line 181 of file MdcCalibFunSvc.h.

Referenced by getXtKey(), and initCalibConst().

const int MdcCalibFunSvc::XTLAYER_MASK = 0x1F800 [static, private]

Definition at line 182 of file MdcCalibFunSvc.h.

Referenced by getXtKey().

const int MdcCalibFunSvc::XTLR_DECO = 0x3 [static, private]

Definition at line 191 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::XTLR_INDEX = 4 [static, private]

Definition at line 189 of file MdcCalibFunSvc.h.

Referenced by getXtKey(), and initCalibConst().

const int MdcCalibFunSvc::XTLR_MASK = 0x30 [static, private]

Definition at line 190 of file MdcCalibFunSvc.h.

Referenced by getXtKey().

const int MdcCalibFunSvc::XTORDER_DECO = 0xF [static, private]

Definition at line 195 of file MdcCalibFunSvc.h.

Referenced by initCalibConst().

const int MdcCalibFunSvc::XTORDER_INDEX = 0 [static, private]

Definition at line 193 of file MdcCalibFunSvc.h.

Referenced by getXtKey(), and initCalibConst().

const int MdcCalibFunSvc::XTORDER_MASK = 0xF [static, private]

Definition at line 194 of file MdcCalibFunSvc.h.

Referenced by getXtKey().


Generated on Tue Nov 29 23:20:09 2016 for BOSS_7.0.2 by  doxygen 1.4.7