]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnFunctionAxis.cxx
Added a CORRFW analysis task for selection of single tracks with the same style as...
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnFunctionAxis.cxx
CommitLineData
b2028424 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//
b2028424 11
4fbb2459 12#include <TArrayD.h>
b2028424 13
14#include "AliRsnEvent.h"
15#include "AliRsnPairParticle.h"
16#include "AliRsnPairDef.h"
17#include "AliRsnFunctionAxis.h"
18
19ClassImp(AliRsnFunctionAxis)
20
21//_____________________________________________________________________________
22AliRsnFunctionAxis::AliRsnFunctionAxis() :
4fbb2459 23 fType(kAxisTypes),
24 fNBins(0),
25 fMin(0.0),
26 fMax(0.0)
b2028424 27{
28//
29// Default constructor
30//
31}
32
33//_____________________________________________________________________________
34AliRsnFunctionAxis::AliRsnFunctionAxis
35(EAxisType type, Int_t nbins, Double_t min, Double_t max) :
4fbb2459 36 fType(type),
37 fNBins(0),
38 fMin(0.0),
39 fMax(0.0)
b2028424 40{
41//
42// Main constructor (version 1)
43//
44
45 SetBins(nbins, min, max);
46}
47
48//_____________________________________________________________________________
49AliRsnFunctionAxis::AliRsnFunctionAxis
50(EAxisType type, Double_t min, Double_t max, Double_t step) :
4fbb2459 51 fType(type),
52 fNBins(0),
53 fMin(0.0),
54 fMax(0.0)
b2028424 55{
56//
57// Main constructor (version 2)
58//
59
60 SetBins(min, max, step);
61}
62
63//_____________________________________________________________________________
64const char* AliRsnFunctionAxis::GetName() const
65{
66//
67// Return the name of this object defined by the type
68//
69
eca224a3 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";
b2028424 85 }
86}
87
88//_____________________________________________________________________________
4fbb2459 89TArrayD 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//_____________________________________________________________________________
106AliRsnFunctionAxis::EAxisObject AliRsnFunctionAxis::GetAxisObject() const
b2028424 107{
108//
109// Tells what kind of object must be evaluated for this axis
110//
111
eca224a3 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;
b2028424 131 }
132}
133
134//_____________________________________________________________________________
135void AliRsnFunctionAxis::SetBins(Int_t n, Double_t min, Double_t max)
136{
137//
138// Set binning for histogram.
139//
140
141 fNBins = n;
142
4fbb2459 143 if (min < max) {
b2028424 144 fMin = min;
145 fMax = max;
4fbb2459 146 } else {
b2028424 147 fMin = max;
148 fMax = min;
149 }
150}
151
152//_____________________________________________________________________________
153void AliRsnFunctionAxis::SetBins(Double_t min, Double_t max, Double_t step)
154{
155//
156// Binning for histogram.
157//
158
4fbb2459 159 if (min < max) {
b2028424 160 fMin = min;
161 fMax = max;
4fbb2459 162 } else {
b2028424 163 fMin = max;
164 fMax = min;
165 }
166
167 fNBins = (Int_t)((fMax - fMin) / (step)) + 1;
168}
169
170//_____________________________________________________________________________
eca224a3 171Double_t AliRsnFunctionAxis::Eval(AliRsnDaughter* daughter) const
b2028424 172{
173//
174// EValuation method for single tracks
175// (currently disabled)
176//
177
eca224a3 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
b2028424 189 return 0.0;
190}
191
192//_____________________________________________________________________________
4fbb2459 193Double_t AliRsnFunctionAxis::Eval(AliRsnPairParticle * const pair, AliRsnPairDef *const pairDef) const
b2028424 194{
195//
196// EValuation method for pairs.
197// Requires also the pair definitions, in order to retrieve mass.
198//
199
eca224a3 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;
b2028424 228 }
229}
230
231//_____________________________________________________________________________
4fbb2459 232Double_t AliRsnFunctionAxis::Eval(AliRsnEvent *const event) const
b2028424 233{
234//
235// EValuation method for events
236//
237
eca224a3 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;
b2028424 245 }
246}