]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/qaRec/AliTRDtrackInfo/AliTRDtrackInfo.cxx
QA of TRD tracking performance
[u/mrichter/AliRoot.git] / TRD / qaRec / AliTRDtrackInfo / AliTRDtrackInfo.cxx
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:                                                              //
23 //    Markus Fasel <M.Fasel@gsi.de>                                       //
24 //                                                                        //
25 ////////////////////////////////////////////////////////////////////////////
26
27 #include "AliTrackReference.h"
28 #include "AliExternalTrackParam.h"
29 #include "AliTRDseedV1.h"
30 #include "AliTRDtrackV1.h"
31
32 #include <cstdio>
33 #include <cstdlib>
34
35 #include "AliTRDtrackInfo.h"
36
37 ClassImp(AliTRDtrackInfo)
38
39 //___________________________________________________
40 AliTRDtrackInfo::AliTRDtrackInfo():
41   TObject()
42   ,fPDG(0)
43   ,fStatus(0)
44   ,fId(-1)
45   ,fLabel(0)
46   ,fNClusters(0)
47   ,fNTrackRefs(0)
48   ,fTRDtrack(0x0)
49   ,fOP(0x0)
50 {
51   //
52   // Default constructor
53   //
54
55   // Set 0-Pointers
56   memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
57 }
58
59 //___________________________________________________
60 AliTRDtrackInfo::AliTRDtrackInfo(Int_t pdg):
61   TObject()
62   ,fPDG(pdg)
63   ,fStatus(0)
64   ,fId(-1)
65   ,fLabel(0)
66   ,fNClusters(0)
67   ,fNTrackRefs(0)
68   ,fTRDtrack(0x0)
69   ,fOP(0x0)
70 {
71   //
72   // PDG constructor
73   //
74
75   // Set 0-Pointers
76   memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
77 }
78
79 //___________________________________________________
80 AliTRDtrackInfo::AliTRDtrackInfo(const AliTRDtrackInfo &trdInfo):
81   TObject((const TObject&)trdInfo)  
82   ,fPDG(trdInfo.fPDG)
83   ,fStatus(trdInfo.fStatus)
84   ,fId(trdInfo.fId)
85   ,fLabel(trdInfo.fLabel)
86   ,fNClusters(trdInfo.fNClusters)
87   ,fNTrackRefs(trdInfo.fNTrackRefs)
88   ,fTRDtrack(0x0)
89   ,fOP(0x0)
90 {
91   //
92   // copy Entries
93   //
94
95   memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
96   for(Int_t ien = 0; ien < 12; ien++){
97         if(trdInfo.fTrackRefs[ien])
98       fTrackRefs[ien] = new AliTrackReference(*(trdInfo.fTrackRefs[ien]));
99   }
100   if(trdInfo.fOP) fOP = new AliExternalTrackParam(*trdInfo.fOP);
101   if(trdInfo.fTRDtrack) fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack);
102 }
103
104 //___________________________________________________
105 AliTRDtrackInfo::~AliTRDtrackInfo()
106 {
107   //
108   // Destructor
109   //
110
111   if(fOP) delete fOP;
112   for(Int_t ien = 0; ien < 12; ien++){
113     if(fTrackRefs[ien]) delete fTrackRefs[ien];
114   }
115   if(fTRDtrack) delete fTRDtrack;
116 }
117
118
119 //___________________________________________________
120 AliTRDtrackInfo& AliTRDtrackInfo::operator=(const AliTRDtrackInfo &trdInfo)
121 {
122   //
123   // = Operator
124   //
125
126   fPDG    = trdInfo.fPDG;
127   fStatus = trdInfo.fStatus;
128   fId     = trdInfo.fId;
129   fLabel  = trdInfo.fLabel;
130   fNClusters  = trdInfo.fNClusters;
131   fNTrackRefs = trdInfo.fNTrackRefs;
132
133   // copy Entries
134   memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
135   for(Int_t ien = 0; ien < 12; ien++){
136     if(trdInfo.fTrackRefs[ien])
137         if(!fTrackRefs[ien])
138                 fTrackRefs[ien] = new AliTrackReference(*(trdInfo.fTrackRefs[ien]));
139         else
140                 new(&fTrackRefs[ien]) AliTrackReference(*(trdInfo.fTrackRefs[ien]));
141   }
142   if(trdInfo.fOP){
143         if(!fOP)
144                 fOP = new AliExternalTrackParam(*trdInfo.fOP);
145         else
146                 new(fOP) AliExternalTrackParam(*trdInfo.fOP);
147   }
148   if(trdInfo.fTRDtrack){
149         if(!fTRDtrack)
150                 fTRDtrack = new AliTRDtrackV1(*trdInfo.fTRDtrack);
151         else
152                 new(fTRDtrack) AliTRDtrackV1(*trdInfo.fTRDtrack);
153   }
154
155   return *this;
156 }
157
158 //___________________________________________________
159 void AliTRDtrackInfo::Delete(const Option_t *)
160 {
161   //
162   // Delete
163   //
164
165   fPDG    = 0;
166   fStatus = 0;
167   fId     = -1;
168   fLabel  = 0;
169   fNClusters  = 0;
170   fNTrackRefs = 0;
171   if(fOP) delete fOP; fOP = 0x0;
172   if(fTRDtrack) delete fTRDtrack; fTRDtrack = 0x0;
173   for(Int_t ien = 0; ien < 12; ien++){
174     if(fTrackRefs[ien])
175       delete fTrackRefs[ien];
176   }
177   memset(fTrackRefs, 0, sizeof(AliTrackReference *) * 12);
178 }
179
180
181 //___________________________________________________
182 void AliTRDtrackInfo::SetTRDtrack(const AliTRDtrackV1 *track)
183 {
184   //
185   // Set the TRD track
186   //
187
188   if(!fTRDtrack)
189         fTRDtrack = new AliTRDtrackV1(*track);  
190   else
191         new(fTRDtrack)AliTRDtrackV1(*track);
192         fTRDtrack->SetOwner();
193   // Make a copy for the object in order to avoid ownership problems
194 }
195
196 //___________________________________________________
197 void AliTRDtrackInfo::AddTrackRef(const AliTrackReference *tref)
198 {
199   //
200   // Add track reference
201   //
202
203   if(fNTrackRefs >= 12){ 
204     SetCurved();
205     return;
206   }
207   // Make a copy for the object in order to avoid ownership problems
208   fTrackRefs[fNTrackRefs++] = new AliTrackReference(*tref);
209 }
210
211 //___________________________________________________
212 AliTRDseedV1* AliTRDtrackInfo::GetTracklet(Int_t idx) const 
213 {
214   //
215   // Returns a tracklet
216   //
217
218         if(!fTRDtrack) return 0x0;
219   return idx < 6 ? const_cast<AliTRDseedV1 *>(fTRDtrack->GetTracklet(idx)) : 0x0;
220 }
221
222 //___________________________________________________
223 AliTrackReference * AliTRDtrackInfo::GetTrackRef(Int_t idx) const
224 {
225   //
226   // Returns a track reference
227   //
228
229   return idx < 12 ? fTrackRefs[idx] : 0x0;
230 }
231
232 //___________________________________________________
233 Int_t AliTRDtrackInfo::GetNumberOfClusters() const
234 {
235   //
236   // Returns the number of clusters
237   //
238
239   Int_t n = 0;
240         if(!fTRDtrack) return 0;
241   if(fTRDtrack->GetNumberOfTracklets() == 0) return n;
242   AliTRDseedV1 *tracklet = 0x0;
243   for(Int_t ip=0; ip<6; ip++){
244         if(!(tracklet = const_cast<AliTRDseedV1 *>(fTRDtrack->GetTracklet(ip)))) continue;
245     n+=tracklet->GetN();
246   }
247   return n;
248 }
249
250
251 //___________________________________________________
252 void  AliTRDtrackInfo::SetOuterParam(const AliExternalTrackParam *op)
253 {
254   //
255   // Set outer track parameters
256   //
257
258   if(!op) return;
259   if(fOP) new(fOP) AliExternalTrackParam(*op);
260   else
261         fOP = new AliExternalTrackParam(*op);
262 }
263
264 //___________________________________________________
265 Int_t AliTRDtrackInfo::GetNTracklets() const
266 {
267   //
268   // Return the number of tracklets
269   //
270
271         if(!fTRDtrack) return 0x0;
272         return fTRDtrack->GetNumberOfTracklets();
273 }