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 if (cluster.fDigitsInCluster) {
86 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
87 fDigitsInCluster -> SetOwner(kTRUE);
90 fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
91 fDigitsInCluster -> SetOwner(kTRUE);
96 //====================================================================================================================================================
98 AliMFTCluster& AliMFTCluster::operator=(const AliMFTCluster& cluster) {
100 // Asignment operator
102 // check assignement to self
103 if (this == &cluster) return *this;
105 // base class assignement
106 TObject::operator=(cluster);
114 fErrX = cluster.fErrX;
115 fErrY = cluster.fErrY;
116 fErrZ = cluster.fErrZ;
117 fNElectrons = cluster.fNElectrons;
118 fNMCTracks = cluster.fNMCTracks;
119 fPlane = cluster.fPlane;
120 fDetElemID = cluster.fDetElemID;
121 fSize = cluster.fSize;
122 fTrackChi2 = cluster.fTrackChi2;
123 fLocalChi2 = cluster.fLocalChi2;
124 fIsClusterEditable = cluster.fIsClusterEditable;
126 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
127 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
128 fDigitsInCluster->SetOwner(kTRUE);
134 //====================================================================================================================================================
136 Double_t AliMFTCluster::GetDistanceFromPixel(AliMFTDigit *pixel) {
138 // the distance is expressed in units of pixels!!!
139 // useful to decide if the pixel is compatible with the current digits array
141 Double_t distance = -1;
143 if (!fSize) return distance;
145 if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.;
147 for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) {
148 AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit);
149 Int_t distX = TMath::Abs(tmpDig->GetPixelX() - pixel->GetPixelX());
150 Int_t distY = TMath::Abs(tmpDig->GetPixelY() - pixel->GetPixelY());
151 if (distX<=1 && distY<=1) return 0;
152 if (!iDigit) distance = TMath::Sqrt(distX*distX + distY*distY);
153 else distance = TMath::Min(distance, TMath::Sqrt(distX*distX + distY*distY));
160 //====================================================================================================================================================
162 Bool_t AliMFTCluster::AddPixel(AliMFTDigit *pixel) {
164 if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE;
165 if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE;
167 new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel);
170 SetPlane(pixel->GetPlane());
171 SetDetElemID(pixel->GetDetElemID());
180 //====================================================================================================================================================
182 void AliMFTCluster::TerminateCluster() {
184 Double_t xCenters[fNMaxDigitsPerCluster] = {0};
185 Double_t yCenters[fNMaxDigitsPerCluster] = {0};
186 Double_t nElectrons = 0.;
188 for (Int_t iDigit=0; iDigit<fDigitsInCluster->GetEntries(); iDigit++) {
189 AliMFTDigit *tmpDig = (AliMFTDigit*) fDigitsInCluster->At(iDigit);
190 xCenters[iDigit] = tmpDig->GetPixelCenterX();
191 yCenters[iDigit] = tmpDig->GetPixelCenterY();
192 nElectrons += tmpDig->GetNElectrons();
193 for (Int_t iTrack=0; iTrack<tmpDig->GetNMCTracks(); iTrack++) AddMCLabel(tmpDig->GetMCLabel(iTrack));
196 SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters));
197 SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters));
198 SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ());
200 Double_t minErrX = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthX() / TMath::Sqrt(12.);
201 Double_t minErrY = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthY() / TMath::Sqrt(12.);
202 Double_t minErrZ = ((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelWidthZ() / TMath::Sqrt(12.);
203 SetErrX( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), xCenters), minErrX) );
204 SetErrY( TMath::Max(TMath::RMS(fDigitsInCluster->GetEntries(), yCenters), minErrY) );
207 SetNElectrons(nElectrons);
209 fIsClusterEditable = kFALSE;
213 //====================================================================================================================================================
215 void AliMFTCluster::AddMCLabel(Int_t label) {
217 if (fNMCTracks>=fNMaxMCTracks) return;
219 for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return;
221 fMCLabel[fNMCTracks++]=label;
225 //====================================================================================================================================================
227 AliMUONRawCluster* AliMFTCluster::CreateMUONCluster() {
229 AliMUONRawCluster *cluster = new AliMUONRawCluster();
231 cluster->SetXYZ(GetX(), GetY(), GetZ());
232 cluster->SetErrXY(GetErrX(),GetErrY());
233 cluster->SetDetElemId(100); // to get the cluster compatible with the AliMUONTrack::AddTrackParamAtCluster(...) method
239 //====================================================================================================================================================