BOSS 6.6.4.p03
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 "GaudiKernel/MsgStream.h"
26#include "GaudiKernel/AlgFactory.h"
27#include "GaudiKernel/ISvcLocator.h"
28#include "GaudiKernel/SmartDataPtr.h"
29#include "GaudiKernel/IDataProviderSvc.h"
30#include "GaudiKernel/PropertyMgr.h"
31#include "EventModel/Event.h"
32#include "MdcRawEvent/MdcDigi.h"
33#include "EmcRawEvent/EmcDigi.h"
34#include "McTruth/McParticle.h"
35
39#include <vector>
40#include <iostream>
41#include <cstdio>
42
43
44#include "EsTimeAlg/Emc_helix.h"
45#include "CLHEP/Vector/ThreeVector.h"
47
48#include "CLHEP/Geometry/Point3D.h"
49
50#ifndef ENABLE_BACKWARDS_COMPATIBILITY
52#endif
53
54using CLHEP::HepVector;
55using CLHEP::Hep3Vector;
56
57
59 piby1=3.141593;
60 pi2=2.0*piby1;
61 _debug=0;
62 _pathl_cut= 1000.0;
63
64 }
65
66
67int Emc_helix::Emc_Get(double rEmc, int id, double fzisan[]) {
68 // crossing points of the helix on the Emc cylinder
69 double xc,yc; // center of the circle
70 double rho; // radius of emc cyclinder
71 double xx[2],yy[2]; // coordinates of hits
72 double emcx,emcy; // (x,y) on the radius of R_emc
73 double nx,ny; // direction cosines of mom vector at vertex
74 double cosx,sinx;
75 double aa,ca,cb,cc,detm;
76
77
78 // fzisan track ID and EMC radius
79 int Id_cdfztrk = id; R_emc = rEmc;
80
81 if( Id_cdfztrk<0 ) {
82 if (_debug) std::cout << " Emc_helix *** wrong id_cdfztrk ="
83 << Id_cdfztrk << std::endl;
84 return(-1);
85 }
86
87 // fzisan track
88 /* FTFinder * ftrk = FTFinder:: GetPointer();
89 FTList<FTTrack *> & FsTrks = ftrk->tracks();
90 NTrk = FsTrks.length();
91
92 if (NTrk<=0) return (-3);
93
94 // get helix params for Id_cdfztrk
95 FTTrack & trk = * FsTrks[Id_cdfztrk];
96 const Helix hel = * trk.helix();
97
98 const HepPoint3D pivot1(0.,0.,0.);
99 HepVector a(5,0);
100 a[0] = hel.a()[0];
101 a[1] = hel.a()[1];
102 a[2] = hel.a()[2];
103 a[3] = hel.a()[3];
104 a[4] = hel.a()[4];
105 */
106 const HepPoint3D pivot1(0.,0.,0.);
107 HepVector a(5,0);
108 a[0] = fzisan[0];
109 a[1] = fzisan[1];
110 a[2] = fzisan[2];
111 a[3] = fzisan[3];
112 a[4] = fzisan[4];
113
114 // Ill-fitted track in fzisan (dz=tanl=-9999.)
115 if (abs(a[3])>50.0 || abs(a[4])>500.0) return (-5);
116
117 // D e f i n e h e l i x
118 Helix helix1(pivot1,a);
119 Dr = helix1.a()[0];
120 Phi0 = helix1.a()[1];
121 Kappa = helix1.a()[2];
122 Dz = helix1.a()[3];
123 Tanl = helix1.a()[4];
124
125 /* double detaphi=asin(0.5*0.81*0.3*fabs(Kappa));
126 double phi=Phi0+detaphi+ piby1/2;
127 */
128
129 // check cdfztrk hit on Emc cyclinder
130 rho = helix1.radius();
131 // cout<<" Emc_helix:: rho ="<<rho<<endl; // radius of the circle in cm
132 HepPoint3D xyz = helix1.center();
133 xc = xyz(0);
134 yc = xyz(1);
135
136 Hep3Vector vxyz = helix1.direction();
137 nx = vxyz(0); // direction of track at the vertex
138 ny = vxyz(1);
139
140 // get hit on Emc cylinder at radius R_Emc;
141 if( xc==0.0 && yc==0.0 ) return(-3);
142
143 // coefficients of quadratic equation
144 ca = xc*xc + yc*yc ;
145 aa = 0.5 * ( ca - rho*rho + R_emc*R_emc );
146
147 if ( xc != 0.0 ) {
148 cb = aa * yc;
149 cc = aa*aa - R_emc*R_emc*xc*xc;
150 // determinant
151 detm = cb*cb - ca*cc;
152 if ( detm > 0.0 ) {
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 } else return(-1);
158 }
159 else{
160 cb = aa * xc;
161 cc = aa*aa - R_emc*R_emc*yc*yc;
162 // determinant
163 detm = cb*cb - ca*cc;
164 if ( detm > 0.0 ) {
165 xx[0] = ( cb + sqrt(detm) )/ca;
166 yy[0] = ( aa - xx[0]*xc )/yc;
167 xx[1] = ( cb - sqrt(detm) )/ca;
168 yy[1] = ( aa - xx[1]*xc )/yc;
169 } else return(-2);
170 }
171
172
173 // choose one of hits according to track direction at the vertex.
174
175 if( xx[0]*nx + yy[0]*ny > 0.0 ) { emcx = xx[0]; emcy = yy[0]; }
176 else { emcx = xx[1]; emcy = yy[1]; }
177
178 double fi = atan2(emcy ,emcx ); // atna2 from -pi to pi
179
180 if( fi < 0.0 ) fi=pi2+fi;
181 Fi_emc = fi;
182
183 // get phi and z on the emc counter
184 const HepPoint3D pivot2( emcx, emcy, 0.0);
185 helix1.pivot(pivot2);
186
187 // corrected by Ozaki san to avoid negative path length on Aug.10,99
188 Phi1=helix1.a()[1];
189 Z_emc=helix1.a()[3];
190
191 //get(thepa,phi)from the intersection (x,y,z)
192 Hep3Vector intersec(emcx, emcy, Z_emc);
193 theta_emc = intersec.getTheta();
194 phi_emc = intersec.getPhi();
195
196 return(1);
197
198}
199
200
HepGeom::Point3D< double > HepPoint3D
Definition: Emc_helix.cxx:51
double abs(const EvtComplex &c)
Definition: EvtComplex.hh:212
double Kappa
Definition: Emc_helix.h:34
double Z_emc
Definition: Emc_helix.h:29
double Phi1
Definition: Emc_helix.h:36
double theta_emc
Definition: Emc_helix.h:30
double Tanl
Definition: Emc_helix.h:34
double Fi_emc
Definition: Emc_helix.h:27
double Dr
Definition: Emc_helix.h:34
double Dz
Definition: Emc_helix.h:34
Emc_helix(void)
Definition: Emc_helix.cxx:58
double phi_emc
Definition: Emc_helix.h:31
double R_emc
Definition: Emc_helix.h:26
double Phi0
Definition: Emc_helix.h:34
int Emc_Get(double, int, double[])
Definition: Emc_helix.cxx:67
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.