]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliTrackResiduals.cxx
Update rawdata format for trigger (Christian)
[u/mrichter/AliRoot.git] / STEER / AliTrackResiduals.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 base class for track residuals
18 //
19 //
20 //-----------------------------------------------------------------
21
22 #include "AliTrackResiduals.h"
23
24 #include "AliAlignObj.h"
25 #include "AliAlignObjAngles.h"
26 #include "AliTrackPointArray.h"
27
28 ClassImp(AliTrackResiduals)
29
30 //_____________________________________________________________________________
31 AliTrackResiduals::AliTrackResiduals():
32   fN(0),
33   fLast(0),
34   fAlignObj(0),
35   fVolArray(0),
36   fTrackArray(0),
37   fChi2(0),
38   fNdf(0),
39   fMinNPoints(0),
40   fIsOwner(kTRUE)
41 {
42   // Default constructor
43 }
44
45 //_____________________________________________________________________________
46 AliTrackResiduals::AliTrackResiduals(Int_t ntracks):
47   fN(ntracks),
48   fLast(0),
49   fAlignObj(0),
50   fChi2(0),
51   fNdf(0),
52   fMinNPoints(0),
53   fIsOwner(kTRUE)
54 {
55   // Constructor
56   if (ntracks > 0) {
57     fVolArray = new AliTrackPointArray*[ntracks];
58     fTrackArray = new AliTrackPointArray*[ntracks];
59     for (Int_t itrack = 0; itrack < ntracks; itrack++)
60       fVolArray[itrack] = fTrackArray[itrack] = 0x0;
61   }
62 }
63
64 //_____________________________________________________________________________
65 AliTrackResiduals::AliTrackResiduals(const AliTrackResiduals &res):
66   TObject(res),
67   fN(res.fN),
68   fLast(res.fLast),
69   fChi2(res.fChi2),
70   fNdf(res.fNdf),
71   fMinNPoints(res.fMinNPoints),
72   fIsOwner(kTRUE)
73 {
74   // Copy constructor
75   // By default the created copy owns the track point arrays
76   if (res.fAlignObj)
77     fAlignObj = (AliAlignObj *)res.fAlignObj->Clone();
78
79   if (fN > 0) {
80     fVolArray = new AliTrackPointArray*[fN];
81     fTrackArray = new AliTrackPointArray*[fN];
82     for (Int_t itrack = 0; itrack < fN; itrack++)
83       {
84         if (res.fVolArray[itrack])
85           fVolArray[itrack] = new AliTrackPointArray(*res.fVolArray[itrack]);
86         else
87           fVolArray = 0x0;
88         if (res.fTrackArray[itrack])
89           fTrackArray[itrack] = new AliTrackPointArray(*res.fTrackArray[itrack]);
90         else
91           fTrackArray = 0x0;
92       }
93   }
94 }
95
96 //_____________________________________________________________________________
97 AliTrackResiduals &AliTrackResiduals::operator =(const AliTrackResiduals& res)
98 {
99   // assignment operator
100   // Does not copy the track point arrays
101   if(this==&res) return *this;
102   ((TObject *)this)->operator=(res);
103
104   fN = res.fN;
105   fLast = res.fLast;
106   fChi2 = res.fChi2;
107   fNdf  = res.fNdf;
108   fMinNPoints = res.fMinNPoints;
109   fIsOwner = kFALSE;
110   fAlignObj = res.fAlignObj;
111
112   fVolArray = res.fVolArray;
113   fTrackArray = res.fTrackArray;
114
115   return *this;
116 }
117
118 //_____________________________________________________________________________
119 AliTrackResiduals::~AliTrackResiduals()
120 {
121   // Destructor
122   if (fAlignObj) delete fAlignObj;
123   DeleteTrackPointArrays();
124 }
125
126 //_____________________________________________________________________________
127 void AliTrackResiduals::SetNTracks(Int_t ntracks)
128 {
129   // Set new size for the track point arrays.
130   // Delete the old arrays and allocate the
131   // new ones.
132   DeleteTrackPointArrays();
133
134   fN = ntracks;
135   fLast = 0;
136   fChi2 = 0;
137   fNdf  = 0;
138   fIsOwner = kTRUE;
139
140   if (ntracks > 0) {
141     fVolArray = new AliTrackPointArray*[ntracks];
142     fTrackArray = new AliTrackPointArray*[ntracks];
143     for (Int_t itrack = 0; itrack < ntracks; itrack++)
144       fVolArray[itrack] = fTrackArray[itrack] = 0x0;
145   }
146 }
147
148 //_____________________________________________________________________________
149 Bool_t AliTrackResiduals::AddTrackPointArrays(AliTrackPointArray *volarray, AliTrackPointArray *trackarray)
150 {
151   // Adds pair of track space point and
152   // track extrapolation point arrays
153   if (!fVolArray || !fTrackArray) return kFALSE;
154
155   if (!volarray || !trackarray) return kFALSE;
156
157   if (volarray->GetNPoints() < fMinNPoints) return kFALSE;
158
159   if (fLast >= fN) return kFALSE;
160
161   fVolArray[fLast] = volarray;
162   fTrackArray[fLast] = trackarray;
163   fLast++;
164
165   return kTRUE;
166 }
167
168 //_____________________________________________________________________________
169 void AliTrackResiduals::InitAlignObj()
170 {
171   // Create the alignment object 
172   // to be updated
173   if (fAlignObj) delete fAlignObj;
174   fAlignObj = new AliAlignObjAngles;
175 }
176
177
178 //_____________________________________________________________________________
179 Bool_t AliTrackResiduals::GetTrackPointArrays(Int_t i, AliTrackPointArray* &volarray, AliTrackPointArray* &trackarray) const
180 {
181   // Provide an access to a pair of track point arrays
182   // with given index
183   if (i >= fLast) {
184     volarray = trackarray = 0x0;
185     return kFALSE;
186   }
187   else {
188     volarray = fVolArray[i];
189     trackarray = fTrackArray[i];
190     return kTRUE;
191   }
192 }
193
194 //_____________________________________________________________________________
195 void AliTrackResiduals::DeleteTrackPointArrays()
196 {
197   // Deletes the track point arrays only in case
198   // the object is their owner.
199   // Called by the destructor and SetNTracks methods.
200   if (fIsOwner) {
201     for (Int_t itrack = 0; itrack < fLast; itrack++)
202       {
203         delete fVolArray[itrack];
204         delete fTrackArray[itrack];
205       }
206     delete [] fVolArray;
207     delete [] fTrackArray;
208   }
209 }