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