]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliESDv0.cxx
ITS tasks from the pilot train added.
[u/mrichter/AliRoot.git] / STEER / AliESDv0.cxx
index 03f3c110e8b31032eca8272114f49d0f3f04b5f3..2b01157a1bc77e0e7cea7927565877b7e2ca6516 100644 (file)
 //            and  Boris Hippolyte,IPHC, hippolyt@in2p3.fr 
 //-------------------------------------------------------------------------
 
-#include <Riostream.h>
 #include <TMath.h>
 #include <TDatabasePDG.h>
-#include <TPDGCode.h>
 #include <TParticlePDG.h>
+#include <TVector3.h>
 
 #include "AliLog.h"
 #include "AliESDv0.h"
-#include "AliExternalTrackParam.h"
+#include "AliESDV0Params.h"
 
 ClassImp(AliESDv0)
 
-AliESDV0Params  AliESDv0::fgkParams;
+const AliESDV0Params  AliESDv0::fgkParams;
 
 AliESDv0::AliESDv0() :
-  TObject(),
-  fOnFlyStatus(kFALSE),
-  fPdgCode(kK0Short),
-  fEffMass(TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass()),
-  fDcaV0Daughters(0),
-  fPointAngle(0),
-  fChi2V0(31.),
-  fNidx(-1),
+  AliVParticle(),
   fParamN(),
-  fPidx(-1),
   fParamP(),
-  fRr(-1),
-  fStatus(0),
+  fEffMass(TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass()),
+  fDcaV0Daughters(0),
+  fChi2V0(0.),
+  fRr(0),
   fDistSigma(0),
   fChi2Before(0),
-  fNBefore(0),
   fChi2After(0),
-  fNAfter(0),
   fPointAngleFi(0),
-  fPointAngleTh(0)
+  fPointAngleTh(0),
+  fPointAngle(0),
+  fPdgCode(kK0Short),
+  fNidx(0),
+  fPidx(0),
+  fStatus(0),
+  fNBefore(0),
+  fNAfter(0),
+  fOnFlyStatus(kFALSE)
 {
   //--------------------------------------------------------------------
   // Default constructor  (K0s)
@@ -82,26 +81,26 @@ AliESDv0::AliESDv0() :
 }
 
 AliESDv0::AliESDv0(const AliESDv0& v0) :
-  TObject(v0),
-  fOnFlyStatus(v0.fOnFlyStatus),
-  fPdgCode(v0.fPdgCode),
+  AliVParticle(v0),
+  fParamN(v0.fParamN),
+  fParamP(v0.fParamP),
   fEffMass(v0.fEffMass),
   fDcaV0Daughters(v0.fDcaV0Daughters),
-  fPointAngle(v0.fPointAngle),
   fChi2V0(v0.fChi2V0),
-  fNidx(v0.fNidx),
-  fParamN(v0.fParamN),
-  fPidx(v0.fPidx),
-  fParamP(v0.fParamP),
   fRr(v0.fRr),
-  fStatus(v0.fStatus),
   fDistSigma(v0.fDistSigma),
   fChi2Before(v0.fChi2Before),
-  fNBefore(v0.fNBefore),
   fChi2After(v0.fChi2After),
-  fNAfter(v0.fNAfter),
   fPointAngleFi(v0.fPointAngleFi),
-  fPointAngleTh(v0.fPointAngleTh)
+  fPointAngleTh(v0.fPointAngleTh),
+  fPointAngle(v0.fPointAngle),
+  fPdgCode(v0.fPdgCode),
+  fNidx(v0.fNidx),
+  fPidx(v0.fPidx),
+  fStatus(v0.fStatus),
+  fNBefore(v0.fNBefore),
+  fNAfter(v0.fNAfter),
+  fOnFlyStatus(v0.fOnFlyStatus)
 {
   //--------------------------------------------------------------------
   // The copy constructor
@@ -129,28 +128,29 @@ AliESDv0::AliESDv0(const AliESDv0& v0) :
   for (Int_t i=0;i<4;i++){fCausality[i]=v0.fCausality[i];}
 }
 
+
 AliESDv0::AliESDv0(const AliExternalTrackParam &t1, Int_t i1,
                    const AliExternalTrackParam &t2, Int_t i2) :
-  TObject(),
-  fOnFlyStatus(kFALSE),
-  fPdgCode(kK0Short),
+  AliVParticle(),
+  fParamN(t1),
+  fParamP(t2),
   fEffMass(TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass()),
   fDcaV0Daughters(0),
+  fChi2V0(0.),
+  fRr(0),
+  fDistSigma(0),
+  fChi2Before(0),
+  fChi2After(0),
+  fPointAngleFi(0),
+  fPointAngleTh(0),
   fPointAngle(0),
-  fChi2V0(31.),
+  fPdgCode(kK0Short),
   fNidx(i1),
-  fParamN(t1),
   fPidx(i2),
-  fParamP(t2),
-  fRr(-1),
   fStatus(0),
