1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
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 ////////////////////////////////////////////////
26 #include "AliCFPair.h"
27 #include "AliESDtrack.h"
29 #include "AliESDEvent.h"
35 AliCFPair::AliCFPair(AliVParticle* t1, AliVParticle* t2) :
51 AliCFPair::AliCFPair(AliESDv0* v0, AliESDEvent* esd) :
54 fTrackNeg(esd->GetTrack(v0->GetNindex())),
55 fTrackPos(esd->GetTrack(v0->GetPindex())),
67 AliCFPair::AliCFPair(AliAODv0* v0) :
70 fTrackNeg((AliVParticle*)v0->GetSecondaryVtx()->GetDaughter(1)),
71 fTrackPos((AliVParticle*)v0->GetSecondaryVtx()->GetDaughter(0)),
83 AliCFPair::AliCFPair(const AliCFPair& c) :
86 fTrackNeg(c.fTrackNeg),
87 fTrackPos(c.fTrackPos),
99 AliCFPair& AliCFPair::operator=(const AliCFPair& c) {
101 // assignment operator.
105 AliVParticle::operator=(c);
107 fTrackNeg = c.fTrackNeg ;
108 fTrackPos = c.fTrackPos ;
113 fMassNeg = c.fMassNeg ;
114 fMassPos = c.fMassPos;
118 Bool_t AliCFPair::PxPyPz(Double_t p[3]) const {
120 // sets pair total momentum in vector p
123 if (fESDV0) fESDV0->GetPxPyPz(p[0],p[1],p[2]);
124 else if (fAODV0) fAODV0->PxPyPz(p);
125 else Error("PxPyPz","Pointer to V0 not found");
127 else if (fTrackNeg && fTrackPos) {
128 p[0]=fTrackNeg->Px()+fTrackPos->Px();
129 p[1]=fTrackNeg->Py()+fTrackPos->Py();
130 p[2]=fTrackNeg->Pz()+fTrackPos->Pz();
132 else Error("PxPyPz","Could not find V0 nor track pointers");
136 Double32_t AliCFPair::P() const {
138 // returns pair total momentum norm
142 return TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]+mom[2]*mom[2]);
145 Double32_t AliCFPair::Px() const {
147 // returns pair X-projected momentum
153 Double32_t AliCFPair::Py() const {
155 // returns pair Y-projected momentum
161 Double32_t AliCFPair::Pz() const {
163 // returns pair Z-projected momentum
169 Double32_t AliCFPair::Pt() const {
171 // returns pair transverse (XY) momentum
175 return sqrt(mom[0]*mom[0]+mom[1]*mom[1]);
177 Double32_t AliCFPair::E() const {
179 // returns pair total energy according to ESD-calculated mass
183 Double32_t mass=M() ;
184 return TMath::Sqrt(mass*mass + mom[0]*mom[0]+ mom[1]*mom[1]+ mom[2]*mom[2]);
186 Bool_t AliCFPair::XvYvZv(Double_t x[3]) const {
188 // sets pair position to x
189 // since this class is designed for resonances, the assumed pair position
190 // should be the same for both tracks. neg track position is kept here
194 if (fESDV0) fESDV0->GetXYZ(x[0],x[1],x[2]);
195 else if (fAODV0) fAODV0->XvYvZv(x);
196 else Error("PxPyPz","Pointer to V0 not found");
198 else if (fTrackNeg) fTrackNeg->PxPyPz(x);
199 else Error("PxPyPz","Could not find V0 nor track pointers");
203 Double32_t AliCFPair::Xv() const {
205 // returns pair X-projected position
211 Double32_t AliCFPair::Yv() const {
213 // returns pair Y-projected position
219 Double32_t AliCFPair::Zv() const {
221 // returns pair Z-projected position
227 Double32_t AliCFPair::Phi() const {
229 // returns pair phi angle (in transverse plane)
231 return TMath::Pi()+TMath::ATan2(-Py(),-Px());
233 Double32_t AliCFPair::Theta() const {
235 // returns pair theta angle (in YZ plane)
237 return (Pz()==0)?TMath::PiOver2():TMath::ACos(Pz()/P());
239 Double32_t AliCFPair::Eta() const {
241 // returns pair pseudo-rapidity
243 Double32_t pmom = P();
244 Double32_t pz = Pz();
245 if (pmom != TMath::Abs(pz)) return 0.5*TMath::Log((pmom+pz)/(pmom-pz));
248 Double32_t AliCFPair::Y() const {
250 // returns pair rapidity
253 Double32_t pz = Pz();
255 if (e == pz || e == -pz) {
256 printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
260 printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
263 Double32_t y = 0.5 * log((e + pz) / (e - pz));
266 Double32_t AliCFPair::M() const {
268 // returns pair invariant mass
269 // in case of a V0, returns the current mass hypothesis
270 // otherwise returns ESD-calculated mass
273 Double32_t minv = 0. ;
277 fESDV0->ChangeMassHypothesis(fV0PDG);
278 minv = (Double32_t)fESDV0->GetEffMass();
282 case 310 : minv = fAODV0->MassK0Short() ; break ;
283 case 3122 : minv = fAODV0->MassLambda() ; break ;
284 case -3122: minv = fAODV0->MassAntiLambda() ; break ;
285 default: minv = -1. ; break ;
288 else Error("PxPyPz","Pointer to V0 not found");
290 else if (fTrackNeg && fTrackPos) {
293 if (fMassNeg==0. && fMassPos==0.) {
294 e = fTrackNeg->E() + fTrackPos->E() ;
298 TMath::Sqrt(TMath::Power(fTrackNeg->P(),2)+TMath::Power(fMassNeg,2)) +
299 TMath::Sqrt(TMath::Power(fTrackPos->P(),2)+TMath::Power(fMassPos,2)) ;
301 minv = TMath::Sqrt(e*e-p*p);
303 else Error("M","Could not find V0 nor track pointers");