]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnPairDef.cxx
42308e8f2bd9827e136e81b2f278c109633d7065
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnPairDef.cxx
1 //
2 // Class AliRsnPairDef
3 //
4 // Defines a decay channel for a resonance,
5 // resulting in a specified PDG code for the mother,
6 // and the particle type for the daughters, defined
7 // according to the internal PID format of the package
8 //
9 // author: A. Pulvirenti (alberto.pulvirenti@ct.infn.it)
10 //
11
12 #include "AliLog.h"
13 #include "AliRsnDaughter.h"
14 #include "AliRsnPairDef.h"
15
16 ClassImp(AliRsnPairDef)
17
18 //_____________________________________________________________________________
19 AliRsnPairDef::AliRsnPairDef() :
20   fMotherPDG(0)
21 {
22 //
23 // Empty constructor.
24 // Initializes the data members to default values:
25 //  - no definition of particles in the pair;
26 //  - histogram binning undefined.
27 // When using this constructor, all analysis elements (particles, histogram)
28 // must be defined before starting event processing.
29 //
30
31     Int_t i;
32     for (i = 0; i < 2; i++) {
33         fCharge[i] = '0';
34         fMass[i] = 0.0;
35         fType[i] = AliRsnPID::kUnknown;
36     }
37 }
38
39 //_____________________________________________________________________________
40 AliRsnPairDef::AliRsnPairDef
41 (Char_t sign1, AliRsnPID::EType type1, Char_t sign2, AliRsnPID::EType type2, Int_t motherPDG) :
42   fMotherPDG(motherPDG)
43 {
44 //
45 // Constructor with arguments.
46 // This constructor allows to define all the working parameters.
47 //
48
49     SetPair(sign1, type1, sign2, type2);
50 }
51
52 //_____________________________________________________________________________
53 AliRsnPairDef::AliRsnPairDef(const AliRsnPairDef &copy) :
54   TObject(copy),
55   fMotherPDG(copy.fMotherPDG)
56 {
57 //
58 // Copy constructor with standard behavior
59 //
60
61     SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
62 }
63
64 //_____________________________________________________________________________
65 const AliRsnPairDef& AliRsnPairDef::operator=(const AliRsnPairDef &copy)
66 {
67 //
68 // Assignment operator with standard behavior.
69 //
70
71     fMotherPDG = copy.fMotherPDG;
72     SetPair(copy.fCharge[0], copy.fType[0], copy.fCharge[1], copy.fType[1]);
73
74     return (*this);
75 }
76
77 //_____________________________________________________________________________
78 Bool_t AliRsnPairDef::SetPairElement(Int_t i, Char_t charge, AliRsnPID::EType type)
79 {
80 //
81 // Set one element of the pair
82 // and returns warnings if the type is not valid.
83 //
84     if (i < 0 || i > 1) {
85         AliError("Index out of range");
86         return kFALSE;
87     }
88     if (charge != '+' && charge != '-') {
89         AliError(Form("Character '%c' not recognized as charge sign"));
90         return kFALSE;
91     }
92     if (type < AliRsnPID::kElectron && type > AliRsnPID::kUnknown) {
93         AliError("Type index out of enumeration range");
94         return kFALSE;
95     }
96     fCharge[i] = charge;
97     fType[i] = type;
98     fMass[i] = AliRsnPID::ParticleMass(type);
99     return kTRUE;
100 }
101
102 //_____________________________________________________________________________
103 Bool_t AliRsnPairDef::SetPair
104 (Char_t charge1, AliRsnPID::EType type1, Char_t charge2, AliRsnPID::EType type2)
105 {
106 //
107 // Set both elements of the pair,
108 // returning logical AND of check for each one.
109 //
110
111     Bool_t part1 = SetPairElement(0, charge1, type1);
112     Bool_t part2 = SetPairElement(1, charge2, type2);
113     return (part1 && part2);
114 }
115
116 //_____________________________________________________________________________
117 Double_t AliRsnPairDef::ComputeWeight(AliRsnDaughter *d0, AliRsnDaughter *d1)
118 {
119 //
120 // Compute a weight for filling the histograms:
121 // probability of first track to be identified as 'type[0]' times
122 // the probability of second track to be identified as 'type[1]',
123 // according to the order of appearance in argument list.
124 //
125
126     Double_t prob0 = d0->PIDProb()[fType[0]];
127     Double_t prob1 = d1->PIDProb()[fType[1]];
128
129     return prob0*prob1;
130 }