CMS 3D CMS Logo

LocalError.h
Go to the documentation of this file.
1 #ifndef Geom_LocalError_H
2 #define Geom_LocalError_H
3 
9 #include <cmath>
10 #include <iosfwd>
11 
12 class LocalError {
13 public:
14  LocalError() : thexx(0), thexy(0), theyy(0) {}
15  LocalError(InvalidError) : thexx(-9999.e10f), thexy(0), theyy(-9999.e10f) {}
16 
17  LocalError( float xx, float xy, float yy) :
18  thexx(xx), thexy(xy), theyy(yy) {}
19 
20  bool invalid() const { return thexx<-1.e10f;}
21  bool valid() const { return !invalid();}
22 
23 
24  float xx() const { return thexx;}
25  float xy() const { return thexy;}
26  float yy() const { return theyy;}
27 
33  LocalError scale(float s) const {
34  float s2 = s*s;
35  return LocalError(s2*xx(), s2*xy(), s2*yy());
36  }
37 
39  LocalError rotate(float x, float y) const {
40  return rotateCosSin( x, y, 1.f/(x*x+y*y) );
41  }
42 
44  LocalError rotate(float phi) const {
45  return rotateCosSin( cos(phi), sin(phi));
46  }
47 
49  LocalError rotateCosSin( float c, float s, float mag2i=1.f) const {
50  return LocalError( mag2i*( (c*c)*xx() + (s*s)*yy() - 2.f*(c*s)*xy()),
51  mag2i*( (c*s)*(xx() - yy()) + (c*c-s*s)*xy()) ,
52  mag2i*( (s*s)*xx() + (c*c)*yy() + 2.f*(c*s)*xy())
53  );
54  }
55 
56 private:
57 
58  float thexx;
59  float thexy;
60  float theyy;
61 
62 };
63 
64 std::ostream & operator<<( std::ostream& s, const LocalError& err) ;
65 
66 #endif // LocalError_H
bool valid() const
Definition: LocalError.h:21
float xx() const
Definition: LocalError.h:24
float thexy
Definition: LocalError.h:59
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
LocalError(InvalidError)
Definition: LocalError.h:15
float xy() const
Definition: LocalError.h:25
float yy() const
Definition: LocalError.h:26
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double f[11][100]
LocalError rotateCosSin(float c, float s, float mag2i=1.f) const
Return a new LocalError, rotated by an angle defined by it&#39;s cosine and sine.
Definition: LocalError.h:49
bool invalid() const
Definition: LocalError.h:20
float thexx
Definition: LocalError.h:58
LocalError rotate(float phi) const
Return a new LocalError, rotated by an angle phi.
Definition: LocalError.h:44
std::ostream & operator<<(std::ostream &s, const LocalError &err)
Definition: LocalError.cc:4
float theyy
Definition: LocalError.h:60
LocalError(float xx, float xy, float yy)
Definition: LocalError.h:17
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)
Definition: LocalError.h:39
LocalError scale(float s) const
Definition: LocalError.h:33