]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnDaughter.cxx
Several updates from the validation phase of the Fast Or DA (A. Mastroserio)
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.cxx
index bbe48e5835ea0fe3600c4db04d589fa59e583e10..36112a0686d9460cb64387422a8df3547274d900 100644 (file)
@@ -1,14 +1,12 @@
 //
 // Class AliRsnDaughter
 //
+// Light-weight AOD object which contains all required track details
+// which are used for resonance analysis.
+// Provides converters from all kinds of input track type: ESD, AOD and MC.
 //
-// Light-weight 'track' object into an internal format used
-// for further steps of resonance analysis.
-// Provides converters from all kinds of input track type
-// (ESD, AOD and MC).
-// Contains also a facility to compute invariant mass of a pair.
-//
-// author: A. Pulvirenti --- email: alberto.pulvirenti@ct.infn.it
+// authors: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
+//          M. Vala (martin.vala@cern.ch)
 //
 
 #include <Riostream.h>
 #include "AliAODTrack.h"
 #include "AliMCParticle.h"
 
+#include "AliRsnPIDDefESD.h"
 #include "AliRsnMCInfo.h"
 #include "AliRsnDaughter.h"
 
 ClassImp(AliRsnDaughter)
 
-AliRsnDaughter::EPIDMethod AliRsnDaughter::fgPIDMethod = AliRsnDaughter::kNoPID;
+AliRsnDaughter::EPIDMethod AliRsnDaughter::fgPIDMethod = AliRsnDaughter::kRealistic;
 
 //_____________________________________________________________________________
 AliRsnDaughter::AliRsnDaughter() :
-    AliVParticle(),
-    fIndex(-1),
-    fLabel(-1),
-    fCharge(0),
-    fFlags(0),
-    fMass(0.0),
-    fRealisticPID(AliRsnPID::kUnknown),
-    fMCInfo(0x0)
+  AliVParticle(),
+  fIndex(-1),
+  fLabel(-1),
+  fCharge(0),
+  fFlags(0),
+  fKink(0),
+  fMass(0.0),
+  fChi2(0.0),
+  fNSigmaToVertex(-1.0),
+  fITSnum(0),
+  fTPCnum(0),
+  fRealisticPID(AliRsnPID::kUnknown),
+  fMCInfo(0x0)
 {
 //
 // Default constructor.
@@ -59,14 +63,19 @@ AliRsnDaughter::AliRsnDaughter() :
 
 //_____________________________________________________________________________
 AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) :
-    AliVParticle(copy),
-    fIndex(copy.fIndex),
-    fLabel(copy.fLabel),
-    fCharge(copy.fCharge),
-    fFlags(copy.fFlags),
-    fMass(copy.fMass),
-    fRealisticPID(copy.fRealisticPID),
-    fMCInfo(0x0)
+  AliVParticle(copy),
+  fIndex(copy.fIndex),
+  fLabel(copy.fLabel),
+  fCharge(copy.fCharge),
+  fFlags(copy.fFlags),
+  fKink(copy.fKink),
+  fMass(copy.fMass),
+  fChi2(copy.fChi2),
+  fNSigmaToVertex(copy.fNSigmaToVertex),
+  fITSnum(copy.fITSnum),
+  fTPCnum(copy.fTPCnum),
+  fRealisticPID(copy.fRealisticPID),
+  fMCInfo(0x0)
 {
 //
 // Copy constructor.
@@ -89,66 +98,6 @@ AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) :
   if (copy.fMCInfo) fMCInfo = new AliRsnMCInfo(*(copy.fMCInfo));
 }
 
