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