BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
MdcTrackUtil.cxx
Go to the documentation of this file.
1#include "TrackUtil/MdcTrackUtil.h"
2#include "CLHEP/Units/PhysicalConstants.h"
3#include "EventModel/EventHeader.h"
4#include "GaudiKernel/Bootstrap.h"
5#include "GaudiKernel/ISvcLocator.h"
6#include "GaudiKernel/MsgStream.h"
7#include "GaudiKernel/SmartDataPtr.h"
8#include "RawEvent/RawDataUtil.h"
9// Mointe-Carlo data
10#include "Identifier/MdcID.h"
11#include "MdcRawEvent/MdcDigi.h"
12
13#ifndef ENABLE_BACKWARDS_COMPATIBILITY
14// backwards compatblty wll be enabled ONLY n CLHEP 1.9
15typedef HepGeom::Point3D<double> HepPoint3D;
16#endif
17
18// MDC reconstructed data
19#include "MdcRecEvent/RecMdcHit.h"
20#include "MdcRecEvent/RecMdcTrack.h"
21
22// MDC Geometory
23#include "MdcGeomSvc/IMdcGeomSvc.h"
24
25using namespace std;
26using namespace Event;
27
28MdcTrackUtil* MdcTrackUtil::_myself = 0;
29
31 if ( 0 == _myself ) { _myself = new MdcTrackUtil(); }
32 return _myself;
33}
34
36 // Initalze magnetic flied
37 m_pIMF = service( "MagneticFieldSvc" );
38 if ( !m_pIMF ) { std::cout << " ERROR Unable to open Magnetic field service " << std::endl; }
39 // get Bz for Check TEMP, Bz may be changed by run
40 double gaussToTesla = 1000.;
41 Bz = m_pIMF->getReferField() * gaussToTesla;
42
43 // Initialize MdcGeomSvc
44 m_mdcGeomSvc = service( "MdcGeomSvc" );
45 if ( !m_mdcGeomSvc ) { std::cout << " FATAL Could not load MdcGeomSvc! " << std::endl; }
46}
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
49int MdcTrackUtil::nLayerTrackPassed( const HepVector helix ) {
50 double helixParam[5];
51 for ( int i = 0; i < 5; ++i ) helixParam[i] = helix[i];
52
53 return nLayerTrackPassed( helixParam );
54}
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
57int MdcTrackUtil::nLayerTrackPassed( const double helix[5] ) {
58 int nLayer = 0;
59
60 for ( unsigned iLayer = 0; iLayer < 43; iLayer++ )
61 {
62 // flightLength is the path length of track in the x-y plane
63 // guess flightLength by the radius in middle of the wire.
64 double rMidLayer = m_mdcGeomSvc->Layer( iLayer )->Radius();
65 double flightLength = rMidLayer;
66
67 HepPoint3D pivot( 0., 0., 0. );
68 double dz = helix[3];
69 double c = CLHEP::c_light * 100.; // unit from m/s to cm/s
70 double alpha = 1 / ( c * Bz ); //~333.567
71 double kappa = helix[2];
72 double rc = ( -1. ) * alpha / kappa;
73 // std::cout<<"MdcTrackUtil alpha "<<alpha<<std::endl;
74 double tanl = helix[4];
75 double phi0 = helix[1];
76 double phi = flightLength / rc + phi0; // turning angle
77 double z = pivot.z() + dz - ( alpha / kappa ) * tanl * phi;
78
79 double layerHalfLength = m_mdcGeomSvc->Layer( iLayer )->Length() / 2.;
80
81 // std::cout<<"MdcTrackUtil length "<<layerHalfLength<<std::endl;
82
83 if ( fabs( z ) < fabs( layerHalfLength ) ) ++nLayer;
84 }
85
86 return nLayer;
87}
88
89// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
90HepVector MdcTrackUtil::patRecPar2BesPar( const HepVector& helixPar ) {
91 HepVector helix( 5, 0 );
92 double d0 = -helixPar[0]; // cm
93 double phi0 = helixPar[1] + CLHEP::halfpi;
94 double omega = Bz * helixPar[2] / -333.567;
95 double z0 = helixPar[3]; // cm
96 double tanl = helixPar[4];
97 helix[0] = d0;
98 helix[1] = phi0;
99 helix[2] = omega;
100 helix[3] = z0;
101 helix[4] = tanl;
102 // std::cout<<"helix "<<helix<<std::endl;
103 return helix;
104}
105
106// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
107HepSymMatrix MdcTrackUtil::patRecErr2BesErr( const HepSymMatrix& err ) {
108 // error matrix
109 // std::cout<<" err1 "<<err<<" "<<err.num_row()<<std::endl;
110 // V(Y)=S * V(X) * ST , mS = S , mVy = V(Y) , err() = V(X)
111 // int n = err.num_row();
112 HepSymMatrix mS( err.num_row(), 0 );
113 mS[0][0] = -1.; // dr0=-d0
114 mS[1][1] = 1.;
115 mS[2][2] = Bz / -333.567; // pxy -> cpa
116 mS[3][3] = 1.;
117 mS[4][4] = 1.;
118 HepSymMatrix mVy = err.similarity( mS );
119 // std::cout<<" err2 "<<n<<" "<<mVy<<std::endl;
120 return mVy;
121}
HepGeom::Point3D< double > HepPoint3D
double alpha
static MdcTrackUtil * instance()
int nLayerTrackPassed(const HepVector helix)
HepSymMatrix patRecErr2BesErr(const HepSymMatrix &err)
HepVector patRecPar2BesPar(const HepVector &helixPar)