-  fDistSigma(0),
-  fChi2Before(0),
   fNBefore(0),
-  fChi2After(0),
   fNAfter(0),
-  fPointAngleFi(0),
-  fPointAngleTh(0)
+  fOnFlyStatus(kFALSE)
 {
   //--------------------------------------------------------------------
   // Main constructor  (K0s)
@@ -194,14 +194,146 @@ AliESDv0::AliESDv0(const AliExternalTrackParam &t1, Int_t i1,
   for (Int_t i=0;i<4;i++){fCausality[i]=0;}
 }
 
+AliESDv0& AliESDv0::operator=(const AliESDv0 &v0)
+{
+  //--------------------------------------------------------------------
+  // The assignment operator
+  //--------------------------------------------------------------------
+
+  if(this==&v0)return *this;
+  AliVParticle::operator=(v0);
+  fParamN  = v0.fParamN;
+  fParamP  = v0.fParamP;
+  fEffMass = v0.fEffMass;
+  fDcaV0Daughters = v0.fDcaV0Daughters;
+  fChi2V0 = v0.fChi2V0;
+  fRr = v0.fRr;
+  fDistSigma    = v0.fDistSigma;
+  fChi2Before   = v0.fChi2Before;
+  fChi2After    = v0.fChi2After;
+  fPointAngleFi = v0.fPointAngleFi;
+  fPointAngleTh = v0.fPointAngleTh;
+  fPointAngle   = v0.fPointAngle;
+  fPdgCode      = v0.fPdgCode;
+  fNidx         = v0.fNidx;
+  fPidx         = v0.fPidx;
+  fStatus       = v0.fStatus;
+  fNBefore      = v0.fNBefore;
+  fNAfter       = v0.fNAfter;
+  fOnFlyStatus  = v0.fOnFlyStatus;
+
+  for (int i=0; i<3; i++) {
+    fPos[i]  = v0.fPos[i];
+    fNmom[i] = v0.fNmom[i];
+    fPmom[i] = v0.fPmom[i];
+  }
+  for (int i=0; i<6; i++) {
+    fPosCov[i]  = v0.fPosCov[i];
+  }
+  for (Int_t i=0; i<2; i++) {
+    fNormDCAPrim[i]=v0.fNormDCAPrim[i];
+  }
+  for (Int_t i=0;i<6;i++){
+      fClusters[0][i]=v0.fClusters[0][i]; 
+      fClusters[1][i]=v0.fClusters[1][i];
+  }
+  for (Int_t i=0;i<3;i++){
+      fAngle[i]=v0.fAngle[i];
+  }
+  for (Int_t i=0;i<4;i++){fCausality[i]=v0.fCausality[i];}
+
+  return *this;
+}
+
+void AliESDv0::Copy(TObject& obj) const {
+
+  // this overwrites the virtual TOBject::Copy()
+  // to allow run time copying without casting
+  // in AliESDEvent
+
+  if(this==&obj)return;
+  AliESDv0 *robj = dynamic_cast<AliESDv0*>(&obj);
+  if(!robj)return; // not an aliesesv0
+  *robj = *this;
+}
+
 AliESDv0::~AliESDv0(){
   //--------------------------------------------------------------------
   // Empty destructor
   //--------------------------------------------------------------------
 }
 
+// Start with AliVParticle functions
+Double_t AliESDv0::E() const {
+  //--------------------------------------------------------------------
+  // This gives the energy assuming the ChangeMassHypothesis was called
+  //--------------------------------------------------------------------
+  return E(fPdgCode);
+}
 
+Double_t AliESDv0::Y() const {
+  //--------------------------------------------------------------------
+  // This gives the energy assuming the ChangeMassHypothesis was called
+  //--------------------------------------------------------------------
+  return Y(fPdgCode);
+}
 
+// Then extend AliVParticle functions
+Double_t AliESDv0::E(Int_t pdg) const {
+  //--------------------------------------------------------------------
+  // This gives the energy with the particle hypothesis as argument 
+  //--------------------------------------------------------------------
+  Double_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
+  return TMath::Sqrt(mass*mass+P()*P());
+}
+
+Double_t AliESDv0::Y(Int_t pdg) const {
+  //--------------------------------------------------------------------
+  // This gives the rapidity with the particle hypothesis as argument 
+  //--------------------------------------------------------------------
+  return 0.5*TMath::Log((E(pdg)+Pz())/(E(pdg)-Pz()+1.e-13));
+}
+
+// Now the functions for analysis consistency
+Double_t AliESDv0::RapK0Short() const {
+  //--------------------------------------------------------------------
+  // This gives the pseudorapidity assuming a K0s particle
+  //--------------------------------------------------------------------
+  return Y(kK0Short);
+}
+
+Double_t AliESDv0::RapLambda() const {
+  //--------------------------------------------------------------------
+  // This gives the pseudorapidity assuming a (Anti) Lambda particle
+  //--------------------------------------------------------------------
+  return Y(kLambda0);
+}
+
+Double_t AliESDv0::AlphaV0() const {
+  //--------------------------------------------------------------------
+  // This gives the Armenteros-Podolanski alpha
+  //--------------------------------------------------------------------
+  TVector3 momNeg(fNmom[0],fNmom[1],fNmom[2]);
+  TVector3 momPos(fPmom[0],fPmom[1],fPmom[2]);
+  TVector3 momTot(Px(),Py(),Pz());
+
+  Double_t lQlNeg = momNeg.Dot(momTot)/momTot.Mag();
+  Double_t lQlPos = momPos.Dot(momTot)/momTot.Mag();
+
+  return 1.-2./(1.+lQlNeg/lQlPos);
+}
+
+Double_t AliESDv0::PtArmV0() const {
+  //--------------------------------------------------------------------
+  // This gives the Armenteros-Podolanski ptarm
+  //--------------------------------------------------------------------
+  TVector3 momNeg(fNmom[0],fNmom[1],fNmom[2]);
+  TVector3 momTot(Px(),Py(),Pz());
+
+  return momNeg.Perp(momTot);
+}
+
+// Eventually the older functions
 Double_t AliESDv0::ChangeMassHypothesis(Int_t code) {
   //--------------------------------------------------------------------
   // This function changes the mass hypothesis for this V0
@@ -291,8 +423,7 @@ Float_t AliESDv0::GetD(Double_t x0, Double_t y0, Double_t z0) const {
   return d;
 }
 
-
-Float_t AliESDv0::GetV0CosineOfPointingAngle(Double_t& refPointX, Double_t& refPointY, Double_t& refPointZ) const {
+Float_t AliESDv0::GetV0CosineOfPointingAngle(Double_t refPointX, Double_t refPointY, Double_t refPointZ) const {
   // calculates the pointing angle of the V0 wrt a reference point
 
   Double_t momV0[3]; //momentum of the V0
@@ -507,7 +638,7 @@ Double_t AliESDv0::GetLikelihoodD(Int_t mode0, Int_t mode1){
 
 }
 
-Double_t AliESDv0::GetLikelihoodC(Int_t mode0, Int_t /*mode1*/){
+Double_t AliESDv0::GetLikelihoodC(Int_t mode0, Int_t /*mode1*/) const {
   //
   // get likelihood for Causality
   // !!!  Causality variables defined in AliITStrackerMI !!! 
@@ -542,7 +673,7 @@ void AliESDv0::SetCausality(Float_t pb0, Float_t pb1, Float_t pa0, Float_t pa1)
   fCausality[2] = pa0;     // probability - track 0 exist close after vertex
   fCausality[3] = pa1;     // probability - track 1 exist close after vertex
 }
-void  AliESDv0::SetClusters(Int_t *clp, Int_t *clm)
+void  AliESDv0::SetClusters(const Int_t *clp, const Int_t *clm)
 {
   //
   // Set its clusters indexes
@@ -550,3 +681,41 @@ void  AliESDv0::SetClusters(Int_t *clp, Int_t *clm)
   for (Int_t i=0;i<6;i++) fClusters[0][i] = clp[i]; 
   for (Int_t i=0;i<6;i++) fClusters[1][i] = clm[i]; 
 }
+
+Double_t AliESDv0::GetEffMass(UInt_t p1, UInt_t p2) const{
+  //
+  // calculate effective mass
+  //
+  const Float_t kpmass[5] = {TDatabasePDG::Instance()->GetParticle(kElectron)->Mass(),
+                            TDatabasePDG::Instance()->GetParticle(kMuonMinus)->Mass(),
+                            TDatabasePDG::Instance()->GetParticle(kPiPlus)->Mass(),
+                            TDatabasePDG::Instance()->GetParticle(kKPlus)->Mass(),
+                            TDatabasePDG::Instance()->GetParticle(kProton)->Mass()};
+  if (p1>4) return -1;
+  if (p2>4) return -1;
+  Float_t mass1 = kpmass[p1]; 
+  Float_t mass2 = kpmass[p2];   
+  const Double_t *m1 = fPmom;
+  const Double_t *m2 = fNmom;
+  //
+  //if (fRP[p1]+fRM[p2]<fRP[p2]+fRM[p1]){
+  //  m1 = fPM;
+  //  m2 = fPP;
+  //}
+  //
+  Float_t e1    = TMath::Sqrt(mass1*mass1+
+                              m1[0]*m1[0]+
+                              m1[1]*m1[1]+
+                              m1[2]*m1[2]);
+  Float_t e2    = TMath::Sqrt(mass2*mass2+
+                              m2[0]*m2[0]+
+                              m2[1]*m2[1]+
+                              m2[2]*m2[2]);  
+  Float_t mass =  
+    (m2[0]+m1[0])*(m2[0]+m1[0])+
+    (m2[1]+m1[1])*(m2[1]+m1[1])+
+    (m2[2]+m1[2])*(m2[2]+m1[2]);
+  
+  mass = TMath::Sqrt((e1+e2)*(e1+e2)-mass);
+  return mass;
+}