]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawCluster.cxx
Getting rid of setprecision in Print and changing Compare method (Laurent)
[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   /*
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;
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;
104 }
105
106 //____________________________________________________
107 Int_t AliMUONRawCluster::BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
108 {
109 /// Find object using a binary search. Array must first have been sorted.
110 /// Search can be limited by setting upto to desired index.
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 }
120 //____________________________________________________
121 void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
122 {
123 /// Get the 3 closest points(cog) one can find on the second cathode 
124 /// starting from a given cog on first cathode
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
179 //____________________________________________________
180 Int_t AliMUONRawCluster::PhysicsContribution() const
181 {
182 /// Evaluate physics contribution to cluster
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 }
199
200 //____________________________________________________
201 void AliMUONRawCluster::Print(Option_t* opt) const
202 {
203   ///
204   /// Printing Raw Cluster (Rec Point) information 
205   /// "full" option for printing all the information about the raw cluster
206   ///
207   TString sopt(opt);
208   sopt.ToUpper();
209  
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                
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);
220   }
221   cout << endl;
222 }
223
224 //____________________________________________________
225 void AliMUONRawCluster::DumpIndex(void)
226 {
227 /// Dumping IdexMap of the cluster
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 }
237 //____________________________________________________
238 Int_t AliMUONRawCluster::AddCharge(Int_t i, Float_t Q)
239 {
240 /// Adding Q to the fQ value
241   if (i==0 || i==1) {
242     fQ[i]+=Q;
243     return 1;
244   }
245   else  return 0;
246 }
247 //____________________________________________________
248 Int_t AliMUONRawCluster::AddX(Int_t i, Float_t X)
249 {
250 /// Adding X to the fX value
251   if (i==0 || i==1) {
252     fX[i]+=X;
253     return 1;
254   }
255   else  return 0;
256 }
257 //____________________________________________________
258 Int_t AliMUONRawCluster::AddY(Int_t i, Float_t Y)
259 {
260 /// Adding Y to the fY value 
261   if (i==0 || i==1) {
262     fY[i]+=Y;
263     return 1;
264   }
265   else return 0;
266 }
267 //____________________________________________________
268 Int_t AliMUONRawCluster::AddZ(Int_t i, Float_t Z)
269 {
270 /// Adding Z to the fZ value
271   if (i==0 || i==1) {
272     fZ[i]+=Z;
273     return 1;
274   }
275   else return 0;
276 }
277 //____________________________________________________
278 Float_t AliMUONRawCluster::GetCharge(Int_t i) const
279 {
280 /// Getting the charge of the cluster
281   if (i==0 || i==1) return fQ[i];
282   else  return 99999;
283 }
284 //____________________________________________________
285 Float_t AliMUONRawCluster::GetX(Int_t i)  const
286 {
287 /// Getting X value of the cluster
288   if (i==0 || i==1) return fX[i];
289   else  return 99999.;
290 }
291 //____________________________________________________
292 Float_t AliMUONRawCluster::GetY(Int_t i) const 
293 {
294 /// Getting Y value of the cluster
295   if (i==0 || i==1) return fY[i];
296   else  return 99999.;
297 }
298 //____________________________________________________
299 Float_t AliMUONRawCluster::GetZ(Int_t i) const 
300 {
301 /// Getting Z value of the cluster
302   if (i==0 || i==1) return fZ[i];
303   else  return 99999.;
304 }
305 //____________________________________________________
306 Int_t AliMUONRawCluster::GetTrack(Int_t i) const 
307 {
308 /// Getting track i contributing to the cluster
309   if (i==0 || i==1 || i==2) return fTracks[i];
310   else  return 99999;
311 }
312 //____________________________________________________
313 Float_t AliMUONRawCluster::GetPeakSignal(Int_t i) const 
314 {
315 /// Getting cluster peaksignal
316   if (i==0 || i==1 ) return fPeakSignal[i];
317   else  return 99999;
318 }
319 //____________________________________________________
320 Int_t AliMUONRawCluster::GetMultiplicity(Int_t i) const 
321 {
322 /// Getting cluster multiplicity
323   if (i==0 || i==1 ) return fMultiplicity[i];
324   else  return 99999;
325 }
326 //____________________________________________________
327 Int_t AliMUONRawCluster::GetClusterType() const 
328 {
329 /// Getting Cluster Type
330   return fClusterType;
331 }
332 //____________________________________________________
333 Int_t AliMUONRawCluster::GetGhost() const 
334 {
335 /// Getting Ghost
336   return fGhost;
337 }
338 //____________________________________________________
339 Int_t AliMUONRawCluster::GetNcluster(Int_t i) const 
340 {
341 /// Getting number of clusters
342   if (i==0 || i==1 ) return fNcluster[i];
343   else  return 99999;
344 }
345 //____________________________________________________
346 Float_t AliMUONRawCluster::GetChi2(Int_t i) const 
347 {
348 /// Getting chi2 value of the cluster
349   if (i==0 || i==1) return fChi2[i];
350   else  return 99999.;
351 }
352 //____________________________________________________
353 Int_t AliMUONRawCluster::SetCharge(Int_t i, Float_t Q)
354 {
355 /// Setting Charge of the cluster
356   if (i==0 || i==1) {
357     fQ[i]=Q;
358     return 1;
359   }
360   else  return 0;
361 }
362 //____________________________________________________
363 Int_t AliMUONRawCluster::SetX(Int_t i, Float_t X)
364 {
365 /// Setting X value of the cluster
366   if (i==0 || i==1) {
367     fX[i]=X;
368     return 1;
369   }
370   else  return 0;
371 }
372 //____________________________________________________
373 Int_t AliMUONRawCluster::SetY(Int_t i, Float_t Y)
374 {
375 /// Setting Y value of the cluster
376   if (i==0 || i==1) {
377     fY[i]=Y;
378     return 1;
379   }
380   else return 0;
381 }
382 //____________________________________________________
383 Int_t AliMUONRawCluster::SetZ(Int_t i, Float_t Z)
384 {
385 /// Setting Z value of the cluste
386   if (i==0 || i==1) {
387     fZ[i]=Z;
388     return 1;
389   }
390   else return 0;
391 }
392 //____________________________________________________
393 Int_t AliMUONRawCluster::SetTrack(Int_t i, Int_t track)
394 {
395 /// Setting tracks contributing to the cluster
396   if (i==0 || i==1 || i==2) {
397     fTracks[i]=track;
398     return 1;
399   }
400   else return 0;
401 }
402 //____________________________________________________
403 Int_t AliMUONRawCluster::SetPeakSignal(Int_t i, Float_t peaksignal)
404 {
405 /// Setting PeakSignal of the cluster
406   if (i==0 || i==1 ) {
407     fPeakSignal[i]=peaksignal;
408     return 1;
409   }
410   else return 0;
411 }
412 //____________________________________________________
413 Int_t AliMUONRawCluster::SetMultiplicity(Int_t i, Int_t mul)
414 {
415 /// Setting multiplicity of the cluster
416   if (i==0 || i==1 ) {
417     fMultiplicity[i]=mul;
418     return 1;
419   }
420   else return 0;
421 }
422 //____________________________________________________
423 Int_t AliMUONRawCluster::SetClusterType(Int_t type)
424 {
425 /// Setting the cluster type
426   fClusterType=type;
427   return 1;
428 }
429 //____________________________________________________
430 Int_t AliMUONRawCluster::SetGhost(Int_t ghost)
431 {
432 /// Setting the ghost
433   fGhost=ghost;
434   return 1;
435 }
436 //____________________________________________________
437 Int_t AliMUONRawCluster::SetNcluster(Int_t i, Int_t ncluster)
438 {
439 /// Setting number the cluster
440   if (i==0 || i==1 ) {
441     fNcluster[i]=ncluster;
442     return 1;
443   }
444   else return 0;
445 }
446 //____________________________________________________
447 Int_t AliMUONRawCluster::SetChi2(Int_t i, Float_t chi2)
448 {
449 /// Setting chi2 of the cluster
450   if (i==0 || i==1) {
451     fChi2[i]=chi2;
452     return 1;
453   }
454   else return 0;
455 }
456