BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Reconstruction/KalFitAlg/include/KalFitAlg/KalFitWire.h
Go to the documentation of this file.
1//-----------------------------------------------------------------------
2// File from KalFit module
3//
4// Filename : KalFitWires.cc
5//------------------------------------------------------------------------
6// Description :
7//------------------------------------------------------------------------
8// Modif :
9//------------------------------------------------------------------------
10#ifndef _DEFINE_WIRE_H_
11#define _DEFINE_WIRE_H_
12
13#define WireHit 1
14#define WireHitInvalid 2
15#define WireHitAppended 4
16#define WireHitAppendedorInvalid 6
17#define WireNeighbor0 8
18#define WireNeighbor1 16
19#define WireNeighbor2 32
20#define WireNeighbor3 64
21#define WireNeighbor4 128
22#define WireNeighbor5 256
23
24#ifndef M_PI
25# define M_PI 3.14159265358979323846
26#endif
27
28#include "KalFitAlg/lpav/Lpav.h"
29
30// #ifndef CLHEP_POINT3D_H
31#include "CLHEP/Geometry/Point3D.h"
32#ifndef ENABLE_BACKWARDS_COMPATIBILITY
33typedef HepGeom::Point3D<double> HepPoint3D;
34#endif
35// #endif
36#include "KalFitAlg/KalFitLayer_Mdc.h"
37
38using CLHEP::Hep3Vector;
39using CLHEP::HepMatrix;
40using CLHEP::HepSymMatrix;
41using CLHEP::HepVector;
42
43using namespace CLHEP;
44using KalmanFit::Lpav;
45
46/// Description of a Wire class
47class KalFitWire {
48
49 enum { NREGION = 3 };
50 static const double A[NREGION];
51 enum { NLAYER = 50 };
52 static const double F[NLAYER];
53
54public:
55 /// constructor
56 KalFitWire( const int localID, const KalFitLayer_Mdc& layer, const HepPoint3D& fwd,
57 const HepPoint3D& bck, KalFitWire* const vt, unsigned int geoID,
58 unsigned int stereo );
59
61
62 /// destructor
63 ~KalFitWire( void );
64
65 /// Extractor :
66 unsigned int localId( void ) const { return localId_; }
67 const KalFitLayer_Mdc& layer( void ) const { return layer_; }
68 KalFitWire** neighborPtr( void ) { return neighbor_; }
69 unsigned int state( void ) const { return state_; }
70 unsigned stateAND( const unsigned mask ) const;
71 unsigned int geoID( void ) const { return geoID_; }
72 unsigned int stereo( void ) const { return stereo_; }
73
74 /// returns drift distance
75 double distance( void ) const;
76
77 /// returns z_distance from the center of wire by drift distance
78 double distance_z( void ) const;
79
80 void state( const unsigned int i ) { state_ = i; }
81 void stateOR( const unsigned mask );
82 void stateXOR( const unsigned mask );
83 void stateORXOR( const unsigned mask );
84 void sagcoef( void );
85 void ddl( const double d ) { ddl_ = d; }
86 void ddr( const double d ) { ddr_ = d; }
87
88 /// Geometry :
89 HepPoint3D fwd( void ) const { return fwd_; }
90 HepPoint3D bck( void ) const { return bck_; }
91 HepPoint3D xyPosition( void ) const { return xyPosition_; }
92 double Acoef( void ) const { return A_; }
93 double lzx( void ) const { return lzx_; }
94 void chk_left_and_right( void );
95
96 //
97 double x( void ) const { return x_; }
98 double y( void ) const { return y_; }
99
100 /// returns z for track la
101 int z( const Lpav& la, double& z ) const;
102
103 double phi( void ) const;
104
105 /// set drift distance
106 double distance( const double distance );
107
108private:
109 const KalFitWire* left( void ) const;
110 const KalFitWire* right( void ) const;
111 const KalFitWire* innerLeft( KalFitWire* const vtWire ) const;
112 const KalFitWire* innerRight( KalFitWire* const vtWire ) const;
113 const KalFitWire* outerLeft( KalFitWire* const vtWire ) const;
114 const KalFitWire* outerRight( KalFitWire* const vtWire ) const;
115
116private:
117 int localId_;
118 double A_;
119 double lzx_;
120 HepPoint3D fwd_;
121 HepPoint3D bck_;
122 const KalFitLayer_Mdc& layer_;
123 HepPoint3D xyPosition_;
124 unsigned int state_;
125 KalFitWire* neighbor_[6];
126 unsigned int geoID_;
127 unsigned int stereo_;
128 double ddl_, ddr_;
129 double distance_;
130 double x_;
131 double y_;
132 double dx_;
133 double dy_;
134};
135
136#ifdef KalFitWire_NO_INLINE
137# define inline
138#else
139# undef inline
140# define KalFitWire_INLINE_DEFINE_HERE
141#endif
142
143#ifdef KalFitWire_INLINE_DEFINE_HERE
144inline unsigned KalFitWire::stateAND( const unsigned mask ) const { return state_ & mask; }
145
146inline void KalFitWire::stateOR( const unsigned mask ) { state_ |= mask; }
147
148inline void KalFitWire::stateXOR( const unsigned mask ) { state_ ^= mask; }
149
150inline void KalFitWire::stateORXOR( const unsigned mask ) {
151 state_ = ( state_ | mask ) ^ mask;
152}
153
154inline double KalFitWire::phi( void ) const {
155 return M_PI * ( layer_.offset() + 2 * localId_ ) / (double)layer_.superLayer().nWire();
156}
157
158inline double KalFitWire::distance( void ) const { return distance_; }
159
160inline double KalFitWire::distance_z( void ) const {
161 return distance_ * fabs( layer_.tanSlant() );
162}
163
164inline double KalFitWire::distance( const double distance ) { return distance_ = distance; }
165
166inline int KalFitWire::z( const Lpav& la, double& z ) const {
167 HepVector center = la.center();
168 double rho = la.radius();
169 double dx2 = center( 1 ) - x_;
170 double dy2 = center( 2 ) - y_;
171 double par1 = dx_ * dx_ + dy_ * dy_;
172 double par2 = ( dx_ * dx2 + dy_ * dy2 ) / par1;
173 double par3 = dx_ * dy2 - dy_ * dx2;
174 double par4 = rho * rho * par1 - par3 * par3;
175 if ( par4 < 0. ) return 0;
176 par4 = sqrt( par4 ) / par1;
177 double delta = par2 + par4;
178 if ( delta >= 0. && delta < 1. )
179 {
180 z = layer_.zb() + delta * ( layer_.zf() - layer_.zb() );
181 return 1;
182 }
183 else
184 {
185 delta = par2 - par4;
186 if ( delta >= 0. && delta < 1. )
187 {
188 z = layer_.zb() + delta * ( layer_.zf() - layer_.zb() );
189 return 1;
190 }
191 }
192 return 0;
193}
194
195#endif
196#undef inline
197
198#endif /* _DEFINE_WIRE_H_ */
HepGeom::Point3D< double > HepPoint3D
HepGeom::Point3D< double > HepPoint3D
~KalFitWire(void)
destructor
double distance_z(void) const
returns z_distance from the center of wire by drift distance
void stateORXOR(const unsigned mask)
double distance(void) const
returns drift distance
void stateXOR(const unsigned mask)
void stateOR(const unsigned mask)
KalFitWire(const int localID, const KalFitLayer_Mdc &layer, const HepPoint3D &fwd, const HepPoint3D &bck, KalFitWire *const vt, unsigned int geoID, unsigned int stereo)
constructor
double phi(void) const
double distance(const double distance)
set drift distance
unsigned int localId(void) const
Extractor :
void sagcoef(void)
int z(const Lpav &la, double &z) const
returns z for track la
unsigned stateAND(const unsigned mask) const
void chk_left_and_right(void)