]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDfriendTrack.cxx
1) corrections for Coverity reports
[u/mrichter/AliRoot.git] / STEER / AliESDfriendTrack.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 //-------------------------------------------------------------------------
17 //               Implementation of the AliESDfriendTrack class
18 //  This class keeps complementary to the AliESDtrack information 
19 //      Origin: Iouri Belikov, CERN, Jouri.Belikov@cern.ch
20 //-------------------------------------------------------------------------
21 #include "AliTrackPointArray.h"
22 #include "AliESDfriendTrack.h"
23 #include "TObjArray.h"
24 #include "AliKalmanTrack.h"
25
26 ClassImp(AliESDfriendTrack)
27
28 AliESDfriendTrack::AliESDfriendTrack(): 
29 TObject(), 
30 f1P(0), 
31 fnMaxITScluster(0),
32 fnMaxTPCcluster(0),
33 fnMaxTRDcluster(0),
34 fITSindex(0x0),
35 fTPCindex(0x0),
36 fTRDindex(0x0),
37 fPoints(0),
38 fCalibContainer(0),
39 fITStrack(0),
40 fTRDtrack(0),
41 fTPCOut(0),
42 fITSOut(0),
43 fTRDIn(0)
44 {
45   //
46   // Default constructor
47   //
48         //  Int_t i;
49   //  fITSindex = new Int_t[fnMaxITScluster];
50   //fTPCindex = new Int_t[fnMaxTPCcluster];
51   //fTRDindex = new Int_t[fnMaxTRDcluster];
52   //for (i=0; i<kMaxITScluster; i++) fITSindex[i]=-2;
53   //for (i=0; i<kMaxTPCcluster; i++) fTPCindex[i]=-2;
54   //for (i=0; i<kMaxTRDcluster; i++) fTRDindex[i]=-2;
55 }
56
57 AliESDfriendTrack::AliESDfriendTrack(const AliESDfriendTrack &t): 
58 TObject(t),
59 f1P(t.f1P),
60 fnMaxITScluster(t.fnMaxITScluster),
61 fnMaxTPCcluster(t.fnMaxTPCcluster),
62 fnMaxTRDcluster(t.fnMaxTRDcluster),
63 fITSindex(0x0),
64 fTPCindex(0x0),
65 fTRDindex(0x0),
66 fPoints(0),
67 fCalibContainer(0),
68 fITStrack(0),
69 fTRDtrack(0),
70 fTPCOut(0),
71 fITSOut(0),
72 fTRDIn(0)
73 {
74   //
75   // Copy constructor
76   //
77   AliDebug(2,"Calling copy constructor");
78
79   Int_t i;
80   if (fnMaxITScluster != 0){
81           fITSindex = new Int_t[fnMaxITScluster];
82           for (i=0; i<fnMaxITScluster; i++) fITSindex[i]=t.fITSindex[i];
83   }
84   if (fnMaxTPCcluster != 0){
85           fTPCindex = new Int_t[fnMaxTPCcluster];
86           for (i=0; i<fnMaxTPCcluster; i++) fTPCindex[i]=t.fTPCindex[i];
87   }
88   if (fnMaxTRDcluster != 0){
89           fTRDindex = new Int_t[fnMaxTRDcluster];
90           for (i=0; i<fnMaxTRDcluster; i++) fTRDindex[i]=t.fTRDindex[i]; 
91   }
92   AliDebug(2,Form("fnMaxITScluster = %d",fnMaxITScluster));
93   AliDebug(2,Form("fnMaxTPCcluster = %d",fnMaxTPCcluster));
94   AliDebug(2,Form("fnMaxTRDcluster = %d",fnMaxTRDcluster));
95   if (t.fPoints) fPoints=new AliTrackPointArray(*t.fPoints);
96   if (t.fCalibContainer) {
97      fCalibContainer = new TObjArray(5);
98      Int_t no=t.fCalibContainer->GetEntriesFast();
99      for (i=0; i<no; i++) {
100        TObject *o=t.fCalibContainer->At(i);
101        fCalibContainer->AddLast(o->Clone());
102      }  
103   }
104
105   if (t.fTPCOut) fTPCOut = new AliExternalTrackParam(*(t.fTPCOut));
106   if (t.fITSOut) fITSOut = new AliExternalTrackParam(*(t.fITSOut));
107   if (t.fTRDIn)  fTRDIn = new AliExternalTrackParam(*(t.fTRDIn));
108
109 }
110
111 AliESDfriendTrack::~AliESDfriendTrack() {
112   //
113   // Simple destructor
114   //
115    delete fPoints;
116    if (fCalibContainer) fCalibContainer->Delete();
117    delete fCalibContainer;
118    delete fITStrack;
119    delete fTRDtrack;
120    delete fTPCOut;
121    delete fITSOut;
122    delete fTRDIn;
123    delete[] fITSindex;
124    delete[] fTPCindex;
125    delete[] fTRDindex;
126 }
127
128
129 void AliESDfriendTrack::AddCalibObject(TObject * calibObject){
130   //
131   // add calibration object to array -
132   // track is owner of the objects in the container 
133   //
134   if (!fCalibContainer) fCalibContainer = new TObjArray(5);
135   fCalibContainer->AddLast(calibObject);
136 }
137
138 TObject * AliESDfriendTrack::GetCalibObject(Int_t index){
139   //
140   //
141   //
142   if (!fCalibContainer) return 0;
143   if (index>=fCalibContainer->GetEntriesFast()) return 0;
144   return fCalibContainer->At(index);
145 }
146
147
148 void AliESDfriendTrack::SetTPCOut(const AliExternalTrackParam &param) {
149   // 
150   // backup TPC out track
151   //
152   delete fTPCOut;
153   fTPCOut=new AliExternalTrackParam(param);
154
155 void AliESDfriendTrack::SetITSOut(const AliExternalTrackParam &param) {
156   //
157   // backup ITS out track
158   //
159   delete fITSOut;
160   fITSOut=new AliExternalTrackParam(param);
161
162 void AliESDfriendTrack::SetTRDIn(const AliExternalTrackParam  &param)  {
163   //
164   // backup TRD in track
165   //
166   delete fTRDIn;
167   fTRDIn=new AliExternalTrackParam(param);
168
169
170 void AliESDfriendTrack::SetITSIndices(Int_t* indices, Int_t n){
171
172         //
173         // setting fITSindex
174         // instantiating the pointer if still NULL
175         //
176
177         fnMaxITScluster = n;
178         AliDebug(2,Form("fnMaxITScluster = %d",fnMaxITScluster));
179         if (fITSindex == 0x0){
180                 fITSindex = new Int_t[fnMaxITScluster];
181         }
182         for (Int_t i = 0; i < fnMaxITScluster; i++){
183                 fITSindex[i] = indices[i];
184         }
185 }
186
187 void AliESDfriendTrack::SetTPCIndices(Int_t* indices, Int_t n){
188
189         //
190         // setting fTPCindex
191         // instantiating the pointer if still NULL
192         //
193
194         fnMaxTPCcluster = n;
195         AliDebug(2,Form("fnMaxTPCcluster = %d",fnMaxTPCcluster));
196         if (fTPCindex == 0x0){
197                 fTPCindex = new Int_t[fnMaxTPCcluster];
198         }
199         for (Int_t i = 0; i < fnMaxTPCcluster; i++){
200                 fTPCindex[i] = indices[i];
201         }
202 }
203
204 void AliESDfriendTrack::SetTRDIndices(Int_t* indices, Int_t n){
205
206         //
207         // setting fTRDindex
208         // instantiating the pointer if still NULL
209         //
210
211         fnMaxTRDcluster = n;
212         AliDebug(2,Form("fnMaxTRDcluster = %d",fnMaxTRDcluster));
213         if (fTRDindex == 0x0){
214                 fTRDindex = new Int_t[fnMaxTRDcluster];
215         }
216         for (Int_t i = 0; i < fnMaxTRDcluster; i++){
217                 fTRDindex[i] = indices[i];
218         }
219 }
220