]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/STEER/AliRecPoint.cxx
Coverity
[u/mrichter/AliRoot.git] / STEER / STEER / AliRecPoint.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$ */
17
18 //-*-C++-*-
19 //_________________________________________________________________________
20 // Base Class for reconstructed space points 
21 // usually coming from the clusterisation algorithms
22 // run on the digits
23 //
24 //*-- Author : Yves Schutz  SUBATECH 
25 //////////////////////////////////////////////////////////////////////////////
26
27
28 // --- ROOT system ---
29
30 // --- Standard library ---
31
32 // --- AliRoot header files ---
33
34 #include "AliRecPoint.h"
35 #include "AliGeometry.h"
36 #include "AliDigitNew.h"
37
38 ClassImp(AliRecPoint)
39
40
41 //_______________________________________________________________________
42 AliRecPoint::AliRecPoint():
43   fAmp(0),
44   fGeom(0),
45   fIndexInList(-1), // to be set when the point is already stored
46   fLocPos(0,0,0),
47   fLocPosM(0),
48   fMaxDigit(100),
49   fMulDigit(0),
50   fMaxTrack(5),
51   fMulTrack(0),
52   fDigitsList(0),
53   fTracksList(0)
54 {
55   //
56   // default ctor  
57   //
58 }
59
60 //_______________________________________________________________________
61 AliRecPoint::AliRecPoint(const char * ):
62   fAmp(0),
63   fGeom(0),
64   fIndexInList(-1), // to be set when the point is already stored
65   fLocPos(0,0,0),
66   fLocPosM(new TMatrixF(3,3)),
67   fMaxDigit(100),
68   fMulDigit(0),
69   fMaxTrack(5),
70   fMulTrack(0),
71   fDigitsList(new int[fMaxDigit]),
72   fTracksList(new int[fMaxTrack])
73 {
74   //
75   // Standard ctor  
76   //
77 }
78
79 //_______________________________________________________________________
80 AliRecPoint::AliRecPoint(const AliRecPoint& recp):
81   TObject(recp),
82   fAmp(recp.fAmp),
83   fGeom(recp.fGeom),
84   fIndexInList(-1), // to be set when the point is already stored
85   fLocPos(recp.fLocPos),
86   fLocPosM(new TMatrixF(*(recp.fLocPosM))),
87   fMaxDigit(recp.fMaxDigit),
88   fMulDigit(recp.fMulDigit),
89   fMaxTrack(recp.fMaxTrack),
90   fMulTrack(recp.fMulTrack),
91   fDigitsList(new Int_t[fMulDigit]),
92   fTracksList(new Int_t[fMulTrack])
93 {
94   //
95   // Copy constructor
96   //
97   memcpy(fDigitsList,recp.fDigitsList,sizeof(Int_t)*fMulDigit);
98   memcpy(fTracksList,recp.fTracksList,sizeof(Int_t)*fMulTrack);
99 }
100
101 //_______________________________________________________________________
102 AliRecPoint::~AliRecPoint()
103 {
104   // dtor
105   
106   delete fLocPosM ; 
107   delete [] fDigitsList ; 
108   delete [] fTracksList ;  
109   
110 }
111   
112 //_______________________________________________________________________
113 void AliRecPoint::AddDigit(AliDigitNew & digit)
114 {
115   // adds a digit to the digits list
116   // and accumulates the total amplitude and the multiplicity 
117   
118   
119   if ( fMulDigit >= fMaxDigit ) { // increase the size of the list 
120     int * tempo = new int[fMaxDigit*2]; 
121     
122     Int_t index ; 
123     
124     for ( index = 0 ; index < fMulDigit ; index++ )
125       tempo[index] = fDigitsList[index] ; 
126     
127     delete [] fDigitsList ; 
128     fDigitsList = tempo ; 
129   }
130   
131   fDigitsList[fMulDigit] = digit.GetIndexInList()  ; 
132   fMulDigit++ ; 
133   fAmp += digit.GetAmp() ; 
134 }
135
136 //_______________________________________________________________________
137 // void AliRecPoint::AddTrack(AliTrack & track)
138 // {
139 //   // adds a digit to the digits list
140 //   // and accumulates the total amplitude and the multiplicity 
141
142
143 //   if ( fMulTrack >= fMaxTrack ) { // increase the size of the list 
144 //     int * tempo = new int[fMaxTrack*=2] ; 
145 //     Int_t index ; 
146 //     for ( index = 0 ; index < fMulTrack ; index++ )
147 //       tempo[index] = fTracksList[index] ; 
148 //     delete fTracksList ; 
149 //     fTracksList = tempo ; 
150 //   }
151
152 //   fTracksList[fMulTrack++]=  (int) &Track  ; 
153 // }
154
155 //_______________________________________________________________________
156 void AliRecPoint::Copy(TObject& recp) const
157 {
158   //
159   // Copy *this onto pts
160   //
161   // Copy all first
162   if((TObject*)this != &recp) {
163     ((TObject*) this)->Copy(recp);
164     (dynamic_cast<AliRecPoint&>(recp)).fAmp = fAmp;
165     (dynamic_cast<AliRecPoint&>(recp)).fGeom = fGeom;
166     (dynamic_cast<AliRecPoint&>(recp)).fIndexInList = fIndexInList;
167     (dynamic_cast<AliRecPoint&>(recp)).fLocPos = fLocPos;
168     (dynamic_cast<AliRecPoint&>(recp)).fLocPosM = new TMatrixF(*fLocPosM);
169     (dynamic_cast<AliRecPoint&>(recp)).fMaxDigit = fMaxDigit;
170     (dynamic_cast<AliRecPoint&>(recp)).fMulDigit = fMulDigit;
171     (dynamic_cast<AliRecPoint&>(recp)).fMaxTrack = fMaxTrack;
172     (dynamic_cast<AliRecPoint&>(recp)).fMulTrack = fMulTrack;
173     
174     // Duplicate pointed objects
175     (dynamic_cast<AliRecPoint&>(recp)).fDigitsList = new Int_t[fMulDigit];
176     memcpy((dynamic_cast<AliRecPoint&>(recp)).fDigitsList,fDigitsList,fMulDigit*sizeof(Int_t));
177     (dynamic_cast<AliRecPoint&>(recp)).fTracksList = new Int_t[fMulTrack];
178     memcpy((dynamic_cast<AliRecPoint&>(recp)).fTracksList,fTracksList,fMulTrack*sizeof(Int_t));
179   }
180 }
181
182 //_______________________________________________________________________
183 void AliRecPoint::GetCovarianceMatrix(TMatrixF & mat) const
184 {
185   // returns the covariant matrix for the local position
186   
187   mat = *fLocPosM ; 
188
189 }
190
191 //____________________________________________________________________________
192 void AliRecPoint::GetLocalPosition(TVector3 & pos) const
193 {
194   // returns the position of the cluster in the local reference system of the sub-detector
195
196   pos = fLocPos;
197
198  
199 }
200
201 //____________________________________________________________________________
202 void AliRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const
203 {
204   // returns the position of the cluster in the global reference system of ALICE
205   // and the uncertainty on this position
206   
207
208   fGeom->GetGlobal(this, gpos, gmat) ;
209  
210 }
211
212