AliRoot Core  3dc7879 (3dc7879)
AliVParticle.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2007, 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 /* $Id$ */
17 
18 //-------------------------------------------------------------------------
19 // base class for ESD and AOD particles
20 // Author: Markus Oldenburg, CERN
21 //-------------------------------------------------------------------------
22 
23 #include "AliVParticle.h"
24 #include "TMath.h"
25 
26 ClassImp(AliVParticle)
27 
29  TObject(vPart) { } // Copy constructor
30 
32 { if (this!=&vPart) {
33  TObject::operator=(vPart);
34  }
35 
36  return *this;
37 }
38 
39 Bool_t AliVParticle::Local2GlobalMomentum(Double_t p[3], Double_t alpha) const {
40  //----------------------------------------------------------------
41  // This function performs local->global transformation of the
42  // track momentum.
43  // When called, the arguments are:
44  // p[0] = 1/pt * charge of the track;
45  // p[1] = sine of local azim. angle of the track momentum;
46  // p[2] = tangent of the track momentum dip angle;
47  // alpha - rotation angle.
48  // The result is returned as:
49  // p[0] = px
50  // p[1] = py
51  // p[2] = pz
52  // Results for (nearly) straight tracks are meaningless !
53  //----------------------------------------------------------------
54  if (TMath::Abs(p[0])<=kAlmost0) return kFALSE;
55  if (TMath::Abs(p[1])> kAlmost1) return kFALSE;
56 
57  Double_t pt=1./TMath::Abs(p[0]);
58  Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
59  Double_t r=TMath::Sqrt((1. - p[1])*(1. + p[1]));
60  p[0]=pt*(r*cs - p[1]*sn); p[1]=pt*(p[1]*cs + r*sn); p[2]=pt*p[2];
61 
62  return kTRUE;
63 }
64 
65 Bool_t AliVParticle::Local2GlobalPosition(Double_t r[3], Double_t alpha) const {
66  //----------------------------------------------------------------
67  // This function performs local->global transformation of the
68  // track position.
69  // When called, the arguments are:
70  // r[0] = local x
71  // r[1] = local y
72  // r[2] = local z
73  // alpha - rotation angle.
74  // The result is returned as:
75  // r[0] = global x
76  // r[1] = global y
77  // r[2] = global z
78  //----------------------------------------------------------------
79  Double_t cs=TMath::Cos(alpha), sn=TMath::Sin(alpha), x=r[0];
80  r[0]=x*cs - r[1]*sn; r[1]=x*sn + r[1]*cs;
81 
82  return kTRUE;
83 }
84 
85 Bool_t AliVParticle::Global2LocalMomentum(Double_t p[3], Short_t charge, Double_t &alpha) const {
86  //----------------------------------------------------------------
87  // This function performs global->local transformation of the
88  // track momentum.
89  // When called, the arguments are:
90  // p[0] = px
91  // p[1] = py
92  // p[2] = pz
93  // charge - of the track
94  // alpha - rotation angle.
95  // The result is returned as:
96  // p[0] = 1/pt * charge of the track;
97  // p[1] = sine of local azim. angle of the track momentum;
98  // p[2] = tangent of the track momentum dip angle;
99  // Results for (nearly) straight tracks are meaningless !
100  //----------------------------------------------------------------
101  double pt = TMath::Sqrt(p[0]*p[0]+p[1]*p[1]);
102  if (pt == 0.) return kFALSE;
103  alpha = TMath::Pi() + TMath::ATan2(-p[1], -p[0]);
104 
105  p[0] = 1./pt * (float)charge;
106  p[1] = 0.;
107  p[2] = p[2]/pt;
108 
109  return kTRUE;
110 }
111 
112 Bool_t AliVParticle::Global2LocalPosition(Double_t r[3], Double_t alpha) const {
113  return Local2GlobalPosition(r, -alpha);
114 }
115 
116 
117 Int_t AliVParticle::Compare( const TObject* obj) const {
118 
119  //
120  // see header file for class documentation
121  //
122 
123  if (this == obj)
124  return 0;
125  // check type
126  if ( Pt() < ((AliVParticle*)(obj))->Pt())
127  return 1;
128  else
129  return -1;
130 }
131 
Int_t Compare(const TObject *obj) const
AliVParticle & operator=(const AliVParticle &vPart)
Float_t p[]
Definition: kNNTest.C:133
Bool_t Local2GlobalMomentum(Double_t p[3], Double_t alpha) const
const Float_t kAlmost0
Bool_t Global2LocalPosition(Double_t r[3], Double_t alpha) const
Bool_t Global2LocalMomentum(Double_t p[3], Short_t charge, Double_t &alpha) const
virtual Double_t Pt() const =0
Bool_t Local2GlobalPosition(Double_t r[3], Double_t alpha) const
const Double_t kAlmost1
Definition: AliVParticle.h:22