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