AliRoot Core  edcc906 (edcc906)
AliMFTCluster.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15 
16 //====================================================================================================================================================
17 //
18 // Class for the description of the clusters of the ALICE Muon Forward Tracker
19 //
20 // Contact author: antonio.uras@cern.ch
21 //
22 //====================================================================================================================================================
23 
24 #include "TObject.h"
25 #include "AliMUONRawCluster.h"
26 #include "AliMUONVCluster.h"
27 #include "AliMFTDigit.h"
28 #include "TMath.h"
29 #include "AliMFTCluster.h"
30 
31 ClassImp(AliMFTCluster)
32 
33 //====================================================================================================================================================
34 
36  TObject(),
37  fX(0),
38  fY(0),
39  fZ(0),
40  fErrX(0),
41  fErrY(0),
42  fErrZ(0),
43  fNElectrons(0),
44  fNMCTracks(0),
45  fPlane(-1),
46  fDetElemID(-1),
47  fSize(0),
48  fTrackChi2(0),
49  fLocalChi2(0),
50  fDigitsInCluster(0),
51  fIsClusterEditable(kTRUE),
52  fIsClusterFront(kTRUE)
53 {
54 
55  // default constructor
56 
57  for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = -1;
58 
59  fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
60  fDigitsInCluster -> SetOwner(kTRUE);
61 }
62 
63 //====================================================================================================================================================
64 
66  TObject(cluster),
67  fX(cluster.fX),
68  fY(cluster.fY),
69  fZ(cluster.fZ),
70  fErrX(cluster.fErrX),
71  fErrY(cluster.fErrY),
72  fErrZ(cluster.fErrZ),
73  fNElectrons(cluster.fNElectrons),
74  fNMCTracks(cluster.fNMCTracks),
75  fPlane(cluster.fPlane),
76  fDetElemID(cluster.fDetElemID),
77  fSize(cluster.fSize),
78  fTrackChi2(cluster.fTrackChi2),
79  fLocalChi2(cluster.fLocalChi2),
80  fDigitsInCluster(NULL),
81  fIsClusterEditable(cluster.fIsClusterEditable),
82  fIsClusterFront(cluster.fIsClusterFront)
83 {
84 
85  // copy constructor
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);
90  }
91  else {
92  fDigitsInCluster = new TClonesArray("AliMFTDigit", fNMaxDigitsPerCluster);
93  fDigitsInCluster -> SetOwner(kTRUE);
94  }
95 
96 }
97 
98 //====================================================================================================================================================
99 
101 
102  // Asignment operator
103 
104  // check assignement to self
105  if (this == &cluster) return *this;
106 
107  // base class assignement
108  TObject::operator=(cluster);
109 
110  // clear memory
111  Clear("");
112 
113  fX = cluster.fX;
114  fY = cluster.fY;
115  fZ = cluster.fZ;
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;
128 
129  for (Int_t iTrack=0; iTrack<fNMaxMCTracks; iTrack++) fMCLabel[iTrack] = (cluster.fMCLabel)[iTrack];
130  fDigitsInCluster = new TClonesArray(*(cluster.fDigitsInCluster));
131  fDigitsInCluster->SetOwner(kTRUE);
132 
133  return *this;
134 
135 }
136 
137 //====================================================================================================================================================
138 
140 
141  // the distance is expressed in units of pixels!!!
142  // useful to decide if the pixel is compatible with the current digits array
143 
144  Double_t distance = -1;
145 
146  if (!fSize) return distance;
147 
148  if (pixel->GetDetElemID()!=fDetElemID || pixel->GetPlane()!=fPlane) return 9999.;
149 
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));
157  }
158 
159  return distance;
160 
161 }
162 
163 //====================================================================================================================================================
164 
166 
167  if (!fIsClusterEditable || fSize>=fNMaxDigitsPerCluster) return kFALSE;
168  if (fSize && (pixel->GetPlane()!=fPlane || pixel->GetDetElemID()!=fDetElemID)) return kFALSE;
169 
170  new ((*fDigitsInCluster)[fDigitsInCluster->GetEntries()]) AliMFTDigit(*pixel);
171 
172  if (!fSize) {
173  SetPlane(pixel->GetPlane());
174  SetDetElemID(pixel->GetDetElemID());
175  }
176 
177  fSize++;
178 
179  return kTRUE;
180 
181 }
182 
183 //====================================================================================================================================================
184 
186 
187  Double_t xCenters[fNMaxDigitsPerCluster] = {0};
188  Double_t yCenters[fNMaxDigitsPerCluster] = {0};
189  Double_t nElectrons = 0.;
190 
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));
197  }
198 
199  SetX(TMath::Mean(fDigitsInCluster->GetEntries(), xCenters));
200  SetY(TMath::Mean(fDigitsInCluster->GetEntries(), yCenters));
201  SetZ(((AliMFTDigit*) fDigitsInCluster->At(0))->GetPixelCenterZ());
202 
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) );
208  SetErrZ( minErrZ );
209 
210  SetNElectrons(nElectrons);
211 
212  fIsClusterEditable = kFALSE;
213 
214 }
215 
216 //====================================================================================================================================================
217 
218 void AliMFTCluster::AddMCLabel(Int_t label) {
219 
220  if (fNMCTracks>=fNMaxMCTracks) return;
221 
222  for (Int_t iTrack=0; iTrack<fNMCTracks; iTrack++) if (label==fMCLabel[iTrack]) return;
223 
224  fMCLabel[fNMCTracks++]=label;
225 
226 }
227 
228 //====================================================================================================================================================
229 
231 
232  AliMUONRawCluster *cluster = new AliMUONRawCluster();
233 
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
237 
238  return cluster;
239 
240 }
241 
242 //====================================================================================================================================================
Int_t GetNMCTracks() const
Definition: AliMFTDigit.h:47
Bool_t fIsClusterEditable
(Temporary) Array of the digits composing the cluster
Double_t fErrY
Int_t GetDetElemID() const
Definition: AliMFTDigit.h:53
void SetPlane(Int_t plane)
Definition: AliMFTCluster.h:66
void TerminateCluster()
void SetZ(Double_t z)
Definition: AliMFTCluster.h:39
Double_t fTrackChi2
Double_t GetY() const
Definition: AliMFTCluster.h:42
void SetY(Double_t y)
Definition: AliMFTCluster.h:38
virtual void Clear(const Option_t *)
Definition: AliMFTCluster.h:33
Int_t GetPixelX() const
Definition: AliMFTDigit.h:54
static const Int_t fNMaxDigitsPerCluster
Definition: AliMFTCluster.h:97
Double_t fErrZ
void AddMCLabel(Int_t label)
Double_t GetPixelCenterX() const
Definition: AliMFTDigit.h:57
void SetNElectrons(Double_t nElectrons)
Definition: AliMFTCluster.h:58
AliMUONRawCluster * CreateMUONCluster()
Int_t fMCLabel[fNMaxMCTracks]
Double_t GetPixelCenterY() const
Definition: AliMFTDigit.h:58
Double_t GetDistanceFromPixel(AliMFTDigit *pixel)
Int_t GetMCLabel(Int_t track) const
Definition: AliMFTDigit.h:48
MUON raw cluster.
Double_t GetX() const
Definition: AliMFTCluster.h:41
Double_t GetErrY() const
Definition: AliMFTCluster.h:52
Bool_t fIsClusterFront
void SetErrX(Double_t errX)
Definition: AliMFTCluster.h:47
Double_t GetErrX() const
Definition: AliMFTCluster.h:51
virtual void SetXYZ(Double_t x, Double_t y, Double_t z)
Set coordinates (cm)
void SetErrZ(Double_t errZ)
Definition: AliMFTCluster.h:49
void SetErrY(Double_t errY)
Definition: AliMFTCluster.h:48
Int_t GetPixelY() const
Definition: AliMFTDigit.h:55
Double_t fErrX
Bool_t AddPixel(AliMFTDigit *pixel)
void SetDetElemID(Int_t detElemID)
Definition: AliMFTCluster.h:69
void SetX(Double_t x)
Definition: AliMFTCluster.h:37
Double_t GetZ() const
Definition: AliMFTCluster.h:43
virtual void SetErrXY(Double_t errX, Double_t errY)
Set resolution (cm) on coordinates (X,Y)
Double_t fLocalChi2
TClonesArray * fDigitsInCluster
Int_t GetPlane() const
Definition: AliMFTDigit.h:52
void SetDetElemId(Int_t id)
Set detection element Id.
static const Int_t fNMaxMCTracks
Definition: AliMFTCluster.h:96
Double_t GetNElectrons() const
Definition: AliMFTDigit.h:51
Double_t fNElectrons
AliMFTCluster & operator=(const AliMFTCluster &)