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) :
49 AliCFPair::AliCFPair(AliESDv0* v0, AliESDEvent* esd) :
52 fTrackNeg(esd->GetTrack(v0->GetNindex())),
53 fTrackPos(esd->GetTrack(v0->GetPindex())),
63 AliCFPair::AliCFPair(AliAODv0* v0) :
66 fTrackNeg((AliVParticle*)v0->GetSecondaryVtx()->GetDaughter(1)),
67 fTrackPos((AliVParticle*)v0->GetSecondaryVtx()->GetDaughter(0)),
77 AliCFPair::AliCFPair(const AliCFPair& c) :
80 fTrackNeg(c.fTrackNeg),
81 fTrackPos(c.fTrackPos),
91 AliCFPair& AliCFPair::operator=(const AliCFPair& c) {
93 // assignment operator.
97 AliVParticle::operator=(c);
99 fTrackNeg = c.fTrackNeg ;
100 fTrackPos = c.fTrackPos ;
108 Bool_t AliCFPair::PxPyPz(Double_t p[3]) const {
110 // sets pair total momentum in vector p
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");
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();
122 else Error("PxPyPz","Could not find V0 nor track pointers");
126 Double32_t AliCFPair::P() const {
128 // returns pair total momentum norm
132 return TMath::Sqrt(mom[0]*mom[0]+mom[1]*mom[1]+mom[2]*mom[2]);
135 Double32_t AliCFPair::Px() const {
137 // returns pair X-projected momentum
143 Double32_t AliCFPair::Py() const {
145 // returns pair Y-projected momentum
151 Double32_t AliCFPair::Pz() const {
153 // returns pair Z-projected momentum
159 Double32_t AliCFPair::Pt() const {
161 // returns pair transverse (XY) momentum
165 return sqrt(mom[0]*mom[0]+mom[1]*mom[1]);
167 Double32_t AliCFPair::E() const {
169 // returns pair total energy according to ESD-calculated mass
173 Double32_t mass=M() ;
174 return TMath::Sqrt(mass*mass + mom[0]*mom[0]+ mom[1]*mom[1]+ mom[2]*mom[2]);
176 Bool_t AliCFPair::XvYvZv(Double_t x[3]) const {
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
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");
188 else if (fTrackNeg) fTrackNeg->PxPyPz(x);
189 else Error("PxPyPz","Could not find V0 nor track pointers");
193 Double32_t AliCFPair::Xv() const {
195 // returns pair X-projected position
201 Double32_t AliCFPair::Yv() const {
203 // returns pair Y-projected position
209 Double32_t AliCFPair::Zv() const {
211 // returns pair Z-projected position
217 Double32_t AliCFPair::Phi() const {
219 // returns pair phi angle (in transverse plane)
221 return TMath::Pi()+TMath::ATan2(-Py(),-Px());
223 Double32_t AliCFPair::Theta() const {
225 // returns pair theta angle (in YZ plane)
227 return (Pz()==0)?TMath::PiOver2():TMath::ACos(Pz()/P());
229 Double32_t AliCFPair::Eta() const {
231 // returns pair pseudo-rapidity
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));
238 Double32_t AliCFPair::Y() const {
240 // returns pair rapidity
243 Double32_t pz = Pz();
245 if (e == pz || e == -pz) {
246 printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
250 printf("GetRapidity : ERROR : rapidity for 4-vector with E = Pz -- infinite result");
253 Double32_t y = 0.5 * log((e + pz) / (e - pz));
256 Double32_t AliCFPair::M() const {
258 // returns pair invariant mass
259 // in case of a V0, returns the current mass hypothesis
260 // otherwise returns ESD-calculated mass
263 Double32_t minv = 0. ;
267 fESDV0->ChangeMassHypothesis(fV0PDG);
268 minv = (Double32_t)fESDV0->GetEffMass();
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 ;
278 else Error("PxPyPz","Pointer to V0 not found");
280 else if (fTrackNeg && fTrackPos) {
282 Double32_t e = fTrackNeg->E() + fTrackPos->E() ;
283 minv = TMath::Sqrt(e*e-p*p);
285 else Error("M","Could not find V0 nor track pointers");