AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONRawCluster.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 /* $Id$ */
17 
18 //-----------------------------------------------------------------------------
19 // Class AliMUONRawCluster
20 // -------------------------
21 // Class for the MUON RecPoint
22 // It contains the properties of the physics cluters found in the tracking chambers
23 // RawCluster contains also the information from the both cathode of the chambers.
24 //-----------------------------------------------------------------------------
25 
26 
27 #include "Riostream.h"
28 
29 #include <TArrayF.h>
30 #include <TString.h>
31 
32 #include "AliMUONRawCluster.h"
33 
34 using std::endl;
35 using std::cout;
36 using std::setw;
40 
41 
42 //____________________________________________________
44  : AliMUONVCluster(),
45  fClusterType(0),
46  fGhost(0),
47  fDetElemId(0)
48 {
50  fTracks[0]=fTracks[1]=fTracks[2]=-1;
51  for (int j=0;j<2;j++) {
52  fQ[j]=0;
53  fX[j]=0;
54  fY[j]=0;
55  fZ[j]=0;
56  fMultiplicity[j]=0;
57  fPeakSignal[j]=-1;
58  fChi2[j]=-1;
59 
60  for (int k=0;k<50;k++) {
61  fIndexMap[k][j]=-1;
62  fOffsetMap[k][j]=0;
63  fContMap[k][j]=0;
64  fPhysicsMap[k]=-1;
65  }
66  }
67  fNcluster[0]=fNcluster[1]=-1;
68  fErrXY[0] = FLT_MAX;
69  fErrXY[1] = FLT_MAX;
70 }
71 
72 //____________________________________________________
74 {
76 }
77 
78 //____________________________________________________
79 void AliMUONRawCluster::SetDigitsId(Int_t nDigits, const UInt_t *digitsId)
80 {
83 
84  fMultiplicity[0] = (nDigits < 50) ? nDigits : 50;
85 
86  if (fMultiplicity[0] == 0) return;
87  if (digitsId == 0)
88  for (Int_t i=0; i<fMultiplicity[0]; i++) fIndexMap[i][0] = 0;
89  else
90  for (Int_t i=0; i<fMultiplicity[0]; i++) fIndexMap[i][0] = (Int_t) digitsId[i];
91 }
92 
93 //____________________________________________________
94 Int_t AliMUONRawCluster::Compare(const TObject *obj) const
95 {
97 
98  /*
99  AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
100  Float_t r=GetRadius();
101  Float_t ro=raw->GetRadius();
102  if (r>ro) return 1;
103  else if (r<ro) return -1;
104  else return 0;
105  */
106  /*
107  AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
108  Float_t y=fY[0];
109  Float_t yo=raw->fY[0];
110  if (y>yo) return 1;
111  else if (y<yo) return -1;
112  else return 0;
113  */
114 
115  const AliMUONRawCluster* raw = static_cast<const AliMUONRawCluster*>(obj);
116  if ( GetCharge() > raw->GetCharge() )
117  {
118  return 1;
119  }
120  else if ( GetCharge() < raw->GetCharge() )
121  {
122  return -1;
123  }
124  return 0;
125 }
126 
127 //____________________________________________________
128 Int_t AliMUONRawCluster::BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
129 {
132 
133  Int_t low=from, high=upto-1, half;
134  while(high-low>1) {
135  half=(high+low)/2;
136  if(y>coord[half]) low=half;
137  else high=half;
138  }
139  return low;
140 }
141 //____________________________________________________
142 void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
143 {
146 
147  //
148  // Loop over deltax, only 3 times
149  //
150 
151  Float_t xmin;
152  Int_t jmin;
153  Int_t id[3] = {-2,-2,-2};
154  Float_t jx[3] = {0.,0.,0.};
155  Float_t jy[3] = {0.,0.,0.};
156  Float_t jq[3] = {0.,0.,0.};
157  Int_t jid[3] = {-2,-2,-2};
158  Int_t i,j,imax;
159 
160  if (ntr<3) imax=ntr;
161  else imax=3;
162  for(i=0;i<imax;i++){
163  xmin=1001.;
164  jmin=0;
165 
166  for(j=0;j<ntr;j++){
167  if ((i == 1 && j == id[i-1])
168  ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
169  if (TMath::Abs(xdarray[j]) < xmin) {
170  xmin = TMath::Abs(xdarray[j]);
171  jmin=j;
172  }
173  } // j
174  if (xmin != 1001.) {
175  id[i]=jmin;
176  jx[i]=xarray[jmin];
177  jy[i]=yarray[jmin];
178  jq[i]=qarray[jmin];
179  jid[i]=idx[jmin];
180  }
181 
182  } // i
183 
184  for (i=0;i<3;i++){
185  if (jid[i] == -2) {
186  xarray[i]=1001.;
187  yarray[i]=1001.;
188  qarray[i]=1001.;
189  idx[i]=-1;
190  } else {
191  xarray[i]=jx[i];
192  yarray[i]=jy[i];
193  qarray[i]=jq[i];
194  idx[i]=jid[i];
195  }
196  }
197 
198 }
199 
200 //____________________________________________________
202 {
204  Int_t iPhys=0;
205  Int_t iBg=0;
206  Int_t iMixed=0;
207  for (Int_t i=0; i<fMultiplicity[0]; i++) {
208  if (fPhysicsMap[i]==2) iPhys++;
209  if (fPhysicsMap[i]==1) iMixed++;
210  if (fPhysicsMap[i]==0) iBg++;
211  }
212  if (iMixed==0 && iBg==0) {
213  return 2;
214  } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
215  return 1;
216  } else {
217  return 0;
218  }
219 }
220 
221 //____________________________________________________
222 void AliMUONRawCluster::Print(Option_t* opt) const
223 {
228  TString sopt(opt);
229  sopt.ToUpper();
230 
231  cout << Form("<AliMUONRawCluster>: DetEle=%4d (x,y,z)=(%7.4f,%7.4f,%7.4f) cm"
232  " Chi2=%7.2f Q=%7.2f",
233  GetDetElemId(),GetX(),GetY(),GetZ(),GetChi2(),
234  GetCharge());
235 
236  if ( sopt.Contains("FULL") )
237  {
238  cout << ", Hit=" << setw(4) << GetTrack(0) <<
239  ", Track1=" << setw(4) << GetTrack(1) <<
240  ", Track2=" << setw(4) << GetTrack(2);
241  }
242  cout << endl;
243 }
244 
245 //____________________________________________________
247 {
249  printf ("-----\n");
250  for (Int_t icat=0;icat<2;icat++) {
251  printf ("Mult %d\n",fMultiplicity[icat]);
252  for (Int_t idig=0;idig<fMultiplicity[icat];idig++){
253  printf("Index %d",fIndexMap[idig][icat]);
254  }
255  printf("\n");
256  }
257 }
258 //____________________________________________________
259 Int_t AliMUONRawCluster::AddCharge(Int_t i, Float_t Q)
260 {
262  if (i==0 || i==1) {
263  fQ[i]+=Q;
264  return 1;
265  }
266  else return 0;
267 }
268 //____________________________________________________
269 Int_t AliMUONRawCluster::AddX(Int_t i, Float_t X)
270 {
272  if (i==0 || i==1) {
273  fX[i]+=X;
274  return 1;
275  }
276  else return 0;
277 }
278 //____________________________________________________
279 Int_t AliMUONRawCluster::AddY(Int_t i, Float_t Y)
280 {
282  if (i==0 || i==1) {
283  fY[i]+=Y;
284  return 1;
285  }
286  else return 0;
287 }
288 //____________________________________________________
289 Int_t AliMUONRawCluster::AddZ(Int_t i, Float_t Z)
290 {
292  if (i==0 || i==1) {
293  fZ[i]+=Z;
294  return 1;
295  }
296  else return 0;
297 }
298 //____________________________________________________
299 Float_t AliMUONRawCluster::GetCharge(Int_t i) const
300 {
302  if (i==0 || i==1) return fQ[i];
303  else return 99999;
304 }
305 //____________________________________________________
306 Float_t AliMUONRawCluster::GetX(Int_t i) const
307 {
309  if (i==0 || i==1) return fX[i];
310  else return 99999.;
311 }
312 //____________________________________________________
313 Float_t AliMUONRawCluster::GetY(Int_t i) const
314 {
316  if (i==0 || i==1) return fY[i];
317  else return 99999.;
318 }
319 //____________________________________________________
320 Float_t AliMUONRawCluster::GetZ(Int_t i) const
321 {
323  if (i==0 || i==1) return fZ[i];
324  else return 99999.;
325 }
326 //____________________________________________________
327 Int_t AliMUONRawCluster::GetTrack(Int_t i) const
328 {
330  if (i==0 || i==1 || i==2) return fTracks[i];
331  else return 99999;
332 }
333 //____________________________________________________
334 Float_t AliMUONRawCluster::GetPeakSignal(Int_t i) const
335 {
337  if (i==0 || i==1 ) return fPeakSignal[i];
338  else return 99999;
339 }
340 //____________________________________________________
342 {
344  if (i==0 || i==1 ) return fMultiplicity[i];
345  else return 99999;
346 }
347 //____________________________________________________
349 {
351  return fClusterType;
352 }
353 //____________________________________________________
355 {
357  return fGhost;
358 }
359 //____________________________________________________
360 Int_t AliMUONRawCluster::GetNcluster(Int_t i) const
361 {
363  if (i==0 || i==1 ) return fNcluster[i];
364  else return 99999;
365 }
366 //____________________________________________________
367 Float_t AliMUONRawCluster::GetChi2(Int_t i) const
368 {
370  if (i==0 || i==1) return fChi2[i];
371  else return 99999.;
372 }
373 //____________________________________________________
374 Int_t AliMUONRawCluster::SetCharge(Int_t i, Float_t Q)
375 {
377  if (i==0 || i==1) {
378  fQ[i]=Q;
379  return 1;
380  }
381  else return 0;
382 }
383 //____________________________________________________
384 Int_t AliMUONRawCluster::SetX(Int_t i, Float_t X)
385 {
387  if (i==0 || i==1) {
388  fX[i]=X;
389  return 1;
390  }
391  else return 0;
392 }
393 //____________________________________________________
394 Int_t AliMUONRawCluster::SetY(Int_t i, Float_t Y)
395 {
397  if (i==0 || i==1) {
398  fY[i]=Y;
399  return 1;
400  }
401  else return 0;
402 }
403 //____________________________________________________
404 Int_t AliMUONRawCluster::SetZ(Int_t i, Float_t Z)
405 {
407  if (i==0 || i==1) {
408  fZ[i]=Z;
409  return 1;
410  }
411  else return 0;
412 }
413 //____________________________________________________
414 Int_t AliMUONRawCluster::SetTrack(Int_t i, Int_t track)
415 {
417  if (i==0 || i==1 || i==2) {
418  fTracks[i]=track;
419  return 1;
420  }
421  else return 0;
422 }
423 //____________________________________________________
424 Int_t AliMUONRawCluster::SetPeakSignal(Int_t i, Float_t peaksignal)
425 {
427  if (i==0 || i==1 ) {
428  fPeakSignal[i]=peaksignal;
429  return 1;
430  }
431  else return 0;
432 }
433 //____________________________________________________
434 Int_t AliMUONRawCluster::SetMultiplicity(Int_t i, Int_t mul)
435 {
437  if (i==0 || i==1 ) {
438  fMultiplicity[i]=mul;
439  return 1;
440  }
441  else return 0;
442 }
443 //____________________________________________________
445 {
447  fClusterType=type;
448  return 1;
449 }
450 //____________________________________________________
451 Int_t AliMUONRawCluster::SetGhost(Int_t ghost)
452 {
454  fGhost=ghost;
455  return 1;
456 }
457 //____________________________________________________
458 Int_t AliMUONRawCluster::SetNcluster(Int_t i, Int_t ncluster)
459 {
461  if (i==0 || i==1 ) {
462  fNcluster[i]=ncluster;
463  return 1;
464  }
465  else return 0;
466 }
467 //____________________________________________________
468 Int_t AliMUONRawCluster::SetChi2(Int_t i, Float_t chi2)
469 {
471  if (i==0 || i==1) {
472  fChi2[i]=chi2;
473  return 1;
474  }
475  else return 0;
476 }
477 
478 
Int_t GetMultiplicity(Int_t i=0) const
Int_t fPhysicsMap[50]
Distinguish signal and background contr.
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
virtual Double_t GetCharge() const
Set the cluster charge.
Int_t AddY(Int_t i, Float_t Y)
Float_t fQ[2]
Q of cluster (in ADC counts)
virtual Double_t GetX() const
Return coordinate X (cm)
Int_t SetClusterType(Int_t type)
Float_t GetPeakSignal(Int_t i=0) const
Int_t SetGhost(Int_t ghost)
static Int_t BinarySearch(Float_t r, TArrayF ccord, Int_t from, Int_t upto)
Int_t AddX(Int_t i, Float_t X)
Int_t fIndexMap[50][2]
Indices of digits.
Int_t fTracks[3]
Labels of overlapped tracks.
virtual Double_t GetChi2() const
Return chi2 of cluster.
Int_t SetZ(Int_t i, Float_t Z)
Int_t GetTrack(Int_t i=0) const
Float_t fX[2]
X of cluster.
Int_t GetGhost() const
virtual void SetDigitsId(Int_t nDigits, const UInt_t *digitsId)
Set Id of associated digits.
Int_t PhysicsContribution() const
AliTPCfastTrack * track
Int_t Compare(const TObject *obj) const
Int_t GetClusterType() const
Int_t SetPeakSignal(Int_t i, Float_t peaksignal)
Float_t fPeakSignal[2]
Peak signal.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
virtual Double_t GetZ() const
Return coordinate Z (cm)
Double_t chi2
Definition: AnalyzeLaser.C:7
abstract base class for clusters
Int_t AddZ(Int_t i, Float_t Z)
Int_t SetMultiplicity(Int_t i, Int_t mul)
virtual Int_t GetDetElemId() const
Return detection element Id.
MUON raw cluster.
Int_t SetNcluster(Int_t i, Int_t ncluster)
virtual void Print(Option_t *opt="") const
static void SortMin(Int_t *idx, Float_t *xdarray, Float_t *xarray, Float_t *yarray, Float_t *qarray, Int_t ntr)
Int_t fClusterType
Cluster type.
Int_t SetX(Int_t i, Float_t X)
Float_t fChi2[2]
Chi**2 of fit.
Float_t fZ[2]
Z of cluster.
Float_t fY[2]
Y of cluster.
Int_t AddCharge(Int_t i, Float_t Q)
Int_t GetNcluster(Int_t i=0) const
Int_t fMultiplicity[2]
Cluster multiplicity.
virtual void SetChi2(Double_t chi2)
Set chi2 of cluster.
Int_t fGhost
Ghost info.
virtual Double_t GetY() const
Return coordinate Y (cm)
Int_t fNcluster[2]
Number of clusters.
Int_t SetY(Int_t i, Float_t Y)
Int_t SetTrack(Int_t i, Int_t track)
virtual void SetCharge(Double_t q)
Set the cluster charge.