]>
Commit | Line | Data |
---|---|---|
820b4d9e | 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 | // | |
18 | // Class for the description of the clusters of the ALICE Muon Forward Tracker | |
19 | // | |
20 | // Contact author: antonio.uras@cern.ch | |
21 | // | |
22 | //==================================================================================================================================================== | |
23 | ||
24 | #include "TObject.h" | |
25 | #include "AliMUONRawCluster.h" | |
26 | #include "AliMUONVCluster.h" | |
d4643a10 | 27 | #include "AliMFTDigit.h" |
28 | #include "TMath.h" | |
820b4d9e | 29 | #include "AliMFTCluster.h" |
30 | ||
31 | ClassImp(AliMFTCluster) | |
32 | ||
33 | //==================================================================================================================================================== | |
34 | ||
35 | AliMFTCluster::AliMFTCluster(): | |
36 | TObject(), | |
37 | fX(0), | |
38 | fY(0), | |
39 | fZ(0), | |
40 | fErrX(0), | |
41 | fErrY(0), | |
42 | fErrZ(0), | |
43 | fNElectrons(0), | |
44 | fNMCTracks(0), | |
d4643a10 | 45 | fPlane(-1), |
46 | fDetElemID(-1), | |
820b4d9e | 47 | fSize(0), |
48 | fTrackChi2(0), | |
d4643a10 | 49 | fLocalChi2(0), |
50 | fDigitsInCluster(0), | |
51 | fIsClusterEditable(kTRUE) | |
820b4d9e | 52 | { |
53 | ||
54 | // default constructor | |
55 | ||
56 | for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = -1; | |
57 | ||
d4643a10 | 58 | fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster); |
274c2dce | 59 | fDigitsInCluster -> SetOwner(kTRUE); |
d4643a10 | 60 | } |
61 | ||
62 | //==================================================================================================================================================== | |
63 | ||
64 | AliMFTCluster::AliMFTCluster(const AliMFTCluster& cluster): | |
65 | TObject(cluster), | |
66 | fX(cluster.fX), | |
67 | fY(cluster.fY), | |
68 | fZ(cluster.fZ), | |
69 | fErrX(cluster.fErrX), | |
70 | fErrY(cluster.fErrY), | |
71 | fErrZ(cluster.fErrZ), | |
72 | fNElectrons(cluster.fNElectrons), | |
73 | fNMCTracks(cluster.fNMCTracks), | |
74 | fPlane(cluster.fPlane), | |
75 | fDetElemID(cluster.fDetElemID), | |
76 | fSize(cluster.fSize), | |
77 | fTrackChi2(cluster.fTrackChi2), | |
78 | fLocalChi2(cluster.fLocalChi2), | |
274c2dce | 79 | fDigitsInCluster(NULL), |
d4643a10 | 80 | fIsClusterEditable(cluster.fIsClusterEditable) |
81 | { | |
82 | ||
83 | // copy constructor | |
84 | for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack]; | |
e21f8bf5 | 85 | if (cluster.fDigitsInCluster) { |
e21f8bf5 | 86 | fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster)); |
87 | fDigitsInCluster -> SetOwner(kTRUE); | |
88 | } | |
89 | else { | |
e21f8bf5 | 90 | fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster); |
91 | fDigitsInCluster -> SetOwner(kTRUE); | |
92 | } | |
274c2dce | 93 | |
d4643a10 | 94 | } |
95 | ||
96 | //==================================================================================================================================================== | |
97 | ||
98 | AliMFTCluster& AliMFTCluster::operator=(const AliMFTCluster& cluster) { | |
99 | ||
100 | // Asignment operator | |
101 | ||
102 | // check assignement to self | |
103 | if (this == &cluster) return *this; | |
104 | ||
105 | // base class assignement | |
106 | TObject::operator=(cluster); | |
107 | ||
108 | // clear memory | |
274c2dce | 109 | Clear(""); |
d4643a10 | 110 | |
111 | fX = cluster.fX; | |
112 | fY = cluster.fY; | |
113 | fZ = cluster.fZ; | |
114 | fErrX = cluster.fErrX; | |
115 | fErrY = cluster.fErrY; | |
116 | fErrZ = cluster.fErrZ; | |
117 | fNElectrons = cluster.fNElectrons; | |
118 | fNMCTracks = cluster.fNMCTracks; | |
119 | fPlane = cluster.fPlane; | |
120 | fDetElemID = cluster.fDetElemID; | |
121 | fSize = cluster.fSize; | |
122 | fTrackChi2 = cluster.fTrackChi2; | |
123 | fLocalChi2 = cluster.fLocalChi2; | |
d4643a10 | 124 | fIsClusterEditable = cluster.fIsClusterEditable; |
125 | ||
126 | for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack]; | |
274c2dce | 127 | fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster)); |
128 | fDigitsInCluster->SetOwner(kTRUE); | |
129 | ||
d4643a10 | 130 | return *this; |
131 | ||
132 | } | |
133 | ||
134 | //==================================================================================================================================================== | |
135 | ||
136 | Double_t AliMFTCluster::GetDistanceFromPixel(AliMFTDigit *pixel) { | |
137 | ||
138 | // the distance is expressed in units of pixels!!! | |
139 | // useful to decide if the pixel is compatible with the current digits array | |
140 | ||
141 | Double_t distance = -1; | |
142 | ||
143 | if (!fSize) return distance; | |
144 | ||
145 | if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.; | |
146 | ||
147 | for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) { | |
148 | AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit); | |
149 | Int_t distX = TMath::Abs(tmpDig->GetPixelX() - pixel->GetPixelX()); | |
150 | Int_t distY = TMath::Abs(tmpDig->GetPixelY() - pixel->GetPixelY()); | |
151 | if (distX<=1 && distY<=1) return 0; | |
152 | if (!iDigit) distance = TMath::Sqrt(distX*distX + distY*distY); | |
153 | else distance = TMath::Min(distance, TMath::Sqrt(distX*distX + distY*distY)); | |
154 | } | |
155 | ||
156 | return distance; | |
157 | ||
158 | } | |
159 | ||
160 | //==================================================================================================================================================== | |
161 | ||
162 | Bool_t AliMFTCluster::AddPixel(AliMFTDigit *pixel) { | |
163 | ||
164 | if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE; | |
165 | if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE; | |
166 | ||
167 | new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel); | |
168 | ||
169 | if (!fSize) { | |
170 | SetPlane(pixel->GetPlane()); | |
171 | SetDetElemID(pixel->GetDetElemID()); | |
172 | } | |
173 | ||
174 | fSize++; | |
175 | ||
176 | return kTRUE; | |
177 | ||
178 | } | |
179 | ||
180 | //==================================================================================================================================================== | |
181 | ||
182 | void AliMFTCluster::TerminateCluster() { | |
183 | ||
184 | Double_t xCenters[fNMaxDigitsPerCluster] = {0}; | |
185 | Double_t yCenters[fNMaxDigitsPerCluster] = {0}; | |
186 | Double_t nElectrons = 0.; | |
187 | ||
188 | for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) { | |
189 | AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit); | |
190 | xCenters[iDigit] = tmpDig->GetPixelCenterX(); | |
191 | yCenters[iDigit] = tmpDig->GetPixelCenterY(); | |
192 | nElectrons += tmpDig->GetNElectrons(); | |
193 | for (Int_t iTrack=0; iTrack<tmpDig->GetNMCTracks(); iTrack++) AddMCLabel(tmpDig->GetMCLabel(iTrack)); | |
194 | } | |
195 | ||
196 | SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters)); | |
197 | SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters)); | |
198 | SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ()); | |
199 | ||
200 | Double_t minErrX = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthX() / TMath::Sqrt(12.); | |
201 | Double_t minErrY = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthY() / TMath::Sqrt(12.); | |
202 | Double_t minErrZ = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthZ() / TMath::Sqrt(12.); | |
203 | SetErrX( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), xCenters), minErrX) ); | |
204 | SetErrY( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), yCenters), minErrY) ); | |
205 | SetErrZ( minErrZ ); | |
206 | ||
207 | SetNElectrons(nElectrons); | |
208 | ||
209 | fIsClusterEditable = kFALSE; | |
210 | ||
211 | } | |
212 | ||
213 | //==================================================================================================================================================== | |
214 | ||
215 | void AliMFTCluster::AddMCLabel(Int_t label) { | |
216 | ||
217 | if (fNMCTracks>=fNMaxMCTracks) return; | |
218 | ||
219 | for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return; | |
220 | ||
221 | fMCLabel[fNMCTracks++]=label; | |
222 | ||
820b4d9e | 223 | } |
224 | ||
225 | //==================================================================================================================================================== | |
226 | ||
227 | AliMUONRawCluster* AliMFTCluster::CreateMUONCluster() { | |
228 | ||
229 | AliMUONRawCluster *cluster = new AliMUONRawCluster(); | |
230 | ||
231 | cluster->SetXYZ(GetX(), GetY(), GetZ()); | |
232 | cluster->SetErrXY(GetErrX(),GetErrY()); | |
233 | cluster->SetDetElemId(100); // to get the cluster compatible with the AliMUONTrack::AddTrackParamAtCluster(...) method | |
234 | ||
235 | return cluster; | |
236 | ||
237 | } | |
238 | ||
239 | //==================================================================================================================================================== |