BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
TrkExchangeData.cxx
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2// File and Version Information:
3// $Id: TrkExchangeData.cxx,v 1.3 2010/03/25 09:56:26 zhangy Exp $
4//
5// Description:
6// Class TrkExchangeData;
7//
8// Environment:
9// Software developed for the BaBar Detector at the SLAC B-Factory.
10//
11// Copyright Infomation;
12// Copyright (C) 2000 Lawrence Berkeley Laboratory
13//
14// Author(s): Dave Brown
15//
16//------------------------------------------------------------------------
17#include "TrkBase/TrkExchangeData.h"
18#include "MdcGeom/Constants.h"
19#include "MdcRecoUtil/ComPackBase.h"
20#include "MdcRecoUtil/ComPackFlatFloat.h"
21#include "MdcRecoUtil/ComPackSignedExpFloat.h"
22#include <assert.h>
23#include <math.h>
24#define BITSPERBYTE 8
25
26// packing statics. Note that these define the meaning of the data
27// and should NEVER BE CHANGED. Or, if they must be changed, this
28// class will need to be subclassed and any persistent data based on it
29// have its schema 'migrated'.
30
31const ComPackSignedExpFloat TrkExchangeData::_packd0( 16, 6, 128.0 );
32const ComPackFlatFloat TrkExchangeData::_packphi0( -Constants::pi, Constants::pi, 16 );
33const ComPackSignedExpFloat TrkExchangeData::_packomega( 16, 6, 0.5 );
34const ComPackSignedExpFloat TrkExchangeData::_packz0( 16, 6, 256.0 );
35const ComPackFlatFloat TrkExchangeData::_packlambda( -Constants::pi / 2.0, Constants::pi / 2.0,
36 16 );
37
38const ComPackBase<double>& TrkExchangeData::paramPacker( int index ) {
39 switch ( index )
40 {
41 case TrkExchangePar::ex_d0: return _packd0;
42 case TrkExchangePar::ex_phi0: return _packphi0;
43 case TrkExchangePar::ex_omega: return _packomega;
44 case TrkExchangePar::ex_z0: return _packz0;
45 case TrkExchangePar::ex_tanDip: return _packlambda;
46 default: assert( 0 ); return _packd0;
47 }
48}
49
51 for ( unsigned ipar = 0; ipar < TrkExchangePar::nParam; ipar++ ) _params[ipar] = 0;
52}
53
55 // pack the parameters and the diagonal errors
56 assert( traj != 0 );
57 for ( int ipar = TrkExchangePar::ex_d0; ipar < TrkExchangePar::nParam; ipar++ )
58 {
59 unsigned parpack( 0 );
60 const ComPackBase<double>& packpar = paramPacker( ipar );
61 // convert from tandip to dip
62 double pval( 0 );
63 switch ( ipar )
64 {
65 case TrkExchangePar::ex_d0: pval = traj->d0(); break;
66 case TrkExchangePar::ex_phi0: pval = traj->phi0(); break;
67 case TrkExchangePar::ex_omega: pval = traj->omega(); break;
68 case TrkExchangePar::ex_z0: pval = traj->z0(); break;
69 case TrkExchangePar::ex_tanDip: pval = atan( traj->tanDip() ); break;
70 }
71 ComPackBaseBase::StatusCode pcode = packpar.pack( pval, parpack );
72 assert( pcode != ComPackBaseBase::TAG_BAD );
73 _params[ipar] = parpack;
74 }
75}
76
77TrkExchangeData::TrkExchangeData( const TrkExchangeData& other ) { *this = other; }
78
80 if ( this != &other )
81 {
82 for ( int ipar = TrkExchangePar::ex_d0; ipar < TrkExchangePar::nParam; ipar++ )
83 _params[ipar] = other._params[ipar];
84 }
85 return *this;
86}
87
89
91 // unpack the parameters and the errors
92 HepVector pvec( 5, 0 );
93 for ( int ipar = TrkExchangePar::ex_d0; ipar < TrkExchangePar::nParam; ipar++ )
94 {
95 const ComPackBase<double>& packpar = paramPacker( ipar );
96 ComPackBaseBase::StatusCode pcode = packpar.unpack( _params[ipar], pvec[ipar] );
97 assert( pcode != ComPackBaseBase::TAG_BAD );
98 }
99 // convert back from dip to tandip
101 return new TrkExchangePar( pvec );
102}
virtual StatusCode unpack(const d_ULong, T &) const =0
virtual StatusCode pack(const T, d_ULong &) const =0
TrkExchangeData & operator=(const TrkExchangeData &)
TrkExchangePar * exchange() const