]> git.uio.no Git - u/mrichter/AliRoot.git/blob - CORRFW/AliCFPair.cxx
added low and high flux parameters to the array
[u/mrichter/AliRoot.git] / CORRFW / AliCFPair.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 ////////////////////////////////////////////////
18 // Class to handle pairs of tracks
19 // Useful for resonance analysis
20 // Derives from AliVParticle => 
21 // usable in Correction Framework
22 ////////////////////////////////////////////////
23 // author : renaud.vernet@cern.ch
24 ////////////////////////////////////////////////
25
26 #include "AliCFPair.h"
27 #include "AliESDtrack.h"
28 #include "AliESDv0.h"
29 #include "AliESDEvent.h"
30 #include "TMath.h"
31 #include "AliAODv0.h"
32
33 ClassImp(AliCFPair)
34
35 AliCFPair::AliCFPair(AliVParticle* t1, AliVParticle* t2) :
36   AliVParticle(),
37   fIsV0(0),
38   fTrackNeg(t1),
39   fTrackPos(t2),
40   fESDV0(0x0),
41   fAODV0(0x0),
42   fLabel(-1),
43   fV0PDG(0)
44 {
45   //  
46   // 2-track ctor
47   //
48 }
49 AliCFPair::AliCFPair(AliESDv0* v0, AliESDEvent* esd) :
50   AliVParticle(),
51   fIsV0(1),
52   fTrackNeg(esd->GetTrack(v0->GetNindex())),
53   fTrackPos(esd->GetTrack(v0->GetPindex())),
54   fESDV0(v0),
55   fAODV0(0x0),
56   fLabel(-1),
57   fV0PDG(0)
58 {
59   //  
60   // V0 ctor
61   //
62 }
63 AliCFPair::AliCFPair(AliAODv0* v0) :
64   AliVParticle(),
65   fIsV0(1),
66   fTrackNeg((AliVParticle*)v0->GetSecondaryVtx()->GetDaughter(1)),
67   fTrackPos((AliVParticle*)v0->GetSecondaryVtx()->GetDaughter(0)),
68   fESDV0(0x0),
69   fAODV0(v0),
70   fLabel(-1),
71   fV0PDG(0)
72 {
73   //  
74   // V0 ctor
75   //
76 }
77 AliCFPair::AliCFPair(const AliCFPair& c) :
78   AliVParticle(c),
79   fIsV0(c.fIsV0),
80   fTrackNeg(c.fTrackNeg),
81   fTrackPos(c.fTrackPos),
82   fESDV0(c.fESDV0),
83   fAODV0(c.fAODV0),
84   fLabel(c.fLabel),
85   fV0PDG(c.fV0PDG)
86 {
87   // 
88   // Copy constructor.
89   // 
90 }
91 AliCFPair& AliCFPair::operator=(const AliCFPair& c) {
92   // 
93   // assignment operator.
94   // 
95   
96   if (this!=&c) {
97     AliVParticle::operator=(c);
98     fIsV0 = c.fIsV0;
99     fTrackNeg = c.fTrackNeg ;
100     fTrackPos = c.fTrackPos ;
101     fESDV0 = c.fESDV0 ;
102     fAODV0 = c.fAODV0 ;
103     fLabel = c.fLabel ;
104     fV0PDG = c.fV0PDG ;
105   }
106   return *this;
107 }
108 Bool_t AliCFPair::PxPyPz(Double_t p[3]) const {
109   //
110   // sets pair total momentum in vector p
111   //
112   if (fIsV0) {
113     if      (fESDV0) fESDV0->GetPxPyPz(p[0],p[1],p[2]);
114     else if (fAODV0) fAODV0->PxPyPz(p);
115     else Error("PxPyPz","Pointer to V0 not found");
116   }
117   else if (fTrackNeg && fTrackPos) {
118     p[0]=fTrackNeg->Px()+fTrackPos->Px();
119     p[1]=fTrackNeg->Py()+fTrackPos->Py();
120     p[2]=fTrackNeg->Pz()+fTrackPos->Pz();
121   }
122   else Error("PxPyPz","Could not find V0 nor track pointers");
123   return kTRUE;
124 }
125
126 Double32_t AliCFPair::P() const {
127   //
128   // returns pair total momentum norm
129   //
130   Double32_t mom[3];
131   PxPyPz(mom);
132   return TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]+mom[2]*mom[2]);
133 }
134
135 Double32_t AliCFPair::Px() const {
136   //
137   // returns pair X-projected momentum
138   //
139   Double32_t mom[3];
140   PxPyPz(mom);
141   return mom[0];
142 }
143 Double32_t AliCFPair::Py() const {
144   //
145   // returns pair Y-projected momentum
146   //
147   Double32_t mom[3];
148   PxPyPz(mom);
149   return mom[1];
150 }
151 Double32_t AliCFPair::Pz() const {
152   //
153   // returns pair Z-projected momentum
154   //
155   Double32_t mom[3];
156   PxPyPz(mom);
157   return mom[2];
158 }
159 Double32_t AliCFPair::Pt() const {
160   //
161   // returns pair transverse (XY) momentum
162   //
163   Double32_t mom[3];
164   PxPyPz(mom);
165   return sqrt(mom[0]*mom[0]+mom[1]*mom[1]);
166 }
167 Double32_t AliCFPair::E() const {
168   //
169   // returns pair total energy according to ESD-calculated mass
170   //
171   Double32_t mom[3];
172   PxPyPz(mom);
173   Double32_t mass=M() ;
174   return TMath::Sqrt(mass*mass + mom[0]*mom[0]+ mom[1]*mom[1]+ mom[2]*mom[2]);
175 }
176 Bool_t AliCFPair::XvYvZv(Double_t x[3]) const {
177   //
178   // sets pair position to x
179   // since this class is designed for resonances, the assumed pair position
180   // should be the same for both tracks. neg track position is kept here
181   //
182   
183   if (fIsV0) {
184     if      (fESDV0) fESDV0->GetXYZ(x[0],x[1],x[2]);
185     else if (fAODV0) fAODV0->XvYvZv(x);
186     else Error("PxPyPz","Pointer to V0 not found");
187   }
188   else if (fTrackNeg) fTrackNeg->PxPyPz(x);
189   else Error("PxPyPz","Could not find V0 nor track pointers");
190
191   return kTRUE;
192 }
193 Double32_t AliCFPair::Xv() const {
194   //
195   // returns pair X-projected position
196   //
197   Double32_t pos[3];
198   XvYvZv(pos);
199   return pos[0];
200 }
201 Double32_t AliCFPair::Yv() const {
202   //
203   // returns pair Y-projected position
204   //
205   Double32_t pos[3];
206   XvYvZv(pos);
207   return pos[1];
208 }
209 Double32_t AliCFPair::Zv() const {
210   //
211   // returns pair Z-projected position
212   //
213   Double32_t pos[3];
214   XvYvZv(pos);
215   return pos[2];
216 }
217 Double32_t AliCFPair::Phi() const {
218   //
219   // returns pair phi angle (in transverse plane)
220   //
221   return TMath::Pi()+TMath::ATan2(-Py(),-Px()); 
222 }
223 Double32_t AliCFPair::Theta() const { 
224   //
225   // returns pair theta angle (in YZ plane)
226   //
227   return (Pz()==0)?TMath::PiOver2():TMath::ACos(Pz()/P());
228 }
229 Double32_t AliCFPair::Eta() const {
230   //
231   // returns pair pseudo-rapidity
232   //
233   Double32_t pmom = P();
234   Double32_t pz = Pz();
235   if (pmom != TMath::Abs(pz)) return 0.5*TMath::Log((pmom+pz)/(pmom-pz));
236   else                        return 999;
237 }
238 Double32_t AliCFPair::Y() const {
239   //
240   // returns pair rapidity
241   //
242   Double32_t e  = E();
243   Double32_t pz = Pz();
244
245   if (e == pz || e == -pz) {
246     printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
247     return 999;
248   }
249   if (e < pz) {
250     printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
251     return 999;
252   }
253   Double32_t y = 0.5 * log((e + pz) / (e - pz));
254   return y;
255
256 Double32_t AliCFPair::M() const {
257   //
258   // returns pair invariant mass
259   // in case of a V0, returns the current mass hypothesis
260   // otherwise returns ESD-calculated mass
261   //
262
263   Double32_t minv = 0. ;
264
265   if (fIsV0) {
266     if      (fESDV0) {
267       fESDV0->ChangeMassHypothesis(fV0PDG);
268       minv = (Double32_t)fESDV0->GetEffMass();
269     }
270     else if (fAODV0) {
271       switch (fV0PDG) {
272       case 310  : minv = fAODV0->MassK0Short()    ; break ;
273       case 3122 : minv = fAODV0->MassLambda()     ; break ;
274       case -3122: minv = fAODV0->MassAntiLambda() ; break ;
275       default:    minv = -1.              ; break ;
276       }
277     }
278     else Error("PxPyPz","Pointer to V0 not found");
279   }
280   else if (fTrackNeg && fTrackPos) {
281     Double32_t p  = P() ;
282     Double32_t e = fTrackNeg->E() + fTrackPos->E() ;
283     minv = TMath::Sqrt(e*e-p*p);
284   }
285   else Error("M","Could not find V0 nor track pointers");
286   
287   return minv ;
288 }