1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 //====================================================================================================================================================
18 // Class for the description of the clusters of the ALICE Muon Forward Tracker
20 // Contact author: antonio.uras@cern.ch
22 //====================================================================================================================================================
25 #include "AliMUONRawCluster.h"
26 #include "AliMUONVCluster.h"
27 #include "AliMFTDigit.h"
29 #include "AliMFTCluster.h"
31 ClassImp(AliMFTCluster)
33 //====================================================================================================================================================
35 AliMFTCluster::AliMFTCluster():
51 fIsClusterEditable(kTRUE)
54 // default constructor
56 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = -1;
58 fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
59 fDigitsInCluster -> SetOwner(kTRUE);
62 //====================================================================================================================================================
64 AliMFTCluster::AliMFTCluster(const AliMFTCluster& cluster):
72 fNElectrons(cluster.fNElectrons),
73 fNMCTracks(cluster.fNMCTracks),
74 fPlane(cluster.fPlane),
75 fDetElemID(cluster.fDetElemID),
77 fTrackChi2(cluster.fTrackChi2),
78 fLocalChi2(cluster.fLocalChi2),
79 fDigitsInCluster(NULL),
80 fIsClusterEditable(cluster.fIsClusterEditable)
84 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
85 printf("checkpoint1 : cluster.fDigitsInCluster = %p\n",cluster.fDigitsInCluster);
86 if (cluster.fDigitsInCluster) {
87 printf("checkpoint2\n");
88 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
89 fDigitsInCluster -> SetOwner(kTRUE);
92 printf("checkpoint3\n");
93 fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
94 fDigitsInCluster -> SetOwner(kTRUE);
96 printf("checkpoint4\n");
100 //====================================================================================================================================================
102 AliMFTCluster::AliMFTCluster(const AliMFTCluster& cluster, const Bool_t copyDigits):
107 fErrX(cluster.fErrX),
108 fErrY(cluster.fErrY),
109 fErrZ(cluster.fErrZ),
110 fNElectrons(cluster.fNElectrons),
111 fNMCTracks(cluster.fNMCTracks),
112 fPlane(cluster.fPlane),
113 fDetElemID(cluster.fDetElemID),
114 fSize(cluster.fSize),
115 fTrackChi2(cluster.fTrackChi2),
116 fLocalChi2(cluster.fLocalChi2),
117 fDigitsInCluster(NULL),
118 fIsClusterEditable(cluster.fIsClusterEditable)
121 // copy constructor with option for reading digits
123 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
124 printf("checkpoint1\n");
126 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
127 fDigitsInCluster -> SetOwner(kTRUE);
130 fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
131 fDigitsInCluster -> SetOwner(kTRUE);
134 printf("checkpoint2\n");
138 //====================================================================================================================================================
140 AliMFTCluster& AliMFTCluster::operator=(const AliMFTCluster& cluster) {
142 // Asignment operator
144 // check assignement to self
145 if (this == &cluster) return *this;
147 // base class assignement
148 TObject::operator=(cluster);
156 fErrX = cluster.fErrX;
157 fErrY = cluster.fErrY;
158 fErrZ = cluster.fErrZ;
159 fNElectrons = cluster.fNElectrons;
160 fNMCTracks = cluster.fNMCTracks;
161 fPlane = cluster.fPlane;
162 fDetElemID = cluster.fDetElemID;
163 fSize = cluster.fSize;
164 fTrackChi2 = cluster.fTrackChi2;
165 fLocalChi2 = cluster.fLocalChi2;
166 fIsClusterEditable = cluster.fIsClusterEditable;
168 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
169 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
170 fDigitsInCluster->SetOwner(kTRUE);
176 //====================================================================================================================================================
178 Double_t AliMFTCluster::GetDistanceFromPixel(AliMFTDigit *pixel) {
180 // the distance is expressed in units of pixels!!!
181 // useful to decide if the pixel is compatible with the current digits array
183 Double_t distance = -1;
185 if (!fSize) return distance;
187 if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.;
189 for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) {
190 AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit);
191 Int_t distX = TMath::Abs(tmpDig->GetPixelX() - pixel->GetPixelX());
192 Int_t distY = TMath::Abs(tmpDig->GetPixelY() - pixel->GetPixelY());
193 if (distX<=1 && distY<=1) return 0;
194 if (!iDigit) distance = TMath::Sqrt(distX*distX + distY*distY);
195 else distance = TMath::Min(distance, TMath::Sqrt(distX*distX + distY*distY));
202 //====================================================================================================================================================
204 Bool_t AliMFTCluster::AddPixel(AliMFTDigit *pixel) {
206 if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE;
207 if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE;
209 new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel);
212 SetPlane(pixel->GetPlane());
213 SetDetElemID(pixel->GetDetElemID());
222 //====================================================================================================================================================
224 void AliMFTCluster::TerminateCluster() {
226 Double_t xCenters[fNMaxDigitsPerCluster] = {0};
227 Double_t yCenters[fNMaxDigitsPerCluster] = {0};
228 Double_t nElectrons = 0.;
230 for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) {
231 AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit);
232 xCenters[iDigit] = tmpDig->GetPixelCenterX();
233 yCenters[iDigit] = tmpDig->GetPixelCenterY();
234 nElectrons += tmpDig->GetNElectrons();
235 for (Int_t iTrack=0; iTrack<tmpDig->GetNMCTracks(); iTrack++) AddMCLabel(tmpDig->GetMCLabel(iTrack));
238 SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters));
239 SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters));
240 SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ());
242 Double_t minErrX = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthX() / TMath::Sqrt(12.);
243 Double_t minErrY = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthY() / TMath::Sqrt(12.);
244 Double_t minErrZ = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthZ() / TMath::Sqrt(12.);
245 SetErrX( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), xCenters), minErrX) );
246 SetErrY( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), yCenters), minErrY) );
249 SetNElectrons(nElectrons);
251 fIsClusterEditable = kFALSE;
255 //====================================================================================================================================================
257 void AliMFTCluster::AddMCLabel(Int_t label) {
259 if (fNMCTracks>=fNMaxMCTracks) return;
261 for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return;
263 fMCLabel[fNMCTracks++]=label;
267 //====================================================================================================================================================
269 AliMUONRawCluster* AliMFTCluster::CreateMUONCluster() {
271 AliMUONRawCluster *cluster = new AliMUONRawCluster();
273 cluster->SetXYZ(GetX(), GetY(), GetZ());
274 cluster->SetErrXY(GetErrX(),GetErrY());
275 cluster->SetDetElemId(100); // to get the cluster compatible with the AliMUONTrack::AddTrackParamAtCluster(...) method
281 //====================================================================================================================================================