]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/RESONANCES/AliRsnFunctionAxis.cxx
Class version updated.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnFunctionAxis.cxx
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 #include "TObject.h"
12
13 #include "AliLog.h"
14
15 #include "AliRsnEvent.h"
16 #include "AliRsnPairParticle.h"
17 #include "AliRsnPairDef.h"
18 #include "AliRsnFunctionAxis.h"
19
20 ClassImp(AliRsnFunctionAxis)
21
22 //_____________________________________________________________________________
23 AliRsnFunctionAxis::AliRsnFunctionAxis() :
24   fType(kAxisTypes),
25   fNBins(0),
26   fMin(0.0),
27   fMax(0.0)
28 {
29 //
30 // Default constructor
31 //
32 }
33
34 //_____________________________________________________________________________
35 AliRsnFunctionAxis::AliRsnFunctionAxis
36 (EAxisType type, Int_t nbins, Double_t min, Double_t max) :
37   fType(type),
38   fNBins(0),
39   fMin(0.0),
40   fMax(0.0)
41 {
42 //
43 // Main constructor (version 1)
44 //
45
46   SetBins(nbins, min, max);
47 }
48
49 //_____________________________________________________________________________
50 AliRsnFunctionAxis::AliRsnFunctionAxis
51 (EAxisType type, Double_t min, Double_t max, Double_t step) :
52   fType(type),
53   fNBins(0),
54   fMin(0.0),
55   fMax(0.0)
56 {
57 //
58 // Main constructor (version 2)
59 //
60
61   SetBins(min, max, step);
62 }
63
64 //_____________________________________________________________________________
65 const char* AliRsnFunctionAxis::GetName() const
66 {
67 //
68 // Return the name of this object defined by the type
69 //
70
71   switch (fType)
72   {
73     case kPairInvMass:    return "IM";
74     case kPairInvMassMC:  return "IMMC";
75     case kPairInvMassRes: return "IMRES";
76     case kPairPt:         return "PT";
77     case kPairEta:        return "ETA";
78     case kEventMult:      return "MULT";
79     default:              return "UNDEF";
80   }
81 }
82
83 //_____________________________________________________________________________
84 AliRsnFunctionAxis::EAxisObject AliRsnFunctionAxis::GetAxisObject()
85 {
86 //
87 // Tells what kind of object must be evaluated for this axis
88 //
89
90   switch (fType)
91   {
92     case kPairInvMass:
93     case kPairInvMassMC:
94     case kPairInvMassRes:
95     case kPairPt:
96     case kPairEta:
97       return kPair;
98     case kEventMult:
99       return kEvent;
100     default:
101       return kNone;
102   }
103 }
104
105 //_____________________________________________________________________________
106 void AliRsnFunctionAxis::SetBins(Int_t n, Double_t min, Double_t max)
107 {
108 //
109 // Set binning for histogram.
110 //
111
112   fNBins = n;
113
114   if (min < max)
115   {
116     fMin = min;
117     fMax = max;
118   }
119   else
120   {
121     fMin = max;
122     fMax = min;
123   }
124 }
125
126 //_____________________________________________________________________________
127 void AliRsnFunctionAxis::SetBins(Double_t min, Double_t max, Double_t step)
128 {
129 //
130 // Binning for histogram.
131 //
132
133   if (min < max)
134   {
135     fMin = min;
136     fMax = max;
137   }
138   else
139   {
140     fMin = max;
141     fMax = min;
142   }
143
144   fNBins = (Int_t)((fMax - fMin) / (step)) + 1;
145 }
146
147 //_____________________________________________________________________________
148 Double_t AliRsnFunctionAxis::Eval(AliRsnDaughter* /*daughter*/)
149 {
150 //
151 // EValuation method for single tracks
152 // (currently disabled)
153 //
154
155   return 0.0;
156 }
157
158 //_____________________________________________________________________________
159 Double_t AliRsnFunctionAxis::Eval(AliRsnPairParticle *pair, AliRsnPairDef *pairDef)
160 {
161 //
162 // EValuation method for pairs.
163 // Requires also the pair definitions, in order to retrieve mass.
164 //
165
166   switch (fType)
167   {
168     case kPairInvMass:
169       return pair->GetInvMass(pairDef->GetMass(0), pairDef->GetMass(1));
170     case kPairInvMassMC:
171       return pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1));
172     case kPairInvMassRes:
173       {
174         Double_t value;
175         value  = pair->GetInvMass(pairDef->GetMass(0), pairDef->GetMass(1));
176         value -= pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1));
177         value /= pair->GetInvMassMC(pairDef->GetMass(0), pairDef->GetMass(1));
178         return value;
179       }
180     case kPairPt:
181       return pair->GetPt();
182     case kPairEta:
183       return pair->GetEta();
184     default:
185       AliWarning("This axis type cannot be applied to pairs");
186       return -999.0;
187   }
188 }
189
190 //_____________________________________________________________________________
191 Double_t AliRsnFunctionAxis::Eval(AliRsnEvent *event)
192 {
193 //
194 // EValuation method for events
195 //
196
197   switch (fType)
198   {
199     case kEventMult:
200       return (Double_t)event->GetMultiplicity();
201     default:
202       AliWarning("This axis type cannot be applied to events");
203       return 0.0;
204   }
205 }