Adding AliRsnDaughter in the RESONANCES directory
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnDaughter.cxx
CommitLineData
a62a2d82 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16//-------------------------------------------------------------------------
17// Class AliRsnDaughter
18//
19// A simple object which describes a reconstructed track
20// with some references to its related generated particle
21// and some facilities which could help in composing its
22// 4-momentum, for resonance study.
23//
24// author: A. Pulvirenti (email: alberto.pulvirenti@ct.infn.it)
25//-------------------------------------------------------------------------
26
27#include <Riostream.h>
28
29#include <TParticle.h>
30#include <TParticlePDG.h>
31
32#include "AliESDtrack.h"
33#include "AliRsnDaughter.h"
34
35ClassImp(AliRsnDaughter)
36
37//--------------------------------------------------------------------------------------------------------
38AliRsnDaughter::AliRsnDaughter()
39//
40// Default constructor.
41// Its unique argument defines how many PID weights are allowed.
42// Actually, it should be the same as AliESDtrack::kSPECIES (=5).
43//
44{
45 fSign = (Char_t)0;
46 fPDG = (UShort_t)0;
47 fIndex = (UShort_t)0;
48
49 fP[0] = fP[1] = fP[2] = 0.0;
50 fV[0] = fV[1] = fV[2] = 0.0;
51 fMass = 0.0;
52
53 Int_t i;
54 for (i = 0; i < AliPID::kSPECIES; i++) {
55 fPIDwgt[i] = 0.0;
56 }
57
58 fLabel = -1;
59 fTruePDG = 0;
60 fMother = -1;
61 fMotherPDG = 0;
62}
63//--------------------------------------------------------------------------------------------------------
64AliRsnDaughter::AliRsnDaughter(const AliRsnDaughter &copy) : TObject(copy)
65//
66// Copy constructor
67//
68{
69 fSign = copy.fSign;
70 fPDG = copy.fPDG;
71 fIndex = copy.fIndex;
72
73 Int_t i;
74 for (i = 0; i < 3; i++) {
75 fP[i] = copy.fP[i];
76 fV[i] = copy.fV[i];
77 }
78 fMass = copy.fMass;
79
80 for (i = 0; i < AliPID::kSPECIES; i++) {
81 fPIDwgt[i] = copy.fPIDwgt[i];
82 }
83
84 fLabel = copy.fLabel;
85 fTruePDG = copy.fTruePDG;
86 fMother = copy.fMother;
87 fMotherPDG = copy.fMotherPDG;
88}
89//--------------------------------------------------------------------------------------------------------
90Bool_t AliRsnDaughter::Adopt(const AliESDtrack* esdTrack, Bool_t checkITSRefit)
91//
92// Copies reconstructed data from an AliESDtrack:
93//
94// - charge sign
95// - momentum
96// - point of closest approach to primary vertex
97// - ESD pid weights
98// - track label (AliESDtrack::GetLabel())
99//
100// Makes the following checks:
101//
102// - if argument 'checkITSRefit' is TRUE and the "ITS refit" flag is FALSE
103// in the track, the "fIsOK" flag of (this) is set to "false" (track should be rejected)
104// - if the passed label is negative, track is considered as "fake", and
105// this info is kept to allow fake tracks exclusion when doing analysis
106//
107{
108 // check for refit in the ITS (if requested)
109 if (checkITSRefit) {
110 if ( !(esdTrack->GetStatus() & AliESDtrack::kITSrefit) ) {
111 return kFALSE;
112 }
113 }
114
115 // get sign and number of species allowed for PID
116 fSign = (Char_t)esdTrack->GetSign();
117
118 // get (and check) momentum
119 esdTrack->GetPxPyPz(fP);
120 if (fP[0] == 0.0 || fP[1] == 0.0 || fP[2] == 0.0) {
121 return kFALSE;
122 }
123
124 // get (and check) vertex
125 esdTrack->GetXYZ(fV);
126 if (fV[0] == 0.0 || fV[1] == 0.0 || fV[2] == 0.0) {
127 return kFALSE;
128 }
129
130 // get label
131 // (other kinematics informations are set to default and meaningless values)
132 fLabel = esdTrack->GetLabel();
133
134 // get PID weights
135 esdTrack->GetESDpid(fPIDwgt);
136
137 return kTRUE;
138}
139//--------------------------------------------------------------------------------------------------------
140Bool_t AliRsnDaughter::Adopt(TParticle* particle)
141//
142// Copies data from a generated particle:
143//
144// - PDG code
145// - charge sign
146// - momentum
147// - production vertex
148// - GEANT label of mother track
149//
150// When an AliRsnDaughter is copied from a TParticle, it is
151// considered always good for analysis and never fake.
152//
153{
154 // get particle sign form the sign of PDG code
155 Int_t pdg = particle->GetPdgCode();
156 if (TMath::Abs(pdg) < 20) {
157 if (pdg > 0) fSign = -1; else fSign = 1;
158 }
159 else if (TMath::Abs(pdg) < 3000) {
160 if (pdg > 0) fSign = 1; else fSign = -1;
161 }
162
163 // get momentum
164 fP[0] = particle->Px();
165 fP[1] = particle->Py();
166 fP[2] = particle->Pz();
167
168 // get vertex
169 fV[0] = particle->Vx();
170 fV[1] = particle->Vy();
171 fV[2] = particle->Vz();
172
173 // set simulation data
174 fPDG = fTruePDG = (Short_t)particle->GetPdgCode();
175 fMother = particle->GetFirstMother();
176 fMotherPDG = 0;
177
178 return kTRUE;
179}
180//--------------------------------------------------------------------------------------------------------
181AliRsnDaughter operator+(AliRsnDaughter t1, AliRsnDaughter t2)
182//
183// Sum operator overloading.
184// Builds a new AliRsnDaughter object with the sum of momenta of two particles.
185//
186{
187 // create new AliRsnDaughter with default useless values for datamembers
188 AliRsnDaughter out;
189
190 // if the summed particles are daughters of the same resonance
191 // their common mother label becomes the label of the sum
192 Int_t mum1 = t1.GetMother();
193 Int_t mum2 = t2.GetMother();
194 if (mum1 == mum2) {
195 out.SetLabel(mum1);
196 out.SetMotherPDG(t1.GetMotherPDG());
197 }
198 else {
199 out.SetLabel(-1);
200 out.SetMotherPDG(0);
201 }
202
203 // compute total 4-momentum
204 Double_t Etot = t1.GetEnergy() + t2.GetEnergy();
205 Double_t pxTot = t1.GetPx() + t2.GetPx();
206 Double_t pyTot = t1.GetPy() + t2.GetPy();
207 Double_t pzTot = t1.GetPz() + t2.GetPz();
208 Double_t mass = TMath::Sqrt(Etot*Etot - pxTot*pxTot - pyTot*pyTot - pzTot*pzTot);
209
210 //TLorentzVector v1 = track1.Get4Momentum();
211 //TLorentzVector v2 = track2.Get4Momentum();
212 //TLorentzVector sm = v1 + v2;
213 //Double_t pxTot = sum.X();
214 //Double_t pyTot = sum.Y();
215 //Double_t pzTot = sum.Z();
216 //Double_t mass = sm.M();
217
218 out.SetPxPyPz(pxTot, pyTot, pzTot);
219 out.SetMass(mass);
220
221 return out;
222}