]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnValue.cxx
Changes from Constantin:
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnValue.cxx
CommitLineData
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
17ClassImp(AliRsnValue)
18
19//_____________________________________________________________________________
2dab9030 20AliRsnValue::AliRsnValue() :
0d73200d 21 TNamed(),
2dab9030 22 fType(kValueTypes),
23 fNBins(0),
24 fMin(0.0),
25 fMax(0.0),
26 fValue(0.0)
27{
28//
29// Main constructor (version 1)
30// This can also be created without any argument.
31//
32}
33
34//_____________________________________________________________________________
35AliRsnValue::AliRsnValue
0d73200d 36(const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) :
37 TNamed(name, ""),
2dab9030 38 fType(type),
39 fNBins(0),
40 fMin(0.0),
41 fMax(0.0),
42 fValue(0.0)
b9bbd271 43{
44//
2dab9030 45// Main constructor (version 1)
46// This can also be created without any argument.
b9bbd271 47//
2dab9030 48
49 SetBins(nbins, min, max);
50}
51
52//_____________________________________________________________________________
53AliRsnValue::AliRsnValue
0d73200d 54(const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
55 TNamed(name, ""),
2dab9030 56 fType(type),
57 fNBins(0),
58 fMin(0.0),
59 fMax(0.0),
60 fValue(0.0)
61{
62//
63// Main constructor (version 2)
64//
65
66 SetBins(min, max, step);
b9bbd271 67}
68
0d73200d 69/*
b9bbd271 70//_____________________________________________________________________________
71const char* AliRsnValue::GetName() const
72{
73//
74// Return the name of this object defined by the type
75//
76
77 switch (fType)
78 {
b9bbd271 79 case kTrack1P: return "P1";
80 case kTrack2P: return "P2";
81 case kTrack1Pt: return "PT1";
82 case kTrack2Pt: return "PT2";
83 case kPairInvMass: return "IM";
84 case kPairInvMassMC: return "IMMC";
85 case kPairInvMassRes: return "IMRES";
86 case kPairPt: return "PT";
87 case kPairEta: return "ETA";
88 case kPairMt: return "MT";
89 case kPairY: return "Y";
90 case kEventMult: return "MULT";
91 default: return "UNDEF";
92 }
93}
0d73200d 94*/
b9bbd271 95
96//_____________________________________________________________________________
2dab9030 97TArrayD AliRsnValue::GetArray() const
b9bbd271 98{
99//
2dab9030 100// Creates an array with all bin edges
b9bbd271 101//
102
2dab9030 103 TArrayD out(fNBins + 1);
104
105 Int_t i;
106 Double_t step = (fMax - fMin) / (Double_t)fNBins;
107
108 for (i = 0; i <= fNBins; i++) out[i] = fMin + step * (Double_t)i;
109
110 return out;
111}
112
113//_____________________________________________________________________________
114void AliRsnValue::SetBins(Int_t n, Double_t min, Double_t max)
115{
116//
117// Set binning for histogram.
118//
119
120 fNBins = n;
121
122 if (min < max)
b9bbd271 123 {
2dab9030 124 fMin = min;
125 fMax = max;
126 }
127 else
128 {
129 fMin = max;
130 fMax = min;
b9bbd271 131 }
132}
133
134//_____________________________________________________________________________
2dab9030 135void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
136{
137//
138// Binning for histogram.
139//
140
141 if (min < max)
142 {
143 fMin = min;
144 fMax = max;
145 }
146 else
147 {
148 fMin = max;
149 fMax = min;
150 }
151
152 fNBins = (Int_t)((fMax - fMin) / (step)) + 1;
153}
154
155//_____________________________________________________________________________
2e521c29 156Bool_t AliRsnValue::Eval(AliRsnMother * const mother, AliRsnPairDef * const pairDef, AliRsnEvent * const event)
b9bbd271 157{
158//
159// Evaluation of the required value.
160// Checks that the passed object is of the right type
161// and if this check is successful, returns the required value.
162// The output of the function tells if it was successful,
163// and the values must be taken with GetValue().
164//
165
2dab9030 166 // avoid segfaults
167 if (!mother) return kFALSE;
168 if (!pairDef) return kFALSE;
b9bbd271 169
2dab9030 170 Double_t mass = pairDef->GetMotherMass();
b9bbd271 171
172 switch (fType)
173 {
b9bbd271 174 case kTrack1P:
2dab9030 175 fValue = mother->GetDaughter(0)->P().Mag();
176 break;
b9bbd271 177 case kTrack2P:
2dab9030 178 fValue = mother->GetDaughter(1)->P().Mag();
179 break;
b9bbd271 180 case kTrack1Pt:
2dab9030 181 fValue = mother->GetDaughter(0)->P().Perp();
182 break;
b9bbd271 183 case kTrack2Pt:
2dab9030 184 fValue = mother->GetDaughter(1)->P().Perp();
185 break;
b9bbd271 186 case kPairInvMass:
2dab9030 187 fValue = mother->Sum().M();
188 break;
b9bbd271 189 case kPairInvMassMC:
2dab9030 190 fValue = mother->SumMC().M();
191 break;
b9bbd271 192 case kPairInvMassRes:
2dab9030 193 fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M();
194 break;
b9bbd271 195 case kPairPt:
2dab9030 196 fValue = mother->Sum().Perp();
197 break;
b9bbd271 198 case kPairEta:
2dab9030 199 fValue = mother->Sum().Eta();
200 break;
b9bbd271 201 case kPairMt:
202 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
2dab9030 203 fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass);
204 break;
b9bbd271 205 case kPairY:
206 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
2dab9030 207 mother->SetDefaultMass(mass);
208 fValue = mother->Ref().Rapidity();
209 break;
2e521c29 210 case kPairCosThetaStar:
211 fValue = mother->CosThetaStar();
212 break;
cadcd9e0 213 case kPairCosThetaStar1:
2e521c29 214 //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kFALSE));
cadcd9e0 215 break;
216 case kPairCosThetaStar2:
2e521c29 217 //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kFALSE));
cadcd9e0 218 break;
219 case kPairCosThetaStarMC1:
2e521c29 220 //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kTRUE));
cadcd9e0 221 break;
222 case kPairCosThetaStarMC2:
2e521c29 223 //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kTRUE));
cadcd9e0 224 break;
b9bbd271 225 case kEventMult:
2dab9030 226 if (!event) fValue = 0.0;
227 fValue = (Double_t)event->GetMultiplicity();
228 break;
b9bbd271 229 default:
230 AliWarning("Invalid value type");
2dab9030 231 return kFALSE;
b9bbd271 232 }
2dab9030 233
234 return kTRUE;
b9bbd271 235}