]>
Commit | Line | Data |
---|---|---|
2dab9030 | 1 | |
b9bbd271 | 2 | // |
3 | // Class AliRsnValue | |
4 | // | |
5 | // Definition of a single value which can be computed | |
6 | // from any of the defined input objects implemented | |
7 | // in the resonance package. | |
8 | // | |
9 | ||
10 | #include "AliRsnEvent.h" | |
11 | #include "AliRsnDaughter.h" | |
2dab9030 | 12 | #include "AliRsnMother.h" |
b9bbd271 | 13 | #include "AliRsnPairDef.h" |
14 | ||
15 | #include "AliRsnValue.h" | |
16 | ||
17 | ClassImp(AliRsnValue) | |
18 | ||
19 | //_____________________________________________________________________________ | |
2dab9030 | 20 | AliRsnValue::AliRsnValue() : |
0d73200d | 21 | TNamed(), |
2dab9030 | 22 | fType(kValueTypes), |
b2b08ca2 | 23 | fValue(0.0), |
24 | fArray(0) | |
2dab9030 | 25 | { |
26 | // | |
27 | // Main constructor (version 1) | |
28 | // This can also be created without any argument. | |
29 | // | |
30 | } | |
31 | ||
32 | //_____________________________________________________________________________ | |
33 | AliRsnValue::AliRsnValue | |
0d73200d | 34 | (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) : |
35 | TNamed(name, ""), | |
2dab9030 | 36 | fType(type), |
b2b08ca2 | 37 | fValue(0.0), |
38 | fArray(0) | |
b9bbd271 | 39 | { |
40 | // | |
2dab9030 | 41 | // Main constructor (version 1) |
42 | // This can also be created without any argument. | |
b9bbd271 | 43 | // |
2dab9030 | 44 | |
45 | SetBins(nbins, min, max); | |
46 | } | |
47 | ||
48 | //_____________________________________________________________________________ | |
49 | AliRsnValue::AliRsnValue | |
0d73200d | 50 | (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) : |
51 | TNamed(name, ""), | |
2dab9030 | 52 | fType(type), |
b2b08ca2 | 53 | fValue(0.0), |
54 | fArray(0) | |
2dab9030 | 55 | { |
56 | // | |
57 | // Main constructor (version 2) | |
58 | // | |
59 | ||
60 | SetBins(min, max, step); | |
b9bbd271 | 61 | } |
62 | ||
63 | //_____________________________________________________________________________ | |
b2b08ca2 | 64 | AliRsnValue::AliRsnValue |
65 | (const char *name, EValueType type, Int_t nbins, Double_t *array) : | |
66 | TNamed(name, ""), | |
67 | fType(type), | |
68 | fValue(0.0), | |
69 | fArray(0) | |
b9bbd271 | 70 | { |
71 | // | |
b2b08ca2 | 72 | // Main constructor (version 2) |
73 | // | |
74 | ||
75 | SetBins(nbins, array); | |
b9bbd271 | 76 | } |
77 | ||
78 | //_____________________________________________________________________________ | |
b2b08ca2 | 79 | void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max) |
b9bbd271 | 80 | { |
81 | // | |
b2b08ca2 | 82 | // Set binning for the axis in equally spaced bins |
83 | // where the number of bins, minimum and maximum are given. | |
84 | // | |
85 | ||
86 | fArray.Set(nbins + 1); | |
87 | ||
88 | Double_t mymax = TMath::Max(min, max); | |
89 | Double_t mymin = TMath::Min(min, max); | |
90 | ||
91 | Int_t k = 0; | |
92 | Double_t binSize = (mymax - mymin) / ((Double_t)nbins); | |
93 | ||
94 | fArray[0] = mymin; | |
95 | for (k = 1; k <= nbins; k++) fArray[k] = fArray[k-1] + binSize; | |
96 | for (k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1])); | |
2dab9030 | 97 | } |
98 | ||
99 | //_____________________________________________________________________________ | |
b2b08ca2 | 100 | void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step) |
2dab9030 | 101 | { |
102 | // | |
b2b08ca2 | 103 | // Set binning for the axis in equally spaced bins |
104 | // where the bin size, minimum and maximum are given. | |
2dab9030 | 105 | // |
106 | ||
b2b08ca2 | 107 | Double_t dblNbins = TMath::Abs(max - min) / step; |
108 | Int_t intNbins = ((Int_t)dblNbins) + 1; | |
109 | ||
110 | SetBins(intNbins, min, max); | |
b9bbd271 | 111 | } |
112 | ||
113 | //_____________________________________________________________________________ | |
b2b08ca2 | 114 | void AliRsnValue::SetBins(Int_t nbins, Double_t *array) |
2dab9030 | 115 | { |
116 | // | |
b2b08ca2 | 117 | // Set binning for the axis in unequally spaced bins |
118 | // using the same way it is done in TAxis | |
2dab9030 | 119 | // |
120 | ||
b2b08ca2 | 121 | fArray.Adopt(nbins, array); |
122 | for (Int_t k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1])); | |
2dab9030 | 123 | } |
124 | ||
125 | //_____________________________________________________________________________ | |
2e521c29 | 126 | Bool_t AliRsnValue::Eval(AliRsnMother * const mother, AliRsnPairDef * const pairDef, AliRsnEvent * const event) |
b9bbd271 | 127 | { |
128 | // | |
129 | // Evaluation of the required value. | |
130 | // Checks that the passed object is of the right type | |
131 | // and if this check is successful, returns the required value. | |
132 | // The output of the function tells if it was successful, | |
133 | // and the values must be taken with GetValue(). | |
134 | // | |
135 | ||
2dab9030 | 136 | // avoid segfaults |
137 | if (!mother) return kFALSE; | |
138 | if (!pairDef) return kFALSE; | |
b9bbd271 | 139 | |
2dab9030 | 140 | Double_t mass = pairDef->GetMotherMass(); |
b9bbd271 | 141 | |
142 | switch (fType) | |
143 | { | |
b9bbd271 | 144 | case kTrack1P: |
2dab9030 | 145 | fValue = mother->GetDaughter(0)->P().Mag(); |
146 | break; | |
b9bbd271 | 147 | case kTrack2P: |
2dab9030 | 148 | fValue = mother->GetDaughter(1)->P().Mag(); |
149 | break; | |
b9bbd271 | 150 | case kTrack1Pt: |
2dab9030 | 151 | fValue = mother->GetDaughter(0)->P().Perp(); |
152 | break; | |
b9bbd271 | 153 | case kTrack2Pt: |
2dab9030 | 154 | fValue = mother->GetDaughter(1)->P().Perp(); |
155 | break; | |
b9bbd271 | 156 | case kPairInvMass: |
2dab9030 | 157 | fValue = mother->Sum().M(); |
158 | break; | |
b9bbd271 | 159 | case kPairInvMassMC: |
2dab9030 | 160 | fValue = mother->SumMC().M(); |
161 | break; | |
b9bbd271 | 162 | case kPairInvMassRes: |
2dab9030 | 163 | fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M(); |
164 | break; | |
b9bbd271 | 165 | case kPairPt: |
2dab9030 | 166 | fValue = mother->Sum().Perp(); |
167 | break; | |
b9bbd271 | 168 | case kPairEta: |
2dab9030 | 169 | fValue = mother->Sum().Eta(); |
170 | break; | |
b9bbd271 | 171 | case kPairMt: |
172 | if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); | |
2dab9030 | 173 | fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass); |
174 | break; | |
b9bbd271 | 175 | case kPairY: |
176 | if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass)); | |
2dab9030 | 177 | mother->SetDefaultMass(mass); |
178 | fValue = mother->Ref().Rapidity(); | |
179 | break; | |
2e521c29 | 180 | case kPairCosThetaStar: |
181 | fValue = mother->CosThetaStar(); | |
182 | break; | |
cadcd9e0 | 183 | case kPairCosThetaStar1: |
2e521c29 | 184 | //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kFALSE)); |
cadcd9e0 | 185 | break; |
186 | case kPairCosThetaStar2: | |
2e521c29 | 187 | //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kFALSE)); |
cadcd9e0 | 188 | break; |
189 | case kPairCosThetaStarMC1: | |
2e521c29 | 190 | //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kTRUE)); |
cadcd9e0 | 191 | break; |
192 | case kPairCosThetaStarMC2: | |
2e521c29 | 193 | //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kTRUE)); |
cadcd9e0 | 194 | break; |
b9bbd271 | 195 | case kEventMult: |
2dab9030 | 196 | if (!event) fValue = 0.0; |
197 | fValue = (Double_t)event->GetMultiplicity(); | |
198 | break; | |
b9bbd271 | 199 | default: |
200 | AliWarning("Invalid value type"); | |
2dab9030 | 201 | return kFALSE; |
b9bbd271 | 202 | } |
2dab9030 | 203 | |
204 | return kTRUE; | |
b9bbd271 | 205 | } |