]>
Commit | Line | Data |
---|---|---|
1 | // | |
2 | // Class AliRsnFunctionAxis | |
3 | // | |
4 | // Definition for a histogram type. | |
5 | // Since one could do an analysis which is not an invariant mass | |
6 | // the histogram definition should be more flexible, and it is stored | |
7 | // separately in a new class. | |
8 | // This class considers the possibility of a 1D or 2D histograms | |
9 | // with its related binning, and can create a new histo from his definitions | |
10 | // | |
11 | ||
12 | #include <TArrayD.h> | |
13 | ||
14 | #include "AliRsnEvent.h" | |
15 | #include "AliRsnPairParticle.h" | |
16 | #include "AliRsnPairDef.h" | |
17 | #include "AliRsnFunctionAxis.h" | |
18 | ||
19 | ClassImp(AliRsnFunctionAxis) | |
20 | ||
21 | //_____________________________________________________________________________ | |
22 | AliRsnFunctionAxis::AliRsnFunctionAxis() : | |
23 | fType(kAxisTypes), | |
24 | fNBins(0), | |
25 | fMin(0.0), | |
26 | fMax(0.0) | |
27 | { | |
28 | // | |
29 | // Default constructor | |
30 | // | |
31 | } | |
32 | ||
33 | //_____________________________________________________________________________ | |
34 | AliRsnFunctionAxis::AliRsnFunctionAxis | |
35 | (EAxisType type, Int_t nbins, Double_t min, Double_t max) : | |
36 | fType(type), | |
37 | fNBins(0), | |
38 | fMin(0.0), | |
39 | fMax(0.0) | |
40 | { | |
41 | // | |
42 | // Main constructor (version 1) | |
43 | // | |
44 | ||
45 | SetBins(nbins, min, max); | |
46 | } | |
47 | ||
48 | //_____________________________________________________________________________ | |
49 | AliRsnFunctionAxis::AliRsnFunctionAxis | |
50 | (EAxisType type, Double_t min, Double_t max, Double_t step) : | |
51 | fType(type), | |
52 | fNBins(0), | |
53 | fMin(0.0), | |
54 | fMax(0.0) | |
55 | { | |
56 | // | |
57 | // Main constructor (version 2) | |
58 | // | |
59 | ||
60 | SetBins(min, max, step); | |
61 | } | |
62 | ||
63 | //_____________________________________________________________________________ | |
64 | const char* AliRsnFunctionAxis::GetName() const | |
65 | { | |
66 | // | |
67 | // Return the name of this object defined by the type | |
68 | // | |
69 | ||
70 | switch (fType) | |
71 | { | |
72 | case kTrackPt: return "PT"; | |
73 | case kTrackEta: return "ETA"; | |
74 | case kTrack1P: return "P1"; | |
75 | case kTrack2P: return "P2"; | |
76 | case kTrack1Pt: return "PT1"; | |
77 | case kTrack2Pt: return "PT2"; | |
78 | case kPairInvMass: return "IM"; | |
79 | case kPairInvMassMC: return "IMMC"; | |
80 | case kPairInvMassRes: return "IMRES"; | |
81 | case kPairPt: return "PT"; | |
82 | case kPairEta: return "ETA"; | |
83 | case kEventMult: return "MULT"; | |
84 | default: return "UNDEF"; | |
85 | } | |
86 | } | |
87 | ||
88 | //_____________________________________________________________________________ | |
89 | TArrayD AliRsnFunctionAxis::GetArray() const | |
90 | { | |
91 | // | |
92 | // Creates an array with all bin edges | |
93 | // | |
94 | ||
95 | TArrayD out(fNBins + 1); | |
96 | ||
97 | Int_t i; | |
98 | Double_t step = (fMax - fMin) / (Double_t)fNBins; | |
99 | ||
100 | for (i = 0; i <= fNBins; i++) out[i] = fMin + step * (Double_t)i; | |
101 | ||
102 | return out; | |
103 | } | |
104 | ||
105 | //_____________________________________________________________________________ | |
106 | AliRsnFunctionAxis::EAxisObject AliRsnFunctionAxis::GetAxisObject() const | |
107 | { | |
108 | // | |
109 | // Tells what kind of object must be evaluated for this axis | |
110 | // | |
111 | ||
112 | switch (fType) | |
113 | { | |
114 | case kTrackPt: | |
115 | case kTrackEta: | |
116 | return kParticle; | |
117 | case kTrack1P: | |
118 | case kTrack2P: | |
119 | case kTrack1Pt: | |
120 | case kTrack2Pt: | |
121 | case kPairInvMass: | |
122 | case kPairInvMassMC: | |
123 | case kPairInvMassRes: | |
124 | case kPairPt: | |
125 | case kPairEta: | |
126 | return kPair; | |
127 | case kEventMult: | |
128 | return kEvent; | |
129 | default: | |
130 | return kNone; | |
131 | } | |
132 | } | |
133 | ||
134 | //_____________________________________________________________________________ | |
135 | void AliRsnFunctionAxis::SetBins(Int_t n, Double_t min, Double_t max) | |
136 | { | |
137 | // | |
138 | // Set binning for histogram. | |
139 | // | |
140 | ||
141 | fNBins = n; | |
142 | ||
143 | if (min < max) { | |
144 | fMin = min; | |
145 | fMax = max; | |
146 | } else { | |
147 | fMin = max; | |
148 | fMax = min; | |
149 | } | |
150 | } | |
151 | ||
152 | //_____________________________________________________________________________ | |
153 | void AliRsnFunctionAxis::SetBins(Double_t min, Double_t max, Double_t step) | |
154 | { | |
155 | // | |
156 | // Binning for histogram. | |
157 | // | |
158 | ||
159 | if (min < max) { | |
160 | fMin = min; | |
161 | fMax = max; | |
162 | } else { | |
163 | fMin = max; | |
164 | fMax = min; | |
165 | } | |
166 | ||
167 | fNBins = (Int_t)((fMax - fMin) / (step)) + 1; | |
168 | } | |
169 | ||
170 | //_____________________________________________________________________________ | |
171 | Double_t AliRsnFunctionAxis::Eval(AliRsnDaughter* daughter) const | |
172 | { | |
173 | // | |
174 | // EValuation method for single tracks | |
175 | // (currently disabled) | |
176 | // | |
177 | ||
178 | switch (fType) | |
179 | { | |
180 | case kTrackPt: | |
181 | return daughter->Pt(); | |
182 | case kTrackEta: | |
183 | return daughter->Eta(); | |
184 | default: | |
185 | AliWarning("This axis type cannot be applied to particles"); | |
186 | return -999.0; | |
187 | } | |
188 | ||
189 | return 0.0; | |
190 | } | |
191 | ||
192 | //_____________________________________________________________________________ | |
193 | Double_t AliRsnFunctionAxis::Eval(AliRsnPairParticle * const pair, AliRsnPairDef *const pairDef) const | |
194 | { | |
195 | // | |
196 | // EValuation method for pairs. | |
197 | // Requires also the pair definitions, in order to retrieve mass. | |
198 | // | |
199 | ||
200 | switch (fType) | |
201 | { | |
202 | case kTrack1P: | |
203 | return pair->GetDaughter(0)->P(); | |
204 | case kTrack2P: | |
205 | return pair->GetDaughter(1)->P(); | |
206 | case kTrack1Pt: | |
207 | return pair->GetDaughter(0)->Pt(); | |
208 | case kTrack2Pt: | |
209 | return pair->GetDaughter(1)->Pt(); | |
210 | case kPairInvMass: | |
211 | return pair->GetInvMass(pairDef->GetMass(0), pairDef->GetMass(1)); | |
212 | case kPairInvMassMC: | |
213 | return pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1)); | |
214 | case kPairInvMassRes: { | |
215 | Double_t value; | |
216 | value = pair->GetInvMass(pairDef->GetMass(0), pairDef->GetMass(1)); | |
217 | value -= pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1)); | |
218 | value /= pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1)); | |
219 | return value; | |
220 | } | |
221 | case kPairPt: | |
222 | return pair->GetPt(); | |
223 | case kPairEta: | |
224 | return pair->GetEta(); | |
225 | default: | |
226 | AliWarning("This axis type cannot be applied to pairs"); | |
227 | return -999.0; | |
228 | } | |
229 | } | |
230 | ||
231 | //_____________________________________________________________________________ | |
232 | Double_t AliRsnFunctionAxis::Eval(AliRsnEvent *const event) const | |
233 | { | |
234 | // | |
235 | // EValuation method for events | |
236 | // | |
237 | ||
238 | switch (fType) | |
239 | { | |
240 | case kEventMult: | |
241 | return (Double_t)event->GetMultiplicity(); | |
242 | default: | |
243 | AliWarning("This axis type cannot be applied to events"); | |
244 | return 0.0; | |
245 | } | |
246 | } |