Line data Source code
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 "TClonesArray.h"
25 : #include "AliKalmanTrack.h"
26 : #include "AliVTPCseed.h"
27 : #include "AliLog.h"
28 :
29 172 : ClassImp(AliESDfriendTrack)
30 :
31 : AliESDfriendTrack::AliESDfriendTrack():
32 364 : AliVfriendTrack(),
33 364 : f1P(0),
34 364 : fnMaxITScluster(0),
35 364 : fnMaxTPCcluster(0),
36 364 : fnMaxTRDcluster(0),
37 364 : fITSindex(0x0),
38 364 : fTPCindex(0x0),
39 364 : fTRDindex(0x0),
40 364 : fPoints(0),
41 364 : fCalibContainer(0),
42 364 : fITStrack(0),
43 364 : fTRDtrack(0),
44 364 : fTPCOut(0),
45 364 : fITSOut(0),
46 364 : fTRDIn(0)
47 1820 : {
48 : //
49 : // Default constructor
50 : //
51 : // Int_t i;
52 : // fITSindex = new Int_t[fnMaxITScluster];
53 : //fTPCindex = new Int_t[fnMaxTPCcluster];
54 : //fTRDindex = new Int_t[fnMaxTRDcluster];
55 : //for (i=0; i<kMaxITScluster; i++) fITSindex[i]=-2;
56 : //for (i=0; i<kMaxTPCcluster; i++) fTPCindex[i]=-2;
57 : //for (i=0; i<kMaxTRDcluster; i++) fTRDindex[i]=-2;
58 :
59 : //fHmpPhotClus->SetOwner(kTRUE);
60 :
61 728 : }
62 :
63 : AliESDfriendTrack::AliESDfriendTrack(const AliESDfriendTrack &t, Bool_t shallow):
64 223 : AliVfriendTrack(t),
65 223 : f1P(t.f1P),
66 223 : fnMaxITScluster(t.fnMaxITScluster),
67 223 : fnMaxTPCcluster(t.fnMaxTPCcluster),
68 223 : fnMaxTRDcluster(t.fnMaxTRDcluster),
69 223 : fITSindex(0x0),
70 223 : fTPCindex(0x0),
71 223 : fTRDindex(0x0),
72 223 : fPoints(0),
73 223 : fCalibContainer(0),
74 223 : fITStrack(0),
75 223 : fTRDtrack(0),
76 223 : fTPCOut(0),
77 223 : fITSOut(0),
78 223 : fTRDIn(0)
79 669 : {
80 : //
81 : // Copy constructor
82 : //
83 1115 : AliDebug(2,"Calling copy constructor");
84 :
85 223 : if (shallow) { // shallow copy for transfer to TClonesArray in the friends
86 71 : fITSindex = t.fITSindex;
87 71 : fTPCindex = t.fTPCindex;
88 71 : fTRDindex = t.fTRDindex;
89 71 : fPoints = t.fPoints;
90 71 : fCalibContainer = t.fCalibContainer;
91 71 : fTPCOut = t.fTPCOut;
92 71 : fITSOut = t.fITSOut;
93 71 : fTRDIn = t.fTRDIn;
94 : //
95 71 : return;
96 : }
97 : //
98 : Int_t i;
99 152 : if (fnMaxITScluster != 0){
100 32 : fITSindex = new Int_t[fnMaxITScluster];
101 416 : for (i=0; i<fnMaxITScluster; i++) fITSindex[i]=t.fITSindex[i];
102 : }
103 152 : if (fnMaxTPCcluster != 0){
104 272 : fTPCindex = new Int_t[fnMaxTPCcluster];
105 43792 : for (i=0; i<fnMaxTPCcluster; i++) fTPCindex[i]=t.fTPCindex[i];
106 : }
107 152 : if (fnMaxTRDcluster != 0){
108 0 : fTRDindex = new Int_t[fnMaxTRDcluster];
109 0 : for (i=0; i<fnMaxTRDcluster; i++) fTRDindex[i]=t.fTRDindex[i];
110 : }
111 760 : AliDebug(2,Form("fnMaxITScluster = %d",fnMaxITScluster));
112 760 : AliDebug(2,Form("fnMaxTPCcluster = %d",fnMaxTPCcluster));
113 760 : AliDebug(2,Form("fnMaxTRDcluster = %d",fnMaxTRDcluster));
114 152 : if (t.fPoints) fPoints=new AliTrackPointArray(*t.fPoints);
115 152 : if (t.fCalibContainer) {
116 0 : fCalibContainer = new TObjArray(2);
117 0 : fCalibContainer->SetOwner();
118 0 : Int_t no=t.fCalibContainer->GetEntriesFast();
119 0 : for (i=0; i<no; i++) {
120 0 : TObject *o=t.fCalibContainer->At(i);
121 0 : if (o) fCalibContainer->AddLast(o->Clone());
122 : }
123 0 : }
124 :
125 152 : if (t.fTPCOut) fTPCOut = new AliExternalTrackParam(*(t.fTPCOut));
126 152 : if (t.fITSOut) fITSOut = new AliExternalTrackParam(*(t.fITSOut));
127 152 : if (t.fTRDIn) fTRDIn = new AliExternalTrackParam(*(t.fTRDIn));
128 :
129 598 : }
130 :
131 3522 : AliESDfriendTrack::~AliESDfriendTrack() {
132 : //
133 : // Simple destructor
134 : //
135 587 : if(fPoints)
136 152 : delete fPoints;
137 587 : fPoints=0;
138 587 : if (fCalibContainer){
139 120 : fCalibContainer->Delete();
140 240 : delete fCalibContainer;
141 120 : fCalibContainer=0;
142 120 : }
143 587 : if(fITStrack)
144 164 : delete fITStrack;
145 587 : fITStrack=0;
146 587 : if(fTRDtrack)
147 0 : delete fTRDtrack;
148 587 : fTRDtrack=0;
149 587 : if(fTPCOut)
150 268 : delete fTPCOut;
151 587 : fTPCOut=0;
152 587 : if(fITSOut)
153 196 : delete fITSOut;
154 587 : fITSOut=0;
155 587 : if(fTRDIn)
156 84 : delete fTRDIn;
157 587 : fTRDIn=0;
158 587 : if(fITSindex)
159 228 : delete[] fITSindex;
160 587 : fITSindex=0;
161 587 : if(fTPCindex)
162 544 : delete[] fTPCindex;
163 587 : fTPCindex=0;
164 587 : if(fTRDindex)
165 208 : delete[] fTRDindex;
166 587 : fTRDindex=0;
167 1761 : }
168 :
169 : void AliESDfriendTrack::Clear(Option_t*)
170 : {
171 : // clear pointers data, used for shallow copies
172 142 : fPoints = 0;
173 71 : fCalibContainer=0;
174 71 : fITStrack=0;
175 71 : fTRDtrack=0;
176 71 : fTPCOut=0;
177 71 : fITSOut=0;
178 71 : fTRDIn=0;
179 71 : fITSindex=0;
180 71 : fTPCindex=0;
181 71 : fTRDindex=0;
182 : //
183 71 : }
184 :
185 : void AliESDfriendTrack::AddCalibObject(TObject * calibObject){
186 : //
187 : // add calibration object to array -
188 : // track is owner of the objects in the container
189 : //
190 496 : if (!fCalibContainer) {
191 240 : fCalibContainer = new TObjArray(2);
192 120 : fCalibContainer->SetOwner();
193 120 : }
194 248 : fCalibContainer->AddLast(calibObject);
195 248 : }
196 :
197 : void AliESDfriendTrack::RemoveCalibObject(TObject * calibObject){
198 : //
199 : // remove calibration object from the array -
200 : //
201 204 : if (fCalibContainer) fCalibContainer->Remove(calibObject);
202 68 : }
203 :
204 : TObject * AliESDfriendTrack::GetCalibObject(Int_t index) const {
205 : //
206 : //
207 : //
208 3740 : if (!fCalibContainer) return 0;
209 1942 : if (index>=fCalibContainer->GetEntriesFast()) return 0;
210 1654 : return fCalibContainer->At(index);
211 1846 : }
212 :
213 : Int_t AliESDfriendTrack::GetTPCseed( AliTPCseed &seed) const {
214 : TObject* calibObject = NULL;
215 : AliVTPCseed* seedP = NULL;
216 0 : for (Int_t idx = 0; (calibObject = GetCalibObject(idx)); ++idx) {
217 0 : if ((seedP = dynamic_cast<AliVTPCseed*>(calibObject))) {
218 0 : seedP->CopyToTPCseed( seed );
219 0 : return 0;
220 : }
221 : }
222 0 : return -1;
223 0 : }
224 :
225 : const TObject* AliESDfriendTrack::GetTPCseed() const
226 : {
227 : TObject* calibObject = NULL;
228 : AliVTPCseed* seedP = NULL;
229 900 : for (Int_t idx = 0; (calibObject = GetCalibObject(idx)); ++idx) {
230 812 : if ((seedP = dynamic_cast<AliVTPCseed*>(calibObject))) return calibObject;
231 : }
232 84 : return 0;
233 152 : }
234 :
235 :
236 : void AliESDfriendTrack::ResetTPCseed( const AliTPCseed* seed )
237 : {
238 : TObject* calibObject = NULL;
239 : AliVTPCseed* seedP = NULL;
240 0 : for (Int_t idx = 0; (calibObject = GetCalibObject(idx)); ++idx) {
241 0 : if ((seedP = dynamic_cast<AliVTPCseed*>(calibObject))) break;
242 : }
243 0 : if (seedP) seedP->SetFromTPCseed(seed);
244 0 : }
245 :
246 : void AliESDfriendTrack::SetTPCOut(const AliExternalTrackParam ¶m) {
247 : //
248 : // backup TPC out track
249 : //
250 268 : if(fTPCOut)
251 0 : delete fTPCOut;
252 268 : fTPCOut=new AliExternalTrackParam(param);
253 134 : }
254 : void AliESDfriendTrack::SetITSOut(const AliExternalTrackParam ¶m) {
255 : //
256 : // backup ITS out track
257 : //
258 196 : if(fITSOut)
259 0 : delete fITSOut;
260 196 : fITSOut=new AliExternalTrackParam(param);
261 98 : }
262 : void AliESDfriendTrack::SetTRDIn(const AliExternalTrackParam ¶m) {
263 : //
264 : // backup TRD in track
265 : //
266 84 : if(fTRDIn)
267 0 : delete fTRDIn;
268 84 : fTRDIn=new AliExternalTrackParam(param);
269 42 : }
270 :
271 : void AliESDfriendTrack::SetITSIndices(Int_t* indices, Int_t n){
272 :
273 : //
274 : // setting fITSindex
275 : // instantiating the pointer if still NULL
276 : //
277 : // TODO: what if the array was already set but
278 : // the old fnMaxITScluster and n differ!?
279 1618 : if(fnMaxITScluster && fnMaxITScluster!=n){
280 0 : AliError(Form("Array size does not fit %d/%d\n"
281 : ,fnMaxITScluster,n));
282 0 : }
283 :
284 572 : fnMaxITScluster = n;
285 1716 : AliDebug(2,Form("fnMaxITScluster = %d",fnMaxITScluster));
286 572 : if (fITSindex == 0x0){
287 98 : fITSindex = new Int_t[fnMaxITScluster];
288 98 : }
289 14872 : for (Int_t i = 0; i < fnMaxITScluster; i++){
290 6864 : fITSindex[i] = indices[i];
291 : }
292 572 : }
293 :
294 : void AliESDfriendTrack::SetTPCIndices(Int_t* indices, Int_t n){
295 :
296 : //
297 : // setting fTPCindex
298 : // instantiating the pointer if still NULL
299 : //
300 : // TODO: what if the array was already set but
301 : // the old fnMaxITScluster and n differ!?
302 1082 : if(fnMaxTPCcluster && fnMaxTPCcluster!=n){
303 0 : AliError(Form("Array size does not fit %d/%d\n"
304 : ,fnMaxTPCcluster,n));
305 0 : }
306 :
307 406 : fnMaxTPCcluster = n;
308 1218 : AliDebug(2,Form("fnMaxTPCcluster = %d",fnMaxTPCcluster));
309 406 : if (fTPCindex == 0x0){
310 136 : fTPCindex = new Int_t[fnMaxTPCcluster];
311 136 : }
312 406 : memcpy(fTPCindex,indices,sizeof(Int_t)*fnMaxTPCcluster); //RS
313 : //for (Int_t i = 0; i < fnMaxTPCcluster; i++){fTPCindex[i] = indices[i];}
314 406 : }
315 :
316 : void AliESDfriendTrack::SetTRDIndices(Int_t* indices, Int_t n){
317 :
318 : //
319 : // setting fTRDindex
320 : // instantiating the pointer if still NULL
321 : //
322 : // TODO: what if the array was already set but
323 : // the old fnMaxITScluster and n differ!?
324 208 : if(fnMaxTRDcluster && fnMaxTRDcluster!=n){
325 0 : AliError(Form("Array size does not fit %d/%d\n"
326 : ,fnMaxTRDcluster,n));
327 0 : }
328 :
329 104 : fnMaxTRDcluster = n;
330 312 : AliDebug(2,Form("fnMaxTRDcluster = %d",fnMaxTRDcluster));
331 104 : if (fTRDindex == 0x0){
332 104 : fTRDindex = new Int_t[fnMaxTRDcluster];
333 104 : }
334 104 : memcpy(fTRDindex,indices,sizeof(Int_t)*fnMaxTRDcluster); //RS
335 : //for (Int_t i = 0; i < fnMaxTRDcluster; i++){fTRDindex[i] = indices[i];}
336 104 : }
337 :
338 : void AliESDfriendTrack::TagSuppressSharedObjectsBeforeDeletion()
339 : {
340 : // before deletion of the track we need to suppress eventual shared objects (e.g. TPCclusters)
341 : //
342 : // at the moment take care of TPCseeds only
343 :
344 : TObject* calibObject = NULL;
345 : AliVTPCseed* seedP = 0;
346 0 : for (Int_t idx = 0; (calibObject = GetCalibObject(idx)); ++idx) {
347 0 : if ((seedP = dynamic_cast<AliVTPCseed*>(calibObject))) {
348 0 : seedP->TagSuppressSharedClusters();
349 0 : break;
350 : }
351 : }
352 0 : }
|