]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnValue.cxx
Added a protection in case the raw data signal (channel) has a read out error (neg...
[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
d0282f3d 10#include <Riostream.h>
b9bbd271 11#include "AliRsnEvent.h"
12#include "AliRsnDaughter.h"
2dab9030 13#include "AliRsnMother.h"
b9bbd271 14#include "AliRsnPairDef.h"
15
16#include "AliRsnValue.h"
17
18ClassImp(AliRsnValue)
19
20//_____________________________________________________________________________
2dab9030 21AliRsnValue::AliRsnValue() :
0d73200d 22 TNamed(),
b2b08ca2 23 fValue(0.0),
63a2738c 24 fType(kValueTypes),
45bb0283 25 fArray(0),
26 fESDCuts()
2dab9030 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, ""),
b2b08ca2 38 fValue(0.0),
63a2738c 39 fType(type),
45bb0283 40 fArray(0),
41 fESDCuts()
b9bbd271 42{
43//
2dab9030 44// Main constructor (version 1)
45// This can also be created without any argument.
b9bbd271 46//
2dab9030 47
48 SetBins(nbins, min, max);
49}
50
51//_____________________________________________________________________________
52AliRsnValue::AliRsnValue
0d73200d 53(const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
54 TNamed(name, ""),
b2b08ca2 55 fValue(0.0),
63a2738c 56 fType(type),
45bb0283 57 fArray(0),
58 fESDCuts()
2dab9030 59{
60//
61// Main constructor (version 2)
62//
63
64 SetBins(min, max, step);
b9bbd271 65}
66
67//_____________________________________________________________________________
b2b08ca2 68AliRsnValue::AliRsnValue
69(const char *name, EValueType type, Int_t nbins, Double_t *array) :
70 TNamed(name, ""),
b2b08ca2 71 fValue(0.0),
63a2738c 72 fType(type),
45bb0283 73 fArray(0),
74 fESDCuts()
b9bbd271 75{
76//
b2b08ca2 77// Main constructor (version 2)
78//
79
80 SetBins(nbins, array);
b9bbd271 81}
82
83//_____________________________________________________________________________
52944696 84AliRsnValue::AliRsnValue(const AliRsnValue& copy) :
85 TNamed(copy),
86 fValue(copy.fValue),
87 fType(copy.fType),
88 fArray(copy.fArray),
89 fESDCuts(copy.fESDCuts)
90{
91//
92// Copy constructor
93//
94}
95
96//_____________________________________________________________________________
97AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy)
98{
99//
100// Assignment operator
101//
102
103 SetName(copy.GetName());
104
105 fType = copy.fType;
106 fValue = copy.fValue;
107 fArray = copy.fArray;
108 fESDCuts = copy.fESDCuts;
109
110 return (*this);
111}
112
113//_____________________________________________________________________________
b2b08ca2 114void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max)
b9bbd271 115{
116//
b2b08ca2 117// Set binning for the axis in equally spaced bins
118// where the number of bins, minimum and maximum are given.
119//
120
121 fArray.Set(nbins + 1);
122
123 Double_t mymax = TMath::Max(min, max);
124 Double_t mymin = TMath::Min(min, max);
125
126 Int_t k = 0;
127 Double_t binSize = (mymax - mymin) / ((Double_t)nbins);
128
129 fArray[0] = mymin;
130 for (k = 1; k <= nbins; k++) fArray[k] = fArray[k-1] + binSize;
131 for (k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1]));
2dab9030 132}
133
134//_____________________________________________________________________________
b2b08ca2 135void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
2dab9030 136{
137//
b2b08ca2 138// Set binning for the axis in equally spaced bins
139// where the bin size, minimum and maximum are given.
2dab9030 140//
141
b2b08ca2 142 Double_t dblNbins = TMath::Abs(max - min) / step;
143 Int_t intNbins = ((Int_t)dblNbins) + 1;
144
145 SetBins(intNbins, min, max);
b9bbd271 146}
147
148//_____________________________________________________________________________
b2b08ca2 149void AliRsnValue::SetBins(Int_t nbins, Double_t *array)
2dab9030 150{
151//
b2b08ca2 152// Set binning for the axis in unequally spaced bins
153// using the same way it is done in TAxis
2dab9030 154//
155
b2b08ca2 156 fArray.Adopt(nbins, array);
157 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 158}
159
160//_____________________________________________________________________________
a378358c 161Bool_t AliRsnValue::Eval(AliRsnMother *mother, AliRsnPairDef *pairDef, AliRsnEvent *event)
b9bbd271 162{
163//
164// Evaluation of the required value.
165// Checks that the passed object is of the right type
166// and if this check is successful, returns the required value.
167// The output of the function tells if it was successful,
168// and the values must be taken with GetValue().
169//
170
2dab9030 171 // avoid segfaults
172 if (!mother) return kFALSE;
173 if (!pairDef) return kFALSE;
b9bbd271 174
2dab9030 175 Double_t mass = pairDef->GetMotherMass();
b9bbd271 176
177 switch (fType)
178 {
b9bbd271 179 case kTrack1P:
2dab9030 180 fValue = mother->GetDaughter(0)->P().Mag();
181 break;
b9bbd271 182 case kTrack2P:
2dab9030 183 fValue = mother->GetDaughter(1)->P().Mag();
184 break;
b9bbd271 185 case kTrack1Pt:
2dab9030 186 fValue = mother->GetDaughter(0)->P().Perp();
187 break;
b9bbd271 188 case kTrack2Pt:
2dab9030 189 fValue = mother->GetDaughter(1)->P().Perp();
190 break;
3c07ce75 191 case kTrack1Px:
192 fValue = mother->GetDaughter(0)->P().X();
193 break;
194 case kTrack1Py:
195 fValue = mother->GetDaughter(0)->P().Y();
196 break;
197 case kTrack1Pz:
198 fValue = mother->GetDaughter(0)->P().Z();
199 break;
200 case kTrack2Px:
201 fValue = mother->GetDaughter(1)->P().X();
202 break;
203 case kTrack2Py:
204 fValue = mother->GetDaughter(1)->P().Y();
205 break;
206 case kTrack2Pz:
207 fValue = mother->GetDaughter(1)->P().Z();
208 break;
b9bbd271 209 case kPairInvMass:
2dab9030 210 fValue = mother->Sum().M();
211 break;
b9bbd271 212 case kPairInvMassMC:
2dab9030 213 fValue = mother->SumMC().M();
214 break;
b9bbd271 215 case kPairInvMassRes:
2dab9030 216 fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M();
217 break;
b9bbd271 218 case kPairPt:
2dab9030 219 fValue = mother->Sum().Perp();
220 break;
b9bbd271 221 case kPairEta:
2dab9030 222 fValue = mother->Sum().Eta();
223 break;
b9bbd271 224 case kPairMt:
225 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
2dab9030 226 fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass);
227 break;
b9bbd271 228 case kPairY:
229 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
2dab9030 230 mother->SetDefaultMass(mass);
231 fValue = mother->Ref().Rapidity();
232 break;
b8718678 233 case kPairPhi:
234 fValue = mother->Sum().Phi();
235 break;
236 case kPairPhiMC:
237 fValue = mother->SumMC().Phi();
238 break;
239 case kPairPtRatio:
240 fValue = TMath::Abs(mother->GetDaughter(0)->P().Perp() - mother->GetDaughter(1)->P().Perp());
241 fValue /= TMath::Abs(mother->GetDaughter(0)->P().Perp() + mother->GetDaughter(1)->P().Perp());
242 break;
f9b1a0cc 243 case kPairDipAngle:
89202f72 244 fValue = mother->GetDaughter(0)->P().Angle(mother->GetDaughter(1)->P().Vect());
245 fValue = TMath::Abs(TMath::ACos(fValue));
f9b1a0cc 246 break;
2e521c29 247 case kPairCosThetaStar:
248 fValue = mother->CosThetaStar();
249 break;
11ba7ebc 250 case kAngleToLeading:
251 {
252 int ID1 = (mother->GetDaughter(0))->GetID();
253 int ID2 = (mother->GetDaughter(1))->GetID();
254 int leadingID = event->SelectLeadingParticle(0);
255 if(leadingID == ID1 || leadingID == ID2) return kFALSE;
a378358c 256 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
257 AliVParticle *ref = leadingPart.GetRef();
11ba7ebc 258
259 fValue = ref->Phi() - mother->Sum().Phi();
260 //return angle w.r.t. leading particle in the range -pi/2, 3/2pi
261 while(fValue >= TMath::Pi()) fValue -= 2*TMath::Pi();
262 while(fValue < -0.5*TMath::Pi()) fValue += 2*TMath::Pi();
263 //Printf("%g", fValue);
11ba7ebc 264 }
265 break;
b9bbd271 266 case kEventMult:
96e9d35d 267 if (!event)
268 {
269 fValue = 0.0;
270 return kFALSE;
271 }
a378358c 272 else fValue = (Double_t)event->GetMultiplicity(0x0);
2dab9030 273 break;
a378358c 274 case kEventMultESDCuts:
275 if (!event)
45bb0283 276 {
277 fValue = 0.0;
278 return kFALSE;
279 }
a378358c 280 else fValue = (Double_t)event->GetMultiplicity(&fESDCuts);
0cba004a 281 break;
11ba7ebc 282 case kLeadingPt:
96e9d35d 283 if (!event)
284 {
285 fValue = 0.0;
286 return kFALSE;
287 }
288 else
11ba7ebc 289 {
290 int leadingID = event->SelectLeadingParticle(0);
291 if(leadingID >= 0) {
292 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
293 AliVParticle *ref = leadingPart.GetRef();
294 fValue = ref->Pt();
295 }
296 else fValue = 0;
297 }
298 break;
2467e7c3 299 case kQInv:
300 {
301 TLorentzVector diff = mother->GetDaughter(0)->P() - mother->GetDaughter(1)->P();
302 fValue = diff.M();
303 }
304 break;
b9bbd271 305 default:
306 AliWarning("Invalid value type");
2dab9030 307 return kFALSE;
b9bbd271 308 }
2dab9030 309
310 return kTRUE;
b9bbd271 311}
c18b1218 312
69fbb331 313//_____________________________________________________________________________
314Bool_t AliRsnValue::Eval(AliRsnDaughter * const daughter, AliRsnEvent * const event)
315{
316//
317// Evaluation of the required value.
318// Checks that the passed object is of the right type
319// and if this check is successful, returns the required value.
320// The output of the function tells if it was successful,
321// and the values must be taken with GetValue().
322//
323
324 // avoid segfaults
325 if (!daughter) return kFALSE;
326
327 switch (fType)
328 {
96e9d35d 329 case kEventMult:
330 if (!event)
331 {
332 fValue = 0.0;
333 return kFALSE;
334 }
335 else fValue = (Double_t)event->GetMultiplicity();
336 break;
a378358c 337 case kEventMultESDCuts:
338 if (!event)
d0282f3d 339 {
340 fValue = 0.0;
341 return kFALSE;
342 }
a378358c 343 else fValue = (Double_t)event->GetMultiplicity(&fESDCuts);
0cba004a 344 break;
96e9d35d 345 case kLeadingPt:
346 if (!event)
347 {
348 fValue = 0.0;
349 return kFALSE;
350 }
351 else
352 {
353 int leadingID = event->SelectLeadingParticle(0);
354 if(leadingID >= 0) {
355 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
356 AliVParticle *ref = leadingPart.GetRef();
357 fValue = ref->Pt();
358 }
359 else fValue = 0;
360 }
361 break;
69fbb331 362 default:
363 AliWarning("Invalid value type");
364 return kFALSE;
365 }
366
367 return kTRUE;
368}
369
c18b1218 370//_____________________________________________________________________________
371void AliRsnValue::Print(Option_t *) const
372{
373//
374// Print all bins
375//
376
377 Int_t i, n = fArray.GetSize();
378 TString msg("Array values: ");
379
380 for (i = 0; i < n; i++) msg += Form("%f, ", fArray[i]);
381
382 AliInfo(Form("Axis name: %s", GetName()));
383 AliInfo(msg.Data());
384}