]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RALICE/AliBoost.cxx
Add ResetDecayTable() and SsetDecayTable() methods.
[u/mrichter/AliRoot.git] / RALICE / AliBoost.cxx
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$
18 Revision 1.2  1999/09/29 09:24:28  fca
19 Introduction of the Copyright and cvs Log
20
21 */
22
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
67 #include "AliBoost.h"
68  
69 ClassImp(AliBoost) // Class implementation to enable ROOT I/O
70  
71 AliBoost::AliBoost()
72 {
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. 
76  Double_t a[3]={0,0,0};
77  fBeta.SetVector(a,"sph");
78  fGamma=1;
79  fDgamma=0;
80  fDresult=0;
81 }
82 ///////////////////////////////////////////////////////////////////////////
83 AliBoost::~AliBoost()
84 {
85 // Default destructor.
86 }
87 ///////////////////////////////////////////////////////////////////////////
88 void AliBoost::SetBeta(Ali3Vector b)
89 {
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.
93  fBeta=b;
94  Double_t beta2=fBeta.Dot(fBeta);
95  Double_t dbeta2=fBeta.GetResultError();
96
97  if (beta2 > 1.)
98  {
99   cout << " *AliBoost::SetBeta* beta > 1." << endl;
100  }
101  fGamma=0;
102  fDgamma=0;
103  Double_t temp=1.-beta2;
104  if (temp > 0.)
105  {
106   fGamma=sqrt(1./temp);
107   fDgamma=fabs(dbeta2/(2.*pow(temp,1.5)));
108  }
109 }
110 ///////////////////////////////////////////////////////////////////////////
111 void AliBoost::Set4Momentum(Ali4Vector& p)
112 {
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.
116  Double_t E=p.GetScalar();
117  Double_t dE=p.GetResultError();
118  if (E <= 0.)
119  {
120   cout << " *AliBoost::Set4Momentum* Unphysical situation." << endl;
121   p.Info();
122  }
123  else
124  {
125   Ali3Vector b=p.Get3Vector();
126   Double_t vb[3],eb[3];
127   b.GetVector(vb,"car");
128   b.GetErrors(eb,"car");
129   b=b/E;
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");
135   SetBeta(b);
136  }
137 }
138 ///////////////////////////////////////////////////////////////////////////
139 Ali3Vector AliBoost::GetBetaVector()
140 {
141 // Provide the beta 3-vector.
142  return fBeta;
143 }
144 ///////////////////////////////////////////////////////////////////////////
145 Double_t AliBoost::GetBeta()
146 {
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;
152 }
153 ///////////////////////////////////////////////////////////////////////////
154 Double_t AliBoost::GetGamma()
155 {
156 // Provide the gamma factor.
157 // The error on the value can be obtained via GetResultError().
158  fDresult=fDgamma;
159  return fGamma;
160 }
161 ///////////////////////////////////////////////////////////////////////////
162 Double_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 ///////////////////////////////////////////////////////////////////////////
169 void AliBoost::Info(TString f)
170 {
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"; 
177  fBeta.Info(f);
178 }
179 ///////////////////////////////////////////////////////////////////////////
180 Ali4Vector AliBoost::Boost(Ali4Vector& v)
181 {
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)
193  {
194   Double_t E=v.GetScalar();
195   Double_t dE=v.GetResultError();
196
197   Ali3Vector p=v.Get3Vector();
198
199   Double_t pdotbeta=p.Dot(fBeta);
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) );
215
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");
224
225   // Calculate the new 3-vector
226   Ali3Vector pprim=p+add;
227
228   // Set the components and errors of the new 4-vector 
229   Ali4Vector w;
230   w.SetVector(Eprim,pprim);
231   w.SetScalarError(dEprim);
232
233   return w;
234  }
235  else
236  {
237   return v;
238  }
239 }
240 ///////////////////////////////////////////////////////////////////////////
241 Ali4Vector AliBoost::Inverse(Ali4Vector& vprim)
242 {
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)
254  {
255   Double_t Eprim=vprim.GetScalar();
256   Double_t dEprim=vprim.GetResultError();
257
258   Ali3Vector pprim=vprim.Get3Vector();
259
260   Double_t pprimdotbeta=pprim.Dot(fBeta);
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) );
276
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");
285
286   // Calculate the new 3-vector
287   Ali3Vector p=pprim+add;
288
289   // Set the components and errors of the new 4-vector 
290   Ali4Vector w;
291   w.SetVector(E,p);
292   w.SetScalarError(dE);
293
294   return w;
295  }
296  else
297  {
298   return vprim;
299  }
300 }
301 ///////////////////////////////////////////////////////////////////////////