1 /**************************************************************************
2 * Copyright(c) 1998-2006, 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 **************************************************************************/
16 /////////////////////////////////////////////////////////////
18 // Base class for AOD reconstructed decay
20 // Author: A.Dainese, andrea.dainese@lnl.infn.it
21 /////////////////////////////////////////////////////////////
23 #include <TDatabasePDG.h>
25 #include "AliVParticle.h"
26 #include "AliAODRecoDecay.h"
28 ClassImp(AliAODRecoDecay)
30 //--------------------------------------------------------------------------
31 AliAODRecoDecay::AliAODRecoDecay() :
35 fNProngs(0), fNDCA(0), fNPID(0),
36 fPx(0x0), fPy(0x0), fPz(0x0),
40 fEventNumber(-1),fRunNumber(-1)
43 // Default Constructor
45 fSecondaryVtx = new AliAODVertex();
47 //--------------------------------------------------------------------------
48 AliAODRecoDecay::AliAODRecoDecay(AliAODVertex *vtx2,Int_t nprongs,
50 Double_t *px,Double_t *py,Double_t *pz,
55 fNProngs(nprongs), fNDCA(0), fNPID(0),
56 fPx(0x0), fPy(0x0), fPz(0x0),
60 fEventNumber(-1),fRunNumber(-1)
63 // Constructor with AliAODVertex for decay vertex
66 fPx = new Double_t[GetNProngs()];
67 fPy = new Double_t[GetNProngs()];
68 fPz = new Double_t[GetNProngs()];
69 fd0 = new Double_t[GetNProngs()];
70 for(Int_t i=0; i<GetNProngs(); i++) {
77 //--------------------------------------------------------------------------
78 AliAODRecoDecay::AliAODRecoDecay(AliAODVertex *vtx2,Int_t nprongs,
84 fNProngs(nprongs), fNDCA(0), fNPID(0),
85 fPx(0x0), fPy(0x0), fPz(0x0),
89 fEventNumber(-1),fRunNumber(-1)
92 // Constructor with AliAODVertex for decay vertex and without prongs momenta
95 fd0 = new Double_t[GetNProngs()];
96 for(Int_t i=0; i<GetNProngs(); i++) fd0[i] = d0[i];
98 //--------------------------------------------------------------------------
99 AliAODRecoDecay::AliAODRecoDecay(const AliAODRecoDecay &source) :
100 AliVParticle(source),
101 fSecondaryVtx(source.fSecondaryVtx),
102 fCharge(source.fCharge),
103 fNProngs(source.fNProngs), fNDCA(source.fNDCA), fNPID(source.fNPID),
104 fPx(0x0), fPy(0x0), fPz(0x0),
108 fEventNumber(source.fEventNumber),fRunNumber(source.fRunNumber)
113 if(source.GetNProngs()>0) {
114 fd0 = new Double_t[GetNProngs()];
115 memcpy(fd0,source.fd0,GetNProngs()*sizeof(Double_t));
117 fPx = new Double_t[GetNProngs()];
118 fPy = new Double_t[GetNProngs()];
119 fPz = new Double_t[GetNProngs()];
120 memcpy(fPx,source.fPx,GetNProngs()*sizeof(Double_t));
121 memcpy(fPy,source.fPy,GetNProngs()*sizeof(Double_t));
122 memcpy(fPz,source.fPz,GetNProngs()*sizeof(Double_t));
125 fPID = new Double_t[5*GetNProngs()];
126 memcpy(fPID,source.fPID,GetNProngs()*sizeof(Double_t));
129 fDCA = new Float_t[GetNProngs()*(GetNProngs()-1)/2];
130 memcpy(fDCA,source.fDCA,(GetNProngs()*(GetNProngs()-1)/2)*sizeof(Float_t));
134 //--------------------------------------------------------------------------
135 AliAODRecoDecay &AliAODRecoDecay::operator=(const AliAODRecoDecay &source)
138 // assignment operator
140 if(&source == this) return *this;
141 fSecondaryVtx = source.fSecondaryVtx;
142 fCharge = source.fCharge;
143 fNProngs = source.fNProngs;
144 fNDCA = source.fNDCA;
145 fNPID = source.fNPID;
146 fEventNumber = source.fEventNumber;
147 fRunNumber = source.fRunNumber;
148 if(source.GetNProngs()>0) {
149 fd0 = new Double_t[GetNProngs()];
150 memcpy(fd0,source.fd0,GetNProngs()*sizeof(Double_t));
152 fPx = new Double_t[GetNProngs()];
153 fPy = new Double_t[GetNProngs()];
154 fPz = new Double_t[GetNProngs()];
155 memcpy(fPx,source.fPx,GetNProngs()*sizeof(Double_t));
156 memcpy(fPy,source.fPy,GetNProngs()*sizeof(Double_t));
157 memcpy(fPz,source.fPz,GetNProngs()*sizeof(Double_t));
160 fPID = new Double_t[5*GetNProngs()];
161 memcpy(fPID,source.fPID,GetNProngs()*sizeof(Double_t));
164 fDCA = new Float_t[GetNProngs()*(GetNProngs()-1)/2];
165 memcpy(fDCA,source.fDCA,(GetNProngs()*(GetNProngs()-1)/2)*sizeof(Float_t));
170 //--------------------------------------------------------------------------
171 AliAODRecoDecay::~AliAODRecoDecay() {
173 // Default Destructor
175 if(fSecondaryVtx) delete fSecondaryVtx;
176 if(fPx) delete [] fPx;
177 if(fPy) delete [] fPy;
178 if(fPz) delete [] fPz;
179 if(fd0) delete [] fd0;
180 if(fPID) delete [] fPID;
181 if(fDCA) delete [] fDCA;
183 //----------------------------------------------------------------------------
184 Double_t AliAODRecoDecay::Alpha() const
187 // Armenteros-Podolanski alpha for 2-prong decays
189 if(GetNProngs()!=2) {
190 printf("Can be called only for 2-prong decays");
191 return (Double_t)-99999.;
193 return 1.-2./(1.+QlProng(0)/QlProng(1));
195 //----------------------------------------------------------------------------
196 Double_t AliAODRecoDecay::DecayLength(Double_t point[3]) const
199 // Decay length assuming it is produced at "point" [cm]
201 return TMath::Sqrt((point[0]-GetSecVtxX())
202 *(point[0]-GetSecVtxX())
203 +(point[1]-GetSecVtxY())
204 *(point[1]-GetSecVtxY())
205 +(point[2]-GetSecVtxZ())
206 *(point[2]-GetSecVtxZ()));
208 //----------------------------------------------------------------------------
209 Double_t AliAODRecoDecay::DecayLengthXY(Double_t point[3]) const
212 // Decay length in XY assuming it is produced at "point" [cm]
214 return TMath::Sqrt((point[0]-GetSecVtxX())
215 *(point[0]-GetSecVtxX())
216 +(point[1]-GetSecVtxY())
217 *(point[1]-GetSecVtxY()));
219 //----------------------------------------------------------------------------
220 Double_t AliAODRecoDecay::CosPointingAngle(Double_t point[3]) const
223 // Cosine of pointing angle in space assuming it is produced at "point"
225 TVector3 mom(Px(),Py(),Pz());
226 TVector3 fline(GetSecVtxX()-point[0],
227 GetSecVtxY()-point[1],
228 GetSecVtxZ()-point[2]);
230 Double_t pta = mom.Angle(fline);
232 return TMath::Cos(pta);
234 //----------------------------------------------------------------------------
235 Double_t AliAODRecoDecay::CosPointingAngleXY(Double_t point[3]) const
238 // Cosine of pointing angle in transverse plane assuming it is produced
241 TVector3 momXY(Px(),Py(),0.);
242 TVector3 flineXY(GetSecVtxX()-point[0],
243 GetSecVtxY()-point[1],
246 Double_t ptaXY = momXY.Angle(flineXY);
248 return TMath::Cos(ptaXY);
250 //----------------------------------------------------------------------------
251 Double_t AliAODRecoDecay::CosThetaStar(Int_t ip,UInt_t pdgvtx,UInt_t pdgprong0,UInt_t pdgprong1) const
254 // Only for 2-prong decays:
255 // Cosine of decay angle (theta*) in the rest frame of the mother particle
256 // for prong ip (0 or 1) with mass hypotheses pdgvtx for mother particle,
257 // pdgprong0 for prong 0 and pdgprong1 for prong1
259 if(GetNProngs()!=2) {
260 printf("Can be called only for 2-prong decays");
261 return (Double_t)-99999.;
263 Double_t massvtx = TDatabasePDG::Instance()->GetParticle(pdgvtx)->Mass();
265 massp[0] = TDatabasePDG::Instance()->GetParticle(pdgprong0)->Mass();
266 massp[1] = TDatabasePDG::Instance()->GetParticle(pdgprong1)->Mass();
268 Double_t pStar = TMath::Sqrt(TMath::Power(massvtx*massvtx-massp[0]*massp[0]-massp[1]*massp[1],2.)-4.*massp[0]*massp[0]*massp[1]*massp[1])/(2.*massvtx);
270 Double_t beta = P()/E(pdgvtx);
271 Double_t gamma = E(pdgvtx)/massvtx;
273 Double_t cts = (QlProng(ip)/gamma-beta*TMath::Sqrt(pStar*pStar+massp[ip]*massp[ip]))/pStar;
277 //---------------------------------------------------------------------------
278 Double_t AliAODRecoDecay::Ct(UInt_t pdg,Double_t point[3]) const
281 // Decay time * c assuming it is produced at "point" [cm]
283 Double_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
284 return DecayLength(point)*mass/P();
286 //---------------------------------------------------------------------------
287 Double_t AliAODRecoDecay::E(UInt_t pdg) const
292 Double_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
293 return TMath::Sqrt(mass*mass+P()*P());
295 //---------------------------------------------------------------------------
296 Double_t AliAODRecoDecay::EProng(Int_t ip,UInt_t pdg) const
299 // Energy of ip-th prong
301 Double_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
302 return TMath::Sqrt(mass*mass+PProng(ip)*PProng(ip));
304 //---------------------------------------------------------------------------
305 /*Int_t AliAODRecoDecay::GetIndexProng(Int_t ip) const
310 if(!GetNProngs()) return 999999;
311 UShort_t *indices = fSecondaryVtx->GetIndices();
314 //----------------------------------------------------------------------------
315 Double_t AliAODRecoDecay::ImpParXY(Double_t point[3]) const
318 // Impact parameter in the bending plane of the particle
321 Double_t k = -(GetSecVtxX()-point[0])*Px()-(GetSecVtxY()-point[1])*Py();
323 Double_t dx = GetSecVtxX()-point[0]+k*Px();
324 Double_t dy = GetSecVtxY()-point[1]+k*Py();
325 Double_t absImpPar = TMath::Sqrt(dx*dx+dy*dy);
326 TVector3 mom(Px(),Py(),Pz());
327 TVector3 fline(GetSecVtxX()-point[0],
328 GetSecVtxY()-point[1],
329 GetSecVtxZ()-point[2]);
330 TVector3 cross = mom.Cross(fline);
331 return (cross.Z()>0. ? absImpPar : -absImpPar);
333 //----------------------------------------------------------------------------
334 Double_t AliAODRecoDecay::InvMass(Int_t npdg,UInt_t *pdg) const
337 // Invariant mass for prongs mass hypotheses in pdg array
339 if(GetNProngs()!=npdg) {
340 printf("npdg != GetNProngs()");
341 return (Double_t)-99999.;
343 Double_t energysum = 0.;
345 for(Int_t i=0; i<GetNProngs(); i++) {
346 energysum += EProng(i,pdg[i]);
349 Double_t mass = TMath::Sqrt(energysum*energysum-P()*P());
353 //----------------------------------------------------------------------------
354 Double_t AliAODRecoDecay::InvMass2Prongs(Int_t ip1,Int_t ip2,
355 UInt_t pdg1,UInt_t pdg2) const
358 // 2-prong(ip1,ip2) invariant mass for prongs mass hypotheses in pdg1,2
360 Double_t energysum = EProng(ip1,pdg1) + EProng(ip2,pdg2);
361 Double_t psum2 = (PxProng(ip1)+PxProng(ip2))*(PxProng(ip1)+PxProng(ip2))
362 +(PyProng(ip1)+PyProng(ip2))*(PyProng(ip1)+PyProng(ip2))
363 +(PzProng(ip1)+PzProng(ip2))*(PzProng(ip1)+PzProng(ip2));
364 Double_t mass = TMath::Sqrt(energysum*energysum-psum2);
368 //---------------------------------------------------------------------------
369 void AliAODRecoDecay::Print(Option_t* /*option*/) const
372 // Print some information
374 printf("AliAODRecoDecay with %d prongs\n",GetNProngs());
375 printf("Secondary Vertex: (%f, %f, %f)\n",GetSecVtxX(),GetSecVtxY(),GetSecVtxZ());
379 //----------------------------------------------------------------------------
380 Double_t AliAODRecoDecay::ProngsRelAngle(Int_t ip1,Int_t ip2) const
383 // Relative angle between two prongs
385 TVector3 momA(PxProng(ip1),PyProng(ip1),PzProng(ip1));
386 TVector3 momB(PxProng(ip2),PyProng(ip2),PzProng(ip2));
388 Double_t angle = momA.Angle(momB);
392 //----------------------------------------------------------------------------
393 Double_t AliAODRecoDecay::QlProng(Int_t ip) const
396 // Longitudinal momentum of prong w.r.t. to total momentum
398 TVector3 mom(PxProng(ip),PyProng(ip),PzProng(ip));
399 TVector3 momTot(Px(),Py(),Pz());
401 return mom.Dot(momTot)/momTot.Mag();
403 //----------------------------------------------------------------------------
404 Double_t AliAODRecoDecay::QtProng(Int_t ip) const
407 // Transverse momentum of prong w.r.t. to total momentum
409 TVector3 mom(PxProng(ip),PyProng(ip),PzProng(ip));
410 TVector3 momTot(Px(),Py(),Pz());
412 return mom.Perp(momTot);
414 //----------------------------------------------------------------------------
415 Double_t AliAODRecoDecay::QlProngFlightLine(Int_t ip,Double_t point[3]) const
418 // Longitudinal momentum of prong w.r.t. to flight line between "point"
421 TVector3 mom(PxProng(ip),PyProng(ip),PzProng(ip));
422 TVector3 fline(GetSecVtxX()-point[0],
423 GetSecVtxY()-point[1],
424 GetSecVtxZ()-point[2]);
426 return mom.Dot(fline)/fline.Mag();
428 //----------------------------------------------------------------------------
429 Double_t AliAODRecoDecay::QtProngFlightLine(Int_t ip,Double_t point[3]) const
432 // Transverse momentum of prong w.r.t. to flight line between "point" and
435 TVector3 mom(PxProng(ip),PyProng(ip),PzProng(ip));
436 TVector3 fline(GetSecVtxX()-point[0],
437 GetSecVtxY()-point[1],
438 GetSecVtxZ()-point[2]);
440 return mom.Perp(fline);
442 //--------------------------------------------------------------------------