FairRoot/PandaRoot
RhoVector3Err.cxx
Go to the documentation of this file.
1 // //
3 // RhoVectorErr //
4 // //
5 // Vector w/ error class //
6 // //
7 // Author: Marcel Kunze, RUB, Nov. 99 //
8 // Copyright (C) 1999-2001, Ruhr-University Bochum. //
9 // Ralf Kliemt, HIM/GSI Feb.2013 (Cleanup & Restructuring) //
10 // //
12 
13 #include "RhoVector3Err.h"
14 #include "TBuffer.h"
15 #include <float.h>
16 
18 
19 TBuffer& operator>> ( TBuffer& buf, RhoVector3Err *&obj )
20 {
21  obj = ( RhoVector3Err* ) buf.ReadObject ( RhoVector3Err::Class() );
22  return buf;
23 }
24 
25 #include <iostream>
26 using namespace std;
27 
28 RhoVector3Err::RhoVector3Err() : TVector3(), fCovMatrix ( 3 ) {}
29 
30 // auto casting constructor
31 RhoVector3Err::RhoVector3Err ( const TVector3& p ) : TVector3 ( p ), fCovMatrix ( 3 ) {}
32 RhoVector3Err::RhoVector3Err ( const TVector3& p, const RhoError& covMat ) : TVector3 ( p ),
33  fCovMatrix ( 3 )
34 {
35  fCovMatrix=covMat;
36 }
37 
38 // copy constructor:
39 RhoVector3Err::RhoVector3Err ( const RhoVector3Err& v ) : TVector3 ( v ),
40  fCovMatrix ( v.CovMatrix() ) {}
41 
42 // destructor MAY be needed later
43 // virtual ~TVectorErr() {};
44 
45 // assignment operator:
47 {
48  if ( this != &v ) {
49  TVector3::operator= ( v );
50  fCovMatrix = v.CovMatrix();
51  }
52  return *this;
53 }
54 
56 {
57  ( *this ) *= -1.;
58  return *this; // fCovMatrix remains unaltered
59 }
60 
62 {
64  fCovMatrix += v.CovMatrix();
65  return *this;
66 }
67 
69 {
71  fCovMatrix += v.CovMatrix();
72  return *this;
73 }
74 
76 {
77  TVector3::Transform ( rot );
79  return *this;
80 }
81 
82 //void TVectorErr::printOn(ostream& out) const
83 //{
84 // out << "TVector and Covariance Matrix:" << endl;
85 // TVector::printOn(out);
86 // out << endl;
87 // out << fCovMatrix;
88 //}
89 /*
90 TError TVectorErr::covRTPMatrix() const{
91 // protect against 0's
92 Double_t xv = X()==0 ? FLT_MIN : X();
93 Double_t yv = Y()==0 ? FLT_MIN : Y();
94 Double_t zv = Z()==0 ? FLT_MIN : Z();
95 DifNumber xDF(xv,X+1,3), yDF(yv,Y+1,3), zDF(zv,Z+1,3);
96 DifArray pars(3,NUM_PCOORDINATES);
97 pars[Rho] = sqrt(xDF*xDF + yDF*yDF + zDF*zDF);
98 pars[Phi] = atan2(yDF,xDF);
99 pars[Theta] = acos(zDF/pars[Rho]);
100 return covMatrix().Similarity(pars.jacobian());
101 }
102 
103  TError TVectorErr::covRZPMatrix() const{
104  // protect against 0's
105  Double_t xv = X()==0 ? FLT_MIN : X();
106  Double_t yv = Y()==0 ? FLT_MIN : Y();
107  Double_t zv = Z()==0 ? FLT_MIN : Z();
108  DifNumber xDF(xv,X+1,3), yDF(yv,Y+1,3), zDF(zv,Z+1,3);
109  DifArray pars(3,NUM_CCOORDINATES);
110  pars[C_Rho] = sqrt(xDF*xDF + yDF*yDF);
111  pars[C_Phi] = atan2(yDF,xDF);
112  pars[C_Zeta] = zDF;
113  return covMatrix().Similarity(pars.jacobian());
114  }
115 */
116 Double_t RhoVector3Err::DetermineChisq ( const TVector3& refVector )
117 {
118  TVectorD temp ( 3 );
119  temp ( 0 ) = refVector.X()-this->X();
120  temp ( 1 ) = refVector.Y()-this->Y();
121  temp ( 2 ) = refVector.Z()-this->Z();
122  return fCovMatrix.DetermineChisq ( temp );
123 }
124 
125 
127 {
128  RhoVector3Err ve ( TVector3 ( v.X() +w.X(),v.Y() +w.Y(),v.Z() +w.Z() ),
129  ( v.CovMatrix() +w.CovMatrix() ) );
130  return ve;
131 }
132 
134 {
135  RhoVector3Err ve ( TVector3 ( v.X()-w.X(),v.Y()-w.Y(),v.Z()-w.Z() ),
136  ( v.CovMatrix() +w.CovMatrix() ) );
137  return ve;
138 }
139 
140 
141 
142 
143 
145 {
146  stream << ( const TVector3& ) verr
147  << ", " << verr.CovMatrix();
148 
149  return stream;
150 }
151 
153 {
154  RhoError mat ( 3 );
155  stream >> verr >> mat;
156  verr.SetCovMatrix ( mat );
157 
158  return stream;
159 }
160 
RhoError operator-(const RhoError &m1, const RhoError &m2)
Definition: RhoError.cxx:255
Double_t p
Definition: anasim.C:58
RhoError fCovMatrix
Definition: RhoVector3Err.h:88
Double_t DetermineChisq(TVectorD &diff)
Definition: RhoError.cxx:166
void SetCovMatrix(const RhoError &v)
Definition: RhoVector3Err.h:80
RhoVector3Err & operator+=(const RhoVector3Err &v)
std::ostream & operator<<(std::ostream &o, const PndEventInfo &a)
friend void operator+=(F32vec1 &a, const F32vec1 &b)
RhoVector3Err & operator-=(const RhoVector3Err &v)
double Y
Definition: anaLmdDigi.C:68
__m128 v
Definition: P4_F32vec4.h:4
RhoError operator+(const RhoError &m1, const RhoError &m2)
Definition: RhoError.cxx:245
friend void operator-=(F32vec1 &a, const F32vec1 &b)
Double_t DetermineChisq(const TVector3 &refVector)
RhoVector3Err & operator-()
Double_t
RhoVector3Err & operator=(const RhoVector3Err &v)
RhoVector3Err & Transform(const TRotation &rot)
RhoError Similarity(const TMatrixD &m1) const
Definition: RhoError.cxx:104
double X
Definition: anaLmdDigi.C:68
TBuffer & operator>>(TBuffer &buf, PndAnaPidSelector *&obj)
ClassImp(PndAnaContFact)
double Z
Definition: anaLmdDigi.C:68
TGeoRotation rot
const RhoError & CovMatrix() const
Definition: RhoVector3Err.h:68