]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnEvent.cxx
Made a general review to fix as possible most coding conventions violations.
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnEvent.cxx
CommitLineData
06351446 1//
2// *** Class AliRsnEvent ***
3//
4// A container for a collection of AliRsnDaughter objects from an event.
5// Contains also the primary vertex, useful for some cuts.
6// In order to retrieve easily the tracks which have been identified
7// as a specific type and charge, there is an array of indexes which
8// allows to avoid to loop on all tracks and have only the neede ones.
9//
10// authors: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
11// M. Vala (email: martin.vala@cern.ch)
12//
0dffcc8a 13
4fbb2459 14#include <TArrayF.h>
0dffcc8a 15
7c2974c8 16#include "AliLog.h"
5eb970a4 17#include "AliVEvent.h"
18#include "AliESDEvent.h"
19#include "AliAODEvent.h"
20#include "AliMCEvent.h"
21#include "AliStack.h"
4fbb2459 22#include "AliGenEventHeader.h"
7c2974c8 23
0dffcc8a 24#include "AliRsnEvent.h"
25
aec0ec32 26ClassImp(AliRsnEvent)
0dffcc8a 27
7c2974c8 28//_____________________________________________________________________________
5eb970a4 29AliRsnEvent::AliRsnEvent(AliVEvent *ref, AliMCEvent *refMC) :
4fbb2459 30 fRef(ref),
31 fRefMC(refMC),
32 fPIDDefESD()
2f769150 33{
06351446 34//
4fbb2459 35// Default constructor.
36// Set the prior probabilities to some default values
06351446 37//
4fbb2459 38
39 fPrior[0] = 0.02;
40 fPrior[1] = 0.02;
41 fPrior[2] = 0.83;
42 fPrior[3] = 0.07;
43 fPrior[4] = 0.06;
0dffcc8a 44}
7c2974c8 45
46//_____________________________________________________________________________
aec0ec32 47AliRsnEvent::AliRsnEvent(const AliRsnEvent &event) :
4fbb2459 48 TObject(event),
49 fRef(event.fRef),
50 fRefMC(event.fRefMC),
51 fPIDDefESD(event.fPIDDefESD)
2f769150 52{
06351446 53//
0dffcc8a 54// Copy constructor.
06351446 55//
2f769150 56}
7c2974c8 57
58//_____________________________________________________________________________
06351446 59AliRsnEvent& AliRsnEvent::operator= (const AliRsnEvent &event)
0dffcc8a 60{
06351446 61//
62// Works in the same way as the copy constructor.
63//
aec0ec32 64
5eb970a4 65 (TObject)(*this) = (TObject)event;
66 fRef = event.fRef;
67 fRefMC = event.fRefMC;
4fbb2459 68 fPIDDefESD = event.fPIDDefESD;
5eb970a4 69
aec0ec32 70 return (*this);
0dffcc8a 71}
7c2974c8 72
73//_____________________________________________________________________________
74AliRsnEvent::~AliRsnEvent()
2f769150 75{
06351446 76//
7c2974c8 77// Destructor.
06351446 78//
06351446 79}
80
81//_____________________________________________________________________________
5eb970a4 82void AliRsnEvent::SetDaughter(AliRsnDaughter &out, Int_t i)
06351446 83{
84//
5eb970a4 85// Return a track stored here in format of AliRsnDaughter.
86// and finds in the reference event the informations to set
87// the proprietary data members of AliRsnDaughter
06351446 88//
06351446 89
5eb970a4 90 // retrieve reference particle from reference event
4fbb2459 91 // if it is found, by defaul track can be used (good)
5eb970a4 92 AliVParticle *ref = (AliVParticle*)fRef->GetTrack(i);
5eb970a4 93 if (!ref) return;
4fbb2459 94 out.SetRef(ref);
95 out.SetGood();
06351446 96
5eb970a4 97 // if MC info is present, retrieve from it
98 TParticle *refMC = 0;
99 if (fRefMC) {
100 Int_t label = TMath::Abs(ref->GetLabel());
101 refMC = fRefMC->Stack()->Particle(label);
4fbb2459 102 out.SetParticle(refMC);
5eb970a4 103 out.FindMotherPDG(fRefMC->Stack());
4fbb2459 104 }
5eb970a4 105
4fbb2459 106 // retrieve vertex and set impact parameters
5eb970a4 107 Double_t dx = out.Xv(), dy = out.Yv(), dz = out.Zv();
108 const AliVVertex *v = fRef->GetPrimaryVertex();
109 if (v) {
110 dx -= v->GetX();
111 dy -= v->GetY();
112 dz -= v->GetZ();
4fbb2459 113 } else if (fRefMC) {
114 // if reference is an MC event, no primary vertex is supplied
115 // but it is possible to retrieve it from header
116 TArrayF fvertex(3);
117 fRefMC->GenEventHeader()->PrimaryVertex(fvertex);
118 dx -= fvertex[0];
119 dy -= fvertex[1];
120 dz -= fvertex[2];
aec0ec32 121 }
5eb970a4 122 out.SetDr(TMath::Sqrt(dx*dx + dy*dy));
123 out.SetDz(dz);
124
4fbb2459 125 // compute PID probabilities by combining
126 // the PID weights in the source with priors
127 // and eventually using the PIDDefESD
128 // (the AliRsnDaughter objec knows how to manage the latter)
129 out.CombineWithPriors(fPrior, &fPIDDefESD);
130
5eb970a4 131 // dynamic reference to true nature of referenced event
132 // to get kink index
133 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(fRef);
134 AliAODEvent *aod = dynamic_cast<AliAODEvent*>(fRef);
135
136 if (esd) {
137 AliESDtrack *esdTrack = esd->GetTrack(i);
138 out.FindKinkIndex(esdTrack);
139 } else if (aod) {
140 out.FindKinkIndex(aod);
aec0ec32 141 }
e0baff8c 142}
143
15d5fd02 144//_____________________________________________________________________________
5eb970a4 145AliRsnDaughter AliRsnEvent::GetDaughter(Int_t i)
15d5fd02 146{
147//
5eb970a4 148// Return an AliRsnDaughter taken from this event,
149// with all additional data members well set.
15d5fd02 150//
151
5eb970a4 152 AliRsnDaughter out;
153 SetDaughter(out, i);
15d5fd02 154
5eb970a4 155 return out;
15d5fd02 156}
157
7c2974c8 158//_____________________________________________________________________________
5eb970a4 159Int_t AliRsnEvent::GetMultiplicity()
7c2974c8 160{
06351446 161//
5eb970a4 162// Returns event multiplicity
06351446 163//
5eb970a4 164 AliDebug(AliLog::kDebug+2,"<-");
165 if (!fRef) return 0;
166 AliDebug(AliLog::kDebug+2,"->");
167 return fRef->GetNumberOfTracks();
7c2974c8 168}
169
170//_____________________________________________________________________________
5eb970a4 171Double_t AliRsnEvent::GetVz()
78b94cbd 172{
173//
5eb970a4 174// Return Z coord of primary vertex
78b94cbd 175//
5eb970a4 176 AliDebug(AliLog::kDebug+2,"<-");
177 return fRef->GetPrimaryVertex()->GetZ();
178 AliDebug(AliLog::kDebug+2,"->");
78b94cbd 179}
180
181//_____________________________________________________________________________
5eb970a4 182AliRsnDaughter AliRsnEvent::GetLeadingParticle
183(Double_t ptMin, AliPID::EParticleType type)
78b94cbd 184{
185//
186// Searches the collection of all particles with given PID type and charge,
187// and returns the one with largest momentum, provided that it is greater than 1st argument.
188// If one specifies AliRsnPID::kUnknown as type or AliRsnDaughter::kNoPID as method,
189// the check is done over all particles irrespectively of their PID.
190// If the sign argument is '+' or '-', the check is done over the particles of that charge,
191// otherwise it is done irrespectively of the charge.
192//
193
5eb970a4 194 Int_t i, nTracks = fRef->GetNumberOfTracks();
195 AliRsnDaughter output;
196
197 for (i = 0; i < nTracks; i++) {
198 AliRsnDaughter track = GetDaughter(i);
199 if (!AcceptTrackPID(&track, type)) continue;
200 if (track.Pt() < ptMin) continue;
201 if (!output.IsOK() || track.Pt() > output.Pt()) {
202 output = track;
203 output.SetGood();
78b94cbd 204 }
78b94cbd 205 }
206
5eb970a4 207 return output;
78b94cbd 208}
209
5eb970a4 210//_________________________________________________________________________________________________
211Double_t AliRsnEvent::GetAverageMomentum(Int_t &count, AliPID::EParticleType type)
78b94cbd 212{
213//
214// Loops on the list of tracks and computes average total momentum.
215//
216
5eb970a4 217 Int_t i, nTracks = fRef->GetNumberOfTracks();
78b94cbd 218 Double_t pmean = 0.0;
5eb970a4 219
220 for (i = 0, count = 0; i < nTracks; i++) {
221 AliRsnDaughter track = GetDaughter(i);
222 if (!AcceptTrackPID(&track, type)) continue;
223 pmean += track.P();
224 count++;
78b94cbd 225 }
15d5fd02 226
5eb970a4 227 if (count > 0) pmean /= (Double_t)count;
228 else pmean = 0.0;
229
78b94cbd 230 return pmean;
231}
232
233//_____________________________________________________________________________
5eb970a4 234Bool_t AliRsnEvent::GetAngleDistr
235(Double_t &angleMean, Double_t &angleRMS, AliRsnDaughter leading)
78b94cbd 236{
237//
238// Takes the leading particle and computes the mean and RMS
239// of the distribution of directions of all other tracks
240// with respect to the direction of leading particle.
241//
242
5eb970a4 243 if (!leading.IsOK()) return kFALSE;
15d5fd02 244
5eb970a4 245 Int_t i, count, nTracks = fRef->GetNumberOfTracks();
246 Double_t angle, angle2Mean = 0.0;
15d5fd02 247
78b94cbd 248 angleMean = angle2Mean = 0.0;
15d5fd02 249
5eb970a4 250 for (i = 0, count = 0; i < nTracks; i++) {
251 AliRsnDaughter trk = GetDaughter(i);
252 if (trk.GetID() == leading.GetID()) continue;
15d5fd02 253
5eb970a4 254 angle = leading.AngleTo(trk);
15d5fd02 255
78b94cbd 256 angleMean += angle;
257 angle2Mean += angle * angle;
258 count++;
259 }
15d5fd02 260
78b94cbd 261 if (!count) return kFALSE;
15d5fd02 262
78b94cbd 263 angleMean /= (Double_t)count;
264 angle2Mean /= (Double_t)count;
265 angleRMS = TMath::Sqrt(angle2Mean - angleMean*angleMean);
15d5fd02 266
78b94cbd 267 return kTRUE;
268}
5eb970a4 269
270//_____________________________________________________________________________
4fbb2459 271void AliRsnEvent::SetPriorProbability(Double_t *const out)
272{
273//
274// Set all prior probabilities at once, using an assayr of values.
275//
276
277 Int_t i;
278
279 for (i = 0; i < AliPID::kSPECIES; i++)
280 {
281 fPrior[i] = out[i];
282 }
283}
284
285//_____________________________________________________________________________
286void AliRsnEvent::DumpPriors()
287{
288//
289// Print all prior probabilities.
290// Printout is done using AliInfo, so this will not appear when
291// the GlobalLogLevel is set to higher level errors.
292//
293
294 Int_t i;
295
296 for (i = 0; i < AliPID::kSPECIES; i++)
297 {
298 AliInfo(Form("Prior probability for %10s = %3.5f", AliPID::ParticleName((AliPID::EParticleType)i), fPrior[i]));
299 }
300}
301
302//_____________________________________________________________________________
303void AliRsnEvent::GetPriorProbability(Double_t *out) const
304{
305//
306// Stores in the passed argument all the values.
307//
308
309 Int_t i;
310
311 for (i = 0; i < AliPID::kSPECIES; i++)
312 {
313 out[i] = fPrior[i];
314 }
315
316}
317
318//_____________________________________________________________________________
319Bool_t AliRsnEvent::AcceptTrackPID(AliRsnDaughter * const d, AliPID::EParticleType type)
5eb970a4 320{
321//
322// [PRIVATE]
323// Checks if the track PID (according to method in use) corresponds
324// to the required identification species.
325// If the second argument is "kUnknown", answer of this method is always YES.
326//
327
328 if (type == AliPID::kUnknown) return kTRUE;
329
330 return (d->AssignedPID() == type);
331}