ROOT logo
#ifndef ALIRSNDAUGHTERDEF_H
#define ALIRSNDAUGHTERDEF_H

//
//  Definition for a single candidate daughter.
//  They can be chosen among the following possibilities:
//
//  -- particle species, chosen in the enum AliRsnDaughter::ESpecies;
//     this option does two things:
//     -- when possible (needs MC) and required, allow to check is a daughter
//        is of the defined species (e.g.: for selecting true daughters of a resonance)
//     -- defines the mass to be assigned to this object, for any purpose
//        (e.g.: to compute its 4-momentum to be used for a resonance mass)
//
//  -- track charge, which can be '+', '-', '0',
//     -- any other char leaves this undefined (use only in daughter monitor loops)
//     -- when doing resonance analysis, or when RSN Input handler needs to be used,
//        this must always be defined
//
//  -- object type (track/V0/cascade)
//     -- could be needed to select tracks when particle species is not specified
//     -- works only in single daughter loops
//

#include "AliRsnDaughter.h"

class AliRsnDaughterDef : public TObject {
public:

   AliRsnDaughterDef();
   AliRsnDaughterDef(EPARTYPE type, Char_t charge = 0);
   AliRsnDaughterDef(AliRsnDaughter::ESpecies type, Char_t charge = 0);
   AliRsnDaughterDef(AliRsnDaughter::ERefType refType, Char_t charge = 0);
   AliRsnDaughterDef(const AliRsnDaughterDef &copy);
   AliRsnDaughterDef &operator= (const AliRsnDaughterDef &copy);
   virtual ~AliRsnDaughterDef() { }

   AliRsnDaughter::ESpecies GetPID()          const {return fPID;}
   Double_t                 GetMass()         const {return fMass;}
   Char_t                   GetChargeC()      const {return fCharge;}
   Short_t                  GetChargeS()      const {if (fCharge == '+') return 1; else if (fCharge == '-') return -1; else return 0;}
   AliRsnDaughter::ERefType GetRefType()      const {return fRefType;}
   virtual const char      *GetName()         const {return Form("%s%c", AliRsnDaughter::SpeciesName(fPID), fCharge);}
   Bool_t                   IsChargeDefined() const {return (fCharge == '+' || fCharge == '-' || fCharge == '0');}

   void SetPID(AliRsnDaughter::ESpecies pid)      {fPID = pid; fRefType = AliRsnDaughter::RefType(pid); fMass = AliRsnDaughter::SpeciesMass(pid);}
   void SetCharge(Char_t charge)                  {fCharge = charge;}
   void SetRefType(AliRsnDaughter::ERefType type) {fRefType = type;}

   Bool_t MatchesPID(AliRsnDaughter *daughter);
   Bool_t MatchesCharge(AliRsnDaughter *daughter)  const;
   Bool_t MatchesRefType(AliRsnDaughter *daughter) const;
   Bool_t MatchesPDG(Int_t pdgCode)                  {return (AliRsnDaughter::SpeciesPDG(fPID) == pdgCode);}
   Bool_t MatchesChargeS(Short_t charge) const       {return (GetChargeS() == charge);}
   Bool_t MatchesChargeC(Char_t charge)  const       {return (GetChargeC() == charge);}

private:

   AliRsnDaughter::ESpecies  fPID;      // PID of particles
   Double_t                  fMass;     // mass of particles (subordinate to fPID)
   Char_t                    fCharge;   // charge of particles
   AliRsnDaughter::ERefType  fRefType;  // object reference type (track/V0/cascade)

   // ROOT dictionary
   ClassDef(AliRsnDaughterDef, 1)
};

//__________________________________________________________________________________________________
inline Bool_t AliRsnDaughterDef::MatchesPID(AliRsnDaughter *daughter)
{
//
// Checks if the passed daughter true particle type
// matches the species defined in fPID data member,
// by comparing the corresponding PDG codes of both in absolute value.
// Returns kTRUE when the two codes match, and kFALSE when:
// -- PDG codes don't match
// -- fPID is not set to a well-defined species (AliRsnDaughter::kUnknown)
// -- passed daughter has not MC information
//
   if (fPID == AliRsnDaughter::kUnknown) {
      AliError("This DaughterDef has undefined species: cannot check PDG matching with passed arg");
      return kFALSE;
   } else if (!daughter->GetRefMC()) {
      AliError("The passed argument has NULL MC pointer: cannot check PDG matching with this DaughterDef");
      return kFALSE;
   }

   return MatchesPDG(daughter->GetPDGAbs());
}

//__________________________________________________________________________________________________
inline Bool_t AliRsnDaughterDef::MatchesCharge(AliRsnDaughter *daughter) const
{
//
// Checks if the passed daughter charge matches that defined in fCharge data member.
// If fCharge is not initialized to '+', '-' or '0', that is interpreted as if the user
// does not want to select in charge, and then the function returns always kTRUE.
//

   switch (fCharge) {
      case '+': return daughter->IsPos();
      case '-': return daughter->IsNeg();
      case '0': return daughter->IsNeutral();
      default : return kTRUE;
   }
}

//__________________________________________________________________________________________________
inline Bool_t AliRsnDaughterDef::MatchesRefType(AliRsnDaughter *daughter) const
{
//
// Checks that the daughter object type matches that defined in fRefType data member.
// If fRefType is initialized to AliRsnDaughter::kNoType, that is interpreted as if the user
// does not want to select in type and then the function returns always kTRUE.
//

   AliRsnDaughter::ERefType type = daughter->RefType();

   if (fRefType != AliRsnDaughter::kNoType)
      return (type == fRefType);
   else
      return kTRUE;
}