-//_____________________________________________________________________________
-AliRsnDaughter::AliRsnDaughter(AliESDtrack *track, Bool_t useTPC) :
-    AliVParticle(),
-    fIndex(-1),
-    fLabel(-1),
-    fCharge(0),
-    fFlags(0),
-    fMass(0.0),
-    fRealisticPID(AliRsnPID::kUnknown),
-    fMCInfo(0x0)
-{
-//
-// Constructor to get data from an ESD track.
-//
-
-  Int_t i;
-  for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
-  Adopt(track, kEsd,0.0,useTPC);
-}
-
-//_____________________________________________________________________________
-AliRsnDaughter::AliRsnDaughter(AliAODTrack *track) :
-    AliVParticle(),
-    fIndex(-1),
-    fLabel(-1),
-    fCharge(0),
-    fFlags(0),
-    fMass(0.0),
-    fRealisticPID(AliRsnPID::kUnknown),
-    fMCInfo(0x0)
-{
-//
-// Constructor to get data from an AOD track.
-//
-
-  Int_t i;
-  for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
-  Adopt(track);
-}
-
-//_____________________________________________________________________________
-AliRsnDaughter::AliRsnDaughter(AliMCParticle *track) :
-    AliVParticle(),
-    fIndex(-1),
-    fLabel(-1),
-    fCharge(0),
-    fFlags(0),
-    fMass(0.0),
-    fRealisticPID(AliRsnPID::kUnknown),
-    fMCInfo(0x0)
-{
-//
-// Constructor to get data from an MC track.
-//
-
-  Int_t i;
-  for (i = 0; i < AliRsnPID::kSpecies; i++) fPIDProb[i] = 0.0;
-  Adopt(track);
-}
-
 //_____________________________________________________________________________
 AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter &copy)
 {
@@ -162,6 +111,11 @@ AliRsnDaughter& AliRsnDaughter::operator=(const AliRsnDaughter &copy)
   fLabel  = copy.fLabel;
   fCharge = copy.fCharge;
   fFlags  = copy.fFlags;
+  fKink   = copy.fKink;
+  fChi2   = copy.fChi2;
+  fNSigmaToVertex = copy.fNSigmaToVertex;
+  fITSnum = copy.fITSnum;
+  fTPCnum = copy.fTPCnum;
 
   Int_t i;
   for (i = 0; i < AliRsnPID::kSpecies; i++)
@@ -206,17 +160,42 @@ AliRsnDaughter::~AliRsnDaughter()
 }
 
 //_____________________________________________________________________________
