BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Emc_helix.cxx
Go to the documentation of this file.
1////////////////////////////////////////////////////////////
2/// Obtains EMC hit postion that match MDC tracks found ///
3/// by BESIII Fast Tracker, fzisan. ///
4/// ///
5/// How: ///
6/// Extrapolates fzisan tracks (helix) to the inner ///
7/// surface of EMC to obtain corresponding ///
8/// position. ///
9/// ///
10/// Function: Emc_get(double remc, int id) ///
11/// rEmc: Input EMC counter radius ///
12/// id: Input fzisan track Id ///
13/// Return IDs: ///
14/// 1: OK ///
15/// -1: wrong fzisan ID ///
16/// -3: track multiplicity <= 0 ///
17/// -5: inclomplete fitting in fzisan ///
18/// -7: bad path length or Z_emc ///
19/// ///
20/// Based on: helix class ///
21/// ///
22/// ///
23/////////////////////////////////////////////////////////////
24
25#include "CLHEP/Geometry/Point3D.h"
26#include "CLHEP/Matrix/SymMatrix.h"
27#include "CLHEP/Vector/LorentzVector.h"
28#include "CLHEP/Vector/ThreeVector.h"
29#include "GaudiKernel/IDataProviderSvc.h"
30#include "GaudiKernel/ISvcLocator.h"
31#include "GaudiKernel/MsgStream.h"
32#include "GaudiKernel/PropertyMgr.h"
33#include "GaudiKernel/SmartDataPtr.h"
34#include <cstdio>
35#include <iostream>
36#include <vector>
37
38#include "EmcRawEvent/EmcDigi.h"
39#include "EventModel/Event.h"
40#include "McTruth/McParticle.h"
41#include "MdcGeomSvc/IMdcGeomSvc.h"
42#include "MdcGeomSvc/MdcGeoLayer.h"
43#include "MdcGeomSvc/MdcGeoWire.h"
44#include "MdcRawEvent/MdcDigi.h"
45#include "TrackUtil/Helix.h"
46
47#include "Emc_helix.h"
48
49// #include "MdcFastTrkAlg/FTFinder.h"
50
51#ifndef ENABLE_BACKWARDS_COMPATIBILITY
52typedef HepGeom::Point3D<double> HepPoint3D;
53#endif
54
55using CLHEP::Hep3Vector;
56using CLHEP::HepVector;
57
59 piby1 = 3.141593;
60 pi2 = 2.0 * piby1;
61 _debug = 0;
62 _pathl_cut = 1000.0;
63}
64
65int Emc_helix::Emc_Get( double rEmc, int id, double fzisan[] ) {
66 // crossing points of the helix on the Emc cylinder
67 double xc, yc; // center of the circle
68 double rho; // radius of emc cyclinder
69 double xx[2], yy[2]; // coordinates of hits
70 double emcx, emcy; // (x,y) on the radius of R_emc
71 double nx, ny; // direction cosines of mom vector at vertex
72 double cosx, sinx;
73 double aa, ca, cb, cc, detm;
74
75 // fzisan track ID and EMC radius
76 int Id_cdfztrk = id;
77 R_emc = rEmc;
78
79 if ( Id_cdfztrk < 0 )
80 {
81 if ( _debug ) std::cout << " Emc_helix *** wrong id_cdfztrk =" << Id_cdfztrk << std::endl;
82 return ( -1 );
83 }
84
85 // fzisan track
86 /* FTFinder * ftrk = FTFinder:: GetPointer();
87 FTList<FTTrack *> & FsTrks = ftrk->tracks();
88 NTrk = FsTrks.length();
89
90 if (NTrk<=0) return (-3);
91
92 // get helix params for Id_cdfztrk
93 FTTrack & trk = * FsTrks[Id_cdfztrk];
94 const Helix hel = * trk.helix();
95
96 const HepPoint3D pivot1(0.,0.,0.);
97 HepVector a(5,0);
98 a[0] = hel.a()[0];
99 a[1] = hel.a()[1];
100 a[2] = hel.a()[2];
101 a[3] = hel.a()[3];
102 a[4] = hel.a()[4];
103 */
104 const HepPoint3D pivot1( 0., 0., 0. );
105 HepVector a( 5, 0 );
106 a[0] = fzisan[0];
107 a[1] = fzisan[1];
108 a[2] = fzisan[2];
109 a[3] = fzisan[3];
110 a[4] = fzisan[4];
111
112 // Ill-fitted track in fzisan (dz=tanl=-9999.)
113 if ( abs( a[3] ) > 50.0 || abs( a[4] ) > 500.0 ) return ( -5 );
114
115 // D e f i n e h e l i x
116 Helix helix1( pivot1, a );
117 Dr = helix1.a()[0];
118 Phi0 = helix1.a()[1];
119 Kappa = helix1.a()[2];
120 Dz = helix1.a()[3];
121 Tanl = helix1.a()[4];
122
123 /* double detaphi=asin(0.5*0.81*0.3*fabs(Kappa));
124 double phi=Phi0+detaphi+ piby1/2;
125 */
126
127 // check cdfztrk hit on Emc cyclinder
128 rho = helix1.radius();
129 // cout<<" Emc_helix:: rho ="<<rho<<endl; // radius of the circle in cm
130 HepPoint3D xyz = helix1.center();
131 xc = xyz( 0 );
132 yc = xyz( 1 );
133
134 Hep3Vector vxyz = helix1.direction();
135 nx = vxyz( 0 ); // direction of track at the vertex
136 ny = vxyz( 1 );
137
138 // get hit on Emc cylinder at radius R_Emc;
139 if ( xc == 0.0 && yc == 0.0 ) return ( -3 );
140
141 // coefficients of quadratic equation
142 ca = xc * xc + yc * yc;
143 aa = 0.5 * ( ca - rho * rho + R_emc * R_emc );
144
145 if ( xc != 0.0 )
146 {
147 cb = aa * yc;
148 cc = aa * aa - R_emc * R_emc * xc * xc;
149 // determinant
150 detm = cb * cb - ca * cc;
151 if ( detm > 0.0 )
152 {
153 yy[0] = ( cb + sqrt( detm ) ) / ca;
154 xx[0] = ( aa - yy[0] * yc ) / xc;
155 yy[1] = ( cb - sqrt( detm ) ) / ca;
156 xx[1] = ( aa - yy[1] * yc ) / xc;
157 }
158 else return ( -1 );
159 }
160 else
161 {
162 cb = aa * xc;
163 cc = aa * aa - R_emc * R_emc * yc * yc;
164 // determinant
165 detm = cb * cb - ca * cc;
166 if ( detm > 0.0 )
167 {
168 xx[0] = ( cb + sqrt( detm ) ) / ca;
169 yy[0] = ( aa - xx[0] * xc ) / yc;
170 xx[1] = ( cb - sqrt( detm ) ) / ca;
171 yy[1] = ( aa - xx[1] * xc ) / yc;
172 }
173 else return ( -2 );
174 }
175
176 // choose one of hits according to track direction at the vertex.
177
178 if ( xx[0] * nx + yy[0] * ny > 0.0 )
179 {
180 emcx = xx[0];
181 emcy = yy[0];
182 }
183 else
184 {
185 emcx = xx[1];
186 emcy = yy[1];
187 }
188
189 double fi = atan2( emcy, emcx ); // atna2 from -pi to pi
190
191 if ( fi < 0.0 ) fi = pi2 + fi;
192 Fi_emc = fi;
193
194 // get phi and z on the emc counter
195 const HepPoint3D pivot2( emcx, emcy, 0.0 );
196 helix1.pivot( pivot2 );
197
198 // corrected by Ozaki san to avoid negative path length on Aug.10,99
199 Phi1 = helix1.a()[1];
200 Z_emc = helix1.a()[3];
201
202 // get(thepa,phi)from the intersection (x,y,z)
203 Hep3Vector intersec( emcx, emcy, Z_emc );
204 theta_emc = intersec.getTheta();
205 phi_emc = intersec.getPhi();
206
207 return ( 1 );
208}
HepGeom::Point3D< double > HepPoint3D
double Kappa
Definition Emc_helix.h:33
double Z_emc
Definition Emc_helix.h:28
double Phi1
Definition Emc_helix.h:35
double theta_emc
Definition Emc_helix.h:29
double Tanl
Definition Emc_helix.h:33
double Fi_emc
Definition Emc_helix.h:26
double Dr
Definition Emc_helix.h:33
double Dz
Definition Emc_helix.h:33
Emc_helix(void)
Definition Emc_helix.cxx:58
double phi_emc
Definition Emc_helix.h:30
double R_emc
Definition Emc_helix.h:25
double Phi0
Definition Emc_helix.h:33
int Emc_Get(double, int, double[])
Definition Emc_helix.cxx:65
const HepPoint3D & center(void) const
returns position of helix center(z = 0.);
double radius(void) const
returns radious of helix.
const HepVector & a(void) const
returns helix parameters.
const HepPoint3D & pivot(void) const
returns pivot position.
Hep3Vector direction(double dPhi=0.) const
returns direction vector after rotating angle dPhi in phi direction.