]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliRecPoint.cxx
put delete before placement new, mem. leak possible in case entries==0 because of...
[u/mrichter/AliRoot.git] / STEER / AliRecPoint.cxx
... / ...
CommitLineData
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
38ClassImp(AliRecPoint)
39
40
41//_______________________________________________________________________
42AliRecPoint::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//_______________________________________________________________________
61AliRecPoint::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//_______________________________________________________________________
80AliRecPoint::AliRecPoint(const AliRecPoint& recp):
81 TObject(recp),
82 fAmp(0),
83 fGeom(0),
84 fIndexInList(-1), // to be set when the point is already stored
85 fLocPos(0,0,0),
86 fLocPosM(0),
87 fMaxDigit(100),
88 fMulDigit(0),
89 fMaxTrack(5),
90 fMulTrack(0),
91 fDigitsList(0),
92 fTracksList(0)
93{
94 //
95 // Copy constructor
96 //
97 recp.Copy(*this);
98}
99
100//_______________________________________________________________________
101AliRecPoint::~AliRecPoint()
102{
103 // dtor
104
105 delete fLocPosM ;
106 delete [] fDigitsList ;
107 delete [] fTracksList ;
108
109}
110
111//_______________________________________________________________________
112void AliRecPoint::AddDigit(AliDigitNew & digit)
113{
114 // adds a digit to the digits list
115 // and accumulates the total amplitude and the multiplicity
116
117
118 if ( fMulDigit >= fMaxDigit ) { // increase the size of the list
119 int * tempo = new int[fMaxDigit*2];
120
121 Int_t index ;
122
123 for ( index = 0 ; index < fMulDigit ; index++ )
124 tempo[index] = fDigitsList[index] ;
125
126 delete [] fDigitsList ;
127 fDigitsList = tempo ;
128 }
129
130 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
131 fMulDigit++ ;
132 fAmp += digit.GetAmp() ;
133}
134
135//_______________________________________________________________________
136// void AliRecPoint::AddTrack(AliTrack & track)
137// {
138// // adds a digit to the digits list
139// // and accumulates the total amplitude and the multiplicity
140
141
142// if ( fMulTrack >= fMaxTrack ) { // increase the size of the list
143// int * tempo = new int[fMaxTrack*=2] ;
144// Int_t index ;
145// for ( index = 0 ; index < fMulTrack ; index++ )
146// tempo[index] = fTracksList[index] ;
147// delete fTracksList ;
148// fTracksList = tempo ;
149// }
150
151// fTracksList[fMulTrack++]= (int) &Track ;
152// }
153
154//_______________________________________________________________________
155void AliRecPoint::Copy(TObject& recp) const
156{
157 //
158 // Copy *this onto pts
159 //
160 // Copy all first
161 if((TObject*)this != &recp) {
162 ((TObject*) this)->Copy(recp);
163 (dynamic_cast<AliRecPoint&>(recp)).fAmp = fAmp;
164 (dynamic_cast<AliRecPoint&>(recp)).fGeom = fGeom;
165 (dynamic_cast<AliRecPoint&>(recp)).fIndexInList = fIndexInList;
166 (dynamic_cast<AliRecPoint&>(recp)).fLocPos = fLocPos;
167 (dynamic_cast<AliRecPoint&>(recp)).fLocPosM = new TMatrixF(*fLocPosM);
168 (dynamic_cast<AliRecPoint&>(recp)).fMaxDigit = fMaxDigit;
169 (dynamic_cast<AliRecPoint&>(recp)).fMulDigit = fMulDigit;
170 (dynamic_cast<AliRecPoint&>(recp)).fMaxTrack = fMaxTrack;
171 (dynamic_cast<AliRecPoint&>(recp)).fMulTrack = fMulTrack;
172
173 // Duplicate pointed objects
174 (dynamic_cast<AliRecPoint&>(recp)).fDigitsList = new Int_t[fMulDigit];
175 memcpy((dynamic_cast<AliRecPoint&>(recp)).fDigitsList,fDigitsList,fMulDigit*sizeof(Int_t));
176 (dynamic_cast<AliRecPoint&>(recp)).fTracksList = new Int_t[fMulTrack];
177 memcpy((dynamic_cast<AliRecPoint&>(recp)).fTracksList,fTracksList,fMulTrack*sizeof(Int_t));
178 }
179}
180
181//_______________________________________________________________________
182void AliRecPoint::GetCovarianceMatrix(TMatrixF & mat) const
183{
184 // returns the covariant matrix for the local position
185
186 mat = *fLocPosM ;
187
188}
189
190//____________________________________________________________________________
191void AliRecPoint::GetLocalPosition(TVector3 & pos) const
192{
193 // returns the position of the cluster in the local reference system of the sub-detector
194
195 pos = fLocPos;
196
197
198}
199
200//____________________________________________________________________________
201void AliRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const
202{
203 // returns the position of the cluster in the global reference system of ALICE
204 // and the uncertainty on this position
205
206
207 fGeom->GetGlobal(this, gpos, gmat) ;
208
209}
210
211