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