CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
KalFitCylinder.cxx
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// File from KalFit module
3//
4// Filename : KalFitCylinder.cc
5//------------------------------------------------------------------------
6// Description :
7// Cylinder is an Element whose shape is a cylinder.
8//------------------------------------------------------------------------
9// Modif :
10//------------------------------------------------------------------------
11#include <float.h>
12#include "CLHEP/Geometry/Point3D.h"
13#ifndef ENABLE_BACKWARDS_COMPATIBILITY
15#endif
16//#include "TrackUtil/Helix.h"
17#include "KalFitAlg/helix/Helix.h"
18
19#include "KalFitAlg/KalFitTrack.h"
20#include "KalFitAlg/KalFitMaterial.h"
21#include "KalFitAlg/KalFitCylinder.h"
22
24 HepPoint3D& x) const
25{
26 double dPhi[4];
27 dPhi[0] = track.intersect_cylinder(ro_);
28 if(dPhi[0] == 0) return -1;
29 dPhi[1] = track.intersect_cylinder(ri_);
30 if(dPhi[1] == 0) return -1;
31 dPhi[2] = track.intersect_xy_plane(zf_);
32 dPhi[3] = track.intersect_xy_plane(zb_);
33
34 int n[2];
35 int j = 0;
36 for(int i = 0; i < 4 && j < 2; i++){
37 HepPoint3D xx = track.x(dPhi[i]);
38 if(isInside(xx)) n[j++] = i;
39 }
40 if(j < 2) return -1;
41
42 x = track.x((dPhi[n[0]] + dPhi[n[1]]) * .5);
43
44 double tanl = track.tanl();
45 //cout<<"KalFitCylinder: track radius"<<track.radius()<<" dphi0 "
46 // <<dPhi[n[0]]<<" dphi1 "<<dPhi[n[1]]<<" tanl "<<tanl<<endl;
47 return fabs(track.radius() * (dPhi[n[0]] - dPhi[n[1]])
48 * sqrt(1 + tanl * tanl));
49}
50
51
53 HepPoint3D& x, const HepPoint3D& point) const
54{
55
56 const double ro = sqrt(point.x()*point.x()+point.y()*point.y());
57
58 //std::cout<<" ro: "<<ro<<std::endl;
59
60 double dPhi[4];
61 dPhi[0] = track.intersect_cylinder(ro);
62 if(dPhi[0] == 0) return -1;
63 dPhi[1] = track.intersect_cylinder(ri_);
64 if(dPhi[1] == 0) return -1;
65 dPhi[2] = track.intersect_xy_plane(zf_);
66 dPhi[3] = track.intersect_xy_plane(zb_);
67
68 //for(int ii=0; ii<4; ii++)
69 //std::cout<<"dPhi["<<ii<<"]"<<dPhi[ii]<<std::endl;
70
71 int n[2];
72 int j = 0;
73 for(int i = 0; i < 4 && j < 2; i++){
74 HepPoint3D xx = track.x(dPhi[i]);
75 if(isInside(xx)) n[j++] = i;
76 }
77
78 if(j < 2) return -1;
79
80 x = track.x((dPhi[n[0]] + dPhi[n[1]]) * .5);
81
82 double tanl = track.tanl();
83
84 return fabs(track.radius() * (dPhi[n[0]] - dPhi[n[1]])
85 * sqrt(1 + tanl * tanl));
86 }
87
88//Attention!!! [ri,ro] must be within [ri_,ro_]
90 HepPoint3D& x, const double ri, const double ro) const
91{
92
93 //std::cout<<" ro: "<<ro<<std::endl;
94
95 double dPhi[4];
96 dPhi[0] = track.intersect_cylinder(ro);
97 if(dPhi[0] == 0) return -1;
98 dPhi[1] = track.intersect_cylinder(ri);
99 if(dPhi[1] == 0) return -1;
100 dPhi[2] = track.intersect_xy_plane(zf_);
101 dPhi[3] = track.intersect_xy_plane(zb_);
102
103 //for(int ii=0; ii<4; ii++)
104 //std::cout<<"dPhi["<<ii<<"]"<<dPhi[ii]<<std::endl;
105
106 int n[2];
107 int j = 0;
108 for(int i = 0; i < 4 && j < 2; i++){
109 HepPoint3D xx = track.x(dPhi[i]);
110 if(isInside(xx,ri,ro)) n[j++] = i;
111 }
112
113 if(j < 2) return -1;
114
115 x = track.x((dPhi[n[0]] + dPhi[n[1]]) * .5);
116
117 double tanl = track.tanl();
118
119 return fabs(track.radius() * (dPhi[n[0]] - dPhi[n[1]])
120 * sqrt(1 + tanl * tanl));
121 }
122
123
124bool KalFitCylinder::isInside(const HepPoint3D& x, const double ri, const double ro) const
125{
126 double r = x.perp();
127 double z = x.z();
128 //std::cout<<"r: "<<r<<" z: "<<z<<" ri: "<<ri_<<" ro: "<<ro_<<" zb_: "<<zb_<<"zf: "<<zf_<<std::endl;
129
130 return (r >= ri - FLT_EPSILON &&
131 r <= ro + FLT_EPSILON &&
132 z >= zb_ - FLT_EPSILON &&
133 z <= zf_ + FLT_EPSILON);
134}
135
137{
138 double r = x.perp();
139 double z = x.z();
140 //std::cout<<"r: "<<r<<" z: "<<z<<" ri: "<<ri_<<" ro: "<<ro_<<" zb_: "<<zb_<<"zf: "<<zf_<<std::endl;
141
142 return (r >= ri_ - FLT_EPSILON &&
143 r <= ro_ + FLT_EPSILON &&
144 z >= zb_ - FLT_EPSILON &&
145 z <= zf_ + FLT_EPSILON);
146}
147
148
150{
151 double r = x.perp();
152 double z = x.z();
153 //std::cout<<"r: "<<r<<" z: "<<z<<" ri: "<<ri_<<" ro: "<<ro_<<" zb_: "<<zb_<<"zf: "<<zf_<<std::endl;
154
155 return (r <= ro_ + FLT_EPSILON &&
156 z >= zb_ - FLT_EPSILON &&
157 z <= zf_ + FLT_EPSILON);
158}
159
const Int_t n
Double_t x[10]
HepGeom::Point3D< double > HepPoint3D
bool isInside(const HepPoint3D &x) const
Check if the position x is inside the current cylinder.
virtual double intersect(const KalFitTrack &track, HepPoint3D &x) const
Find intersection with Helix.
bool isInside2(const HepPoint3D &x) const
Description of a track class (<- Helix.cc)
double intersect_cylinder(double r) const
Intersection with different geometry.
double intersect_xy_plane(double z) const
HepPoint3D x(double dPhi=0.) const
returns position after rotating angle dPhi in phi direction.
double radius(void) const
returns radious of helix.