/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/MdcData/MdcData-00-01-27/src/MdcHit.cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: MdcHit.cxx,v 1.37 2012/08/13 00:01:16 zhangy Exp $
00004 //
00005 // Description:
00006 //      Class Implementation |MdcHit|
00007 //
00008 // Environment:
00009 //      Software developed for the BESIII Detector at the BEPCII
00010 //
00011 // Author List:
00012 //      S. Schaffner - Original
00013 //      A. Snyder - Mods
00014 //      S. Sen                  Feb 17 1998     New digi()->MCPtr() references
00015 //
00016 // Copyright Information:
00017 //      Copyright (C) 1996      SLAC
00018 // 
00019 // History:
00020 //      Migration for BESIII MDC
00021 //
00022 //------------------------------------------------------------------------
00023 
00024 #include "MdcData/MdcHit.h"
00025 #include "TrkBase/TrkHitOnTrk.h"
00026 #include "TrkBase/TrkRecoTrk.h"
00027 #include "RawEvent/RawDataUtil.h"
00028 #include "Identifier/MdcID.h"
00029 
00030 bool MdcHit::m_cosmicFit= false;
00031 bool MdcHit::m_countPropTime = true;            
00032 
00033 MdcHit::MdcHit( const MdcDigi*& aDigi, const MdcDetector*& det):
00034   TrkFundHit(), _digiPtr(aDigi), _geomPtr(det)
00035 { 
00036   _digiPtr  = aDigi;
00037   _geomPtr  = det;
00038   assert( _digiPtr != NULL);
00039   assert( _geomPtr != NULL);
00040   _id       = aDigi->identify();
00041   _layerPtr = det->Layer(_id);
00042   _wirePtr  = det->Wire(_id);
00043   assert( _layerPtr != NULL);
00044   assert( _wirePtr  != NULL);
00045   m_mdcCalibFunSvc = NULL;
00046   _layer    = MdcID::layer(_id); 
00047   _wire     = MdcID::wire (_id); 
00048   _iTdc     = _digiPtr->getTimeChannel();
00049   _iAdc     = _digiPtr->getChargeChannel();
00050   _rawTime  = RawDataUtil::MdcTime(_iTdc);
00051   _charge   = RawDataUtil::MdcCharge(_iAdc);
00052   _rmid     = _wirePtr->rMid();
00053   _zlen     = _layerPtr->zLength();   
00054   _phi      = _wirePtr->phi();
00055   _cosphi   = cos(_phi);
00056   _sinphi   = sin(_phi);
00057   _status   = 0;
00058 }
00059 
00060 MdcHit::MdcHit(const MdcHit& other) :
00061   TrkFundHit() , _digiPtr(other._digiPtr), _geomPtr(other._geomPtr),
00062   _layerPtr(other._layerPtr), _wirePtr(other._wirePtr), _id(other._id),
00063   _layer(other._layer), _wire(other._wire),
00064   _iTdc(other._iTdc), _iAdc(other._iAdc),
00065   _rawTime(other._rawTime), _charge(other._charge),
00066   _rmid(other._rmid), _zlen(other._zlen), 
00067   _phi(other._phi), _cosphi(other._cosphi), _sinphi(other._sinphi),
00068   _status(other._status), _T0Walk(other._T0Walk) 
00069 {
00070   m_mdcCalibFunSvc = other.m_mdcCalibFunSvc;
00071 }
00072 
00073 MdcHit&
00074 MdcHit::operator = (const MdcHit& other) {
00075   if(&other != this){
00076     _digiPtr     = other._digiPtr;
00077     _geomPtr     = other._geomPtr;
00078     _layerPtr    = other._layerPtr;
00079     _wirePtr     = other._wirePtr;
00080     m_mdcCalibFunSvc = other.m_mdcCalibFunSvc;
00081     _id          = other._id;
00082     _layer       = other._layer;
00083     _wire        = other._wire;
00084     _iTdc        = other._iTdc;
00085     _iAdc        = other._iAdc;
00086     _rawTime     = other._rawTime;
00087     _charge      = other._charge;
00088     _digiPtr     = other._digiPtr;
00089     _rmid        = other._rmid;
00090     _zlen        = other._zlen;
00091     _phi         = other._phi;
00092     _cosphi      = other._cosphi;
00093     _sinphi      = other._sinphi;
00094     _status      = other._status;
00095     _T0Walk      = other._T0Walk;
00096   }
00097   return *this;
00098 }
00099 
00100 
00101 //Destructor
00102 MdcHit::~MdcHit() {
00103   // This is ugly and inefficient.  This, along with the rest of 
00104   //  the hitList mess, should be cleaned up by handling the 
00105   //  association in an external map
00106 
00107   // Not written as a loop because removeHit() modifies TrkFundHit::_hitList
00108   short count = 0;
00109   while (nUsedHits() > count) {
00110     bool removed = _hitList[count]->parentTrack()->hits()->removeHit(this);
00111     if (!removed) count++;
00112   }
00113 }
00114 
00115 bool
00116 MdcHit::operator==( const MdcHit& rhs ) const {
00117   return (this == &rhs);
00118 }
00119 
00120 void 
00121 MdcHit::print( ostream& o ) const {
00122   o << "(" << _layer << ","<< _wire <<","<<digi()->getTrackIndex()<<")";
00123 }
00124 
00125 void
00126 MdcHit::printAll( ostream& o ) const {
00127   o << "Hit:(" <<  _layer << "," << _wire 
00128     << ") x:" << x() << " y:" << y()
00129     << " rt:" << rawTime()
00130     << " dt:" <<driftTime(0.0,0)
00131     << " dd:" <<driftDist(0.0,1)
00132     << endl;
00133 }
00134 
00135 void 
00136 MdcHit::setCalibSvc(const MdcCalibFunSvc* calibSvc) { 
00137   m_mdcCalibFunSvc = calibSvc;  
00138   _T0Walk = m_mdcCalibFunSvc->getT0(_layer,_wire) +  m_mdcCalibFunSvc->getTimeWalk(_layer, _iAdc);
00139 }
00140 
00141 double
00142 MdcHit::driftTime(double tof, double z) const {
00143   // t prop
00144   double tprop = 0.;
00145   if (m_countPropTime){ tprop = m_mdcCalibFunSvc->getTprop(_layer,z*10.); }
00146 
00147   //tof in s, driftTime in ns, _T0Walk in ns
00148   double driftT = _rawTime - _T0Walk -1.e9*tof - tprop;
00149 
00150   //if(driftT >10000)
00151   //std::cout<< "driftTime ("<<_layer<<","<<_wire<<") dt "<<driftT<<" rawTime "<<_rawTime<<" z "<<z<<" tprop "<<tprop <<" t0walk "<<_T0Walk<<" tof "<<1.e9*tof<< std::endl;//yzhang debug
00152   return driftT; 
00153 }  
00154 
00155 double 
00156 MdcHit::driftDist(double tof, int ambig, double entranceAngle,  
00157     double /*dipAngle*/, double z) const
00158 { 
00159   double driftD;
00160   //drift time ns, layer id begin with 0, entrance angle rads,
00161   //lr ambig: wire ambig 1,-1,0 -> Calib 0,1,2
00162   int lrCalib=2;
00163   if (ambig==1) lrCalib = 0;
00164   else if (ambig==-1) lrCalib = 1;
00165 
00166   // tof in s, driftDist in cm, dirftTime in ns
00167   if (fabs(z)>150. || fabs(driftTime(tof,z))>1500.){
00168     return 9999.;
00169   }
00170   driftD = 0.1 * m_mdcCalibFunSvc->driftTimeToDist(driftTime(tof,z),_layer,_wire,lrCalib,entranceAngle);//to cm
00171   //std::cout<<"driftDist "<<"("<<_layer <<","<<_wire <<") dd "<<driftD<<" dt "<<driftTime(tof,z) <<" lr "<<lrCalib <<" eAng "<<entranceAngle <<" tof "<<tof*1.e9<<" z "<<z <<" t0walk "<<_T0Walk<<" rawT "<<_rawTime <<" tprop "<< _rawTime - driftTime(tof,z)- _T0Walk-1.e9*tof<<std::endl;
00172 
00173   if (abs(driftD)<Constants::epsilon) driftD = 0.00001;
00174   return driftD;
00175 }
00176 
00177 double 
00178 MdcHit::driftDist(double bunchTime, int ambig) const  {
00179   return driftDist(bunchTime+crudeTof(), ambig, 0., 0., 0. );
00180 }
00181 
00182 
00183 double 
00184 MdcHit::sigma(double driftdist, int ambig, double entranceAngle, 
00185     double dipAngle, double z) const {
00186   double sig = 9999.;
00187 
00188 #ifdef MDCPATREC_RESLAYER
00189   if (_layer == m_resLayer){
00190     //give a huge sigma to skip this layer when fit track
00191     return 9999.;
00192   }
00193 #endif
00194   //if(fabs(z)>150. || driftdist==9999. ) {
00195   //  return 9999.;
00196   //} 
00197   if ( m_mdcCalibFunSvc ) {
00198     //layid begin with 0, entrance angle in rads,
00199     //distance: cm ->Calib mm //z: cm -> Calib mm
00200     //Q: MonteCalo eV -> Calib fC FIXME
00201     //lr ambig: wire ambig 1,-1,0 -> Calib 0,1,2 
00202     int lrCalib=2;
00203     if (ambig==1) lrCalib = 0;
00204     else if (ambig==-1) lrCalib = 1;
00205 
00206     //std::cout<<"layer "<<_layer<< " lrCalib "<< lrCalib<< " driftdist "<< driftdist << " eAngle "<<entranceAngle
00207     //<<" tan(dipAngle) "<<tan(dipAngle)<< " z "<<z <<" iAdc "<<_iAdc<<std::endl;
00208     sig = 0.1 * m_mdcCalibFunSvc->getSigma(_layer,lrCalib,driftdist*10.,entranceAngle,
00209         tan(dipAngle),z*10.,_iAdc); //Calib special resolution mm -> cm
00210 
00211     if(fabs(sig)<Constants::epsilon){
00212       sig = 999.;
00213     }
00214     //if(sig<=0){
00215     //std::cout<<__FILE__<<"   "<<__LINE__ <<" sigma "<<sig
00216     //<<" layer "<<_layer <<" lrCalib "<<lrCalib <<" driftdist "<<driftdist*10
00217     //<<" eAngle "<<entranceAngle<<" dipAngle "<<(dipAngle) <<" tanl "<<tan(dipAngle)
00218     //<<" z "<<z <<" iAdc "<<_iAdc <<std::endl;
00219     //}
00220   }
00221   //if (_layer<4) sig /=5.;//yzhang TEST 2011-05-27 
00222   return sig;
00223 }
00224 
00225 double 
00226 MdcHit::sigma(double driftdist, int ambig) const {
00227   return sigma(driftdist, ambig, 0., 0., 0.);// cm
00228 }
00229 
00230 const Trajectory*
00231 MdcHit::hitTraj() const {
00232   return layer()->makeHitTrajInGlobalCoords(wirenumber(),0.0);
00233 }
00234 
00235 extern ostream& 
00236 operator<<( ostream &o, const MdcHit& hit ) {
00237   hit.print(o);
00238   return o;
00239 } 
00240 

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