LCOV - code coverage report
Current view: top level - STEER/ESD - AliESDv0.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 190 421 45.1 %
Date: 2016-06-14 17:26:59 Functions: 19 46 41.3 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       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             :  **************************************************************************/
      15             : 
      16             : /* $Id$ */
      17             : 
      18             : //-------------------------------------------------------------------------
      19             : //               Implementation of the ESD V0 vertex class
      20             : //            This class is part of the Event Data Summary
      21             : //            set of classes and contains information about
      22             : //            V0 kind vertexes generated by a neutral particle
      23             : //     Origin: Iouri Belikov, IReS, Strasbourg, Jouri.Belikov@cern.ch
      24             : //     Modified by: Marian Ivanov,  CERN, Marian.Ivanov@cern.ch
      25             : //            and  Boris Hippolyte,IPHC, hippolyt@in2p3.fr 
      26             : //-------------------------------------------------------------------------
      27             : 
      28             : #include <TMath.h>
      29             : #include <TDatabasePDG.h>
      30             : #include <TParticlePDG.h>
      31             : #include <TVector3.h>
      32             : 
      33             : #include "AliLog.h"
      34             : #include "AliESDv0.h"
      35             : #include "AliESDV0Params.h"
      36             : #include "AliKFParticle.h"
      37             : #include "AliKFVertex.h"
      38             : #include "AliESDVertex.h"
      39             : 
      40         172 : ClassImp(AliESDv0)
      41             : 
      42         172 : const AliESDV0Params  AliESDv0::fgkParams;
      43             : 
      44             : AliESDv0::AliESDv0() :
      45          84 :   AliVParticle(),
      46          84 :   fParamN(),
      47          84 :   fParamP(),
      48         252 :   fEffMass(TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass()),
      49          84 :   fDcaV0Daughters(0),
      50          84 :   fChi2V0(0.),
      51          84 :   fRr(0),
      52          84 :   fDistSigma(0),
      53          84 :   fChi2Before(0),
      54          84 :   fChi2After(0),
      55          84 :   fPointAngleFi(0),
      56          84 :   fPointAngleTh(0),
      57          84 :   fPointAngle(0),
      58          84 :   fPdgCode(kK0Short),
      59          84 :   fNidx(0),
      60          84 :   fPidx(0),
      61          84 :   fStatus(0),
      62          84 :   fNBefore(0),
      63          84 :   fNAfter(0),
      64          84 :   fOnFlyStatus(kFALSE)
      65         336 : {
      66             :   //--------------------------------------------------------------------
      67             :   // Default constructor  (K0s)
      68             :   //--------------------------------------------------------------------
      69             : 
      70         672 :   for (Int_t i=0; i<3; i++) {
      71         252 :     fPos[i] = 0.;
      72         252 :     fNmom[i] = 0.;
      73         252 :     fPmom[i] = 0.;
      74             :   }
      75             : 
      76        1176 :   for (Int_t i=0; i<6; i++) {
      77         504 :     fPosCov[i]= 0.;
      78             :   }
      79             : 
      80        1176 :   for (Int_t i=0;i<6;i++){fClusters[0][i]=0; fClusters[1][i]=0;}
      81          84 :   fNormDCAPrim[0]=fNormDCAPrim[1]=0;
      82         672 :   for (Int_t i=0;i<3;i++){fAngle[i]=0;}
      83         840 :   for (Int_t i=0;i<4;i++){fCausality[i]=0;}
      84         126 : }
      85             : 
      86             : AliESDv0::AliESDv0(const AliESDv0& v0) :
      87          62 :   AliVParticle(v0),
      88          62 :   fParamN(v0.fParamN),
      89          62 :   fParamP(v0.fParamP),
      90          62 :   fEffMass(v0.fEffMass),
      91          62 :   fDcaV0Daughters(v0.fDcaV0Daughters),
      92          62 :   fChi2V0(v0.fChi2V0),
      93          62 :   fRr(v0.fRr),
      94          62 :   fDistSigma(v0.fDistSigma),
      95          62 :   fChi2Before(v0.fChi2Before),
      96          62 :   fChi2After(v0.fChi2After),
      97          62 :   fPointAngleFi(v0.fPointAngleFi),
      98          62 :   fPointAngleTh(v0.fPointAngleTh),
      99          62 :   fPointAngle(v0.fPointAngle),
     100          62 :   fPdgCode(v0.fPdgCode),
     101          62 :   fNidx(v0.fNidx),
     102          62 :   fPidx(v0.fPidx),
     103          62 :   fStatus(v0.fStatus),
     104          62 :   fNBefore(v0.fNBefore),
     105          62 :   fNAfter(v0.fNAfter),
     106          62 :   fOnFlyStatus(v0.fOnFlyStatus)
     107         302 : {
     108             :   //--------------------------------------------------------------------
     109             :   // The copy constructor
     110             :   //--------------------------------------------------------------------
     111             : 
     112         496 :   for (int i=0; i<3; i++) {
     113         186 :     fPos[i]  = v0.fPos[i];
     114         186 :     fNmom[i] = v0.fNmom[i];
     115         186 :     fPmom[i] = v0.fPmom[i];
     116             :   }
     117         868 :   for (int i=0; i<6; i++) {
     118         372 :     fPosCov[i]  = v0.fPosCov[i];
     119             :   }
     120             : 
     121         372 :   for (Int_t i=0; i<2; i++) {
     122         124 :     fNormDCAPrim[i]=v0.fNormDCAPrim[i];
     123             :   }
     124         868 :   for (Int_t i=0;i<6;i++){
     125         372 :       fClusters[0][i]=v0.fClusters[0][i]; 
     126         372 :       fClusters[1][i]=v0.fClusters[1][i];
     127             :   }
     128         496 :   for (Int_t i=0;i<3;i++){
     129         186 :       fAngle[i]=v0.fAngle[i];
     130             :   }
     131         620 :   for (Int_t i=0;i<4;i++){fCausality[i]=v0.fCausality[i];}
     132         120 : }
     133             : 
     134             : 
     135             : AliESDv0::AliESDv0(const AliExternalTrackParam &t1, Int_t i1,
     136             :                    const AliExternalTrackParam &t2, Int_t i2) :
     137          24 :   AliVParticle(),
     138          24 :   fParamN(t1),
     139          24 :   fParamP(t2),
     140          72 :   fEffMass(TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass()),
     141          24 :   fDcaV0Daughters(0),
     142          24 :   fChi2V0(0.),
     143          24 :   fRr(0),
     144          24 :   fDistSigma(0),
     145          24 :   fChi2Before(0),
     146          24 :   fChi2After(0),
     147          24 :   fPointAngleFi(0),
     148          24 :   fPointAngleTh(0),
     149          24 :   fPointAngle(0),
     150          24 :   fPdgCode(kK0Short),
     151          24 :   fNidx(i1),
     152          24 :   fPidx(i2),
     153          24 :   fStatus(0),
     154          24 :   fNBefore(0),
     155          24 :   fNAfter(0),
     156          24 :   fOnFlyStatus(kFALSE)
     157         120 : {
     158             :   //--------------------------------------------------------------------
     159             :   // Main constructor  (K0s)
     160             :   //--------------------------------------------------------------------
     161             : 
     162             :   //Make sure the daughters are ordered (needed for the on-the-fly V0s)
     163          48 :   Short_t cN=t1.Charge(), cP=t2.Charge();
     164          24 :   if ((cN>0) && (cN != cP)) {
     165           0 :      fParamN.~AliExternalTrackParam();
     166           0 :      new (&fParamN) AliExternalTrackParam(t2);
     167           0 :      fParamP.~AliExternalTrackParam();
     168           0 :      new (&fParamP) AliExternalTrackParam(t1);
     169             : 
     170           0 :      Int_t index=fNidx;
     171           0 :      fNidx=fPidx;
     172           0 :      fPidx=index;
     173           0 :   }
     174             : 
     175         336 :   for (Int_t i=0; i<6; i++) {
     176         144 :     fPosCov[i]= 0.;
     177             :   }
     178             : 
     179             :   //Trivial estimation of the vertex parameters
     180          48 :   Double_t alpha=t1.GetAlpha(), cs=TMath::Cos(alpha), sn=TMath::Sin(alpha);
     181          24 :   Double_t tmp[3];
     182          24 :   t1.GetPxPyPz(tmp);
     183          24 :   Double_t px1=tmp[0], py1=tmp[1], pz1=tmp[2];
     184          24 :   t1.GetXYZ(tmp);
     185          24 :   Double_t  x1=tmp[0],  y1=tmp[1],  z1=tmp[2];
     186             :   const Double_t ss=0.0005*0.0005;//a kind of a residual misalignment precision
     187          24 :   Double_t sx1=sn*sn*t1.GetSigmaY2()+ss, sy1=cs*cs*t1.GetSigmaY2()+ss; 
     188             : 
     189             : 
     190          48 :   alpha=t2.GetAlpha(); cs=TMath::Cos(alpha); sn=TMath::Sin(alpha);
     191          24 :   t2.GetPxPyPz(tmp);
     192          24 :   Double_t px2=tmp[0], py2=tmp[1], pz2=tmp[2];
     193          24 :   t2.GetXYZ(tmp);
     194          24 :   Double_t  x2=tmp[0],  y2=tmp[1],  z2=tmp[2];
     195          24 :   Double_t sx2=sn*sn*t2.GetSigmaY2()+ss, sy2=cs*cs*t2.GetSigmaY2()+ss; 
     196             :     
     197          24 :   Double_t sz1=t1.GetSigmaZ2(), sz2=t2.GetSigmaZ2();
     198          24 :   Double_t wx1=sx2/(sx1+sx2), wx2=1.- wx1;
     199          24 :   Double_t wy1=sy2/(sy1+sy2), wy2=1.- wy1;
     200          24 :   Double_t wz1=sz2/(sz1+sz2), wz2=1.- wz1;
     201          24 :   fPos[0]=wx1*x1 + wx2*x2; fPos[1]=wy1*y1 + wy2*y2; fPos[2]=wz1*z1 + wz2*z2;
     202             : 
     203             :   //fPos[0]=0.5*(x1+x2); fPos[1]=0.5*(y1+y2); fPos[2]=0.5*(z1+z2);
     204          24 :   fNmom[0]=px1; fNmom[1]=py1; fNmom[2]=pz1; 
     205          24 :   fPmom[0]=px2; fPmom[1]=py2; fPmom[2]=pz2;
     206             : 
     207         336 :   for (Int_t i=0;i<6;i++){fClusters[0][i]=0; fClusters[1][i]=0;}
     208          24 :   fNormDCAPrim[0]=fNormDCAPrim[1]=0;
     209         192 :   for (Int_t i=0;i<3;i++){fAngle[i]=0;}
     210         240 :   for (Int_t i=0;i<4;i++){fCausality[i]=0;}
     211          48 : }
     212             : 
     213             : AliESDv0& AliESDv0::operator=(const AliESDv0 &v0)
     214             : {
     215             :   //--------------------------------------------------------------------
     216             :   // The assignment operator
     217             :   //--------------------------------------------------------------------
     218             : 
     219           0 :   if(this==&v0)return *this;
     220           0 :   AliVParticle::operator=(v0);
     221           0 :   fParamN  = v0.fParamN;
     222           0 :   fParamP  = v0.fParamP;
     223           0 :   fEffMass = v0.fEffMass;
     224           0 :   fDcaV0Daughters = v0.fDcaV0Daughters;
     225           0 :   fChi2V0 = v0.fChi2V0;
     226           0 :   fRr = v0.fRr;
     227           0 :   fDistSigma    = v0.fDistSigma;
     228           0 :   fChi2Before   = v0.fChi2Before;
     229           0 :   fChi2After    = v0.fChi2After;
     230           0 :   fPointAngleFi = v0.fPointAngleFi;
     231           0 :   fPointAngleTh = v0.fPointAngleTh;
     232           0 :   fPointAngle   = v0.fPointAngle;
     233           0 :   fPdgCode      = v0.fPdgCode;
     234           0 :   fNidx         = v0.fNidx;
     235           0 :   fPidx         = v0.fPidx;
     236           0 :   fStatus       = v0.fStatus;
     237           0 :   fNBefore      = v0.fNBefore;
     238           0 :   fNAfter       = v0.fNAfter;
     239           0 :   fOnFlyStatus  = v0.fOnFlyStatus;
     240             : 
     241           0 :   for (int i=0; i<3; i++) {
     242           0 :     fPos[i]  = v0.fPos[i];
     243           0 :     fNmom[i] = v0.fNmom[i];
     244           0 :     fPmom[i] = v0.fPmom[i];
     245             :   }
     246           0 :   for (int i=0; i<6; i++) {
     247           0 :     fPosCov[i]  = v0.fPosCov[i];
     248             :   }
     249           0 :   for (Int_t i=0; i<2; i++) {
     250           0 :     fNormDCAPrim[i]=v0.fNormDCAPrim[i];
     251             :   }
     252           0 :   for (Int_t i=0;i<6;i++){
     253           0 :       fClusters[0][i]=v0.fClusters[0][i]; 
     254           0 :       fClusters[1][i]=v0.fClusters[1][i];
     255             :   }
     256           0 :   for (Int_t i=0;i<3;i++){
     257           0 :       fAngle[i]=v0.fAngle[i];
     258             :   }
     259           0 :   for (Int_t i=0;i<4;i++){fCausality[i]=v0.fCausality[i];}
     260             : 
     261           0 :   return *this;
     262           0 : }
     263             : 
     264             : void AliESDv0::Copy(TObject& obj) const {
     265             : 
     266             :   // this overwrites the virtual TOBject::Copy()
     267             :   // to allow run time copying without casting
     268             :   // in AliESDEvent
     269             : 
     270           0 :   if(this==&obj)return;
     271           0 :   AliESDv0 *robj = dynamic_cast<AliESDv0*>(&obj);
     272           0 :   if(!robj)return; // not an aliesesv0
     273           0 :   *robj = *this;
     274           0 : }
     275             : 
     276         732 : AliESDv0::~AliESDv0(){
     277             :   //--------------------------------------------------------------------
     278             :   // Empty destructor
     279             :   //--------------------------------------------------------------------
     280         366 : }
     281             : 
     282             : // Start with AliVParticle functions
     283             : Double_t AliESDv0::E() const {
     284             :   //--------------------------------------------------------------------
     285             :   // This gives the energy assuming the ChangeMassHypothesis was called
     286             :   //--------------------------------------------------------------------
     287           0 :   return E(fPdgCode);
     288             : }
     289             : 
     290             : Double_t AliESDv0::Y() const {
     291             :   //--------------------------------------------------------------------
     292             :   // This gives the energy assuming the ChangeMassHypothesis was called
     293             :   //--------------------------------------------------------------------
     294           0 :   return Y(fPdgCode);
     295             : }
     296             : 
     297             : // Then extend AliVParticle functions
     298             : Double_t AliESDv0::E(Int_t pdg) const {
     299             :   //--------------------------------------------------------------------
     300             :   // This gives the energy with the particle hypothesis as argument 
     301             :   //--------------------------------------------------------------------
     302           0 :   Double_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
     303           0 :   return TMath::Sqrt(mass*mass+P()*P());
     304             : }
     305             : 
     306             : Double_t AliESDv0::Y(Int_t pdg) const {
     307             :   //--------------------------------------------------------------------
     308             :   // This gives the rapidity with the particle hypothesis as argument 
     309             :   //--------------------------------------------------------------------
     310           0 :   return 0.5*TMath::Log((E(pdg)+Pz())/(E(pdg)-Pz()+1.e-13));
     311             : }
     312             : 
     313             : // Now the functions for analysis consistency
     314             : Double_t AliESDv0::RapK0Short() const {
     315             :   //--------------------------------------------------------------------
     316             :   // This gives the pseudorapidity assuming a K0s particle
     317             :   //--------------------------------------------------------------------
     318           0 :   return Y(kK0Short);
     319             : }
     320             : 
     321             : Double_t AliESDv0::RapLambda() const {
     322             :   //--------------------------------------------------------------------
     323             :   // This gives the pseudorapidity assuming a (Anti) Lambda particle
     324             :   //--------------------------------------------------------------------
     325           0 :   return Y(kLambda0);
     326             : }
     327             : 
     328             : Double_t AliESDv0::AlphaV0() const {
     329             :   //--------------------------------------------------------------------
     330             :   // This gives the Armenteros-Podolanski alpha
     331             :   //--------------------------------------------------------------------
     332           0 :   TVector3 momNeg(fNmom[0],fNmom[1],fNmom[2]);
     333           0 :   TVector3 momPos(fPmom[0],fPmom[1],fPmom[2]);
     334           0 :   TVector3 momTot(Px(),Py(),Pz());
     335             : 
     336           0 :   Double_t lQlNeg = momNeg.Dot(momTot)/momTot.Mag();
     337           0 :   Double_t lQlPos = momPos.Dot(momTot)/momTot.Mag();
     338             : 
     339             :   //return 1.-2./(1.+lQlNeg/lQlPos);
     340           0 :   return (lQlPos - lQlNeg)/(lQlPos + lQlNeg);
     341           0 : }
     342             : 
     343             : Double_t AliESDv0::PtArmV0() const {
     344             :   //--------------------------------------------------------------------
     345             :   // This gives the Armenteros-Podolanski ptarm
     346             :   //--------------------------------------------------------------------
     347           0 :   TVector3 momNeg(fNmom[0],fNmom[1],fNmom[2]);
     348           0 :   TVector3 momTot(Px(),Py(),Pz());
     349             : 
     350           0 :   return momNeg.Perp(momTot);
     351           0 : }
     352             : 
     353             : // Eventually the older functions
     354             : Double_t AliESDv0::ChangeMassHypothesis(Int_t code) {
     355             :   //--------------------------------------------------------------------
     356             :   // This function changes the mass hypothesis for this V0
     357             :   // and returns the "kinematical quality" of this hypothesis 
     358             :   //--------------------------------------------------------------------
     359         116 :   static
     360           6 :   Double_t piMass=TDatabasePDG::Instance()->GetParticle(kPiPlus)->Mass();
     361          60 :   static
     362           6 :   Double_t prMass=TDatabasePDG::Instance()->GetParticle(kProton)->Mass();
     363          60 :   static
     364           6 :   Double_t k0Mass=TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass();
     365          60 :   static
     366           6 :   Double_t l0Mass=TDatabasePDG::Instance()->GetParticle(kLambda0)->Mass();
     367             : 
     368          84 :   Double_t nmass=piMass, pmass=piMass, mass=k0Mass, ps=0.206;
     369             : 
     370          84 :   fPdgCode=code;
     371             : 
     372          84 :   switch (code) {
     373             :   case kLambda0:
     374          14 :     nmass=piMass; pmass=prMass; mass=l0Mass; ps=0.101; break;
     375             :   case kLambda0Bar:
     376          14 :     pmass=piMass; nmass=prMass; mass=l0Mass; ps=0.101; break;
     377             :   case kK0Short: 
     378             :     break;
     379             :   default:
     380           0 :     AliError("invalide PDG code ! Assuming K0s...");
     381           0 :     fPdgCode=kK0Short;
     382           0 :     break;
     383             :   }
     384             : 
     385          56 :   Double_t pxn=fNmom[0], pyn=fNmom[1], pzn=fNmom[2]; 
     386          56 :   Double_t pxp=fPmom[0], pyp=fPmom[1], pzp=fPmom[2];
     387             : 
     388          56 :   Double_t en=TMath::Sqrt(nmass*nmass + pxn*pxn + pyn*pyn + pzn*pzn);
     389          56 :   Double_t ep=TMath::Sqrt(pmass*pmass + pxp*pxp + pyp*pyp + pzp*pzp);
     390          56 :   Double_t pxl=pxn+pxp, pyl=pyn+pyp, pzl=pzn+pzp;
     391          56 :   Double_t pl=TMath::Sqrt(pxl*pxl + pyl*pyl + pzl*pzl);
     392             : 
     393          56 :   fEffMass=TMath::Sqrt((en+ep)*(en+ep)-pl*pl);
     394             : 
     395          56 :   Double_t beta=pl/(en+ep);
     396          56 :   Double_t pln=(pxn*pxl + pyn*pyl + pzn*pzl)/pl;
     397          56 :   Double_t plp=(pxp*pxl + pyp*pyl + pzp*pzl)/pl;
     398             : 
     399          56 :   Double_t pt2=pxp*pxp + pyp*pyp + pzp*pzp - plp*plp;
     400             : 
     401          56 :   Double_t a=(plp-pln)/(plp+pln);
     402          56 :   a -= (pmass*pmass-nmass*nmass)/(mass*mass);
     403          56 :   a = 0.25*beta*beta*mass*mass*a*a + pt2;
     404             : 
     405          56 :   return (a - ps*ps);
     406             :   
     407           0 : }
     408             : 
     409             : void AliESDv0::GetPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const {
     410             :   //--------------------------------------------------------------------
     411             :   // This function returns V0's momentum (global)
     412             :   //--------------------------------------------------------------------
     413         120 :   px=fNmom[0]+fPmom[0]; 
     414          60 :   py=fNmom[1]+fPmom[1]; 
     415          60 :   pz=fNmom[2]+fPmom[2]; 
     416          60 : }
     417             : 
     418             : void AliESDv0::GetXYZ(Double_t &x, Double_t &y, Double_t &z) const {
     419             :   //--------------------------------------------------------------------
     420             :   // This function returns V0's position (global)
     421             :   //--------------------------------------------------------------------
     422         160 :   x=fPos[0]; 
     423          80 :   y=fPos[1]; 
     424          80 :   z=fPos[2]; 
     425          80 : }
     426             : 
     427             : Float_t AliESDv0::GetD(Double_t x0, Double_t y0) const {
     428             :   //--------------------------------------------------------------------
     429             :   // This function returns V0's impact parameter calculated in 2D in XY plane
     430             :   //--------------------------------------------------------------------
     431           0 :   Double_t x=fPos[0],y=fPos[1];
     432           0 :   Double_t px=fNmom[0]+fPmom[0];
     433           0 :   Double_t py=fNmom[1]+fPmom[1];
     434             : 
     435           0 :   Double_t dz=(x0-x)*py - (y0-y)*px;
     436           0 :   Double_t d=TMath::Sqrt(dz*dz/(px*px+py*py));
     437           0 :   return d;
     438             : }
     439             : 
     440             : Float_t AliESDv0::GetD(Double_t x0, Double_t y0, Double_t z0) const {
     441             :   //--------------------------------------------------------------------
     442             :   // This function returns V0's impact parameter calculated in 3D
     443             :   //--------------------------------------------------------------------
     444         188 :   Double_t x=fPos[0],y=fPos[1],z=fPos[2];
     445          94 :   Double_t px=fNmom[0]+fPmom[0];
     446          94 :   Double_t py=fNmom[1]+fPmom[1];
     447          94 :   Double_t pz=fNmom[2]+fPmom[2];
     448             : 
     449          94 :   Double_t dx=(y0-y)*pz - (z0-z)*py; 
     450          94 :   Double_t dy=(x0-x)*pz - (z0-z)*px;
     451          94 :   Double_t dz=(x0-x)*py - (y0-y)*px;
     452          94 :   Double_t d=TMath::Sqrt((dx*dx+dy*dy+dz*dz)/(px*px+py*py+pz*pz));
     453          94 :   return d;
     454             : }
     455             : 
     456             : Float_t AliESDv0::GetV0CosineOfPointingAngle(Double_t refPointX, Double_t refPointY, Double_t refPointZ) const {
     457             :   // calculates the pointing angle of the V0 wrt a reference point
     458             : 
     459          48 :   Double_t momV0[3]; //momentum of the V0
     460          24 :   GetPxPyPz(momV0[0],momV0[1],momV0[2]);
     461             : 
     462             :   Double_t deltaPos[3]; //vector between the reference point and the V0 vertex
     463          24 :   deltaPos[0] = fPos[0] - refPointX;
     464          24 :   deltaPos[1] = fPos[1] - refPointY;
     465          24 :   deltaPos[2] = fPos[2] - refPointZ;
     466             : 
     467          24 :   Double_t momV02    = momV0[0]*momV0[0] + momV0[1]*momV0[1] + momV0[2]*momV0[2];
     468          24 :   Double_t deltaPos2 = deltaPos[0]*deltaPos[0] + deltaPos[1]*deltaPos[1] + deltaPos[2]*deltaPos[2];
     469             : 
     470          48 :   Double_t cosinePointingAngle = (deltaPos[0]*momV0[0] +
     471          48 :                                   deltaPos[1]*momV0[1] +
     472          48 :                                   deltaPos[2]*momV0[2] ) /
     473          24 :     TMath::Sqrt(momV02 * deltaPos2);
     474             :   
     475          48 :   return cosinePointingAngle;
     476          24 : }
     477             : 
     478             : 
     479             : // **** The following functions need to be revised
     480             : 
     481             : void AliESDv0::GetPosCov(Double_t cov[6]) const {
     482             : 
     483         240 :   for (Int_t i=0; i<6; ++i) cov[i] = fPosCov[i];
     484             : 
     485          16 : }
     486             : 
     487             : Double_t AliESDv0::GetSigmaY(){
     488             :   //
     489             :   // return sigmay in y  at vertex position  using covariance matrix 
     490             :   //
     491           0 :   const Double_t * cp  = fParamP.GetCovariance();
     492           0 :   const Double_t * cm  = fParamN.GetCovariance();
     493           0 :   Double_t sigmay = cp[0]+cm[0]+ cp[5]*(fParamP.GetX()-fRr)*(fParamP.GetX()-fRr)+ cm[5]*(fParamN.GetX()-fRr)*(fParamN.GetX()-fRr);
     494           0 :   return (sigmay>0) ? TMath::Sqrt(sigmay):100;
     495             : }
     496             : 
     497             : Double_t AliESDv0::GetSigmaZ(){
     498             :   //
     499             :   // return sigmay in y  at vertex position  using covariance matrix 
     500             :   //
     501           0 :   const Double_t * cp  = fParamP.GetCovariance();
     502           0 :   const Double_t * cm  = fParamN.GetCovariance();
     503           0 :   Double_t sigmaz = cp[2]+cm[2]+ cp[9]*(fParamP.GetX()-fRr)*(fParamP.GetX()-fRr)+ cm[9]*(fParamN.GetX()-fRr)*(fParamN.GetX()-fRr);
     504           0 :   return (sigmaz>0) ? TMath::Sqrt(sigmaz):100;
     505             : }
     506             : 
     507             : Double_t AliESDv0::GetSigmaD0(){
     508             :   //
     509             :   // Sigma parameterization using covariance matrix
     510             :   //
     511             :   // sigma of distance between two tracks in vertex position 
     512             :   // sigma of DCA is proportianal to sigmaD0
     513             :   // factor 2 difference is explained by the fact that the DCA is calculated at the position 
     514             :   // where the tracks as closest together ( not exact position of the vertex)
     515             :   //
     516           0 :   const Double_t * cp      = fParamP.GetCovariance();
     517           0 :   const Double_t * cm      = fParamN.GetCovariance();
     518           0 :   Double_t sigmaD0   = cp[0]+cm[0]+cp[2]+cm[2]+fgkParams.fPSigmaOffsetD0*fgkParams.fPSigmaOffsetD0;
     519           0 :   sigmaD0           += ((fParamP.GetX()-fRr)*(fParamP.GetX()-fRr))*(cp[5]+cp[9]);
     520           0 :   sigmaD0           += ((fParamN.GetX()-fRr)*(fParamN.GetX()-fRr))*(cm[5]+cm[9]);
     521           0 :   return (sigmaD0>0)? TMath::Sqrt(sigmaD0):100;
     522             : }
     523             : 
     524             : 
     525             : Double_t AliESDv0::GetSigmaAP0(){
     526             :   //
     527             :   //Sigma parameterization using covariance matrices
     528             :   //
     529           0 :   Double_t prec  = TMath::Sqrt((fNmom[0]+fPmom[0])*(fNmom[0]+fPmom[0])
     530           0 :                               +(fNmom[1]+fPmom[1])*(fNmom[1]+fPmom[1])
     531           0 :                               +(fNmom[2]+fPmom[2])*(fNmom[2]+fPmom[2]));
     532           0 :   Double_t normp = TMath::Sqrt(fPmom[0]*fPmom[0]+fPmom[1]*fPmom[1]+fPmom[2]*fPmom[2])/prec;  // fraction of the momenta
     533           0 :   Double_t normm = TMath::Sqrt(fNmom[0]*fNmom[0]+fNmom[1]*fNmom[1]+fNmom[2]*fNmom[2])/prec;  
     534           0 :   const Double_t * cp      = fParamP.GetCovariance();
     535           0 :   const Double_t * cm      = fParamN.GetCovariance();
     536           0 :   Double_t sigmaAP0 = fgkParams.fPSigmaOffsetAP0*fgkParams.fPSigmaOffsetAP0;                           // minimal part
     537           0 :   sigmaAP0 +=  (cp[5]+cp[9])*(normp*normp)+(cm[5]+cm[9])*(normm*normm);          // angular resolution part
     538           0 :   Double_t sigmaAP1 = GetSigmaD0()/(TMath::Abs(fRr)+0.01);                       // vertex position part
     539           0 :   sigmaAP0 +=  0.5*sigmaAP1*sigmaAP1;                              
     540           0 :   return (sigmaAP0>0)? TMath::Sqrt(sigmaAP0):100;
     541             : }
     542             : 
     543             : Double_t AliESDv0::GetEffectiveSigmaD0(){
     544             :   //
     545             :   // minimax - effective Sigma parameterization 
     546             :   // p12 effective curvature and v0 radius postion used as parameters  
     547             :   //  
     548           0 :   Double_t p12 = TMath::Sqrt(fParamP.GetParameter()[4]*fParamP.GetParameter()[4]+
     549           0 :                              fParamN.GetParameter()[4]*fParamN.GetParameter()[4]);
     550           0 :   Double_t sigmaED0= TMath::Max(TMath::Sqrt(fRr)-fgkParams.fPSigmaRminDE,0.0)*fgkParams.fPSigmaCoefDE*p12*p12;
     551           0 :   sigmaED0*= sigmaED0;
     552           0 :   sigmaED0*= sigmaED0;
     553           0 :   sigmaED0 = TMath::Sqrt(sigmaED0+fgkParams.fPSigmaOffsetDE*fgkParams.fPSigmaOffsetDE);
     554           0 :   return (sigmaED0<fgkParams.fPSigmaMaxDE) ? sigmaED0: fgkParams.fPSigmaMaxDE;
     555             : }
     556             : 
     557             : 
     558             : Double_t AliESDv0::GetEffectiveSigmaAP0(){
     559             :   //
     560             :   // effective Sigma parameterization of point angle resolution 
     561             :   //
     562           0 :   Double_t p12 = TMath::Sqrt(fParamP.GetParameter()[4]*fParamP.GetParameter()[4]+
     563           0 :                              fParamN.GetParameter()[4]*fParamN.GetParameter()[4]);
     564           0 :   Double_t sigmaAPE= fgkParams.fPSigmaBase0APE;
     565           0 :   sigmaAPE+= fgkParams.fPSigmaR0APE/(fgkParams.fPSigmaR1APE+fRr);
     566           0 :   sigmaAPE*= (fgkParams.fPSigmaP0APE+fgkParams.fPSigmaP1APE*p12);
     567           0 :   sigmaAPE = TMath::Min(sigmaAPE,fgkParams.fPSigmaMaxAPE);
     568           0 :   return sigmaAPE;
     569             : }
     570             : 
     571             : 
     572             : Double_t  AliESDv0::GetMinimaxSigmaAP0(){
     573             :   //
     574             :   // calculate mini-max effective sigma of point angle resolution
     575             :   //
     576             :   //compv0->fTree->SetAlias("SigmaAP2","max(min((SigmaAP0+SigmaAPE0)*0.5,1.5*SigmaAPE0),0.5*SigmaAPE0+0.003)");
     577           0 :   Double_t    effectiveSigma = GetEffectiveSigmaAP0();
     578           0 :   Double_t    sigmaMMAP = 0.5*(GetSigmaAP0()+effectiveSigma);
     579           0 :   sigmaMMAP  = TMath::Min(sigmaMMAP, fgkParams.fPMaxFractionAP0*effectiveSigma);
     580           0 :   sigmaMMAP  = TMath::Max(sigmaMMAP, fgkParams.fPMinFractionAP0*effectiveSigma+fgkParams.fPMinAP0);
     581           0 :   return sigmaMMAP;
     582             : }
     583             : Double_t  AliESDv0::GetMinimaxSigmaD0(){
     584             :   //
     585             :   // calculate mini-max sigma of dca resolution
     586             :   // 
     587             :   //compv0->fTree->SetAlias("SigmaD2","max(min((SigmaD0+SigmaDE0)*0.5,1.5*SigmaDE0),0.5*SigmaDE0)");
     588           0 :   Double_t    effectiveSigma = GetEffectiveSigmaD0();
     589           0 :   Double_t    sigmaMMD0 = 0.5*(GetSigmaD0()+effectiveSigma);
     590           0 :   sigmaMMD0  = TMath::Min(sigmaMMD0, fgkParams.fPMaxFractionD0*effectiveSigma);
     591           0 :   sigmaMMD0  = TMath::Max(sigmaMMD0, fgkParams.fPMinFractionD0*effectiveSigma+fgkParams.fPMinD0);
     592           0 :   return sigmaMMD0;
     593             : }
     594             : 
     595             : 
     596             : Double_t AliESDv0::GetLikelihoodAP(Int_t mode0, Int_t mode1){
     597             :   //
     598             :   // get likelihood for point angle
     599             :   //
     600             :   Double_t sigmaAP = 0.007;            //default sigma
     601           0 :   switch (mode0){
     602             :   case 0:
     603           0 :     sigmaAP = GetSigmaAP0();           // mode 0  - covariance matrix estimates used 
     604           0 :     break;
     605             :   case 1:
     606           0 :     sigmaAP = GetEffectiveSigmaAP0();  // mode 1 - effective sigma used
     607           0 :     break;
     608             :   case 2:
     609           0 :     sigmaAP = GetMinimaxSigmaAP0();    // mode 2 - minimax sigma
     610           0 :     break;
     611             :   }
     612           0 :   Double_t apNorm = TMath::Min(TMath::ACos(fPointAngle)/sigmaAP,50.);  
     613             :   //normalized point angle, restricted - because of overflow problems in Exp
     614             :   Double_t likelihood = 0;
     615           0 :   switch(mode1){
     616             :   case 0:
     617           0 :     likelihood = TMath::Exp(-0.5*apNorm*apNorm);   
     618             :     // one component
     619           0 :     break;
     620             :   case 1:
     621           0 :     likelihood = (TMath::Exp(-0.5*apNorm*apNorm)+0.5* TMath::Exp(-0.25*apNorm*apNorm))/1.5;
     622             :     // two components
     623           0 :     break;
     624             :   case 2:
     625           0 :     likelihood = (TMath::Exp(-0.5*apNorm*apNorm)+0.5* TMath::Exp(-0.25*apNorm*apNorm)+0.25*TMath::Exp(-0.125*apNorm*apNorm))/1.75;
     626             :     // three components
     627           0 :     break;
     628             :   }
     629           0 :   return likelihood;
     630             : }
     631             : 
     632             : Double_t AliESDv0::GetLikelihoodD(Int_t mode0, Int_t mode1){
     633             :   //
     634             :   // get likelihood for DCA
     635             :   //
     636             :   Double_t sigmaD = 0.03;            //default sigma
     637           0 :   switch (mode0){
     638             :   case 0:
     639           0 :     sigmaD = GetSigmaD0();           // mode 0  - covariance matrix estimates used 
     640           0 :     break;
     641             :   case 1:
     642           0 :     sigmaD = GetEffectiveSigmaD0();  // mode 1 - effective sigma used
     643           0 :     break;
     644             :   case 2:
     645           0 :     sigmaD = GetMinimaxSigmaD0();    // mode 2 - minimax sigma
     646           0 :     break;
     647             :   }
     648             : 
     649             :   //Bo:  Double_t dNorm = TMath::Min(fDist2/sigmaD,50.);
     650           0 :   Double_t dNorm = TMath::Min(fDcaV0Daughters/sigmaD,50.);//Bo:
     651             :   //normalized point angle, restricted - because of overflow problems in Exp
     652             :   Double_t likelihood = 0;
     653           0 :   switch(mode1){
     654             :   case 0:
     655           0 :     likelihood = TMath::Exp(-2.*dNorm);   
     656             :     // one component
     657           0 :     break;
     658             :   case 1:
     659           0 :     likelihood = (TMath::Exp(-2.*dNorm)+0.5* TMath::Exp(-dNorm))/1.5;
     660             :     // two components
     661           0 :     break;
     662             :   case 2:
     663           0 :     likelihood = (TMath::Exp(-2.*dNorm)+0.5* TMath::Exp(-dNorm)+0.25*TMath::Exp(-0.5*dNorm))/1.75;
     664             :     // three components
     665           0 :     break;
     666             :   }
     667           0 :   return likelihood;
     668             : 
     669             : }
     670             : 
     671             : Double_t AliESDv0::GetLikelihoodC(Int_t mode0, Int_t /*mode1*/) const {
     672             :   //
     673             :   // get likelihood for Causality
     674             :   // !!!  Causality variables defined in AliITStrackerMI !!! 
     675             :   //      when more information was available
     676             :   //  
     677             :   Double_t likelihood = 0.5;
     678           0 :   Double_t minCausal  = TMath::Min(fCausality[0],fCausality[1]);
     679           0 :   Double_t maxCausal  = TMath::Max(fCausality[0],fCausality[1]);
     680             :   //  minCausal           = TMath::Max(minCausal,0.5*maxCausal);
     681             :   //compv0->fTree->SetAlias("LCausal","(1.05-(2*(0.8-exp(-max(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1])))+2*(0.8-exp(-min(RC.fV0rec.fCausality[0],RC.fV0rec.fCausality[1]))))/2)**4");
     682             :   
     683           0 :   switch(mode0){
     684             :   case 0:
     685             :     //normalization 
     686           0 :     likelihood = TMath::Power((1.05-2*(0.8-TMath::Exp(-maxCausal))),4.);
     687           0 :     break;
     688             :   case 1:
     689           0 :     likelihood = TMath::Power(1.05-(2*(0.8-TMath::Exp(-maxCausal))+(2*(0.8-TMath::Exp(-minCausal))))*0.5,4.);
     690           0 :     break;
     691             :   }
     692           0 :   return likelihood;
     693             :   
     694             : }
     695             : 
     696             : void AliESDv0::SetCausality(Float_t pb0, Float_t pb1, Float_t pa0, Float_t pa1)
     697             : {
     698             :   //
     699             :   // set probabilities
     700             :   //
     701          28 :   fCausality[0] = pb0;     // probability - track 0 exist before vertex
     702          14 :   fCausality[1] = pb1;     // probability - track 1 exist before vertex
     703          14 :   fCausality[2] = pa0;     // probability - track 0 exist close after vertex
     704          14 :   fCausality[3] = pa1;     // probability - track 1 exist close after vertex
     705          14 : }
     706             : void  AliESDv0::SetClusters(const Int_t *clp, const Int_t *clm)
     707             : {
     708             :   //
     709             :   // Set its clusters indexes
     710             :   //
     711         360 :   for (Int_t i=0;i<6;i++) fClusters[0][i] = clp[i]; 
     712         336 :   for (Int_t i=0;i<6;i++) fClusters[1][i] = clm[i]; 
     713          24 : }
     714             : 
     715             : Double_t AliESDv0::GetEffMass(UInt_t p1, UInt_t p2) const{
     716             :   //
     717             :   // calculate effective mass
     718             :   //
     719           0 :   const Double_t kpmass[5] = {TDatabasePDG::Instance()->GetParticle(kElectron)->Mass(),
     720           0 :                              TDatabasePDG::Instance()->GetParticle(kMuonMinus)->Mass(),
     721           0 :                              TDatabasePDG::Instance()->GetParticle(kPiPlus)->Mass(),
     722           0 :                              TDatabasePDG::Instance()->GetParticle(kKPlus)->Mass(),
     723           0 :                              TDatabasePDG::Instance()->GetParticle(kProton)->Mass()};
     724             :   /*
     725             :   if (p1>4) return -1;
     726             :   if (p2>4) return -1;
     727             :   Double_t mass1 = kpmass[p1]; 
     728             :   Double_t mass2 = kpmass[p2];   
     729             :   const Double_t *m1 = fPmom;
     730             :   const Double_t *m2 = fNmom;
     731             :   //
     732             :   //if (fRP[p1]+fRM[p2]<fRP[p2]+fRM[p1]){
     733             :   //  m1 = fPM;
     734             :   //  m2 = fPP;
     735             :   //}
     736             :   //
     737             :   Double_t e1    = TMath::Sqrt(mass1*mass1+
     738             :                               m1[0]*m1[0]+
     739             :                               m1[1]*m1[1]+
     740             :                               m1[2]*m1[2]);
     741             :   Double_t e2    = TMath::Sqrt(mass2*mass2+
     742             :                               m2[0]*m2[0]+
     743             :                               m2[1]*m2[1]+
     744             :                               m2[2]*m2[2]);  
     745             :   Double_t mass =  
     746             :     (m2[0]+m1[0])*(m2[0]+m1[0])+
     747             :     (m2[1]+m1[1])*(m2[1]+m1[1])+
     748             :     (m2[2]+m1[2])*(m2[2]+m1[2]);
     749             :   
     750             :   mass = (e1+e2)*(e1+e2)-mass;
     751             :   if (mass < 0.) mass = 0.;
     752             :   return (TMath::Sqrt(mass));
     753             :   */
     754           0 :   if(p1>4 || p2>4) return -1;
     755           0 :   return GetEffMassExplicit(kpmass[p1],kpmass[p2]);                            
     756           0 : }
     757             : 
     758             : Double_t AliESDv0::GetEffMassExplicit(Double_t m1, Double_t m2) const {
     759             :   //
     760             :   // calculate effective mass with given masses of decay products
     761             :   //
     762           0 :   const AliExternalTrackParam *paramP = GetParamP();
     763           0 :   const AliExternalTrackParam *paramN = GetParamN();
     764           0 :   if (paramP->GetParameter()[4]<0){
     765           0 :     paramP=GetParamN();
     766           0 :     paramN=GetParamP();
     767           0 :   }
     768           0 :   Double_t pmom[3]={0}, nmom[3]={0};
     769           0 :   paramP->GetPxPyPz(pmom);
     770           0 :   paramN->GetPxPyPz(nmom);
     771           0 :   Double_t e12   = m1*m1+pmom[0]*pmom[0]+pmom[1]*pmom[1]+pmom[2]*pmom[2];
     772           0 :   Double_t e22   = m2*m2+nmom[0]*nmom[0]+nmom[1]*nmom[1]+nmom[2]*nmom[2];
     773           0 :   Double_t cmass = TMath::Sqrt(TMath::Max(m1*m1+m2*m2
     774           0 :                                           +2.*(TMath::Sqrt(e12*e22)-pmom[0]*nmom[0]-pmom[1]*nmom[1]-pmom[2]*nmom[2]),0.));
     775           0 :   return cmass;
     776             :                                
     777           0 : }
     778             : 
     779             : 
     780             : 
     781             : Double_t AliESDv0::GetKFInfo(UInt_t p1, UInt_t p2, Int_t type) const{
     782             :   //
     783             :   // type:
     784             :   //   0 - return mass
     785             :   //   1 - return err mass
     786             :   //   2 - return chi2
     787             :   // 
     788             :   const Int_t spdg[5]={kPositron,kMuonPlus,kPiPlus, kKPlus, kProton};
     789           0 :   const AliExternalTrackParam *paramP = GetParamP();
     790           0 :   const AliExternalTrackParam *paramN = GetParamN();
     791           0 :   if (paramP->GetSign()<0){
     792           0 :     paramP=GetParamN();
     793           0 :     paramN=GetParamP();
     794           0 :   }
     795           0 :   AliKFParticle kfp1(  *(paramP), spdg[p1] *TMath::Sign(1,p1) );
     796           0 :   AliKFParticle kfp2( *(paramN), spdg[p2] *TMath::Sign(1,p2) );
     797           0 :   AliKFParticle *v0KF = new AliKFParticle;
     798           0 :   *(v0KF)+=kfp1;
     799           0 :   *(v0KF)+=kfp2;
     800           0 :   if (type==0) return v0KF->GetMass();
     801           0 :   if (type==1) return v0KF->GetErrMass();
     802           0 :   if (type==2) return v0KF->GetChi2();
     803           0 :   return 0;
     804           0 : }
     805             : 
     806             : 
     807             : Double_t AliESDv0::GetKFInfoScale(UInt_t p1, UInt_t p2, Int_t type, Double_t d1pt, Double_t s1pt) const{
     808             :   //
     809             :   // type
     810             :   //   0 - return mass
     811             :   //   1 - return err mass
     812             :   //   2 - return chi2
     813             :   //   d1pt - 1/pt shift
     814             :   //   s1pt - scaling of 1/pt
     815             :   // Important function to benchmark the pt resolution, and to find out systematic distortion
     816             :   //
     817             :   const Int_t spdg[5]={kPositron,kMuonPlus,kPiPlus, kKPlus, kProton};
     818           0 :   const AliExternalTrackParam *paramP = GetParamP();
     819           0 :   const AliExternalTrackParam *paramN = GetParamN();
     820           0 :   if (paramP->GetSign()<0){
     821           0 :     paramP=GetParamP();
     822           0 :     paramN=GetParamN();
     823           0 :   }
     824           0 :   Double_t *pparam1 = (Double_t*)paramP->GetParameter();
     825           0 :   Double_t *pparam2 = (Double_t*)paramN->GetParameter();
     826           0 :   pparam1[4]+=d1pt;
     827           0 :   pparam2[4]+=d1pt;
     828           0 :   pparam1[4]*=(1+s1pt);
     829           0 :   pparam2[4]*=(1+s1pt);
     830             :   //
     831           0 :   AliKFParticle kfp1( *paramP, spdg[p1] *TMath::Sign(1,p1) );
     832           0 :   AliKFParticle kfp2( *paramN, spdg[p2] *TMath::Sign(1,p2) );
     833           0 :   AliKFParticle *v0KF = new AliKFParticle;
     834           0 :   *(v0KF)+=kfp1;
     835           0 :   *(v0KF)+=kfp2;
     836           0 :   if (type==0) return v0KF->GetMass();
     837           0 :   if (type==1) return v0KF->GetErrMass();
     838           0 :   if (type==2) return v0KF->GetChi2();
     839           0 :   return 0;
     840           0 : }
     841             : 
     842             : 
     843             : AliESDVertex AliESDv0::GetVertex() const{
     844             :   // Build an AliESDVertex from this AliESDv0
     845           0 :   AliESDVertex vtx(fPos,fPosCov,fChi2V0,2);
     846             :   return vtx;
     847           0 : }
     848             : 

Generated by: LCOV version 1.11