5 // Definition of a single value which can be computed
6 // from any of the defined input objects implemented
7 // in the resonance package.
10 #include <Riostream.h>
11 #include "AliRsnEvent.h"
12 #include "AliRsnDaughter.h"
13 #include "AliRsnMother.h"
14 #include "AliRsnPairDef.h"
16 #include "AliRsnValue.h"
20 //_____________________________________________________________________________
21 AliRsnValue::AliRsnValue() :
29 // Main constructor (version 1)
30 // This can also be created without any argument.
34 //_____________________________________________________________________________
35 AliRsnValue::AliRsnValue
36 (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) :
44 // Main constructor (version 1)
45 // This can also be created without any argument.
48 SetBins(nbins, min, max);
51 //_____________________________________________________________________________
52 AliRsnValue::AliRsnValue
53 (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
61 // Main constructor (version 2)
64 SetBins(min, max, step);
67 //_____________________________________________________________________________
68 AliRsnValue::AliRsnValue
69 (const char *name, EValueType type, Int_t nbins, Double_t *array) :
77 // Main constructor (version 2)
80 SetBins(nbins, array);
83 //_____________________________________________________________________________
84 AliRsnValue::AliRsnValue(const AliRsnValue& copy) :
89 fESDCuts(copy.fESDCuts)
96 //_____________________________________________________________________________
97 AliRsnValue& AliRsnValue::operator=(const AliRsnValue& copy)
100 // Assignment operator
103 SetName(copy.GetName());
106 fValue = copy.fValue;
107 fArray = copy.fArray;
108 fESDCuts = copy.fESDCuts;
113 //_____________________________________________________________________________
114 void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max)
117 // Set binning for the axis in equally spaced bins
118 // where the number of bins, minimum and maximum are given.
121 fArray.Set(nbins + 1);
123 Double_t mymax = TMath::Max(min, max);
124 Double_t mymin = TMath::Min(min, max);
127 Double_t binSize = (mymax - mymin) / ((Double_t)nbins);
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]));
134 //_____________________________________________________________________________
135 void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
138 // Set binning for the axis in equally spaced bins
139 // where the bin size, minimum and maximum are given.
142 Double_t dblNbins = TMath::Abs(max - min) / step;
143 Int_t intNbins = ((Int_t)dblNbins) + 1;
145 SetBins(intNbins, min, max);
148 //_____________________________________________________________________________
149 void AliRsnValue::SetBins(Int_t nbins, Double_t *array)
152 // Set binning for the axis in unequally spaced bins
153 // using the same way it is done in TAxis
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]));
160 //_____________________________________________________________________________
161 Bool_t AliRsnValue::Eval(AliRsnMother * const mother, AliRsnPairDef * const pairDef, AliRsnEvent * const event)
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().
172 if (!mother) return kFALSE;
173 if (!pairDef) return kFALSE;
175 Double_t mass = pairDef->GetMotherMass();
180 fValue = mother->GetDaughter(0)->P().Mag();
183 fValue = mother->GetDaughter(1)->P().Mag();
186 fValue = mother->GetDaughter(0)->P().Perp();
189 fValue = mother->GetDaughter(1)->P().Perp();
192 fValue = mother->GetDaughter(0)->P().X();
195 fValue = mother->GetDaughter(0)->P().Y();
198 fValue = mother->GetDaughter(0)->P().Z();
201 fValue = mother->GetDaughter(1)->P().X();
204 fValue = mother->GetDaughter(1)->P().Y();
207 fValue = mother->GetDaughter(1)->P().Z();
210 fValue = mother->Sum().M();
213 fValue = mother->SumMC().M();
215 case kPairInvMassRes:
216 fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M();
219 fValue = mother->Sum().Perp();
222 fValue = mother->Sum().Eta();
225 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
226 fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass);
229 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
230 mother->SetDefaultMass(mass);
231 fValue = mother->Ref().Rapidity();
234 fValue = mother->Sum().Phi();
237 fValue = mother->SumMC().Phi();
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());
244 fValue = mother->GetDaughter(0)->P().Angle(mother->GetDaughter(1)->P().Vect());
245 fValue = TMath::Abs(TMath::ACos(fValue));
247 case kPairCosThetaStar:
248 fValue = mother->CosThetaStar();
250 case kPairCosThetaStar1:
251 //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kFALSE));
253 case kPairCosThetaStar2:
254 //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kFALSE));
256 case kPairCosThetaStarMC1:
257 //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kTRUE));
259 case kPairCosThetaStarMC2:
260 //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kTRUE));
262 case kAngleToLeading:
264 int ID1 = (mother->GetDaughter(0))->GetID();
265 int ID2 = (mother->GetDaughter(1))->GetID();
266 int leadingID = event->SelectLeadingParticle(0);
267 if(leadingID == ID1 || leadingID == ID2) return kFALSE;
268 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
269 AliVParticle *ref = leadingPart.GetRef();
271 fValue = ref->Phi() - mother->Sum().Phi();
272 //return angle w.r.t. leading particle in the range -pi/2, 3/2pi
273 while(fValue >= TMath::Pi()) fValue -= 2*TMath::Pi();
274 while(fValue < -0.5*TMath::Pi()) fValue += 2*TMath::Pi();
275 //Printf("%g", fValue);
284 else fValue = (Double_t)event->GetMultiplicity();
286 case kEventMultESDcuts:
294 AliESDEvent *esd = event->GetRefESD();
297 AliError("Cannot use method based on ESD cuts when input is not ESD.");
301 fValue = (Double_t)fESDCuts.CountAcceptedTracks(esd);
312 int leadingID = event->SelectLeadingParticle(0);
314 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
315 AliVParticle *ref = leadingPart.GetRef();
323 TLorentzVector diff = mother->GetDaughter(0)->P() - mother->GetDaughter(1)->P();
328 AliWarning("Invalid value type");
335 //_____________________________________________________________________________
336 Bool_t AliRsnValue::Eval(AliRsnDaughter * const daughter, AliRsnEvent * const event)
339 // Evaluation of the required value.
340 // Checks that the passed object is of the right type
341 // and if this check is successful, returns the required value.
342 // The output of the function tells if it was successful,
343 // and the values must be taken with GetValue().
347 if (!daughter) return kFALSE;
357 else fValue = (Double_t)event->GetMultiplicity();
359 case kEventMultESDcuts:
367 AliESDEvent *esd = event->GetRefESD();
370 AliError("Cannot use method based on ESD cuts when input is not ESD.");
374 fValue = (Double_t)fESDCuts.CountAcceptedTracks(esd);
385 int leadingID = event->SelectLeadingParticle(0);
387 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
388 AliVParticle *ref = leadingPart.GetRef();
395 AliWarning("Invalid value type");
402 //_____________________________________________________________________________
403 void AliRsnValue::Print(Option_t *) const
409 Int_t i, n = fArray.GetSize();
410 TString msg("Array values: ");
412 for (i = 0; i < n; i++) msg += Form("%f, ", fArray[i]);
414 AliInfo(Form("Axis name: %s", GetName()));