]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawCluster.cxx
Correct function Compare() for "pixels" from MLEM cluster finder.
[u/mrichter/AliRoot.git] / MUON / AliMUONRawCluster.cxx
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
16 /* $Id$ */
17
18 // -------------------------
19 // Class AliMUONRawCluster
20 // -------------------------
21 // Class for the MUON RecPoint
22 // It contains the properties of the physics cluters found in the tracking chambers
23 // RawCluster contains also the information from the both cathode of the chambers.
24
25
26 #include "Riostream.h"
27
28 #include <TArrayF.h>
29 #include <TString.h>
30
31 #include "AliMUONRawCluster.h"
32
33 /// \cond CLASSIMP
34 ClassImp(AliMUONRawCluster)
35 /// \endcond
36
37 //____________________________________________________
38 AliMUONRawCluster::AliMUONRawCluster() 
39   : TObject(),
40     fClusterType(0),
41     fGhost(0),
42     fDetElemId(0)   
43 {
44 /// Constructor
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;
62     fErrXY[0] = 0.144;
63     fErrXY[1] = 0.01;
64 }
65
66 //____________________________________________________
67 AliMUONRawCluster::~AliMUONRawCluster() 
68 {
69 /// Destructor
70 }
71
72 //____________________________________________________
73 Int_t AliMUONRawCluster::Compare(const TObject *obj) const
74 {
75 /// Compare
76
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 }
93 //____________________________________________________
94 Int_t AliMUONRawCluster::BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
95 {
96 /// Find object using a binary search. Array must first have been sorted.
97 /// Search can be limited by setting upto to desired index.
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 }
107 //____________________________________________________
108 void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
109 {
110 /// Get the 3 closest points(cog) one can find on the second cathode 
111 /// starting from a given cog on first cathode
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
166 //____________________________________________________
167 Int_t AliMUONRawCluster::PhysicsContribution() const
168 {
169 /// Evaluate physics contribution to cluster
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 }
186
187 //____________________________________________________
188 void AliMUONRawCluster::Print(Option_t* opt) const
189 {
190   ///
191   /// Printing Raw Cluster (Rec Point) information 
192   /// "full" option for printing all the information about the raw cluster
193   ///
194   TString sopt(opt);
195   sopt.ToUpper();
196  
197   cout << "<AliMUONRawCluster>: DetEle="        << setw(4)  << GetDetElemId() << 
198     ", (x,y,z)=(" << setw(8) << setprecision(5) << GetX() << "," << setw(8) 
199     << setprecision(5) << GetY() <<  "," << setw(8) << setprecision(5) << GetZ() << 
200     ") cm, Chi2=" << setw(8) << setprecision(3) << GetChi2() << 
201     ", Q=" << setw(4) << GetCharge();
202   if ( sopt.Contains("FULL") )
203   {
204     cout << ", Hit=" << setw(4)  << GetTrack(0) <<
205     ", Track1=" <<  setw(4)  << GetTrack(1) <<
206     ", Track2=" <<  setw(4)  << GetTrack(2);
207   }
208   cout << endl;
209 }
210
211 //____________________________________________________
212 void AliMUONRawCluster::DumpIndex(void)
213 {
214 /// Dumping IdexMap of the cluster
215     printf ("-----\n");
216     for (Int_t icat=0;icat<2;icat++) {
217         printf ("Mult %d\n",fMultiplicity[icat]);
218         for (Int_t idig=0;idig<fMultiplicity[icat];idig++){
219             printf("Index %d",fIndexMap[idig][icat]);
220         }
221         printf("\n");
222     }
223 }
224 //____________________________________________________
225 Int_t AliMUONRawCluster::AddCharge(Int_t i, Float_t Q)
226 {
227 /// Adding Q to the fQ value
228   if (i==0 || i==1) {
229     fQ[i]+=Q;
230     return 1;
231   }
232   else  return 0;
233 }
234 //____________________________________________________
235 Int_t AliMUONRawCluster::AddX(Int_t i, Float_t X)
236 {
237 /// Adding X to the fX value
238   if (i==0 || i==1) {
239     fX[i]+=X;
240     return 1;
241   }
242   else  return 0;
243 }
244 //____________________________________________________
245 Int_t AliMUONRawCluster::AddY(Int_t i, Float_t Y)
246 {
247 /// Adding Y to the fY value 
248   if (i==0 || i==1) {
249     fY[i]+=Y;
250     return 1;
251   }
252   else return 0;
253 }
254 //____________________________________________________
255 Int_t AliMUONRawCluster::AddZ(Int_t i, Float_t Z)
256 {
257 /// Adding Z to the fZ value
258   if (i==0 || i==1) {
259     fZ[i]+=Z;
260     return 1;
261   }
262   else return 0;
263 }
264 //____________________________________________________
265 Float_t AliMUONRawCluster::GetCharge(Int_t i) const
266 {
267 /// Getting the charge of the cluster
268   if (i==0 || i==1) return fQ[i];
269   else  return 99999;
270 }
271 //____________________________________________________
272 Float_t AliMUONRawCluster::GetX(Int_t i)  const
273 {
274 /// Getting X value of the cluster
275   if (i==0 || i==1) return fX[i];
276   else  return 99999.;
277 }
278 //____________________________________________________
279 Float_t AliMUONRawCluster::GetY(Int_t i) const 
280 {
281 /// Getting Y value of the cluster
282   if (i==0 || i==1) return fY[i];
283   else  return 99999.;
284 }
285 //____________________________________________________
286 Float_t AliMUONRawCluster::GetZ(Int_t i) const 
287 {
288 /// Getting Z value of the cluster
289   if (i==0 || i==1) return fZ[i];
290   else  return 99999.;
291 }
292 //____________________________________________________
293 Int_t AliMUONRawCluster::GetTrack(Int_t i) const 
294 {
295 /// Getting track i contributing to the cluster
296   if (i==0 || i==1 || i==2) return fTracks[i];
297   else  return 99999;
298 }
299 //____________________________________________________
300 Float_t AliMUONRawCluster::GetPeakSignal(Int_t i) const 
301 {
302 /// Getting cluster peaksignal
303   if (i==0 || i==1 ) return fPeakSignal[i];
304   else  return 99999;
305 }
306 //____________________________________________________
307 Int_t AliMUONRawCluster::GetMultiplicity(Int_t i) const 
308 {
309 /// Getting cluster multiplicity
310   if (i==0 || i==1 ) return fMultiplicity[i];
311   else  return 99999;
312 }
313 //____________________________________________________
314 Int_t AliMUONRawCluster::GetClusterType() const 
315 {
316 /// Getting Cluster Type
317   return fClusterType;
318 }
319 //____________________________________________________
320 Int_t AliMUONRawCluster::GetGhost() const 
321 {
322 /// Getting Ghost
323   return fGhost;
324 }
325 //____________________________________________________
326 Int_t AliMUONRawCluster::GetNcluster(Int_t i) const 
327 {
328 /// Getting number of clusters
329   if (i==0 || i==1 ) return fNcluster[i];
330   else  return 99999;
331 }
332 //____________________________________________________
333 Float_t AliMUONRawCluster::GetChi2(Int_t i) const 
334 {
335 /// Getting chi2 value of the cluster
336   if (i==0 || i==1) return fChi2[i];
337   else  return 99999.;
338 }
339 //____________________________________________________
340 Int_t AliMUONRawCluster::SetCharge(Int_t i, Float_t Q)
341 {
342 /// Setting Charge of the cluster
343   if (i==0 || i==1) {
344     fQ[i]=Q;
345     return 1;
346   }
347   else  return 0;
348 }
349 //____________________________________________________
350 Int_t AliMUONRawCluster::SetX(Int_t i, Float_t X)
351 {
352 /// Setting X value of the cluster
353   if (i==0 || i==1) {
354     fX[i]=X;
355     return 1;
356   }
357   else  return 0;
358 }
359 //____________________________________________________
360 Int_t AliMUONRawCluster::SetY(Int_t i, Float_t Y)
361 {
362 /// Setting Y value of the cluster
363   if (i==0 || i==1) {
364     fY[i]=Y;
365     return 1;
366   }
367   else return 0;
368 }
369 //____________________________________________________
370 Int_t AliMUONRawCluster::SetZ(Int_t i, Float_t Z)
371 {
372 /// Setting Z value of the cluste
373   if (i==0 || i==1) {
374     fZ[i]=Z;
375     return 1;
376   }
377   else return 0;
378 }
379 //____________________________________________________
380 Int_t AliMUONRawCluster::SetTrack(Int_t i, Int_t track)
381 {
382 /// Setting tracks contributing to the cluster
383   if (i==0 || i==1 || i==2) {
384     fTracks[i]=track;
385     return 1;
386   }
387   else return 0;
388 }
389 //____________________________________________________
390 Int_t AliMUONRawCluster::SetPeakSignal(Int_t i, Float_t peaksignal)
391 {
392 /// Setting PeakSignal of the cluster
393   if (i==0 || i==1 ) {
394     fPeakSignal[i]=peaksignal;
395     return 1;
396   }
397   else return 0;
398 }
399 //____________________________________________________
400 Int_t AliMUONRawCluster::SetMultiplicity(Int_t i, Int_t mul)
401 {
402 /// Setting multiplicity of the cluster
403   if (i==0 || i==1 ) {
404     fMultiplicity[i]=mul;
405     return 1;
406   }
407   else return 0;
408 }
409 //____________________________________________________
410 Int_t AliMUONRawCluster::SetClusterType(Int_t type)
411 {
412 /// Setting the cluster type
413   fClusterType=type;
414   return 1;
415 }
416 //____________________________________________________
417 Int_t AliMUONRawCluster::SetGhost(Int_t ghost)
418 {
419 /// Setting the ghost
420   fGhost=ghost;
421   return 1;
422 }
423 //____________________________________________________
424 Int_t AliMUONRawCluster::SetNcluster(Int_t i, Int_t ncluster)
425 {
426 /// Setting number the cluster
427   if (i==0 || i==1 ) {
428     fNcluster[i]=ncluster;
429     return 1;
430   }
431   else return 0;
432 }
433 //____________________________________________________
434 Int_t AliMUONRawCluster::SetChi2(Int_t i, Float_t chi2)
435 {
436 /// Setting chi2 of the cluster
437   if (i==0 || i==1) {
438     fChi2[i]=chi2;
439     return 1;
440   }
441   else return 0;
442 }
443