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