Improved Print() function
[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
2f769150 18// ----------------------
a62a2d82 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>
4c2fda1e 30#include <TString.h>
a62a2d82 31
32#include "AliESDtrack.h"
33#include "AliRsnDaughter.h"
34
35ClassImp(AliRsnDaughter)
36
37//--------------------------------------------------------------------------------------------------------
38AliRsnDaughter::AliRsnDaughter()
2f769150 39{
a62a2d82 40//
41// Default constructor.
42// Its unique argument defines how many PID weights are allowed.
43// Actually, it should be the same as AliESDtrack::kSPECIES (=5).
2f769150 44//
a62a2d82 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)
2f769150 65{
a62a2d82 66//
67// Copy constructor
68//
a62a2d82 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)
2f769150 91{
a62a2d82 92//
93// Copies reconstructed data from an AliESDtrack:
94//
95// - charge sign
96// - momentum
97// - point of closest approach to primary vertex
98// - ESD pid weights
99// - track label (AliESDtrack::GetLabel())
100//
101// Makes the following checks:
102//
103// - if argument 'checkITSRefit' is TRUE and the "ITS refit" flag is FALSE
104// in the track, the "fIsOK" flag of (this) is set to "false" (track should be rejected)
105// - if the passed label is negative, track is considered as "fake", and
106// this info is kept to allow fake tracks exclusion when doing analysis
107//
a62a2d82 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)
2f769150 141{
a62a2d82 142//
143// Copies data from a generated particle:
144//
145// - PDG code
146// - charge sign
147// - momentum
148// - production vertex
149// - GEANT label of mother track
150//
151// When an AliRsnDaughter is copied from a TParticle, it is
152// considered always good for analysis and never fake.
153//
a62a2d82 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//--------------------------------------------------------------------------------------------------------
4c2fda1e 181void AliRsnDaughter::Print(Option_t *option) const
182{
183//
184// Print informations about track.
185// All options are used to add some specifical information as required:
186// "S" --> charge sign
187// "L" --> track label
188// "I" --> assigned PID (PDG code)
189// "T" --> true PDG code
190// "V" --> coordinates of track vertex
191// "P" --> coordinates of track momentum
192// "M" --> mother label
193// "N" --> mother PDG code
194// "W" --> ESD PID weights
195//
196
197 TString output("Track info: ");
198 TString opt(option);
199 opt.ToUpper();
200
201 if (opt.Contains("S")) {
202 output.Append(Form("sign = %d -- ", (Int_t)fSign));
203 }
204 if (opt.Contains("L")) {
205 output.Append(Form("label = %d -- ", fLabel));
206 }
207 if (opt.Contains("I")) {
208 output.Append(Form("PDG = %d -- ", fPDG));
209 }
210 if (opt.Contains("T")) {
211 output.Append(Form("true PDG = %d -- ", fTruePDG));
212 }
213 if (opt.Contains("V")) {
214 output.Append(Form("v = %f, %f, %f -- ", fV[0], fV[1], fV[2]));
215 }
216 if (opt.Contains("P")) {
217 output.Append(Form("p = %f, %f, %f -- ", fP[0], fP[1], fP[2]));
218 }
219 if (opt.Contains("M")) {
220 output.Append(Form("mum = %d -- ", fMother));
221 }
222 if (opt.Contains("N")) {
223 output.Append(Form("mum PDG = %d -- ", fMotherPDG));
224 }
225 if (opt.Contains("W")) {
226 output.Append(Form("PID wgts (e, mu, pi, K, p) = %f, %f, %f, %f, %f", fPIDwgt[0], fPIDwgt[1], fPIDwgt[2], fPIDwgt[3], fPIDwgt[4]));
227 }
228
229 cout << output.Data() << endl;
230}
231//--------------------------------------------------------------------------------------------------------
2f769150 232AliRsnDaughter AliRsnDaughter::Sum(AliRsnDaughter t1, AliRsnDaughter t2)
233{
a62a2d82 234//
a62a2d82 235// Builds a new AliRsnDaughter object with the sum of momenta of two particles.
236//
a62a2d82 237 // create new AliRsnDaughter with default useless values for datamembers
238 AliRsnDaughter out;
239
240 // if the summed particles are daughters of the same resonance
241 // their common mother label becomes the label of the sum
242 Int_t mum1 = t1.GetMother();
243 Int_t mum2 = t2.GetMother();
244 if (mum1 == mum2) {
245 out.SetLabel(mum1);
246 out.SetMotherPDG(t1.GetMotherPDG());
247 }
248 else {
249 out.SetLabel(-1);
250 out.SetMotherPDG(0);
251 }
252
253 // compute total 4-momentum
2f769150 254 Double_t etot = t1.GetEnergy() + t2.GetEnergy();
a62a2d82 255 Double_t pxTot = t1.GetPx() + t2.GetPx();
256 Double_t pyTot = t1.GetPy() + t2.GetPy();
257 Double_t pzTot = t1.GetPz() + t2.GetPz();
2f769150 258 Double_t mass = TMath::Sqrt(etot*etot - pxTot*pxTot - pyTot*pyTot - pzTot*pzTot);
a62a2d82 259
260 //TLorentzVector v1 = track1.Get4Momentum();
261 //TLorentzVector v2 = track2.Get4Momentum();
262 //TLorentzVector sm = v1 + v2;
263 //Double_t pxTot = sum.X();
264 //Double_t pyTot = sum.Y();
265 //Double_t pzTot = sum.Z();
266 //Double_t mass = sm.M();
267
268 out.SetPxPyPz(pxTot, pyTot, pzTot);
269 out.SetMass(mass);
270
271 return out;
272}