]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWG2/RESONANCES/AliRsnPairDef.cxx
Major upgrade to the package, in order to speed-up the execution and remove some...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairDef.cxx
index 42308e8f2bd9827e136e81b2f278c109633d7065..24d953082cc0ca4a02938eb585f36daa5c03e53c 100644 (file)
 //
 
 #include "AliLog.h"
-#include "AliRsnDaughter.h"
+#include "AliPID.h"
 #include "AliRsnPairDef.h"
 
 ClassImp(AliRsnPairDef)
 
 //_____________________________________________________________________________
-AliRsnPairDef::AliRsnPairDef() :
-  fMotherPDG(0)
+AliRsnPairDef::AliRsnPairDef() : fMotherMass(0.0), fMotherPDG(0)
 {
 //
 // Empty constructor.
@@ -28,17 +27,19 @@ AliRsnPairDef::AliRsnPairDef() :
 // must be defined before starting event processing.
 //
 
-    Int_t i;
-    for (i = 0; i < 2; i++) {
-        fCharge[i] = '0';
-        fMass[i] = 0.0;
-        fType[i] = AliRsnPID::kUnknown;
-    }
+  Int_t i;
+  for (i = 0; i < 2; i++) {
+    fCharge[i] = '0';
+    fMass[i] = 0.0;
+    fPID[i] = AliPID::kUnknown;
+    fDaughterType[i] = AliRsnDaughter::kTrack;
+  }
 }
 
 //_____________________________________________________________________________
 AliRsnPairDef::AliRsnPairDef
-(Char_t sign1, AliRsnPID::EType type1, Char_t sign2, AliRsnPID::EType type2, Int_t motherPDG) :
+(AliPID::EParticleType type1, Char_t sign1, AliPID::EParticleType type2, Char_t sign2, Int_t motherPDG, Double_t motherMass) :
+  fMotherMass(motherMass),
   fMotherPDG(motherPDG)
 {
 //
@@ -46,19 +47,21 @@ AliRsnPairDef::AliRsnPairDef
 // This constructor allows to define all the working parameters.
 //
 
-    SetPair(sign1, type1, sign2, type2);
+  SetDaughters(type1, sign1, type2, sign2);
 }
 
+
 //_____________________________________________________________________________
 AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef &copy) :
   TObject(copy),
+  fMotherMass(copy.fMotherMass),
   fMotherPDG(copy.fMotherPDG)
 {
 //
 // Copy constructor with standard behavior
 //
 
-    SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
+  SetDaughters(copy.fPID[0], copy.fCharge[0], copy.fPID[1], copy.fCharge[1]);
 }
 
 //_____________________________________________________________________________
@@ -68,63 +71,74 @@ const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef &copy)
 // Assignment operator with standard behavior.
 //
 
-    fMotherPDG = copy.fMotherPDG;
-    SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
+  fMotherMass = copy.fMotherMass;
+  fMotherPDG = copy.fMotherPDG;
+  SetDaughters(copy.fPID[0], copy.fCharge[0], copy.fPID[1], copy.fCharge[1]);
 
-    return (*this);
+  return (*this);
 }
 
 //_____________________________________________________________________________
-Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType type)
+Bool_t AliRsnPairDef::SetDaughter(Int_t i, AliPID::EParticleType type, Char_t charge)
 {
 //
 // Set one element of the pair
 // and returns warnings if the type is not valid.
 //
-    if (i < 0 || i > 1) {
-        AliError("Index out of range");
-        return kFALSE;
-    }
-    if (charge != '+' && charge != '-') {
-        AliError(Form("Character '%c' not recognized as charge sign"));
-        return kFALSE;
-    }
-    if (type < AliRsnPID::kElectron && type > AliRsnPID::kUnknown) {
-        AliError("Type index out of enumeration range");
-        return kFALSE;
-    }
-    fCharge[i] = charge;
-    fType[i] = type;
-    fMass[i] = AliRsnPID::ParticleMass(type);
-    return kTRUE;
+
+  AliPID pid;
+
+  if (i < 0 || i > 1) 
+  {
+    AliError("Index out of range");
+    return kFALSE;
+  }
+  if (charge != '+' && charge != '-' && charge != '0')
+  {
+    AliError(Form("Character '%c' not recognized as charge sign"));
+    return kFALSE;
+  }
+  if (type < 0 && type > (Int_t)AliPID::kSPECIESN) 
+  {
+    AliError("Type index out of enumeration range");
+    return kFALSE;
+  }
+  
+  fCharge[i] = charge;
+  fPID[i] = type;
+  fMass[i] = pid.ParticleMass(type);
+  if ((Int_t)type < AliPID::kSPECIES) fDaughterType[i] = AliRsnDaughter::kTrack;
+  else if (type == AliPID::kKaon0) 
+  {
+    fDaughterType[i] = AliRsnDaughter::kV0;
+    fCharge[i] = '0';
+  }
+  else return kFALSE;
+
+  return kTRUE;
 }
 
 //_____________________________________________________________________________
-Bool_t AliRsnPairDef::SetPair
-(Char_t charge1, AliRsnPID::EType type1, Char_t charge2, AliRsnPID::EType type2)
+Bool_t AliRsnPairDef::SetDaughters
+(AliPID::EParticleType type1, Char_t charge1, AliPID::EParticleType type2, Char_t charge2)
 {
 //
 // Set both elements of the pair,
 // returning logical AND of check for each one.
 //
+  Bool_t part1 = SetDaughter(0, type1, charge1);
+  Bool_t part2 = SetDaughter(1, type2, charge2);
 
-    Bool_t part1 = SetPairElement(0, charge1, type1);
-    Bool_t part2 = SetPairElement(1, charge2, type2);
-    return (part1 && part2);
+  return (part1 && part2);
 }
 
 //_____________________________________________________________________________
-Double_t AliRsnPairDef::ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1)
+const char* AliRsnPairDef::GetPairName() const
 {
 //
-// Compute a weight for filling the histograms:
-// probability of first track to be identified as 'type[0]' times
-// the probability of second track to be identified as 'type[1]',
-// according to the order of appearance in argument list.
+// Returns a compact string with the name of the pair,
+// to be used for naming objects related to it.
 //
 
-    Double_t prob0 = d0->PIDProb()[fType[0]];
-    Double_t prob1 = d1->PIDProb()[fType[1]];
-
-    return prob0*prob1;
+  return Form("%s%c%s%c", AliPID::ParticleShortName(fPID[0]), fCharge[0], AliPID::ParticleShortName(fPID[1]), fCharge[1]);
 }