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 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
86 fDigitsInCluster -> SetOwner(kTRUE);
90 //====================================================================================================================================================
92 AliMFTCluster& AliMFTCluster::operator=(const AliMFTCluster& cluster) {
96 // check assignement to self
97 if (this == &cluster) return *this;
99 // base class assignement
100 TObject::operator=(cluster);
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;
118 fIsClusterEditable = cluster.fIsClusterEditable;
120 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
121 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
122 fDigitsInCluster->SetOwner(kTRUE);
128 //====================================================================================================================================================
130 Double_t AliMFTCluster::GetDistanceFromPixel(AliMFTDigit *pixel) {
132 // the distance is expressed in units of pixels!!!
133 // useful to decide if the pixel is compatible with the current digits array
135 Double_t distance = -1;
137 if (!fSize) return distance;
139 if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.;
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));
154 //====================================================================================================================================================
156 Bool_t AliMFTCluster::AddPixel(AliMFTDigit *pixel) {
158 if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE;
159 if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE;
161 new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel);
164 SetPlane(pixel->GetPlane());
165 SetDetElemID(pixel->GetDetElemID());
174 //====================================================================================================================================================
176 void AliMFTCluster::TerminateCluster() {
178 Double_t xCenters[fNMaxDigitsPerCluster] = {0};
179 Double_t yCenters[fNMaxDigitsPerCluster] = {0};
180 Double_t nElectrons = 0.;
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));
190 SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters));
191 SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters));
192 SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ());
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) );
201 SetNElectrons(nElectrons);
203 fIsClusterEditable = kFALSE;
207 //====================================================================================================================================================
209 void AliMFTCluster::AddMCLabel(Int_t label) {
211 if (fNMCTracks>=fNMaxMCTracks) return;
213 for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return;
215 fMCLabel[fNMCTracks++]=label;
219 //====================================================================================================================================================
221 AliMUONRawCluster* AliMFTCluster::CreateMUONCluster() {
223 AliMUONRawCluster *cluster = new AliMUONRawCluster();
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
233 //====================================================================================================================================================