BOSS 8.0.0
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 "CLHEP/Geometry/Point3D.h"
12#include <float.h>
13#ifndef ENABLE_BACKWARDS_COMPATIBILITY
14typedef HepGeom::Point3D<double> HepPoint3D;
15#endif
16// #include "TrackUtil/Helix.h"
17#include "KalFitAlg/helix/Helix.h"
18
19#include "KalFitAlg/KalFitCylinder.h"
20#include "KalFitAlg/KalFitMaterial.h"
21#include "KalFitAlg/KalFitTrack.h"
22
23double KalFitCylinder::intersect( const KalFitTrack& track, HepPoint3D& x ) const {
24 double dPhi[4];
25 dPhi[0] = track.intersect_cylinder( ro_ );
26 if ( dPhi[0] == 0 ) return -1;
27 dPhi[1] = track.intersect_cylinder( ri_ );
28 if ( dPhi[1] == 0 ) return -1;
29 dPhi[2] = track.intersect_xy_plane( zf_ );
30 dPhi[3] = track.intersect_xy_plane( zb_ );
31
32 int n[2];
33 int j = 0;
34 for ( int i = 0; i < 4 && j < 2; i++ )
35 {
36 HepPoint3D xx = track.x( dPhi[i] );
37 if ( isInside( xx ) ) n[j++] = i;
38 }
39 if ( j < 2 ) return -1;
40
41 x = track.x( ( dPhi[n[0]] + dPhi[n[1]] ) * .5 );
42
43 double tanl = track.tanl();
44 // cout<<"KalFitCylinder: track radius"<<track.radius()<<" dphi0 "
45 // <<dPhi[n[0]]<<" dphi1 "<<dPhi[n[1]]<<" tanl "<<tanl<<endl;
46 return fabs( track.radius() * ( dPhi[n[0]] - dPhi[n[1]] ) * sqrt( 1 + tanl * tanl ) );
47}
48
50 const HepPoint3D& point ) const {
51
52 const double ro = sqrt( point.x() * point.x() + point.y() * point.y() );
53
54 // std::cout<<" ro: "<<ro<<std::endl;
55
56 double dPhi[4];
57 dPhi[0] = track.intersect_cylinder( ro );
58 if ( dPhi[0] == 0 ) return -1;
59 dPhi[1] = track.intersect_cylinder( ri_ );
60 if ( dPhi[1] == 0 ) return -1;
61 dPhi[2] = track.intersect_xy_plane( zf_ );
62 dPhi[3] = track.intersect_xy_plane( zb_ );
63
64 // for(int ii=0; ii<4; ii++)
65 // std::cout<<"dPhi["<<ii<<"]"<<dPhi[ii]<<std::endl;
66
67 int n[2];
68 int j = 0;
69 for ( int i = 0; i < 4 && j < 2; i++ )
70 {
71 HepPoint3D xx = track.x( dPhi[i] );
72 if ( isInside( xx ) ) n[j++] = i;
73 }
74
75 if ( j < 2 ) return -1;
76
77 x = track.x( ( dPhi[n[0]] + dPhi[n[1]] ) * .5 );
78
79 double tanl = track.tanl();
80
81 return fabs( track.radius() * ( dPhi[n[0]] - dPhi[n[1]] ) * sqrt( 1 + tanl * tanl ) );
82}
83
84bool KalFitCylinder::isInside( const HepPoint3D& x ) const {
85 double r = x.perp();
86 double z = x.z();
87 // std::cout<<"r: "<<r<<" z: "<<z<<" ri: "<<ri_<<" ro: "<<ro_<<" zb_: "<<zb_<<"zf:
88 // "<<zf_<<std::endl;
89
90 return ( r >= ri_ - FLT_EPSILON && r <= ro_ + FLT_EPSILON && z >= zb_ - FLT_EPSILON &&
91 z <= zf_ + FLT_EPSILON );
92}
93
94bool KalFitCylinder::isInside2( const HepPoint3D& x ) const {
95 double r = x.perp();
96 double z = x.z();
97 // std::cout<<"r: "<<r<<" z: "<<z<<" ri: "<<ri_<<" ro: "<<ro_<<" zb_: "<<zb_<<"zf:
98 // "<<zf_<<std::endl;
99
100 return ( r <= ro_ + FLT_EPSILON && z >= zb_ - FLT_EPSILON && z <= zf_ + FLT_EPSILON );
101}
HepGeom::Point3D< double > HepPoint3D
const Int_t n
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.