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),
52 fIsClusterFront(kTRUE)
55 // default constructor
57 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = -1;
59 fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
60 fDigitsInCluster -> SetOwner(kTRUE);
63 //====================================================================================================================================================
65 AliMFTCluster::AliMFTCluster(const AliMFTCluster& cluster):
73 fNElectrons(cluster.fNElectrons),
74 fNMCTracks(cluster.fNMCTracks),
75 fPlane(cluster.fPlane),
76 fDetElemID(cluster.fDetElemID),
78 fTrackChi2(cluster.fTrackChi2),
79 fLocalChi2(cluster.fLocalChi2),
80 fDigitsInCluster(NULL),
81 fIsClusterEditable(cluster.fIsClusterEditable),
82 fIsClusterFront(cluster.fIsClusterFront)
86 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
87 if (cluster.fDigitsInCluster) {
88 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
89 fDigitsInCluster -> SetOwner(kTRUE);
92 fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
93 fDigitsInCluster -> SetOwner(kTRUE);
98 //====================================================================================================================================================
100 AliMFTCluster& AliMFTCluster::operator=(const AliMFTCluster& cluster) {
102 // Asignment operator
104 // check assignement to self
105 if (this == &cluster) return *this;
107 // base class assignement
108 TObject::operator=(cluster);
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;
126 fIsClusterEditable = cluster.fIsClusterEditable;
127 fIsClusterFront = cluster.fIsClusterFront;
129 for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
130 fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
131 fDigitsInCluster->SetOwner(kTRUE);
137 //====================================================================================================================================================
139 Double_t AliMFTCluster::GetDistanceFromPixel(AliMFTDigit *pixel) {
141 // the distance is expressed in units of pixels!!!
142 // useful to decide if the pixel is compatible with the current digits array
144 Double_t distance = -1;
146 if (!fSize) return distance;
148 if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.;
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));
163 //====================================================================================================================================================
165 Bool_t AliMFTCluster::AddPixel(AliMFTDigit *pixel) {
167 if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE;
168 if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE;
170 new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel);
173 SetPlane(pixel->GetPlane());
174 SetDetElemID(pixel->GetDetElemID());
183 //====================================================================================================================================================
185 void AliMFTCluster::TerminateCluster() {
187 Double_t xCenters[fNMaxDigitsPerCluster] = {0};
188 Double_t yCenters[fNMaxDigitsPerCluster] = {0};
189 Double_t nElectrons = 0.;
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));
199 SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters));
200 SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters));
201 SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ());
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) );
210 SetNElectrons(nElectrons);
212 fIsClusterEditable = kFALSE;
216 //====================================================================================================================================================
218 void AliMFTCluster::AddMCLabel(Int_t label) {
220 if (fNMCTracks>=fNMaxMCTracks) return;
222 for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return;
224 fMCLabel[fNMCTracks++]=label;
228 //====================================================================================================================================================
230 AliMUONRawCluster* AliMFTCluster::CreateMUONCluster() {
232 AliMUONRawCluster *cluster = new AliMUONRawCluster();
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
242 //====================================================================================================================================================