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);
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(cluster.fDigitsInCluster),
80 fIsClusterEditable(cluster.fIsClusterEditable)
84 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
88 //====================================================================================================================================================
90 AliMFTCluster& AliMFTCluster::operator=(const AliMFTCluster& cluster) {
94 // check assignement to self
95 if (this == &cluster) return *this;
97 // base class assignement
98 TObject::operator=(cluster);
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;
119 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
125 //====================================================================================================================================================
127 Double_t AliMFTCluster::GetDistanceFromPixel(AliMFTDigit *pixel) {
129 // the distance is expressed in units of pixels!!!
130 // useful to decide if the pixel is compatible with the current digits array
132 Double_t distance = -1;
134 if (!fSize) return distance;
136 if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.;
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));
151 //====================================================================================================================================================
153 Bool_t AliMFTCluster::AddPixel(AliMFTDigit *pixel) {
155 if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE;
156 if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE;
158 new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel);
161 SetPlane(pixel->GetPlane());
162 SetDetElemID(pixel->GetDetElemID());
171 //====================================================================================================================================================
173 void AliMFTCluster::TerminateCluster() {
175 Double_t xCenters[fNMaxDigitsPerCluster] = {0};
176 Double_t yCenters[fNMaxDigitsPerCluster] = {0};
177 Double_t nElectrons = 0.;
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));
187 SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters));
188 SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters));
189 SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ());
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) );
198 SetNElectrons(nElectrons);
200 fIsClusterEditable = kFALSE;
204 //====================================================================================================================================================
206 void AliMFTCluster::AddMCLabel(Int_t label) {
208 if (fNMCTracks>=fNMaxMCTracks) return;
210 for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return;
212 fMCLabel[fNMCTracks++]=label;
216 //====================================================================================================================================================
218 AliMUONRawCluster* AliMFTCluster::CreateMUONCluster() {
220 AliMUONRawCluster *cluster = new AliMUONRawCluster();
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
230 //====================================================================================================================================================