]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RALICE/AliBoost.cxx
First commit
[u/mrichter/AliRoot.git] / RALICE / AliBoost.cxx
CommitLineData
4c039060 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
f531a546 16// $Id$
4c039060 17
959fbac5 18///////////////////////////////////////////////////////////////////////////
19// Class AliBoost
20// Perform various Lorentz transformations.
21//
22// Example :
23// =========
24//
25// Float_t a[3]={0.1,0.2,0.3};
26// Float_t ea[3]={0.01,0.02,0.03};
27// Ali3Vector beta;
28// beta.SetVector(a,"car");
29// beta.SetErrors(ea,"car");
30//
31// AliBoost b1;
32// b1.SetBeta(beta);
33// b1.Info();
34//
35// Float_t b[4]={14,1,2,3};
36// Float_t eb[4]={1.4,0.1,0.2,0.3};
37// Ali4Vector p;
38// p.SetVector(b,"car");
39// p.SetErrors(eb,"car");
40// Ali4Vector pprim=b1.Boost(p);
41// p.Info();
42// pprim.Info();
43//
44// p=b1.Inverse(pprim);
45// pprim.Info();
46// p.Info();
47//
48// Float_t c[4]={5,0,0,4};
49// Float_t ec[4]={0.5,0,0,0.4};
50// Ali4Vector q;
51// q.SetVector(c,"car");
52// q.SetErrors(ec,"car");
53//
54// AliBoost b2;
55// b2.Set4Momentum(q);
56// b2.Info("sph");
57//
58//--- Author: Nick van Eijndhoven 14-may-1996 UU-SAP Utrecht
f531a546 59//- Modified: NvE $Date$ UU-SAP Utrecht
959fbac5 60///////////////////////////////////////////////////////////////////////////
61
d88f97cc 62#include "AliBoost.h"
63
64ClassImp(AliBoost) // Class implementation to enable ROOT I/O
65
66AliBoost::AliBoost()
67{
959fbac5 68// Creation of a Lorentz boost object and initialisation of parameters.
69// Beta is set to (0,0,0) and consequently Gamma=1.
70// All errors are initialised to 0.
d88f97cc 71 Double_t a[3]={0,0,0};
72 fBeta.SetVector(a,"sph");
959fbac5 73 fGamma=1;
74 fDgamma=0;
75 fDresult=0;
d88f97cc 76}
77///////////////////////////////////////////////////////////////////////////
78AliBoost::~AliBoost()
79{
959fbac5 80// Default destructor.
d88f97cc 81}
82///////////////////////////////////////////////////////////////////////////
83void AliBoost::SetBeta(Ali3Vector b)
84{
959fbac5 85// Setting of boost parameters on basis of beta 3-vector.
86// The errors on the beta 3-vector are taken from the input 3-vector.
87// The gamma value and its error are calculated accordingly.
d88f97cc 88 fBeta=b;
959fbac5 89 Double_t beta2=fBeta.Dot(fBeta);
90 Double_t dbeta2=fBeta.GetResultError();
d88f97cc 91
959fbac5 92 if (beta2 > 1.)
d88f97cc 93 {
94 cout << " *AliBoost::SetBeta* beta > 1." << endl;
95 }
d88f97cc 96 fGamma=0;
959fbac5 97 fDgamma=0;
98 Double_t temp=1.-beta2;
99 if (temp > 0.)
d88f97cc 100 {
959fbac5 101 fGamma=sqrt(1./temp);
102 fDgamma=fabs(dbeta2/(2.*pow(temp,1.5)));
d88f97cc 103 }
104}
105///////////////////////////////////////////////////////////////////////////
106void AliBoost::Set4Momentum(Ali4Vector& p)
107{
959fbac5 108// Setting of boost parameters on basis of momentum 4-vector data.
109// The errors of the input 4-vector are used to calculate the
110// errors on the beta 3-vector and the gamma factor.
d88f97cc 111 Double_t E=p.GetScalar();
959fbac5 112 Double_t dE=p.GetResultError();
d88f97cc 113 if (E <= 0.)
114 {
115 cout << " *AliBoost::Set4Momentum* Unphysical situation." << endl;
116 p.Info();
117 }
118 else
119 {
120 Ali3Vector b=p.Get3Vector();
959fbac5 121 Double_t vb[3],eb[3];
122 b.GetVector(vb,"car");
123 b.GetErrors(eb,"car");
d88f97cc 124 b=b/E;
959fbac5 125 for (Int_t i=0; i<3; i++)
126 {
127 eb[i]=sqrt(pow(eb[i]/E,2)+pow(vb[i]*dE/(E*E),2));
128 }
129 b.SetErrors(eb,"car");
d88f97cc 130 SetBeta(b);
131 }
132}
133///////////////////////////////////////////////////////////////////////////
134Ali3Vector AliBoost::GetBetaVector()
135{
959fbac5 136// Provide the beta 3-vector.
d88f97cc 137 return fBeta;
138}
139///////////////////////////////////////////////////////////////////////////
140Double_t AliBoost::GetBeta()
141{
959fbac5 142// Provide the norm of the beta 3-vector.
143// The error on the value can be obtained via GetResultError().
144 Double_t norm=fBeta.GetNorm();
145 fDresult=fBeta.GetResultError();
146 return norm;
d88f97cc 147}
148///////////////////////////////////////////////////////////////////////////
149Double_t AliBoost::GetGamma()
150{
959fbac5 151// Provide the gamma factor.
152// The error on the value can be obtained via GetResultError().
153 fDresult=fDgamma;
d88f97cc 154 return fGamma;
155}
156///////////////////////////////////////////////////////////////////////////
959fbac5 157Double_t AliBoost::GetResultError()
158{
159// Provide the error on the result of an operation yielding a scalar.
160// E.g. GetBeta() or GetGamma()
161 return fDresult;
162}
163///////////////////////////////////////////////////////////////////////////
d88f97cc 164void AliBoost::Info(TString f)
165{
959fbac5 166// Printing of the boost parameter info in coordinate frame f.
167 Double_t beta=fBeta.GetNorm();
168 Double_t dbeta=fBeta.GetResultError();
169 cout << " *AliBoost::Info* beta : " << beta << " error : " << dbeta
170 << " gamma : " << fGamma << " error : " << fDgamma << endl;
171 cout << " Beta";
d88f97cc 172 fBeta.Info(f);
173}
174///////////////////////////////////////////////////////////////////////////
175Ali4Vector AliBoost::Boost(Ali4Vector& v)
176{
959fbac5 177// Perform the Lorentz boost on the 4-vector v.
178// Error propagation is performed automatically.
179// Note : As an approximation Beta and p.Dot(Beta) are considered as
180// independent quantities.
181
182 Double_t beta=fBeta.GetNorm();
183 Double_t dbeta=fBeta.GetResultError();
184
185 Double_t beta2=pow(beta,2);
186
187 if (beta > 1.e-10)
d88f97cc 188 {
189 Double_t E=v.GetScalar();
959fbac5 190 Double_t dE=v.GetResultError();
191
d88f97cc 192 Ali3Vector p=v.Get3Vector();
959fbac5 193
d88f97cc 194 Double_t pdotbeta=p.Dot(fBeta);
959fbac5 195 Double_t dpdotbeta=p.GetResultError();
196
197 // Determine the new vector components
198 Double_t Eprim=fGamma*(E-pdotbeta);
199
200 Double_t z=((fGamma-1.)*pdotbeta/beta2)-fGamma*E;
201 Ali3Vector add=fBeta*z;
202
203 // Determine errors on the new vector components
204 Double_t dEprim=sqrt(pow((E-pdotbeta)*fDgamma,2)+pow(fGamma*dE,2)
205 +pow(fGamma*dpdotbeta,2));
206 Double_t dz=sqrt( pow(((fGamma-1.)/beta2)*dpdotbeta,2) + pow(fGamma*dE,2)
207 +pow((
208 ((2./beta)-(4.*pow(beta,3)-6.*pow(beta,5))/(2.*pow((pow(beta,4)-pow(beta,6)),1.5)))*pdotbeta
209 +beta*E/pow(fGamma,3))*dbeta,2) );
d88f97cc 210
959fbac5 211 Double_t vb[3],eb[3];
212 fBeta.GetVector(vb,"car");
213 fBeta.GetErrors(eb,"car");
214 for (Int_t i=0; i<3; i++)
215 {
216 eb[i]=sqrt(pow(z*eb[i],2)+pow(vb[i]*dz,2));
217 }
218 add.SetErrors(eb,"car");
d88f97cc 219
959fbac5 220 // Calculate the new 3-vector
221 Ali3Vector pprim=p+add;
d88f97cc 222
959fbac5 223 // Set the components and errors of the new 4-vector
d88f97cc 224 Ali4Vector w;
225 w.SetVector(Eprim,pprim);
959fbac5 226 w.SetScalarError(dEprim);
d88f97cc 227
228 return w;
229 }
230 else
231 {
232 return v;
233 }
234}
235///////////////////////////////////////////////////////////////////////////
236Ali4Vector AliBoost::Inverse(Ali4Vector& vprim)
237{
959fbac5 238// Perform the inverse Lorentz boost on the 4-vector vprim.
239// Error propagation is performed automatically.
240// Note : As an approximation Beta and pprim.Dot(Beta) are considered as
241// independent quantities.
242
243 Double_t beta=fBeta.GetNorm();
244 Double_t dbeta=fBeta.GetResultError();
245
246 Double_t beta2=pow(beta,2);
247
248 if (beta > 1.e-10)
d88f97cc 249 {
250 Double_t Eprim=vprim.GetScalar();
959fbac5 251 Double_t dEprim=vprim.GetResultError();
252
d88f97cc 253 Ali3Vector pprim=vprim.Get3Vector();
959fbac5 254
d88f97cc 255 Double_t pprimdotbeta=pprim.Dot(fBeta);
959fbac5 256 Double_t dpprimdotbeta=pprim.GetResultError();
257
258 // Determine the new vector components
259 Double_t E=fGamma*(Eprim+pprimdotbeta);
260
261 Double_t z=((fGamma-1.)*pprimdotbeta/beta2)+fGamma*Eprim;
262 Ali3Vector add=fBeta*z;
263
264 // Determine errors on the prime-vector components
265 Double_t dE=sqrt(pow((Eprim+pprimdotbeta)*fDgamma,2)+pow(fGamma*dEprim,2)
266 +pow(fGamma*dpprimdotbeta,2));
267 Double_t dz=sqrt( pow(((fGamma-1.)/beta2)*dpprimdotbeta,2) + pow(fGamma*dEprim,2)
268 +pow((
269 ((2./beta)-(4.*pow(beta,3)-6.*pow(beta,5))/(2.*pow((pow(beta,4)-pow(beta,6)),1.5)))*pprimdotbeta
270 -beta*Eprim/pow(fGamma,3))*dbeta,2) );
d88f97cc 271
959fbac5 272 Double_t vb[3],eb[3];
273 fBeta.GetVector(vb,"car");
274 fBeta.GetErrors(eb,"car");
275 for (Int_t i=0; i<3; i++)
276 {
277 eb[i]=sqrt(pow(z*eb[i],2)+pow(vb[i]*dz,2));
278 }
279 add.SetErrors(eb,"car");
d88f97cc 280
959fbac5 281 // Calculate the new 3-vector
282 Ali3Vector p=pprim+add;
d88f97cc 283
959fbac5 284 // Set the components and errors of the new 4-vector
d88f97cc 285 Ali4Vector w;
286 w.SetVector(E,p);
959fbac5 287 w.SetScalarError(dE);
d88f97cc 288
289 return w;
290 }
291 else
292 {
293 return vprim;
294 }
295}
296///////////////////////////////////////////////////////////////////////////