]>
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]; | |
274c2dce | 85 | fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster)); |
86 | fDigitsInCluster -> SetOwner(kTRUE); | |
87 | ||
d4643a10 | 88 | } |
89 | ||
90 | //==================================================================================================================================================== | |
91 | ||
92 | AliMFTCluster& AliMFTCluster::operator=(const AliMFTCluster& cluster) { | |
93 | ||
94 | // Asignment operator | |
95 | ||
96 | // check assignement to self | |
97 | if (this == &cluster) return *this; | |
98 | ||
99 | // base class assignement | |
100 | TObject::operator=(cluster); | |
101 | ||
102 | // clear memory | |
274c2dce | 103 | Clear(""); |
d4643a10 | 104 | |
105 | fX = cluster.fX; | |
106 | fY = cluster.fY; | |
107 | fZ = cluster.fZ; | |
108 | fErrX = cluster.fErrX; | |
109 | fErrY = cluster.fErrY; | |
110 | fErrZ = cluster.fErrZ; | |
111 | fNElectrons = cluster.fNElectrons; | |
112 | fNMCTracks = cluster.fNMCTracks; | |
113 | fPlane = cluster.fPlane; | |
114 | fDetElemID = cluster.fDetElemID; | |
115 | fSize = cluster.fSize; | |
116 | fTrackChi2 = cluster.fTrackChi2; | |
117 | fLocalChi2 = cluster.fLocalChi2; | |
d4643a10 | 118 | fIsClusterEditable = cluster.fIsClusterEditable; |
119 | ||
120 | for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack]; | |
274c2dce | 121 | fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster)); |
122 | fDigitsInCluster->SetOwner(kTRUE); | |
123 | ||
d4643a10 | 124 | return *this; |
125 | ||
126 | } | |
127 | ||
128 | //==================================================================================================================================================== | |
129 | ||
130 | Double_t AliMFTCluster::GetDistanceFromPixel(AliMFTDigit *pixel) { | |
131 | ||
132 | // the distance is expressed in units of pixels!!! | |
133 | // useful to decide if the pixel is compatible with the current digits array | |
134 | ||
135 | Double_t distance = -1; | |
136 | ||
137 | if (!fSize) return distance; | |
138 | ||
139 | if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.; | |
140 | ||
141 | for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) { | |
142 | AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit); | |
143 | Int_t distX = TMath::Abs(tmpDig->GetPixelX() - pixel->GetPixelX()); | |
144 | Int_t distY = TMath::Abs(tmpDig->GetPixelY() - pixel->GetPixelY()); | |
145 | if (distX<=1 && distY<=1) return 0; | |
146 | if (!iDigit) distance = TMath::Sqrt(distX*distX + distY*distY); | |
147 | else distance = TMath::Min(distance, TMath::Sqrt(distX*distX + distY*distY)); | |
148 | } | |
149 | ||
150 | return distance; | |
151 | ||
152 | } | |
153 | ||
154 | //==================================================================================================================================================== | |
155 | ||
156 | Bool_t AliMFTCluster::AddPixel(AliMFTDigit *pixel) { | |
157 | ||
158 | if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE; | |
159 | if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE; | |
160 | ||
161 | new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel); | |
162 | ||
163 | if (!fSize) { | |
164 | SetPlane(pixel->GetPlane()); | |
165 | SetDetElemID(pixel->GetDetElemID()); | |
166 | } | |
167 | ||
168 | fSize++; | |
169 | ||
170 | return kTRUE; | |
171 | ||
172 | } | |
173 | ||
174 | //==================================================================================================================================================== | |
175 | ||
176 | void AliMFTCluster::TerminateCluster() { | |
177 | ||
178 | Double_t xCenters[fNMaxDigitsPerCluster] = {0}; | |
179 | Double_t yCenters[fNMaxDigitsPerCluster] = {0}; | |
180 | Double_t nElectrons = 0.; | |
181 | ||
182 | for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) { | |
183 | AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit); | |
184 | xCenters[iDigit] = tmpDig->GetPixelCenterX(); | |
185 | yCenters[iDigit] = tmpDig->GetPixelCenterY(); | |
186 | nElectrons += tmpDig->GetNElectrons(); | |
187 | for (Int_t iTrack=0; iTrack<tmpDig->GetNMCTracks(); iTrack++) AddMCLabel(tmpDig->GetMCLabel(iTrack)); | |
188 | } | |
189 | ||
190 | SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters)); | |
191 | SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters)); | |
192 | SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ()); | |
193 | ||
194 | Double_t minErrX = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthX() / TMath::Sqrt(12.); | |
195 | Double_t minErrY = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthY() / TMath::Sqrt(12.); | |
196 | Double_t minErrZ = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthZ() / TMath::Sqrt(12.); | |
197 | SetErrX( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), xCenters), minErrX) ); | |
198 | SetErrY( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), yCenters), minErrY) ); | |
199 | SetErrZ( minErrZ ); | |
200 | ||
201 | SetNElectrons(nElectrons); | |
202 | ||
203 | fIsClusterEditable = kFALSE; | |
204 | ||
205 | } | |
206 | ||
207 | //==================================================================================================================================================== | |
208 | ||
209 | void AliMFTCluster::AddMCLabel(Int_t label) { | |
210 | ||
211 | if (fNMCTracks>=fNMaxMCTracks) return; | |
212 | ||
213 | for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return; | |
214 | ||
215 | fMCLabel[fNMCTracks++]=label; | |
216 | ||
820b4d9e | 217 | } |
218 | ||
219 | //==================================================================================================================================================== | |
220 | ||
221 | AliMUONRawCluster* AliMFTCluster::CreateMUONCluster() { | |
222 | ||
223 | AliMUONRawCluster *cluster = new AliMUONRawCluster(); | |
224 | ||
225 | cluster->SetXYZ(GetX(), GetY(), GetZ()); | |
226 | cluster->SetErrXY(GetErrX(),GetErrY()); | |
227 | cluster->SetDetElemId(100); // to get the cluster compatible with the AliMUONTrack::AddTrackParamAtCluster(...) method | |
228 | ||
229 | return cluster; | |
230 | ||
231 | } | |
232 | ||
233 | //==================================================================================================================================================== |