CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RadialStripTopology.cc
Go to the documentation of this file.
4 
5 #include <iostream>
6 #include <cmath>
7 #include <algorithm>
8 
9 RadialStripTopology::RadialStripTopology(int ns, float aw, float dh, float r, int yAx, float yMid) :
10  theNumberOfStrips(ns), theAngularWidth(aw),
11  theDetHeight(dh), theCentreToIntersection(r),
12  theYAxisOrientation(yAx), yCentre( yMid) {
13  // Angular offset of extreme edge of detector, so that angle is
14  // zero for a strip lying along local y axis = long symmetry axis of plane of strips
16 
17  LogTrace("RadialStripTopology") << "RadialStripTopology: constructed with"
18  << " strips = " << ns
19  << " width = " << aw << " rad "
20  << " det_height = " << dh
21  << " ctoi = " << r
22  << " phi_edge = " << thePhiOfOneEdge << " rad "
23  << " y_ax_ori = " << theYAxisOrientation
24  << " y_det_centre = " << yCentre
25  << "\n";
26 }
27 
28 int RadialStripTopology::channel(const LocalPoint& lp) const { return std::min( int( strip(lp) ), theNumberOfStrips-1 ) ;}
29 
30 int RadialStripTopology::nearestStrip(const LocalPoint & lp) const { return std::min( nstrips(), static_cast<int>( std::max(float(0), strip(lp)) ) + 1);}
31 
32 float RadialStripTopology::stripAngle(float strip) const { return phiOfOneEdge() + yAxisOrientation() * strip * angularWidth() ;}
33 
35 
37  return detHeight() * std::sqrt(1.f + std::pow( lp.x()/yDistanceToIntersection(lp.y()), 2.f) );
38 }
39 
40 float RadialStripTopology::xOfStrip(int strip, float y) const {
41  return
42  yAxisOrientation() * yDistanceToIntersection( y ) * std::tan( stripAngle(static_cast<float>(strip) - 0.5 ) );
43 }
44 
45 float RadialStripTopology::strip(const LocalPoint& lp) const {
46  const float // phi is measured from y axis --> sign of angle is sign of x * yAxisOrientation --> use atan2(x,y), not atan2(y,x)
47  phi( std::atan2( lp.x(), yDistanceToIntersection( lp.y() ) )),
48  aStrip( ( phi - yAxisOrientation() * phiOfOneEdge() )/angularWidth());
49  return std::max(float(0), std::min( (float)nstrips(), aStrip ));
50 }
51 
53  return LocalPoint( yAxisOrientation() * originToIntersection() * tan( stripAngle(strip) ), 0 );
54 }
55 
57  const float // y = (L/cos(phi))*mp.y()*cos(phi)
58  y( mp.y()*detHeight() + yCentreOfStripPlane() ),
60  return LocalPoint( x, y );
61 }
62 
64  const float // phi is [pi/2 - conventional local phi], use atan2(x,y) rather than atan2(y,x)
65  phi( yAxisOrientation() * std::atan2( lp.x(), yDistanceToIntersection( lp.y() ) ));
67  ( lp.y() - yCentreOfStripPlane() ) / detHeight() );
68 }
69 
70 LocalError RadialStripTopology::localError(float strip, float stripErr2) const {
71  const double
72  phi(stripAngle(strip)), t1(std::tan(phi)), t2(t1*t1),
73  // s1(std::sin(phi)), c1(std::cos(phi)),
74  // cs(s1*c1), s2(s1*s1), c2(1-s2), // rotation matrix
75 
76  tt( stripErr2 * std::pow( centreToIntersection()*angularWidth() ,2.f) ), // tangential sigma^2 *c2
77  rr( std::pow(detHeight(), 2.f) * (1.f/12.f) ), // radial sigma^2( uniform prob density along strip) *c2
78 
79  xx( tt + t2*rr ),
80  yy( t2*tt + rr ),
81  xy( t1*( rr - tt ) );
82 
83  return LocalError( xx, xy, yy );
84 }
85 
87  const double
88  phi(stripAngle(mp.x())), s1(std::sin(phi)), c1(std::cos(phi)),
89  cs(s1*c1), s2(s1*s1), c2(1-s2), // rotation matrix
90 
91  T( angularWidth() * ( centreToIntersection() + yAxisOrientation()*mp.y()*detHeight()) / c1 ), // tangential measurement unit (local pitch)
92  R( detHeight()/ c1 ), // radial measurement unit (strip length)
93  tt( me.uu() * T*T ), // tangential sigma^2
94  rr( me.vv() * R*R ), // radial sigma^2
95  tr( me.uv() * T*R ),
96 
97  xx( c2*tt + 2*cs*tr + s2*rr ),
98  yy( s2*tt - 2*cs*tr + c2*rr ),
99  xy( cs*( rr - tt ) + tr*( c2 - s2 ) );
100 
101  return LocalError( xx, xy, yy );
102 }
103 
105  const double
106  yHitToInter(yDistanceToIntersection(p.y())),
107  t(yAxisOrientation() * p.x() / yHitToInter), // tan(strip angle)
108  cs(t/(1+t*t)), s2(t*cs), c2(1-s2), // rotation matrix
109 
110  T2( 1./(std::pow(angularWidth(),2.f) * ( std::pow(p.x(),2.f) + std::pow(yHitToInter,2)) )), // 1./tangential measurement unit (local pitch) ^2
111  R2( c2/std::pow(detHeight(),2.f) ), // 1./ radial measurement unit (strip length) ^2
112 
113  uu( ( c2*e.xx() - 2*cs*e.xy() + s2*e.yy() ) * T2 ),
114  vv( ( s2*e.xx() + 2*cs*e.xy() + c2*e.yy() ) * R2 ),
115  uv( ( cs*( e.xx() - e.yy() ) + e.xy()*( c2 - s2 ) ) * std::sqrt (T2*R2) );
116 
117  return MeasurementError(uu, uv, vv);
118 }
119 
120 float RadialStripTopology::pitch() const { throw Genexception("RadialStripTopology::pitch() called - makes no sense, use localPitch(.) instead."); return 0.;}
121 
123  // The local pitch is the local x width of the strip at the local (x,y)
124  const int istrip = std::min(nstrips(), static_cast<int>(strip(lp)) + 1); // which strip number
125  const float fangle = stripAngle(static_cast<float>(istrip) - 0.5); // angle of strip centre
126  return
128  std::pow( std::cos(fangle-0.5f*angularWidth()), 2.f);
129 }
130 
131 
132 std::ostream & operator<<( std::ostream & os, const RadialStripTopology & rst ) {
133  os << "RadialStripTopology " << std::endl
134  << " " << std::endl
135  << "number of strips " << rst.nstrips() << std::endl
136  << "centre to whereStripsMeet " << rst.centreToIntersection() << std::endl
137  << "detector height in y " << rst.detHeight() << std::endl
138  << "angular width of strips " << rst.phiPitch() << std::endl
139  << "phi of one edge " << rst.phiOfOneEdge() << std::endl
140  << "y axis orientation " << rst.yAxisOrientation() << std::endl
141  << "y of centre of strip plane " << rst.yCentreOfStripPlane() << std::endl;
142  return os;
143 }
virtual int nstrips() const
float xx() const
Definition: LocalError.h:24
float vv() const
auto_ptr< ClusterSequence > cs
T y() const
Definition: PV2DBase.h:45
virtual MeasurementPoint measurementPosition(const LocalPoint &) const
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
RadialStripTopology(int ns, float aw, float dh, float r, int yAx=1, float yMid=0.)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T y() const
Definition: PV3DBase.h:62
float centreToIntersection() const
virtual float phiPitch(void) const
#define min(a, b)
Definition: mlp_lapack.h:161
float yDistanceToIntersection(float y) const
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
virtual float stripAngle(float strip) const
float xOfStrip(int strip, float y) const
virtual LocalPoint localPosition(float strip) const
tuple s2
Definition: indexGen.py:106
virtual float localStripLength(const LocalPoint &) const
float xy() const
Definition: LocalError.h:25
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
float yy() const
Definition: LocalError.h:26
const T & max(const T &a, const T &b)
T sqrt(T t)
Definition: SSEVec.h:46
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
float uu() const
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double f[11][100]
#define LogTrace(id)
virtual int nearestStrip(const LocalPoint &) const
float yCentreOfStripPlane() const
virtual float localPitch(const LocalPoint &) const
virtual float strip(const LocalPoint &) const
virtual MeasurementError measurementError(const LocalPoint &, const LocalError &) const
float originToIntersection() const
virtual int channel(const LocalPoint &) const
virtual float pitch() const
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
float angularWidth() const
float phiOfOneEdge() const
x
Definition: VDTMath.h:216
T x() const
Definition: PV2DBase.h:44
long double T
T x() const
Definition: PV3DBase.h:61
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
virtual LocalError localError(float strip, float stripErr2) const
float uv() const
Definition: DDAxes.h:10