]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/AliMUONRawCluster.cxx
Corrected GetNeighbours() (Laurent)
[u/mrichter/AliRoot.git] / MUON / AliMUONRawCluster.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
d19b6003 18// -------------------------
19// Class AliMUONRawCluster
20// -------------------------
3afdba21 21// Class for the MUON RecPoint
3b5272e3 22// It contains the properties of the physics cluters found in the tracking chambers
3afdba21 23// RawCluster contains also the information from the both cathode of the chambers.
3afdba21 24
6464217e 25
26#include "Riostream.h"
27
a9e2aefa 28#include <TArrayF.h>
6464217e 29#include <TString.h>
a9e2aefa 30
30178c30 31#include "AliMUONRawCluster.h"
32
5398f946 33/// \cond CLASSIMP
925e6570 34ClassImp(AliMUONRawCluster)
5398f946 35/// \endcond
a9e2aefa 36
30178c30 37AliMUONRawCluster::AliMUONRawCluster()
5398f946 38 : TObject(),
39 fClusterType(0),
40 fGhost(0),
41 fDetElemId(0)
30178c30 42{
d19b6003 43/// Constructor
a9e2aefa 44 fTracks[0]=fTracks[1]=fTracks[2]=-1;
45 for (int j=0;j<2;j++) {
46 fQ[j]=0;
47 fX[j]=0;
48 fY[j]=0;
49 fMultiplicity[j]=0;
50 fPeakSignal[j]=-1;
51 fChi2[j]=-1;
52
53 for (int k=0;k<50;k++) {
54 fIndexMap[k][j]=-1;
55 fOffsetMap[k][j]=0;
56 fContMap[k][j]=0;
57 fPhysicsMap[k]=-1;
58 }
59 }
60 fNcluster[0]=fNcluster[1]=-1;
87e6e2dd 61 fErrXY[0] = 0.144;
62 fErrXY[1] = 0.01;
a9e2aefa 63}
3afdba21 64//____________________________________________________
2a941f4e 65Int_t AliMUONRawCluster::Compare(const TObject *obj) const
a9e2aefa 66{
d19b6003 67/// Compare
68
a9e2aefa 69 /*
70 AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
71 Float_t r=GetRadius();
72 Float_t ro=raw->GetRadius();
73 if (r>ro) return 1;
74 else if (r<ro) return -1;
75 else return 0;
76 */
77 AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
78 Float_t y=fY[0];
79 Float_t yo=raw->fY[0];
80 if (y>yo) return 1;
81 else if (y<yo) return -1;
82 else return 0;
83
84}
3afdba21 85//____________________________________________________
86Int_t AliMUONRawCluster::BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
a9e2aefa 87{
d19b6003 88/// Find object using a binary search. Array must first have been sorted.
89/// Search can be limited by setting upto to desired index.
a9e2aefa 90
91 Int_t low=from, high=upto-1, half;
92 while(high-low>1) {
93 half=(high+low)/2;
94 if(y>coord[half]) low=half;
95 else high=half;
96 }
97 return low;
98}
3afdba21 99//____________________________________________________
a9e2aefa 100void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
101{
d19b6003 102/// Get the 3 closest points(cog) one can find on the second cathode
103/// starting from a given cog on first cathode
a9e2aefa 104
105 //
106 // Loop over deltax, only 3 times
107 //
108
109 Float_t xmin;
110 Int_t jmin;
111 Int_t id[3] = {-2,-2,-2};
112 Float_t jx[3] = {0.,0.,0.};
113 Float_t jy[3] = {0.,0.,0.};
114 Float_t jq[3] = {0.,0.,0.};
115 Int_t jid[3] = {-2,-2,-2};
116 Int_t i,j,imax;
117
118 if (ntr<3) imax=ntr;
119 else imax=3;
120 for(i=0;i<imax;i++){
121 xmin=1001.;
122 jmin=0;
123
124 for(j=0;j<ntr;j++){
125 if ((i == 1 && j == id[i-1])
126 ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
127 if (TMath::Abs(xdarray[j]) < xmin) {
128 xmin = TMath::Abs(xdarray[j]);
129 jmin=j;
130 }
131 } // j
132 if (xmin != 1001.) {
133 id[i]=jmin;
134 jx[i]=xarray[jmin];
135 jy[i]=yarray[jmin];
136 jq[i]=qarray[jmin];
137 jid[i]=idx[jmin];
138 }
139
140 } // i
141
142 for (i=0;i<3;i++){
143 if (jid[i] == -2) {
144 xarray[i]=1001.;
145 yarray[i]=1001.;
146 qarray[i]=1001.;
147 idx[i]=-1;
148 } else {
149 xarray[i]=jx[i];
150 yarray[i]=jy[i];
151 qarray[i]=jq[i];
152 idx[i]=jid[i];
153 }
154 }
155
156}
157
3afdba21 158//____________________________________________________
159Int_t AliMUONRawCluster::PhysicsContribution() const
a9e2aefa 160{
d19b6003 161/// Evaluate physics contribution to cluster
a9e2aefa 162 Int_t iPhys=0;
163 Int_t iBg=0;
164 Int_t iMixed=0;
165 for (Int_t i=0; i<fMultiplicity[0]; i++) {
166 if (fPhysicsMap[i]==2) iPhys++;
167 if (fPhysicsMap[i]==1) iMixed++;
168 if (fPhysicsMap[i]==0) iBg++;
169 }
170 if (iMixed==0 && iBg==0) {
171 return 2;
172 } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
173 return 1;
174 } else {
175 return 0;
176 }
177}
6464217e 178
179//____________________________________________________
180void AliMUONRawCluster::Print(Option_t* opt) const
181{
182 //
183 // Printing Raw Cluster (Rec Point) information
184 // "full" option for printing all the information about the raw cluster
185 //
186 TString sopt(opt);
187 sopt.ToUpper();
188
189 if ( sopt.Contains("FULL") ) {
190 cout << "<AliMUONRawCluster>: DetEle=" << setw(4) << GetDetElemId() <<
191 ", (x,y,z)=(" << setw(8) << setprecision(5) << GetX() << "," << setw(8) << setprecision(5) << GetY() << "," << setw(8) << setprecision(5) << GetZ() <<
192 ") cm, Chi2=" << setw(8) << setprecision(3) << GetChi2() <<
193 ", Q=" << setw(4) << GetCharge() <<
194 ", Hit=" << setw(4) << GetTrack(0) <<
195 ", Track1=" << setw(4) << GetTrack(1) <<
196 ", Track2=" << setw(4) << GetTrack(2) <<endl;
197 }
198 else {
199 cout << "<AliMUONRawCluster>: DetEle=" << setw(4) << GetDetElemId() <<
200 ", (x,y,z)=(" << setw(8) << setprecision(5) << GetX() << "," << setw(8) << setprecision(5) << GetY() << "," << setw(8) << setprecision(5) << GetZ()
201 << endl;
202 }
203}
07cfabcf 204//____________________________________________________
205void AliMUONRawCluster::DumpIndex(void)
206{
d19b6003 207/// Dumping IdexMap of the cluster
07cfabcf 208 printf ("-----\n");
209 for (Int_t icat=0;icat<2;icat++) {
210 printf ("Mult %d\n",fMultiplicity[icat]);
211 for (Int_t idig=0;idig<fMultiplicity[icat];idig++){
212 printf("Index %d",fIndexMap[idig][icat]);
213 }
214 printf("\n");
215 }
216}
3afdba21 217//____________________________________________________
45dd3605 218Int_t AliMUONRawCluster::AddCharge(Int_t i, Float_t Q)
3afdba21 219{
d19b6003 220/// Adding Q to the fQ value
3afdba21 221 if (i==0 || i==1) {
222 fQ[i]+=Q;
223 return 1;
224 }
225 else return 0;
226}
227//____________________________________________________
228Int_t AliMUONRawCluster::AddX(Int_t i, Float_t X)
229{
d19b6003 230/// Adding X to the fX value
3afdba21 231 if (i==0 || i==1) {
232 fX[i]+=X;
233 return 1;
234 }
235 else return 0;
236}
237//____________________________________________________
238Int_t AliMUONRawCluster::AddY(Int_t i, Float_t Y)
239{
d19b6003 240/// Adding Y to the fY value
3afdba21 241 if (i==0 || i==1) {
242 fY[i]+=Y;
243 return 1;
244 }
245 else return 0;
246}
247//____________________________________________________
248Int_t AliMUONRawCluster::AddZ(Int_t i, Float_t Z)
249{
d19b6003 250/// Adding Z to the fZ value
3afdba21 251 if (i==0 || i==1) {
252 fZ[i]+=Z;
253 return 1;
254 }
255 else return 0;
256}
257//____________________________________________________
45dd3605 258Float_t AliMUONRawCluster::GetCharge(Int_t i) const
3afdba21 259{
d19b6003 260/// Getting the charge of the cluster
3afdba21 261 if (i==0 || i==1) return fQ[i];
262 else return 99999;
263}
264//____________________________________________________
265Float_t AliMUONRawCluster::GetX(Int_t i) const
266{
d19b6003 267/// Getting X value of the cluster
3afdba21 268 if (i==0 || i==1) return fX[i];
269 else return 99999.;
270}
271//____________________________________________________
272Float_t AliMUONRawCluster::GetY(Int_t i) const
273{
d19b6003 274/// Getting Y value of the cluster
3afdba21 275 if (i==0 || i==1) return fY[i];
276 else return 99999.;
277}
278//____________________________________________________
279Float_t AliMUONRawCluster::GetZ(Int_t i) const
280{
d19b6003 281/// Getting Z value of the cluster
3afdba21 282 if (i==0 || i==1) return fZ[i];
283 else return 99999.;
284}
9e993f2a 285//____________________________________________________
286Int_t AliMUONRawCluster::GetTrack(Int_t i) const
287{
d19b6003 288/// Getting track i contributing to the cluster
9e993f2a 289 if (i==0 || i==1 || i==2) return fTracks[i];
290 else return 99999;
291}
292//____________________________________________________
45dd3605 293Float_t AliMUONRawCluster::GetPeakSignal(Int_t i) const
9e993f2a 294{
d19b6003 295/// Getting cluster peaksignal
9e993f2a 296 if (i==0 || i==1 ) return fPeakSignal[i];
297 else return 99999;
298}
299//____________________________________________________
300Int_t AliMUONRawCluster::GetMultiplicity(Int_t i) const
301{
d19b6003 302/// Getting cluster multiplicity
9e993f2a 303 if (i==0 || i==1 ) return fMultiplicity[i];
304 else return 99999;
305}
306//____________________________________________________
307Int_t AliMUONRawCluster::GetClusterType() const
308{
d19b6003 309/// Getting Cluster Type
9e993f2a 310 return fClusterType;
311}
3b5272e3 312//____________________________________________________
313Int_t AliMUONRawCluster::GetGhost() const
314{
d19b6003 315/// Getting Ghost
3b5272e3 316 return fGhost;
317}
318//____________________________________________________
319Int_t AliMUONRawCluster::GetNcluster(Int_t i) const
320{
d19b6003 321/// Getting number of clusters
3b5272e3 322 if (i==0 || i==1 ) return fNcluster[i];
323 else return 99999;
324}
325//____________________________________________________
326Float_t AliMUONRawCluster::GetChi2(Int_t i) const
327{
d19b6003 328/// Getting chi2 value of the cluster
3b5272e3 329 if (i==0 || i==1) return fChi2[i];
330 else return 99999.;
331}
3afdba21 332//____________________________________________________
45dd3605 333Int_t AliMUONRawCluster::SetCharge(Int_t i, Float_t Q)
3afdba21 334{
d19b6003 335/// Setting Charge of the cluster
3afdba21 336 if (i==0 || i==1) {
337 fQ[i]=Q;
338 return 1;
339 }
340 else return 0;
341}
342//____________________________________________________
343Int_t AliMUONRawCluster::SetX(Int_t i, Float_t X)
344{
d19b6003 345/// Setting X value of the cluster
3afdba21 346 if (i==0 || i==1) {
347 fX[i]=X;
348 return 1;
349 }
350 else return 0;
351}
352//____________________________________________________
353Int_t AliMUONRawCluster::SetY(Int_t i, Float_t Y)
354{
d19b6003 355/// Setting Y value of the cluster
3afdba21 356 if (i==0 || i==1) {
357 fY[i]=Y;
358 return 1;
359 }
360 else return 0;
361}
362//____________________________________________________
363Int_t AliMUONRawCluster::SetZ(Int_t i, Float_t Z)
364{
d19b6003 365/// Setting Z value of the cluste
3afdba21 366 if (i==0 || i==1) {
367 fZ[i]=Z;
368 return 1;
369 }
370 else return 0;
371}
9e993f2a 372//____________________________________________________
373Int_t AliMUONRawCluster::SetTrack(Int_t i, Int_t track)
374{
d19b6003 375/// Setting tracks contributing to the cluster
9e993f2a 376 if (i==0 || i==1 || i==2) {
377 fTracks[i]=track;
378 return 1;
379 }
380 else return 0;
381}
382//____________________________________________________
45dd3605 383Int_t AliMUONRawCluster::SetPeakSignal(Int_t i, Float_t peaksignal)
9e993f2a 384{
d19b6003 385/// Setting PeakSignal of the cluster
9e993f2a 386 if (i==0 || i==1 ) {
387 fPeakSignal[i]=peaksignal;
388 return 1;
389 }
390 else return 0;
391}
392//____________________________________________________
393Int_t AliMUONRawCluster::SetMultiplicity(Int_t i, Int_t mul)
394{
d19b6003 395/// Setting multiplicity of the cluster
9e993f2a 396 if (i==0 || i==1 ) {
397 fMultiplicity[i]=mul;
398 return 1;
399 }
400 else return 0;
401}
402//____________________________________________________
403Int_t AliMUONRawCluster::SetClusterType(Int_t type)
404{
d19b6003 405/// Setting the cluster type
9e993f2a 406 fClusterType=type;
407 return 1;
408}
3b5272e3 409//____________________________________________________
410Int_t AliMUONRawCluster::SetGhost(Int_t ghost)
411{
d19b6003 412/// Setting the ghost
3b5272e3 413 fGhost=ghost;
414 return 1;
415}
416//____________________________________________________
417Int_t AliMUONRawCluster::SetNcluster(Int_t i, Int_t ncluster)
418{
d19b6003 419/// Setting number the cluster
3b5272e3 420 if (i==0 || i==1 ) {
421 fNcluster[i]=ncluster;
422 return 1;
423 }
424 else return 0;
425}
426//____________________________________________________
427Int_t AliMUONRawCluster::SetChi2(Int_t i, Float_t chi2)
428{
d19b6003 429/// Setting chi2 of the cluster
3b5272e3 430 if (i==0 || i==1) {
431 fChi2[i]=chi2;
432 return 1;
433 }
434 else return 0;
435}
b137f8b9 436