FairRoot/PandaRoot
RhoLorentzVectorErr.cxx
Go to the documentation of this file.
1 // //
3 // RhoLorentzVectorErr //
4 // //
5 // LorentzVector w/ error //
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 "RhoLorentzVectorErr.h"
14 #include "RhoVector3Err.h"
15 #include "TBuffer.h"
16 
18 
19 TBuffer& operator>> ( TBuffer& buf, RhoLorentzVectorErr *&obj )
20 {
21  obj = ( RhoLorentzVectorErr* ) buf.ReadObject ( RhoLorentzVectorErr::Class() );
22  return buf;
23 }
24 
25 #include <iostream>
26 using namespace std;
27 
29  Double_t mass ) :
30  TLorentzVector ( ( const TVector3& ) p3, sqrt ( p3.Mag2() + mass* mass ) )
31 {
32  int i=0,j=0;
33  fCovMatrix = new RhoError ( 4 );
34  // The 3-vector part of the error, initialized as a 0-matrix, then copied
35  // from p3:
36  TMatrixD p4Err ( 4,4 );
37  for ( i = 0; i < 3; ++i ) {
38  for ( j = i; j < 3; ++j ) { // start from j=i, since (i,j) = (j,i)
39  p4Err ( i,j ) = p3.CovMatrix() ( i,j );
40  }
41  }
42 
43  // The energy part of the error:
44  const Double_t energy = E();
45 
46  if ( energy != 0 ) {
47  p4Err ( 4,4 ) = 0.0;
48  for ( i = 0; i < 3; ++i ) {
49  for ( j = 0; j < 3; ++j ) {
50  p4Err ( 4,4 ) += p3[i] * p3[j] *
51  p3.CovMatrix() ( i, j );
52  }
53  }
54  p4Err ( 4,4 ) /= ( energy * energy );
55  }
56 
57  // The E-p correlated part of the error is
58  // <(E - <E>) (Pi - <Pi>)> = dE/dPj Vjk dPi/dPk
59  // Since dPi/dPk = delta_ik, we get dE/dPj Vji.
60  for ( i = 0; i < 3; ++i ) {
61  for ( j = 0; j < 3; ++j ) {
62  p4Err ( i,3 ) += p3 ( j ) / energy * p3.CovMatrix() ( j,i );
63  // No need to switch indices for a TMatrixD, so no p4Err(4,i)
64  }
65  }
66 
67  SetCovMatrix ( p4Err );
68 }
69 
70 // argumentless constructor:
72 {
73  fCovMatrix = new RhoError ( 4 );
74 }
75 
76 // auto casting constructor
77 RhoLorentzVectorErr::RhoLorentzVectorErr ( const TLorentzVector& p ) :
78  TLorentzVector ( p )
79 {
80  fCovMatrix = new RhoError ( 4 );
81 }
82 
83 RhoLorentzVectorErr::RhoLorentzVectorErr ( const TLorentzVector& p, const RhoError& covMat ) :
84  TLorentzVector ( p )
85 {
86  fCovMatrix = new RhoError ( covMat );
87 }
88 
89 // copy constructor
91 {
92  fCovMatrix = new RhoError ( v.CovMatrix() );
93 }
94 
95 // assignment operator:
97 {
98  if ( this != &v ) {
99  TLorentzVector::operator= ( v );
100  fCovMatrix = new RhoError ( v.CovMatrix() );
101  }
102  return *this;
103 }
104 
105 
106 // mathematical modifiers:
108 {
109  ( ( TLorentzVector ) *this ) *= -1.;
110  return *this; // fCovMatrix unaltered
111 }
112 
114 {
116  *fCovMatrix += v.CovMatrix();
117  return *this;
118 }
119 
121 {
123  *fCovMatrix += v.CovMatrix();
124  return *this;
125 }
126 
127 //-------------------------------------------------------------
128 Double_t
129 RhoLorentzVectorErr::DetermineChisq ( const TLorentzVector& refVector )
130 {
131  TVectorD temp ( 4 );
132  temp ( 0 ) = refVector.X()-this->X();
133  temp ( 1 ) = refVector.Y()-this->Y();
134  temp ( 2 ) = refVector.Z()-this->Z();
135  temp ( 3 ) = refVector.T()-this->T();
136 
137  return fCovMatrix->DetermineChisq ( temp );
138 }
139 
140 
141 //-------------------------------------------------------------
143 RhoLorentzVectorErr::Transform ( const TLorentzRotation& rot )
144 {
145  TLorentzVector::Transform ( rot );
146  *fCovMatrix = fCovMatrix->Similarity ( rot );
147  return *this;
148 }
149 
150 //-------------------------------------------------------------
153 {
154  TLorentzVector::Transform ( rot );
155  TMatrixD tempRot ( 4,4 );
156 
157  // Fill a 4x4 matrix from the 3x3 TRotation. Note that they use different
158  // indexing schemes (!?@#$&^*&#$@#):
159 
160  int row;
161  int col;
162  for ( row = 0; row < 3; ++row ) { // 3 is the size of TRotation
163  for ( col = 0; col < 3; ++col ) { // (which provides no enum)
164  tempRot ( row, col ) = rot ( row, col );
165  }
166  }
167 
168  // fill the 4th row:
169  tempRot ( 3,3 ) = 1.0;
170  for ( col = 0; col < 3; ++col ) {
171  tempRot ( 3, col ) = 0.0;
172  }
173 
174  // fill the 4th column:
175  for ( row = 0; row < 3; ++row ) {
176  tempRot ( row, 3 ) = 0.0;
177  }
178 
179  *fCovMatrix = fCovMatrix->Similarity ( tempRot );
180  return *this;
181 }
182 
183 
184 
185 //-------------------------------------------------------------
188 {
189  RhoLorentzVectorErr ve ( TLorentzVector ( v.X() +w.X(),v.Y() +w.Y(),v.Z() +w.Z(),
190  v.T() +w.T() ),
191  ( v.CovMatrix() +w.CovMatrix() ) );
192  return ve;
193 }
194 
195 
196 //-------------------------------------------------------------
199 {
200  RhoLorentzVectorErr ve ( TLorentzVector ( v.X()-w.X(),v.Y()-w.Y(),v.Z()-w.Z(),
201  v.T()-w.T() ),
202  ( v.CovMatrix() +w.CovMatrix() ) );
203  return ve;
204 }
205 
207 {
208  out << X() << "\t" << Y() << "\t" << Z() << "\t" << T();
209 }
210 
212 {
213  verr.PrintOn ( stream );
214  return stream;
215 }
int row
Definition: anaLmdDigi.C:67
Double_t DetermineChisq(TVectorD &diff)
Definition: RhoError.cxx:166
const RhoError & CovMatrix() const
Int_t i
Definition: run_full.C:25
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
ClassImp(RhoLorentzVectorErr) TBuffer &operator>>(TBuffer &buf
RhoLorentzVectorErr operator-(const RhoLorentzVectorErr &v, const RhoLorentzVectorErr &w)
RhoLorentzVectorErr & operator-()
int col
Definition: anaLmdDigi.C:67
friend void operator+=(F32vec1 &a, const F32vec1 &b)
RhoLorentzVectorErr operator+(const RhoLorentzVectorErr &v, const RhoLorentzVectorErr &w)
double Y
Definition: anaLmdDigi.C:68
__m128 v
Definition: P4_F32vec4.h:4
Double_t p
Definition: anasim.C:58
RhoLorentzVectorErr *& obj
friend void operator-=(F32vec1 &a, const F32vec1 &b)
TTree * T
Definition: anaLmdReco.C:32
void PrintOn(std::ostream &o=std::cout) const
Double_t
RhoLorentzVectorErr & operator-=(const RhoLorentzVectorErr &v)
RhoLorentzVectorErr & Transform(const TRotation &rot)
TFile * out
Definition: reco_muo.C:20
RhoLorentzVectorErr & operator=(const RhoLorentzVectorErr &v)
RhoError Similarity(const TMatrixD &m1) const
Definition: RhoError.cxx:104
void SetCovMatrix(const RhoError &v)
double X
Definition: anaLmdDigi.C:68
Double_t DetermineChisq(const TLorentzVector &refVector)
double Z
Definition: anaLmdDigi.C:68
TGeoRotation rot
const RhoError & CovMatrix() const
Definition: RhoVector3Err.h:68
TMatrixT< double > TMatrixD
Definition: PndLmdDim.h:52
return buf
Double_t energy
Definition: plot_dirc.C:15
RhoLorentzVectorErr & operator+=(const RhoLorentzVectorErr &v)
std::ostream & operator<<(std::ostream &stream, const RhoLorentzVectorErr &verr)