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