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