]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/AliTRDtrackInfo/AliTRDtrackInfo.cxx
Using ALICE_TARGET to define the system
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDtrackInfo / AliTRDtrackInfo.cxx
CommitLineData
814ecea4 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/* $Id: AliTRDtrackInfo.cxx 27496 2008-07-22 08:35:45Z cblume $ */
17
18////////////////////////////////////////////////////////////////////////////
19// //
20// Reconstruction QA //
21// //
22// Authors: //
93e41bce 23// Alex Bercuci <A.Bercuci@gsi.de> //
814ecea4 24// Markus Fasel <M.Fasel@gsi.de> //
25// //
26////////////////////////////////////////////////////////////////////////////
27
28#include "AliTrackReference.h"
29#include "AliExternalTrackParam.h"
30#include "AliTRDseedV1.h"
31#include "AliTRDtrackV1.h"
32
33#include <cstdio>
34#include <cstdlib>
35
36#include "AliTRDtrackInfo.h"
37
38ClassImp(AliTRDtrackInfo)
93e41bce 39ClassImp(AliTRDtrackInfo::AliMCinfo)
40ClassImp(AliTRDtrackInfo::AliESDinfo)
814ecea4 41
42//___________________________________________________
43AliTRDtrackInfo::AliTRDtrackInfo():
44 TObject()
93e41bce 45 ,fNClusters(0)
814ecea4 46 ,fTRDtrack(0x0)
47 ,fOP(0x0)
93e41bce 48 ,fMC(0x0)
49 ,fESD()
814ecea4 50{
51 //
52 // Default constructor
53 //
814ecea4 54}
55
814ecea4 56
57//___________________________________________________
58AliTRDtrackInfo::AliTRDtrackInfo(const AliTRDtrackInfo &trdInfo):
59 TObject((const TObject&)trdInfo)
93e41bce 60 ,fNClusters(trdInfo.fNClusters)
814ecea4 61 ,fTRDtrack(0x0)
62 ,fOP(0x0)
93e41bce 63 ,fMC(new AliMCinfo(*trdInfo.fMC))
64 ,fESD(trdInfo.fESD)
814ecea4 65{
66 //
67 // copy Entries
68 //
69
814ecea4 70 if(trdInfo.fOP) fOP = new AliExternalTrackParam(*trdInfo.fOP);
93e41bce 71
72 if(trdInfo.fMC) fMC = new AliMCinfo(*trdInfo.fMC);
73
7102d1b1 74 if(trdInfo.fTRDtrack){
75 fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack);
76 if(trdInfo.fTRDtrack->IsOwner()) fTRDtrack->SetOwner();
77 }
814ecea4 78}
79
93e41bce 80//___________________________________________________
81AliTRDtrackInfo::AliMCinfo::AliMCinfo()
82 :fLabel(0)
83 ,fPDG(0)
84 ,fNTrackRefs(0)
85{
86 // Set 0-Pointers
87 memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
88}
89
90//___________________________________________________
91AliTRDtrackInfo::AliMCinfo::AliMCinfo(const AliMCinfo &mc)
92 :fLabel(mc.fLabel)
93 ,fPDG(mc.fPDG)
94 ,fNTrackRefs(mc.fNTrackRefs)
95{
96 memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
97 for(Int_t ien = 0; ien < 12; ien++){
98 if(mc.fTrackRefs[ien])
99 fTrackRefs[ien] = new AliTrackReference(*(mc.fTrackRefs[ien]));
100 }
101}
102
103//___________________________________________________
104AliTRDtrackInfo::AliESDinfo::AliESDinfo()
105 :fId(-1)
106 ,fStatus(0)
107 ,fTRDpidQuality(0)
108 ,fTRDnSlices(0)
109 ,fTRDslices(0x0)
110{
111 memset(fTRDr, 0, AliPID::kSPECIES*sizeof(Double32_t));
112}
113
114//___________________________________________________
115AliTRDtrackInfo::AliESDinfo::AliESDinfo(const AliESDinfo &esd)
116 :fId(esd.fId)
117 ,fStatus(esd.fStatus)
118 ,fTRDpidQuality(esd.fTRDpidQuality)
119 ,fTRDnSlices(esd.fTRDnSlices)
120 ,fTRDslices(0x0)
121{
122 memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t));
123
124 if(fTRDnSlices){
125 fTRDslices = new Double32_t[fTRDnSlices];
126 memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t));
127 }
128}
129
130
814ecea4 131//___________________________________________________
132AliTRDtrackInfo::~AliTRDtrackInfo()
133{
134 //
135 // Destructor
136 //
137
138 if(fOP) delete fOP;
93e41bce 139 if(fTRDtrack) delete fTRDtrack;
140}
141
142//___________________________________________________
143AliTRDtrackInfo::AliMCinfo::~AliMCinfo()
144{
145 fNTrackRefs = 0;
814ecea4 146 for(Int_t ien = 0; ien < 12; ien++){
147 if(fTrackRefs[ien]) delete fTrackRefs[ien];
93e41bce 148 fTrackRefs[ien] = 0x0;
149 }
150}
151
152//___________________________________________________
153AliTRDtrackInfo::AliESDinfo::~AliESDinfo()
154{
155 if(fTRDnSlices){
156 delete [] fTRDslices;
157 fTRDslices = 0x0;
158 fTRDnSlices = 0;
814ecea4 159 }
814ecea4 160}
161
162
163//___________________________________________________
164AliTRDtrackInfo& AliTRDtrackInfo::operator=(const AliTRDtrackInfo &trdInfo)
165{
166 //
167 // = Operator
168 //
169
814ecea4 170 fNClusters = trdInfo.fNClusters;
93e41bce 171 fESD = trdInfo.fESD;
814ecea4 172
173 // copy Entries
814ecea4 174 if(trdInfo.fOP){
175 if(!fOP)
176 fOP = new AliExternalTrackParam(*trdInfo.fOP);
177 else
178 new(fOP) AliExternalTrackParam(*trdInfo.fOP);
179 }
93e41bce 180
181 if(trdInfo.fMC){
182 if(!fMC)
183 fMC = new AliMCinfo(*trdInfo.fMC);
184 else
185 new(fMC) AliMCinfo(*trdInfo.fMC);
186 }
187
814ecea4 188 if(trdInfo.fTRDtrack){
189 if(!fTRDtrack)
190 fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack);
191 else
192 new(fTRDtrack) AliTRDtrackV1(*trdInfo.fTRDtrack);
39779ce6 193 if(trdInfo.fTRDtrack->IsOwner()) fTRDtrack->SetOwner();
814ecea4 194 }
195
196 return *this;
197}
198
93e41bce 199//___________________________________________________
200AliTRDtrackInfo::AliMCinfo& AliTRDtrackInfo::AliMCinfo::operator=(const AliMCinfo &mc)
201{
202 fLabel = mc.fLabel;
203 fPDG = mc.fPDG;
204 fNTrackRefs = mc.fNTrackRefs;
205
206 AliTrackReference **itr = &fTrackRefs[0];
207 AliTrackReference* const *jtr = &mc.fTrackRefs[0];
208 for(Int_t ien = 0; ien < 12; ien++, itr++, jtr++){
209 if((*jtr)){
210 if(!(*itr)) (*itr) = new AliTrackReference(*(*jtr));
211 else new(&(*itr)) AliTrackReference(*(*jtr));
212 } else (*itr) = 0x0;
213 }
214 return *this;
215}
216
217//___________________________________________________
218AliTRDtrackInfo::AliESDinfo& AliTRDtrackInfo::AliESDinfo::operator=(const AliESDinfo &esd)
219{
220 fId = esd.fId;
221 fStatus = esd.fStatus;
222 fTRDpidQuality = esd.fTRDpidQuality;
223 fTRDnSlices = esd.fTRDnSlices;
224 fTRDslices = 0x0;
225
226 memcpy(fTRDr, esd.fTRDr, AliPID::kSPECIES*sizeof(Double32_t));
227
228 if(fTRDnSlices){
229 fTRDslices = new Double32_t[fTRDnSlices];
230 memcpy(fTRDslices, esd.fTRDslices, fTRDnSlices*sizeof(Double32_t));
231 }
232
233 return *this;
234}
235
814ecea4 236//___________________________________________________
237void AliTRDtrackInfo::Delete(const Option_t *)
238{
239 //
240 // Delete
241 //
242
814ecea4 243 fNClusters = 0;
814ecea4 244 if(fOP) delete fOP; fOP = 0x0;
93e41bce 245 if(fMC) delete fMC; fMC = 0x0;
814ecea4 246 if(fTRDtrack) delete fTRDtrack; fTRDtrack = 0x0;
814ecea4 247}
248
249
250//___________________________________________________
251void AliTRDtrackInfo::SetTRDtrack(const AliTRDtrackV1 *track)
252{
253 //
254 // Set the TRD track
255 //
256
257 if(!fTRDtrack)
258 fTRDtrack = new AliTRDtrackV1(*track);
259 else
260 new(fTRDtrack)AliTRDtrackV1(*track);
261 fTRDtrack->SetOwner();
262 // Make a copy for the object in order to avoid ownership problems
263}
264
265//___________________________________________________
266void AliTRDtrackInfo::AddTrackRef(const AliTrackReference *tref)
267{
268 //
269 // Add track reference
270 //
271
93e41bce 272 SetMC();
273 if(fMC->fNTrackRefs >= 12){
814ecea4 274 SetCurved();
275 return;
276 }
277 // Make a copy for the object in order to avoid ownership problems
93e41bce 278 fMC->fTrackRefs[fMC->fNTrackRefs++] = new AliTrackReference(*tref);
814ecea4 279}
280
281//___________________________________________________
282AliTRDseedV1* AliTRDtrackInfo::GetTracklet(Int_t idx) const
283{
284 //
285 // Returns a tracklet
286 //
287
288 if(!fTRDtrack) return 0x0;
289 return idx < 6 ? const_cast<AliTRDseedV1 *>(fTRDtrack->GetTracklet(idx)) : 0x0;
290}
291
292//___________________________________________________
293AliTrackReference * AliTRDtrackInfo::GetTrackRef(Int_t idx) const
294{
295 //
296 // Returns a track reference
297 //
93e41bce 298 if(!fMC) return 0x0;
299 return idx < 12 ? fMC->fTrackRefs[idx] : 0x0;
814ecea4 300}
301
302//___________________________________________________
303Int_t AliTRDtrackInfo::GetNumberOfClusters() const
304{
305 //
306 // Returns the number of clusters
307 //
308
309 Int_t n = 0;
310 if(!fTRDtrack) return 0;
311 if(fTRDtrack->GetNumberOfTracklets() == 0) return n;
312 AliTRDseedV1 *tracklet = 0x0;
313 for(Int_t ip=0; ip<6; ip++){
314 if(!(tracklet = const_cast<AliTRDseedV1 *>(fTRDtrack->GetTracklet(ip)))) continue;
315 n+=tracklet->GetN();
316 }
317 return n;
318}
319
320
321//___________________________________________________
322void AliTRDtrackInfo::SetOuterParam(const AliExternalTrackParam *op)
323{
324 //
325 // Set outer track parameters
326 //
327
328 if(!op) return;
329 if(fOP) new(fOP) AliExternalTrackParam(*op);
330 else
331 fOP = new AliExternalTrackParam(*op);
332}
333
334//___________________________________________________
335Int_t AliTRDtrackInfo::GetNTracklets() const
336{
337 //
338 // Return the number of tracklets
339 //
340
341 if(!fTRDtrack) return 0x0;
342 return fTRDtrack->GetNumberOfTracklets();
343}
93e41bce 344
345//___________________________________________________
346void AliTRDtrackInfo::SetSlices(Int_t n, Double32_t *s)
347{
348 if(fESD.fTRDnSlices != n){
349 fESD.fTRDnSlices = 0;
350 delete [] fESD.fTRDslices;
351 fESD.fTRDslices = 0x0;
352 }
353
354 if(!fESD.fTRDnSlices){
355 fESD.fTRDnSlices = n;
356 fESD.fTRDslices = new Double32_t[n];
357 }
358
359 memcpy(fESD.fTRDslices, s, n*sizeof(Double32_t));
360}