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