#endif
 AliRsnDaughterDef.h:1
 AliRsnDaughterDef.h:2
 AliRsnDaughterDef.h:3
 AliRsnDaughterDef.h:4
 AliRsnDaughterDef.h:5
 AliRsnDaughterDef.h:6
 AliRsnDaughterDef.h:7
 AliRsnDaughterDef.h:8
 AliRsnDaughterDef.h:9
 AliRsnDaughterDef.h:10
 AliRsnDaughterDef.h:11
 AliRsnDaughterDef.h:12
 AliRsnDaughterDef.h:13
 AliRsnDaughterDef.h:14
 AliRsnDaughterDef.h:15
 AliRsnDaughterDef.h:16
 AliRsnDaughterDef.h:17
 AliRsnDaughterDef.h:18
 AliRsnDaughterDef.h:19
 AliRsnDaughterDef.h:20
 AliRsnDaughterDef.h:21
 AliRsnDaughterDef.h:22
 AliRsnDaughterDef.h:23
 AliRsnDaughterDef.h:24
 AliRsnDaughterDef.h:25
 AliRsnDaughterDef.h:26
 AliRsnDaughterDef.h:27
 AliRsnDaughterDef.h:28
 AliRsnDaughterDef.h:29
 AliRsnDaughterDef.h:30
 AliRsnDaughterDef.h:31
 AliRsnDaughterDef.h:32
 AliRsnDaughterDef.h:33
 AliRsnDaughterDef.h:34
 AliRsnDaughterDef.h:35
 AliRsnDaughterDef.h:36
 AliRsnDaughterDef.h:37
 AliRsnDaughterDef.h:38
 AliRsnDaughterDef.h:39
 AliRsnDaughterDef.h:40
 AliRsnDaughterDef.h:41
 AliRsnDaughterDef.h:42
 AliRsnDaughterDef.h:43
 AliRsnDaughterDef.h:44
 AliRsnDaughterDef.h:45
 AliRsnDaughterDef.h:46
 AliRsnDaughterDef.h:47
 AliRsnDaughterDef.h:48
 AliRsnDaughterDef.h:49
 AliRsnDaughterDef.h:50
 AliRsnDaughterDef.h:51
 AliRsnDaughterDef.h:52
 AliRsnDaughterDef.h:53
 AliRsnDaughterDef.h:54
 AliRsnDaughterDef.h:55
 AliRsnDaughterDef.h:56
 AliRsnDaughterDef.h:57
 AliRsnDaughterDef.h:58
 AliRsnDaughterDef.h:59
 AliRsnDaughterDef.h:60
 AliRsnDaughterDef.h:61
 AliRsnDaughterDef.h:62
 AliRsnDaughterDef.h:63
 AliRsnDaughterDef.h:64
 AliRsnDaughterDef.h:65
 AliRsnDaughterDef.h:66
 AliRsnDaughterDef.h:67
 AliRsnDaughterDef.h:68
 AliRsnDaughterDef.h:69
 AliRsnDaughterDef.h:70
 AliRsnDaughterDef.h:71
 AliRsnDaughterDef.h:72
 AliRsnDaughterDef.h:73
 AliRsnDaughterDef.h:74
 AliRsnDaughterDef.h:75
 AliRsnDaughterDef.h:76
 AliRsnDaughterDef.h:77
 AliRsnDaughterDef.h:78
 AliRsnDaughterDef.h:79
 AliRsnDaughterDef.h:80
 AliRsnDaughterDef.h:81
 AliRsnDaughterDef.h:82
 AliRsnDaughterDef.h:83
 AliRsnDaughterDef.h:84
 AliRsnDaughterDef.h:85
 AliRsnDaughterDef.h:86
 AliRsnDaughterDef.h:87
 AliRsnDaughterDef.h:88
 AliRsnDaughterDef.h:89
 AliRsnDaughterDef.h:90
 AliRsnDaughterDef.h:91
 AliRsnDaughterDef.h:92
 AliRsnDaughterDef.h:93
 AliRsnDaughterDef.h:94
 AliRsnDaughterDef.h:95
 AliRsnDaughterDef.h:96
 AliRsnDaughterDef.h:97
 AliRsnDaughterDef.h:98
 AliRsnDaughterDef.h:99
 AliRsnDaughterDef.h:100
 AliRsnDaughterDef.h:101
 AliRsnDaughterDef.h:102
 AliRsnDaughterDef.h:103
 AliRsnDaughterDef.h:104
 AliRsnDaughterDef.h:105
 AliRsnDaughterDef.h:106
 AliRsnDaughterDef.h:107
 AliRsnDaughterDef.h:108
 AliRsnDaughterDef.h:109
 AliRsnDaughterDef.h:110
 AliRsnDaughterDef.h:111
 AliRsnDaughterDef.h:112
 AliRsnDaughterDef.h:113
 AliRsnDaughterDef.h:114
 AliRsnDaughterDef.h:115
 AliRsnDaughterDef.h:116
 AliRsnDaughterDef.h:117
 AliRsnDaughterDef.h:118
 AliRsnDaughterDef.h:119
 AliRsnDaughterDef.h:120
 AliRsnDaughterDef.h:121
 AliRsnDaughterDef.h:122
 AliRsnDaughterDef.h:123
 AliRsnDaughterDef.h:124
 AliRsnDaughterDef.h:125