]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliAODRecoDecay.h
I added some methods that return squared distances in order to avoid sqrt calculation...
[u/mrichter/AliRoot.git] / STEER / AliAODRecoDecay.h
CommitLineData
7de7497b 1#ifndef ALIAODRECODECAY_H
2#define ALIAODRECODECAY_H
3/* Copyright(c) 1998-2006, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice */
5
6//***********************************************************
7// Class AliAODRecoDecay
8// base class for AOD reconstructed decays
9// Author: A.Dainese, andrea.dainese@lnl.infn.it
10//***********************************************************
11
12#include <TMath.h>
5cc73331 13#include <TRef.h>
bfd68286 14#include <TClonesArray.h>
7de7497b 15#include "AliAODVertex.h"
58b0186f 16#include "AliAODTrack.h"
e045ffda 17#include "AliVTrack.h"
7de7497b 18
6dc40b1c 19class AliVVertex;
20
e045ffda 21class AliAODRecoDecay : public AliVTrack {
7de7497b 22
23 public:
24
25 AliAODRecoDecay();
26 AliAODRecoDecay(AliAODVertex *vtx2,Int_t nprongs,Short_t charge,
27 Double_t *px,Double_t *py,Double_t *pz,
28 Double_t *d0);
29 AliAODRecoDecay(AliAODVertex *vtx2,Int_t nprongs,Short_t charge,
30 Double_t *d0);
31 virtual ~AliAODRecoDecay();
32
33 AliAODRecoDecay(const AliAODRecoDecay& source);
34 AliAODRecoDecay& operator=(const AliAODRecoDecay& source);
35
36
37 // decay vertex
5cc73331 38 Double_t GetSecVtxX() const {return GetSecondaryVtx()->GetX();}
39 Double_t GetSecVtxY() const {return GetSecondaryVtx()->GetY();}
40 Double_t GetSecVtxZ() const {return GetSecondaryVtx()->GetZ();}
7de7497b 41 Double_t RadiusSecVtx() const;
42 void SetSecondaryVtx(AliAODVertex *vtx2) {fSecondaryVtx=vtx2;}
a11de4a0 43 AliAODVertex* GetSecondaryVtx() const { return (((AliAODVertex*)fSecondaryVtx.GetObject()) ? (AliAODVertex*)fSecondaryVtx.GetObject() : GetOwnSecondaryVtx()); }
44 void SetOwnSecondaryVtx(AliAODVertex *vtx2) {fOwnSecondaryVtx=vtx2;}
45 AliAODVertex* GetOwnSecondaryVtx() const {return fOwnSecondaryVtx;}
7de7497b 46 void GetSecondaryVtx(Double_t vtx[3]) const;
5cc73331 47 Double_t GetReducedChi2() const {return GetSecondaryVtx()->GetChi2perNDF();}
7de7497b 48 Short_t Charge() const {return fCharge;}
49 Short_t GetCharge() const {return fCharge;}
50 void SetCharge(Short_t charge=0) {fCharge=charge;}
51
bfd68286 52 // Match to MC signal:
53 // check if this candidate is matched to a MC signal
54 // If no, return -1
55 // If yes, return label (>=0) of the AliAODMCParticle
9c4d0454 56 // if ndgCk>0, checks also daughters PDGs
57 Int_t MatchToMC(Int_t pdgabs,TClonesArray *mcArray,Int_t ndgCk=0,Int_t *pdgDg=0) const;
bfd68286 58
7de7497b 59 // PID
60 void SetPID(Int_t nprongs,Double_t *pid);
61 Double_t *GetPID() const { return fPID; }
62 void GetPIDProng(Int_t ip,Double_t *pid) const;
63 virtual const Double_t *PID() const { return fPID; }
64
65 // prong-to-prong DCAs
5cc73331 66 void SetDCAs(Int_t nDCA,Double_t *dca);
67 void SetDCA(Double_t dca); // 2 prong
68 Double_t GetDCA(Int_t i=0) const {return fDCA[i];}
7de7497b 69
70 //event and run number
71 void SetEventRunNumbers(Int_t en,Int_t rn)
72 { fEventNumber=en; fRunNumber=rn; return; }
73 Int_t GetEventNumber() const { return fEventNumber; }
74 Int_t GetRunNumber() const { return fRunNumber; }
75
e045ffda 76 // methods of AliVTrack
77 virtual Int_t GetID() const { return -1; }
78 virtual UChar_t GetITSClusterMap() const;
79 virtual ULong_t GetStatus() const;
80 virtual Bool_t GetXYZ(Double_t *p) const { return XvYvZv(p); }
81 virtual Bool_t GetCovarianceXYZPxPyPz(Double_t cv[21]) const;
6dc40b1c 82 virtual Bool_t PropagateToDCA(const AliVVertex* vtx,Double_t b,Double_t maxd,Double_t dz[2],Double_t covar[3]);
e045ffda 83
7de7497b 84 // kinematics & topology
85 Double_t Px() const;
86 Double_t Py() const;
87 Double_t Pz() const;
6766c805 88 Double_t P2() const {return Px()*Px()+Py()*Py()+Pz()*Pz();}
89 Double_t Pt2() const {return Px()*Px()+Py()*Py();}
90 Double_t P() const {return TMath::Sqrt(Pt2());}
91 Double_t Pt() const {return TMath::Sqrt(P2());}
7de7497b 92 Double_t OneOverPt() const {return (Pt() ? 1./Pt() : 0.);}
c683ddc2 93 Bool_t PxPyPz(Double_t p[3]) const { p[0] = Px(); p[1] = Py(); p[2] = Pz(); return kTRUE; }
1eab4b5c 94 Double_t Phi() const {return TMath::Pi()+TMath::ATan2(-Py(),-Px());}
7de7497b 95 Double_t Theta() const {return 0.5*TMath::Pi()-TMath::ATan(Pz()/(Pt()+1.e-13));}
96 Double_t Eta() const {return 0.5*TMath::Log((P()+Pz())/(P()-Pz()+1.e-13));}
c683ddc2 97 Double_t Xv() const { return GetSecVtxX(); }
98 Double_t Yv() const { return GetSecVtxY(); }
99 Double_t Zv() const { return GetSecVtxZ(); }
100 virtual Bool_t XvYvZv(Double_t x[3]) const { x[0] = Xv(); x[1] = Yv(); x[2] = Zv(); return kTRUE; }
7de7497b 101 Double_t E(UInt_t pdg) const;
102 Double_t Y(UInt_t pdg) const {return 0.5*TMath::Log((E(pdg)+Pz())/(E(pdg)-Pz()+1.e-13));}
6766c805 103 Double_t DecayLength2(Double_t point[3]) const;
104 Double_t DecayLength(Double_t point[3]) const {return TMath::Sqrt(DecayLength2(point));}
105 Double_t DecayLength2(AliAODVertex *vtx1) const
106 {return GetSecondaryVtx()->Distance2ToVertex(vtx1);}
7de7497b 107 Double_t DecayLength(AliAODVertex *vtx1) const
6766c805 108 {return TMath::Sqrt(DecayLength2(vtx1));}
109 Double_t DecayLengthError2(AliAODVertex *vtx1) const
110 {return GetSecondaryVtx()->Error2DistanceToVertex(vtx1);}
7de7497b 111 Double_t DecayLengthError(AliAODVertex *vtx1) const
6766c805 112 {return TMath::Sqrt(DecayLengthError2(vtx1));}
113 Double_t NormalizedDecayLength2(AliAODVertex *vtx1) const
114 {return DecayLength2(vtx1)/DecayLengthError2(vtx1);}
7de7497b 115 Double_t NormalizedDecayLength(AliAODVertex *vtx1) const
6766c805 116 {return TMath::Sqrt(NormalizedDecayLength2(vtx1));}
7de7497b 117 Double_t DecayLengthXY(Double_t point[3]) const;
118 Double_t DecayLengthXY(AliAODVertex *vtx1) const
5cc73331 119 {return GetSecondaryVtx()->DistanceXYToVertex(vtx1);}
7de7497b 120 Double_t DecayLengthXYError(AliAODVertex *vtx1) const
5cc73331 121 {return GetSecondaryVtx()->ErrorDistanceXYToVertex(vtx1);}
7de7497b 122 Double_t NormalizedDecayLengthXY(AliAODVertex *vtx1) const
123 {return DecayLengthXY(vtx1)/DecayLengthXYError(vtx1);}
124 Double_t Ct(UInt_t pdg,Double_t point[3]) const;
125 Double_t Ct(UInt_t pdg,AliAODVertex *vtx1) const;
126 Double_t CosPointingAngle(Double_t point[3]) const;
127 Double_t CosPointingAngle(AliAODVertex *vtx1) const;
128 Double_t CosPointingAngleXY(Double_t point[3]) const;
129 Double_t CosPointingAngleXY(AliAODVertex *vtx1) const;
130 Double_t CosThetaStar(Int_t ip,UInt_t pdgvtx,UInt_t pdgprong0,UInt_t pdgprong1) const;
131 Double_t InvMass(Int_t npdg,UInt_t *pdg) const;
132 Double_t ImpParXY(Double_t point[3]) const;
133 Double_t ImpParXY(AliAODVertex *vtx1) const;
134
135 // prongs
e045ffda 136 Int_t GetNProngs() const {return fNProngs;}
137 Int_t GetNDaughters() const {return GetSecondaryVtx()->GetNDaughters();}
138 TObject *GetDaughter(Int_t i) const {return (GetNDaughters()>i ? GetSecondaryVtx()->GetDaughter(i) : 0x0);}
7de7497b 139
e045ffda 140 Short_t ChargeProng(Int_t ip) const;
7de7497b 141 Double_t Getd0Prong(Int_t ip) const {return fd0[ip];}
142 Double_t Prodd0d0(Int_t ip1=0,Int_t ip2=0) const {return fd0[ip1]*fd0[ip2];}
88891753 143 void SetPxPyPzProngs(Int_t nprongs,Double_t *px,Double_t *py,Double_t *pz);
7de7497b 144 Double_t PxProng(Int_t ip) const {return fPx[ip];}
145 Double_t PyProng(Int_t ip) const {return fPy[ip];}
146 Double_t PzProng(Int_t ip) const {return fPz[ip];}
6766c805 147 Double_t PtProng(Int_t ip) const {return TMath::Sqrt(Pt2Prong(ip));}
148 Double_t Pt2Prong(Int_t ip) const;
7de7497b 149 Double_t PProng(Int_t ip) const;
150 Double_t PhiProng(Int_t ip) const
151 {return TMath::ATan2(PyProng(ip),PxProng(ip));}
152 Double_t ThetaProng(Int_t ip) const
153 {return 0.5*TMath::Pi()-TMath::ATan(PzProng(ip)/(PtProng(ip)+1.e-13));}
154 Double_t EtaProng(Int_t ip) const
155 {return -TMath::Log(TMath::Tan(0.5*ThetaProng(ip)));}
156 Double_t EProng(Int_t ip,UInt_t pdg) const;
157 Double_t YProng(Int_t ip,UInt_t pdg) const
158 {return 0.5*TMath::Log((EProng(ip,pdg)+PzProng(ip))/(EProng(ip,pdg)-PzProng(ip)+1.e-13));}
159 Double_t Alpha() const; // for Armenteros-Podolanski plot (V0's)
160 Double_t QlProng(Int_t ip) const;
161 Double_t QtProng(Int_t ip=0) const; // for Armenteros-Podolanski plot (V0's)
162 Double_t QlProngFlightLine(Int_t ip,Double_t point[3]) const;
163 Double_t QlProngFlightLine(Int_t ip,AliAODVertex *vtx1) const;
164 Double_t QtProngFlightLine(Int_t ip,Double_t point[3]) const;
165 Double_t QtProngFlightLine(Int_t ip,AliAODVertex *vtx1) const;
166 Double_t InvMass2Prongs(Int_t ip1,Int_t ip2,UInt_t pdg1,UInt_t pdg2) const;
167 Double_t ProngsRelAngle(Int_t ip1=0,Int_t ip2=1) const;
168
169 // relate to other objects
170 //Double_t DistanceToVertex(AliAODVertex *vtx) // distance to a AliAODVertex
171 //Double_t DistanceToTrack(AliAODTrack *trk) // distance to a AliAODTrack
172
173
174 // print
175 void Print(Option_t* option = "") const;
5cc73331 176 //void PrintIndices() const {GetSecondaryVtx()->PrintIndices();}
7de7497b 177
ff7c57dd 178 // dummy functions for inheritance from AliVParticle
7de7497b 179 Double_t E() const
180 {printf("Dummy function; use AliAODRecoDecay::E(UInt_t pdg) instead"); return (Double_t)-999.;}
181 Double_t Y() const
182 {printf("Dummy function; use AliAODRecoDecay::Y(UInt_t pdg) instead"); return (Double_t)-999.;}
183 Double_t M() const
184 {printf("Dummy function"); return (Double_t)-999.;}
3c43fb2b 185 Int_t GetLabel() const {return -1;}
6a8e543a 186 Int_t PdgCode() const {return 0;}
c8fe2783 187
7de7497b 188 protected:
189
9c4d0454 190 Int_t MatchToMC(Int_t pdgabs,TClonesArray *mcArray,Int_t dgLabels[10],Int_t ndg,Int_t ndgCk=0,Int_t *pdgDg=0) const;
8862e6bf 191 Int_t MatchToMC(Int_t pdgabs,TClonesArray *mcArray,Int_t dgLabels[10]) const { return MatchToMC(pdgabs,mcArray,dgLabels,GetNDaughters()); }
192
5cc73331 193 TRef fSecondaryVtx; // decay vertex
a11de4a0 194 AliAODVertex *fOwnSecondaryVtx; // temporary solution (to work outside AliAODEvent)
5cc73331 195 Short_t fCharge; // charge, use this convention for prongs charges:
196 // if(charge== 0) even-index prongs are +
197 // odd-index prongs are -
198 // if(charge==+1) even-index prongs are +
199 // odd-index prongs are -
200 // if(charge==-1) even-index prongs are -
201 // odd-index prongs are +
7de7497b 202
203 // TEMPORARY, to be removed when we do analysis on AliAODEvent
5cc73331 204 Int_t fNProngs; // number of prongs
205 Int_t fNDCA; // number of dca's
206 Int_t fNPID; // number of PID probabilities
207 Double32_t *fPx; //[fNProngs] px of tracks at the vertex [GeV/c]
208 Double32_t *fPy; //[fNProngs] py of tracks at the vertex [GeV/c]
209 Double32_t *fPz; //[fNProngs] pz of tracks at the vertex [GeV/c]
210 Double32_t *fd0; //[fNProngs] rphi impact params w.r.t. Primary Vtx [cm]
211 Double32_t *fDCA; //[fNDCA] prong-to-prong DCA [cm]
212 // convention:fDCA[0]=p0p1,fDCA[1]=p0p2,fDCA[2]=p1p2,...
213 Double32_t *fPID; //[fNPID] combined pid
214 // (combined detector response probabilities)
7de7497b 215
216 // TEMPORARY, to be removed when we do analysis on AliAODEvent
217 Int_t fEventNumber;
218 Int_t fRunNumber;
219 // TO BE PUT IN SPECIAL MC CLASS
220 //Bool_t fSignal; // TRUE if signal, FALSE if background (for simulation)
7de7497b 221 //Int_t fTrkNum[2]; // numbers of the two decay tracks
222 //Int_t fPdg[2]; // PDG codes of the two tracks (for sim.)
223 //Int_t fMum[2]; // PDG codes of the mothers (for sim.)
224
225 //
226
e045ffda 227 ClassDef(AliAODRecoDecay,4) // base class for AOD reconstructed decays
7de7497b 228};
229
230
231inline Short_t AliAODRecoDecay::ChargeProng(Int_t ip) const
232{
233 if(fCharge==0 || fCharge==+1) {
234 if(ip%2==0) {
235 return (Short_t)1;
236 } else {
237 return (Short_t)-1;
238 }
239 } else { // fCharge==-1
240 if(ip%2==0) {
241 return (Short_t)-1;
242 } else {
243 return (Short_t)1;
244 }
245 }
246}
247
248inline Double_t AliAODRecoDecay::RadiusSecVtx() const
249{
250 return TMath::Sqrt(GetSecVtxX()*GetSecVtxX()+GetSecVtxY()*GetSecVtxY());
251}
252
253inline void AliAODRecoDecay::GetSecondaryVtx(Double_t vtx[3]) const
254{
5cc73331 255 GetSecondaryVtx()->GetPosition(vtx);
7de7497b 256 return;
257}
258
259inline Double_t AliAODRecoDecay::Px() const
260{
261 Double_t px=0.;
262 for(Int_t i=0;i<GetNProngs();i++) px+=PxProng(i);
263 return px;
264}
265
266inline Double_t AliAODRecoDecay::Py() const
267{
268 Double_t py=0.;
269 for(Int_t i=0;i<GetNProngs();i++) py+=PyProng(i);
270 return py;
271}
272
273inline Double_t AliAODRecoDecay::Pz() const
274{
275 Double_t pz=0.;
276 for(Int_t i=0;i<GetNProngs();i++) pz+=PzProng(i);
277 return pz;
278}
279
280inline Double_t AliAODRecoDecay::Ct(UInt_t pdg,AliAODVertex *vtx1) const
281{
282 Double_t v[3];
283 vtx1->GetPosition(v);
284 return Ct(pdg,v);
285}
286
287inline Double_t AliAODRecoDecay::CosPointingAngle(AliAODVertex *vtx1) const
288{
289 Double_t v[3];
290 vtx1->GetPosition(v);
291 return CosPointingAngle(v);
292}
293
294inline Double_t AliAODRecoDecay::CosPointingAngleXY(AliAODVertex *vtx1) const
295{
296 Double_t v[3];
297 vtx1->GetPosition(v);
298 return CosPointingAngleXY(v);
299}
300
301inline Double_t AliAODRecoDecay::ImpParXY(AliAODVertex *vtx1) const
302{
303 Double_t v[3];
304 vtx1->GetPosition(v);
305 return ImpParXY(v);
306}
307
6766c805 308inline Double_t AliAODRecoDecay::Pt2Prong(Int_t ip) const
7de7497b 309{
6766c805 310 return PxProng(ip)*PxProng(ip)+PyProng(ip)*PyProng(ip);
7de7497b 311}
312
313inline Double_t AliAODRecoDecay::PProng(Int_t ip) const
314{
315 return TMath::Sqrt(PtProng(ip)*PtProng(ip)+PzProng(ip)*PzProng(ip));
316}
317
318inline Double_t AliAODRecoDecay::QlProngFlightLine(Int_t ip,AliAODVertex *vtx1) const
319{
320 Double_t v[3];
321 vtx1->GetPosition(v);
322 return QlProngFlightLine(ip,v);
323}
324
325inline Double_t AliAODRecoDecay::QtProngFlightLine(Int_t ip,AliAODVertex *vtx1) const
326{
327 Double_t v[3];
328 vtx1->GetPosition(v);
329 return QtProngFlightLine(ip,v);
330}
331
88891753 332inline void AliAODRecoDecay::SetPxPyPzProngs(Int_t nprongs,Double_t *px,Double_t *py,Double_t *pz)
333{
334 if(nprongs!=GetNProngs()) {
335 printf("Wrong number of momenta, must be nProngs");
336 return;
337 }
338 if(!fPx) {
339 fPx = new Double32_t[nprongs];
340 fPy = new Double32_t[nprongs];
341 fPz = new Double32_t[nprongs];
342 }
343 for(Int_t i=0;i<nprongs;i++) {
344 fPx[i] = px[i];
345 fPy[i] = py[i];
346 fPz[i] = pz[i];
347 }
348
349 return;
350}
351
5cc73331 352inline void AliAODRecoDecay::SetDCAs(Int_t nDCA,Double_t *dca)
7de7497b 353{
354 if(nDCA!=(GetNProngs()*(GetNProngs()-1)/2)) {
355 printf("Wrong number of DCAs, must be nProngs*(nProngs-1)/2");
356 return;
357 }
358 if(fDCA) delete [] fDCA;
94de4057 359 fNDCA = nDCA;
5cc73331 360 fDCA = new Double32_t[nDCA];
7de7497b 361 for(Int_t i=0;i<nDCA;i++)
362 fDCA[i] = dca[i];
363 return;
364}
365
5cc73331 366inline void AliAODRecoDecay::SetDCA(Double_t dca)
7de7497b 367{
5cc73331 368 Double_t ddca[1]; ddca[0]=dca;
7de7497b 369 SetDCAs(1,ddca);
370 return;
371}
372
373inline void AliAODRecoDecay::SetPID(Int_t nprongs,Double_t *pid)
374{
375 if(nprongs!=GetNProngs()) {
376 printf("Wrong number of prongs");
377 return;
378 }
379 if(fPID) delete [] fPID;
58b0186f 380 fNPID = nprongs*5;
5cc73331 381 fPID = new Double32_t[nprongs*5];
7de7497b 382 for(Int_t i=0;i<nprongs;i++)
383 for(Int_t j=0;j<5;j++)
384 fPID[i*5+j] = pid[i*5+j];
385 return;
386}
387
388inline void AliAODRecoDecay::GetPIDProng(Int_t ip,Double_t *pid) const
389{
390 for(Int_t j=0;j<5;j++)
391 pid[j] = fPID[ip*5+j];
392 return;
393}
394
395
396
397#endif
bfd68286 398