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) : thexx(xx), thexy(xy), theyy(yy) {}
18 
19  bool invalid() const { return thexx < -1.e10f; }
20  bool valid() const { return !invalid(); }
21 
22  float xx() const { return thexx; }
23  float xy() const { return thexy; }
24  float yy() const { return theyy; }
25 
31  LocalError scale(float s) const {
32  float s2 = s * s;
33  return LocalError(s2 * xx(), s2 * xy(), s2 * yy());
34  }
35 
37  LocalError rotate(float x, float y) const { return rotateCosSin(x, y, 1.f / (x * x + y * y)); }
38 
40  LocalError rotate(float phi) const { return rotateCosSin(cos(phi), sin(phi)); }
41 
43  LocalError rotateCosSin(float c, float s, float mag2i = 1.f) const {
44  return LocalError(mag2i * ((c * c) * xx() + (s * s) * yy() - 2.f * (c * s) * xy()),
45  mag2i * ((c * s) * (xx() - yy()) + (c * c - s * s) * xy()),
46  mag2i * ((s * s) * xx() + (c * c) * yy() + 2.f * (c * s) * xy()));
47  }
48 
49 private:
50  float thexx;
51  float thexy;
52  float theyy;
53 };
54 
55 std::ostream& operator<<(std::ostream& s, const LocalError& err);
56 
57 #endif // LocalError_H
LocalError scale(float s) const
Definition: LocalError.h:31
float thexy
Definition: LocalError.h:51
bool valid() const
Definition: LocalError.h:20
LocalError rotate(float x, float y) const
Return a new LocalError, rotated by an angle defined by the direction (x,y)
Definition: LocalError.h:37
std::ostream & operator<<(std::ostream &s, const LocalError &err)
Definition: LocalError.cc:4
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
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:43
LocalError(InvalidError)
Definition: LocalError.h:15
float yy() const
Definition: LocalError.h:24
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double f[11][100]
float xy() const
Definition: LocalError.h:23
float thexx
Definition: LocalError.h:50
LocalError rotate(float phi) const
Return a new LocalError, rotated by an angle phi.
Definition: LocalError.h:40
float theyy
Definition: LocalError.h:52
bool invalid() const
Definition: LocalError.h:19
LocalError(float xx, float xy, float yy)
Definition: LocalError.h:17
float xx() const
Definition: LocalError.h:22