-void AliRsnDaughter::SetPIDWeight(Int_t i, Double_t value)
+void AliRsnDaughter::RotateP(Double_t angle, Bool_t isDegrees)
 {
 //
-// I the argument 'i' is in the correct range,
-// sets the i-th PID weight to 'value'
+// Rotate the transverse momentum by an angle (in DEGREES)
+// around Z axis (does not change the Z component)
 //
 
-  if (i >= 0 && i < AliRsnPID::kSpecies) fPIDWeight[i] = value;
-  else
-  {
-    AliError(Form("Cannot set a weight related to slot %d", i));
+  if (isDegrees) angle *= TMath::DegToRad();
+
+  Double_t s = TMath::Sin(angle);
+  Double_t c = TMath::Cos(angle);
+  Double_t xx = fP[0];
+  fP[0] = c*xx - s*fP[1];
+  fP[1] = s*xx + c*fP[1];
+}
+
+//_____________________________________________________________________________
+Double_t AliRsnDaughter::AngleTo(AliRsnDaughter *d, Bool_t outInDegrees)
+{
+//
+// Compute angle between the vector momentum of this
+// and the one of argument.
+//
+
+  Double_t arg, dot, ptot2 = P2() * d->P2();
+
+  if(ptot2 <= 0) {
+    return 0.0;
+  }
+  else {
+    dot = Px()*d->Px() + Py()*d->Py() + Pz()*d->Pz();
+    arg = dot / TMath::Sqrt(ptot2);
+    if (arg >  1.0) arg =  1.0;
+    if (arg < -1.0) arg = -1.0;
+    if (outInDegrees) return TMath::ACos(arg) * TMath::RadToDeg();
+    else return TMath::ACos(arg);
   }
 }
 
@@ -256,12 +235,14 @@ AliRsnPID::EType AliRsnDaughter::PIDType(Double_t &prob) const
   {
     case kNoPID:
       AliWarning("Requested a PIDtype call in NoPID mode");
+      prob = 1.0;
       return AliRsnPID::kUnknown;
     case kPerfect:
+      prob = 1.0;
       if (fMCInfo) return AliRsnPID::InternalType(fMCInfo->PDG());
       else return AliRsnPID::kUnknown;
     default:
-      if (fRealisticPID > 0 && fRealisticPID < AliRsnPID::kSpecies)
+      if (fRealisticPID >= 0 && fRealisticPID < AliRsnPID::kSpecies)
       {
         prob = fPIDProb[fRealisticPID];
         return fRealisticPID;
@@ -274,181 +255,6 @@ AliRsnPID::EType AliRsnDaughter::PIDType(Double_t &prob) const
   }
 }
 
-//_____________________________________________________________________________
-void AliRsnDaughter::SetPIDProb(Int_t i, Double_t value)
-{
-//
-// I the argument 'i' is in the correct range,
-// sets the i-th PID probability to 'value'
-//
-
-  if (i >= 0 && i < AliRsnPID::kSpecies) fPIDProb[i] = value;
-  else
-  {
-    AliError(Form("Cannot set a weight related to slot %d", i));
-  }
-}
-
-//_____________________________________________________________________________
-Bool_t AliRsnDaughter::Adopt(AliESDtrack* esdTrack,EPIDType pidType ,Double_t divValue, Bool_t useTPCInnerParam)
-{
-//
-// Copies data from an AliESDtrack into "this":
-//  - charge sign
-//  - momentum
-//  - point of closest approach to primary vertex
-//  - ESD pid weights
-// In case of errors returns kFALSE, otherwise kTRUE.
-//
-
-  if (!esdTrack)
-  {
-    AliError("Passed NULL object: nothing done");
-    return kFALSE;
-  }
-
-  // copy momentum and vertex
-  if (!useTPCInnerParam)
-  {
-    esdTrack->GetPxPyPz(fP);
-    esdTrack->GetXYZ(fV);
-  }
-  else
-  {
-    if (!esdTrack->GetTPCInnerParam()) return kFALSE;
-    esdTrack->GetTPCInnerParam()->GetPxPyPz(fP);
-    esdTrack->GetTPCInnerParam()->GetXYZ(fV);
-  }
-
-  Double_t p = esdTrack->P();
-  // copy PID weights
-  Int_t    i;
-  Double_t pid[5];
-  if (!useTPCInnerParam)
-  {
-    GetESDPID(esdTrack,pid,pidType,divValue,p);
-  }
-  else
-  {
-//     fCurrentESDPID = kTPC;
-    GetESDPID(esdTrack,pid,kTPC,0.0,p);
-  }
-  for (i = 0; i < 5; i++) fPIDWeight[i] = pid[i];
-
-  // copy flags
-  fFlags = esdTrack->GetStatus();
-
-  // copy charge sign
-  fCharge = (Short_t)esdTrack->Charge();
-
-  return kTRUE;
-}
-
-
-//_____________________________________________________________________________
-Bool_t AliRsnDaughter::Adopt(AliAODTrack* aodTrack)
-{
-//
-// Copies data from an AliAODtrack into "this":
-//  - charge sign
-//  - momentum
-//  - point of closest approach to primary vertex
-//  - ESD pid weights
-// In case of errors returns kFALSE, otherwise kTRUE.
-//
-
-  if (!aodTrack)
-  {
-    AliError("Passed NULL object: nothing done");
-    return kFALSE;
-  }
-
-  // copy momentum  and vertex
-  fP[0] = aodTrack->Px();
-  fP[1] = aodTrack->Py();
-  fP[2] = aodTrack->Pz();
-  fV[0] = aodTrack->Xv();
-  fV[1] = aodTrack->Yv();
-  fV[2] = aodTrack->Zv();
-
-  // copy PID weights
-  Int_t i;
-  for (i = 0; i < 5; i++) fPIDWeight[i] = aodTrack->PID()[i];
-
-  // copy flags
-  fFlags = aodTrack->GetStatus();
-
-  // copy sign
-  fCharge = aodTrack->Charge();
-
-  return kTRUE;
-}
-
-
-//_____________________________________________________________________________
-Bool_t AliRsnDaughter::Adopt(AliMCParticle *mcParticle)
-{
-//
-// Copies data from a MCParticle into "this":
-//  - charge sign
-//  - momentum
-//  - point of closest approach to primary vertex
-//  - ESD pid weights
-//  - true PDG code
-//  - mother
-// In case of errors returns kFALSE, otherwise kTRUE.
-//
-
-  if (!mcParticle)
-  {
-    AliError("Passed NULL object: nothing done");
-    return kFALSE;
-  }
-
-  // retrieve the TParticle object from the argument
-  TParticle *particle = mcParticle->Particle();
-  if (!particle)
-  {
-    AliError("AliMCParticle::Particle() returned NULL");
-    return kFALSE;
-  }
-
-  // copy momentum  and vertex
-  fP[0] = particle->Px();
-  fP[1] = particle->Py();
-  fP[2] = particle->Pz();
-  fV[0] = particle->Vx();
-  fV[1] = particle->Vy();
-  fV[2] = particle->Vz();
-
-  // recognize charge sign from PDG code sign
-  Int_t pdg = particle->GetPdgCode();
-  Int_t absPDG = TMath::Abs(pdg);
-  if (absPDG <= 15)
-  {
-    if (pdg > 0) fCharge = -1; else fCharge = 1;
-  }
-  else if (absPDG < 3000)
-  {
-    if (pdg > 0) fCharge = 1; else fCharge = -1;
-  }
-  else
-  {
-    fCharge = 0;
-    return kFALSE;
-  }
-
-  // flags and PID weights make no sense with MC tracks
-  fFlags = 0;
-  for (pdg = 0; pdg < AliRsnPID::kSpecies; pdg++) fPIDWeight[pdg] = 0.0;
-  fPIDWeight[AliRsnPID::InternalType(absPDG)] = 1.0;
-
-  // copy other MC info (mother PDG code cannot be retrieved here)
-  InitMCInfo(particle);
-
-  return kTRUE;
-}
-
 //_____________________________________________________________________________
 void AliRsnDaughter::Print(Option_t *option) const
 {
@@ -462,6 +268,7 @@ void AliRsnDaughter::Print(Option_t *option) const
 // - W --> PID weights
 // - M --> Montecarlo (from AliRsnMCInfo)
 // - L --> index & label
+// - A --> angles
 // - ALL --> All oprions switched on
 //
 // Index and label are printed by default.
@@ -479,6 +286,10 @@ void AliRsnDaughter::Print(Option_t *option) const
   {
     cout << ".......Px, Py, Pz, Pt   : " << Px() << ' ' << Py() << ' ' << Pz() << ' ' << Pt() << endl;
   }
+  if (opt.Contains("A") || opt.Contains("ALL"))
+  {
+    cout << ".......Phi, Theta       : " << Phi() << ' ' << Theta() << endl;
+  }
   if (opt.Contains("V") || opt.Contains("ALL"))
   {
     cout << ".......Vx, Vy, Vz       : " << Xv() << ' ' << Yv() << ' ' << Zv() << endl;
@@ -558,24 +369,6 @@ Bool_t AliRsnDaughter::InitMCInfo(TParticle *particle)
   return kTRUE;
 }
 
-//_____________________________________________________________________________
-Bool_t AliRsnDaughter::InitMCInfo(AliMCParticle *mcParticle)
-{
-//
-// Copies data from an MC particle into the object which
-// contains all MC details taken from kinematics info.
-// If requested by second argument, momentum and vertex
-// of the Particle are copied into the 'fP' and 'fV'
-// data members, to simulate a perfect reconstruction.
-// If something goes wrong, returns kFALSE,
-// otherwise returns kTRUE.
-//
-
-  // retrieve the TParticle object pointed by this MC track
-  TParticle *particle = mcParticle->Particle();
-  return InitMCInfo(particle);
-}
-
 //_____________________________________________________________________________
 Int_t AliRsnDaughter::Compare(const TObject* obj) const
 {
@@ -591,67 +384,3 @@ Int_t AliRsnDaughter::Compare(const TObject* obj) const
   else if (Pt() > that->Pt()) return -1;
   else return 0;
 }
-
-//_____________________________________________________________________________
-void AliRsnDaughter::GetESDPID(AliESDtrack * track, Double_t * pid,EPIDType pidType, Double_t divValue, Double_t val)
-{
-//
-// return PID from EPIDType type
-//
-
-  Double_t ctmp[AliRsnPID::kSpecies];
-  switch (pidType)
-  {
-    case kEsd :
-      track->GetESDpid(pid);
-      break;
-    case kITS :
-      track->GetITSpid(pid);
-      break;
-    case kTPC :
-      track->GetTPCpid(pid);
-      break;
-    case kTOF :
-      track->GetTOFpid(pid);
-      break;
-    case kITS_TPC :
-      track->GetITSpid(pid);
-      track->GetTPCpid(ctmp);
-      for (Int_t i=0;i<5;i++) pid[i]*=ctmp[i];
-      break;
-    case kITS_TOF :
-      track->GetITSpid(pid);
-      track->GetTOFpid(ctmp);
-      for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
-      break;
-    case kTPC_TOF :
-      track->GetTPCpid(pid);
-      track->GetTOFpid(ctmp);
-      for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
-      break;
-    case kITS_TPC_TOF :
-      track->GetITSpid(pid);
-      track->GetTPCpid(ctmp);
-      for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
-      track->GetTOFpid(ctmp);
-      for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
-      break;
-    case kITS_TPC_TOF_SP :
-      if (val<divValue)
-      {
-        track->GetITSpid(pid);
-        track->GetTPCpid(ctmp);
-        for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]*=ctmp[i];
-      }
-      else
-      {
-        track->GetTOFpid(pid);
-      }
-      break;
-    default:
-//       AliWarning("Unrecognized value of EPIDType argument");
-      for (Int_t i=0;i<AliRsnPID::kSpecies;i++) pid[i]=1.0;
-      break;
-  }
-}
-