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