/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Reconstruction/MdcPatRec/TrkBase/TrkBase-00-01-12/src/TrkExchangeData.cxx

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: TrkExchangeData.cxx,v 1.3 2010/03/25 09:56:26 zhangy Exp $
00004 //
00005 //  Description:
00006 //  Class TrkExchangeData;
00007 //
00008 // Environment:
00009 //      Software developed for the BaBar Detector at the SLAC B-Factory.
00010 //
00011 // Copyright Infomation;
00012 //      Copyright (C) 2000      Lawrence Berkeley Laboratory
00013 //
00014 // Author(s): Dave Brown
00015 //
00016 //------------------------------------------------------------------------
00017 #include "TrkBase/TrkExchangeData.h"
00018 #include "MdcRecoUtil/ComPackFlatFloat.h"
00019 #include "MdcRecoUtil/ComPackSignedExpFloat.h"
00020 #include "MdcRecoUtil/ComPackBase.h"
00021 #include "MdcGeom/Constants.h"
00022 #include <assert.h>
00023 #include <math.h>
00024 #define BITSPERBYTE 8
00025 
00026 
00027 // packing statics.  Note that these define the meaning of the data
00028 // and should NEVER BE CHANGED.  Or, if they must be changed, this
00029 // class will need to be subclassed and any persistent data based on it
00030 // have its schema 'migrated'.
00031 
00032 const ComPackSignedExpFloat TrkExchangeData::_packd0(16,6,128.0);
00033 const ComPackFlatFloat TrkExchangeData::_packphi0(-Constants::pi,Constants::pi,16);
00034 const ComPackSignedExpFloat TrkExchangeData::_packomega(16,6,0.5);
00035 const ComPackSignedExpFloat TrkExchangeData::_packz0(16,6,256.0);
00036 const ComPackFlatFloat TrkExchangeData::_packlambda(-Constants::pi/2.0,Constants::pi/2.0,16);
00037 
00038 const ComPackBase<double>&
00039 TrkExchangeData::paramPacker(int index) {
00040   switch(index) {
00041   case TrkExchangePar::ex_d0:
00042     return _packd0;
00043   case TrkExchangePar::ex_phi0:
00044     return _packphi0;
00045   case TrkExchangePar::ex_omega:
00046     return _packomega;
00047   case TrkExchangePar::ex_z0:
00048     return _packz0;
00049   case TrkExchangePar::ex_tanDip:
00050     return _packlambda;
00051   default:
00052     assert(0);
00053     return _packd0;
00054   }
00055 }
00056 
00057 TrkExchangeData::TrkExchangeData() {
00058   for(unsigned ipar=0;ipar<TrkExchangePar::nParam;ipar++)
00059     _params[ipar] = 0;
00060 }
00061 
00062 TrkExchangeData::TrkExchangeData(const TrkExchangePar* traj) {
00063 // pack the parameters and the diagonal errors
00064   assert(traj != 0);
00065   for(int ipar=TrkExchangePar::ex_d0;ipar<TrkExchangePar::nParam;ipar++){
00066     unsigned parpack(0);
00067     const ComPackBase<double>& packpar = paramPacker(ipar);
00068 // convert from tandip to dip
00069     double pval(0) ;
00070     switch (ipar) {
00071     case TrkExchangePar::ex_d0:
00072       pval = traj->d0();
00073       break;
00074     case TrkExchangePar::ex_phi0:
00075       pval = traj->phi0();
00076       break;
00077     case TrkExchangePar::ex_omega:
00078       pval = traj->omega();
00079       break;
00080     case TrkExchangePar::ex_z0:
00081       pval = traj->z0();
00082       break;
00083     case TrkExchangePar::ex_tanDip:
00084       pval = atan(traj->tanDip());
00085       break;
00086     }
00087     ComPackBaseBase::StatusCode pcode = packpar.pack(pval,parpack);
00088     assert(pcode !=ComPackBaseBase::TAG_BAD);
00089     _params[ipar] = parpack;
00090   }
00091 }
00092 
00093 TrkExchangeData::TrkExchangeData(const TrkExchangeData& other){
00094   *this = other;
00095 }
00096 
00097 TrkExchangeData& 
00098 TrkExchangeData::operator =(const TrkExchangeData& other) {
00099   if(this != &other){
00100     for (int ipar=TrkExchangePar::ex_d0;ipar<TrkExchangePar::nParam;ipar++)
00101       _params[ipar] = other._params[ipar];
00102   }
00103   return *this;
00104 }
00105 
00106 TrkExchangeData::~TrkExchangeData(){}
00107 
00108 TrkExchangePar*
00109 TrkExchangeData::exchange() const {
00110 // unpack the parameters and the errors
00111   HepVector pvec(5,0);
00112   for(int ipar=TrkExchangePar::ex_d0;ipar<TrkExchangePar::nParam;ipar++){
00113     const ComPackBase<double>& packpar = paramPacker(ipar);
00114     ComPackBaseBase::StatusCode pcode = packpar.unpack(_params[ipar],pvec[ipar]);
00115     assert(pcode != ComPackBaseBase::TAG_BAD );
00116   }
00117 // convert back from dip to tandip
00118   pvec[TrkExchangePar::ex_tanDip] = tan(pvec[TrkExchangePar::ex_tanDip]);
00119   return new TrkExchangePar(pvec);
00120 }

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