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