]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PWGLF/RESONANCES/AliRsnDaughterDef.h
const correctness of the interaction map (L.Aphecetche)
[u/mrichter/AliRoot.git] / PWGLF / RESONANCES / AliRsnDaughterDef.h
... / ...
CommitLineData
1#ifndef ALIRSNDAUGHTERDEF_H
2#define ALIRSNDAUGHTERDEF_H
3
4//
5// Definition for a single candidate daughter.
6// They can be chosen among the following possibilities:
7//
8// -- particle species, chosen in the enum AliRsnDaughter::ESpecies;
9// this option does two things:
10// -- when possible (needs MC) and required, allow to check is a daughter
11// is of the defined species (e.g.: for selecting true daughters of a resonance)
12// -- defines the mass to be assigned to this object, for any purpose
13// (e.g.: to compute its 4-momentum to be used for a resonance mass)
14//
15// -- track charge, which can be '+', '-', '0',
16// -- any other char leaves this undefined (use only in daughter monitor loops)
17// -- when doing resonance analysis, or when RSN Input handler needs to be used,
18// this must always be defined
19//
20// -- object type (track/V0/cascade)
21// -- could be needed to select tracks when particle species is not specified
22// -- works only in single daughter loops
23//
24
25#include "AliRsnDaughter.h"
26
27class AliRsnDaughterDef : public TObject {
28public:
29
30 AliRsnDaughterDef();
31 AliRsnDaughterDef(EPARTYPE type, Char_t charge = 0);
32 AliRsnDaughterDef(AliRsnDaughter::ESpecies type, Char_t charge = 0);
33 AliRsnDaughterDef(AliRsnDaughter::ERefType refType, Char_t charge = 0);
34 AliRsnDaughterDef(const AliRsnDaughterDef &copy);
35 AliRsnDaughterDef &operator= (const AliRsnDaughterDef &copy);
36 virtual ~AliRsnDaughterDef() { }
37
38 AliRsnDaughter::ESpecies GetPID() const {return fPID;}
39 Double_t GetMass() const {return fMass;}
40 Char_t GetChargeC() const {return fCharge;}
41 Short_t GetChargeS() const {if (fCharge == '+') return 1; else if (fCharge == '-') return -1; else return 0;}
42 AliRsnDaughter::ERefType GetRefType() const {return fRefType;}
43 virtual const char *GetName() const {return Form("%s%c", AliRsnDaughter::SpeciesName(fPID), fCharge);}
44 Bool_t IsChargeDefined() const {return (fCharge == '+' || fCharge == '-' || fCharge == '0');}
45
46 void SetPID(AliRsnDaughter::ESpecies pid) {fPID = pid; fRefType = AliRsnDaughter::RefType(pid); fMass = AliRsnDaughter::SpeciesMass(pid);}
47 void SetCharge(Char_t charge) {fCharge = charge;}
48 void SetRefType(AliRsnDaughter::ERefType type) {fRefType = type;}
49
50 Bool_t MatchesPID(AliRsnDaughter *daughter);
51 Bool_t MatchesCharge(AliRsnDaughter *daughter) const;
52 Bool_t MatchesRefType(AliRsnDaughter *daughter) const;
53 Bool_t MatchesPDG(Int_t pdgCode) {return (AliRsnDaughter::SpeciesPDG(fPID) == pdgCode);}
54 Bool_t MatchesChargeS(Short_t charge) const {return (GetChargeS() == charge);}
55 Bool_t MatchesChargeC(Char_t charge) const {return (GetChargeC() == charge);}
56
57private:
58
59 AliRsnDaughter::ESpecies fPID; // PID of particles
60 Double_t fMass; // mass of particles (subordinate to fPID)
61 Char_t fCharge; // charge of particles
62 AliRsnDaughter::ERefType fRefType; // object reference type (track/V0/cascade)
63
64 // ROOT dictionary
65 ClassDef(AliRsnDaughterDef, 1)
66};
67
68//__________________________________________________________________________________________________
69inline Bool_t AliRsnDaughterDef::MatchesPID(AliRsnDaughter *daughter)
70{
71//
72// Checks if the passed daughter true particle type
73// matches the species defined in fPID data member,
74// by comparing the corresponding PDG codes of both in absolute value.
75// Returns kTRUE when the two codes match, and kFALSE when:
76// -- PDG codes don't match
77// -- fPID is not set to a well-defined species (AliRsnDaughter::kUnknown)
78// -- passed daughter has not MC information
79//
80 if (fPID == AliRsnDaughter::kUnknown) {
81 AliError("This DaughterDef has undefined species: cannot check PDG matching with passed arg");
82 return kFALSE;
83 } else if (!daughter->GetRefMC()) {
84 AliError("The passed argument has NULL MC pointer: cannot check PDG matching with this DaughterDef");
85 return kFALSE;
86 }
87
88 return MatchesPDG(daughter->GetPDGAbs());
89}
90
91//__________________________________________________________________________________________________
92inline Bool_t AliRsnDaughterDef::MatchesCharge(AliRsnDaughter *daughter) const
93{
94//
95// Checks if the passed daughter charge matches that defined in fCharge data member.
96// If fCharge is not initialized to '+', '-' or '0', that is interpreted as if the user
97// does not want to select in charge, and then the function returns always kTRUE.
98//
99
100 switch (fCharge) {
101 case '+': return daughter->IsPos();
102 case '-': return daughter->IsNeg();
103 case '0': return daughter->IsNeutral();
104 default : return kTRUE;
105 }
106}
107
108//__________________________________________________________________________________________________
109inline Bool_t AliRsnDaughterDef::MatchesRefType(AliRsnDaughter *daughter) const
110{
111//
112// Checks that the daughter object type matches that defined in fRefType data member.
113// If fRefType is initialized to AliRsnDaughter::kNoType, that is interpreted as if the user
114// does not want to select in type and then the function returns always kTRUE.
115//
116
117 AliRsnDaughter::ERefType type = daughter->RefType();
118
119 if (fRefType != AliRsnDaughter::kNoType)
120 return (type == fRefType);
121 else
122 return kTRUE;
123}
124
125#endif