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