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