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 "AliRsnEvent.h"
11 #include "AliRsnDaughter.h"
12 #include "AliRsnMother.h"
13 #include "AliRsnPairDef.h"
15 #include "AliRsnValue.h"
19 //_____________________________________________________________________________
20 AliRsnValue::AliRsnValue() :
27 // Main constructor (version 1)
28 // This can also be created without any argument.
32 //_____________________________________________________________________________
33 AliRsnValue::AliRsnValue
34 (const char *name, EValueType type, Int_t nbins, Double_t min, Double_t max) :
41 // Main constructor (version 1)
42 // This can also be created without any argument.
45 SetBins(nbins, min, max);
48 //_____________________________________________________________________________
49 AliRsnValue::AliRsnValue
50 (const char *name, EValueType type, Double_t min, Double_t max, Double_t step) :
57 // Main constructor (version 2)
60 SetBins(min, max, step);
63 //_____________________________________________________________________________
64 AliRsnValue::AliRsnValue
65 (const char *name, EValueType type, Int_t nbins, Double_t *array) :
72 // Main constructor (version 2)
75 SetBins(nbins, array);
78 //_____________________________________________________________________________
79 void AliRsnValue::SetBins(Int_t nbins, Double_t min, Double_t max)
82 // Set binning for the axis in equally spaced bins
83 // where the number of bins, minimum and maximum are given.
86 fArray.Set(nbins + 1);
88 Double_t mymax = TMath::Max(min, max);
89 Double_t mymin = TMath::Min(min, max);
92 Double_t binSize = (mymax - mymin) / ((Double_t)nbins);
95 for (k = 1; k <= nbins; k++) fArray[k] = fArray[k-1] + binSize;
96 for (k = 0; k < fArray.GetSize() - 1; k++) AliDebug(AliLog::kDebug + 3, Form("Bin #%d: %f - %f", k, fArray[k], fArray[k+1]));
99 //_____________________________________________________________________________
100 void AliRsnValue::SetBins(Double_t min, Double_t max, Double_t step)
103 // Set binning for the axis in equally spaced bins
104 // where the bin size, minimum and maximum are given.
107 Double_t dblNbins = TMath::Abs(max - min) / step;
108 Int_t intNbins = ((Int_t)dblNbins) + 1;
110 SetBins(intNbins, min, max);
113 //_____________________________________________________________________________
114 void AliRsnValue::SetBins(Int_t nbins, Double_t *array)
117 // Set binning for the axis in unequally spaced bins
118 // using the same way it is done in TAxis
121 fArray.Adopt(nbins, array);
122 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]));
125 //_____________________________________________________________________________
126 Bool_t AliRsnValue::Eval(AliRsnMother * const mother, AliRsnPairDef * const pairDef, AliRsnEvent * const event)
129 // Evaluation of the required value.
130 // Checks that the passed object is of the right type
131 // and if this check is successful, returns the required value.
132 // The output of the function tells if it was successful,
133 // and the values must be taken with GetValue().
137 if (!mother) return kFALSE;
138 if (!pairDef) return kFALSE;
140 Double_t mass = pairDef->GetMotherMass();
145 fValue = mother->GetDaughter(0)->P().Mag();
148 fValue = mother->GetDaughter(1)->P().Mag();
151 fValue = mother->GetDaughter(0)->P().Perp();
154 fValue = mother->GetDaughter(1)->P().Perp();
157 fValue = mother->GetDaughter(0)->P().X();
160 fValue = mother->GetDaughter(0)->P().Y();
163 fValue = mother->GetDaughter(0)->P().Z();
166 fValue = mother->GetDaughter(1)->P().X();
169 fValue = mother->GetDaughter(1)->P().Y();
172 fValue = mother->GetDaughter(1)->P().Z();
175 fValue = mother->Sum().M();
178 fValue = mother->SumMC().M();
180 case kPairInvMassRes:
181 fValue = (mother->SumMC().M() - mother->Sum().M()) / mother->SumMC().M();
184 fValue = mother->Sum().Perp();
187 fValue = mother->Sum().Eta();
190 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
191 fValue = (TMath::Sqrt(mother->Sum().Perp2() + mass*mass) - mass);
194 if (TMath::Abs(mass) < 1E-5) AliWarning(Form("Suspicious mass value specified: %f", mass));
195 mother->SetDefaultMass(mass);
196 fValue = mother->Ref().Rapidity();
198 case kPairCosThetaStar:
199 fValue = mother->CosThetaStar();
201 case kPairCosThetaStar1:
202 //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kFALSE));
204 case kPairCosThetaStar2:
205 //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kFALSE));
207 case kPairCosThetaStarMC1:
208 //fValue = TMath::Cos(mother->ThetaStar(kTRUE, kTRUE));
210 case kPairCosThetaStarMC2:
211 //fValue = TMath::Cos(mother->ThetaStar(kFALSE, kTRUE));
213 case kAngleToLeading:
215 int ID1 = (mother->GetDaughter(0))->GetID();
216 int ID2 = (mother->GetDaughter(1))->GetID();
217 int leadingID = event->SelectLeadingParticle(0);
218 if(leadingID == ID1 || leadingID == ID2) return kFALSE;
219 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
220 AliVParticle *ref = leadingPart.GetRef();
222 fValue = ref->Phi() - mother->Sum().Phi();
223 //return angle w.r.t. leading particle in the range -pi/2, 3/2pi
224 while(fValue >= TMath::Pi()) fValue -= 2*TMath::Pi();
225 while(fValue < -0.5*TMath::Pi()) fValue += 2*TMath::Pi();
226 //Printf("%g", fValue);
231 if (!event) fValue = 0.0;
232 fValue = (Double_t)event->GetMultiplicity();
236 int leadingID = event->SelectLeadingParticle(0);
238 AliRsnDaughter leadingPart = event->GetDaughter(leadingID);
239 AliVParticle *ref = leadingPart.GetRef();
247 TLorentzVector diff = mother->GetDaughter(0)->P() - mother->GetDaughter(1)->P();
252 AliWarning("Invalid value type");