]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawCluster.cxx
Updated list of MUON libraries
[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   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 }
212 //____________________________________________________
213 void AliMUONRawCluster::DumpIndex(void)
214 {
215 /// Dumping IdexMap of the cluster
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 }
225 //____________________________________________________
226 Int_t AliMUONRawCluster::AddCharge(Int_t i, Float_t Q)
227 {
228 /// Adding Q to the fQ value
229   if (i==0 || i==1) {
230     fQ[i]+=Q;
231     return 1;
232   }
233   else  return 0;
234 }
235 //____________________________________________________
236 Int_t AliMUONRawCluster::AddX(Int_t i, Float_t X)
237 {
238 /// Adding X to the fX value
239   if (i==0 || i==1) {
240     fX[i]+=X;
241     return 1;
242   }
243   else  return 0;
244 }
245 //____________________________________________________
246 Int_t AliMUONRawCluster::AddY(Int_t i, Float_t Y)
247 {
248 /// Adding Y to the fY value 
249   if (i==0 || i==1) {
250     fY[i]+=Y;
251     return 1;
252   }
253   else return 0;
254 }
255 //____________________________________________________
256 Int_t AliMUONRawCluster::AddZ(Int_t i, Float_t Z)
257 {
258 /// Adding Z to the fZ value
259   if (i==0 || i==1) {
260     fZ[i]+=Z;
261     return 1;
262   }
263   else return 0;
264 }
265 //____________________________________________________
266 Float_t AliMUONRawCluster::GetCharge(Int_t i) const
267 {
268 /// Getting the charge of the cluster
269   if (i==0 || i==1) return fQ[i];
270   else  return 99999;
271 }
272 //____________________________________________________
273 Float_t AliMUONRawCluster::GetX(Int_t i)  const
274 {
275 /// Getting X value of the cluster
276   if (i==0 || i==1) return fX[i];
277   else  return 99999.;
278 }
279 //____________________________________________________
280 Float_t AliMUONRawCluster::GetY(Int_t i) const 
281 {
282 /// Getting Y value of the cluster
283   if (i==0 || i==1) return fY[i];
284   else  return 99999.;
285 }
286 //____________________________________________________
287 Float_t AliMUONRawCluster::GetZ(Int_t i) const 
288 {
289 /// Getting Z value of the cluster
290   if (i==0 || i==1) return fZ[i];
291   else  return 99999.;
292 }
293 //____________________________________________________
294 Int_t AliMUONRawCluster::GetTrack(Int_t i) const 
295 {
296 /// Getting track i contributing to the cluster
297   if (i==0 || i==1 || i==2) return fTracks[i];
298   else  return 99999;
299 }
300 //____________________________________________________
301 Float_t AliMUONRawCluster::GetPeakSignal(Int_t i) const 
302 {
303 /// Getting cluster peaksignal
304   if (i==0 || i==1 ) return fPeakSignal[i];
305   else  return 99999;
306 }
307 //____________________________________________________
308 Int_t AliMUONRawCluster::GetMultiplicity(Int_t i) const 
309 {
310 /// Getting cluster multiplicity
311   if (i==0 || i==1 ) return fMultiplicity[i];
312   else  return 99999;
313 }
314 //____________________________________________________
315 Int_t AliMUONRawCluster::GetClusterType() const 
316 {
317 /// Getting Cluster Type
318   return fClusterType;
319 }
320 //____________________________________________________
321 Int_t AliMUONRawCluster::GetGhost() const 
322 {
323 /// Getting Ghost
324   return fGhost;
325 }
326 //____________________________________________________
327 Int_t AliMUONRawCluster::GetNcluster(Int_t i) const 
328 {
329 /// Getting number of clusters
330   if (i==0 || i==1 ) return fNcluster[i];
331   else  return 99999;
332 }
333 //____________________________________________________
334 Float_t AliMUONRawCluster::GetChi2(Int_t i) const 
335 {
336 /// Getting chi2 value of the cluster
337   if (i==0 || i==1) return fChi2[i];
338   else  return 99999.;
339 }
340 //____________________________________________________
341 Int_t AliMUONRawCluster::SetCharge(Int_t i, Float_t Q)
342 {
343 /// Setting Charge of the cluster
344   if (i==0 || i==1) {
345     fQ[i]=Q;
346     return 1;
347   }
348   else  return 0;
349 }
350 //____________________________________________________
351 Int_t AliMUONRawCluster::SetX(Int_t i, Float_t X)
352 {
353 /// Setting X value of the cluster
354   if (i==0 || i==1) {
355     fX[i]=X;
356     return 1;
357   }
358   else  return 0;
359 }
360 //____________________________________________________
361 Int_t AliMUONRawCluster::SetY(Int_t i, Float_t Y)
362 {
363 /// Setting Y value of the cluster
364   if (i==0 || i==1) {
365     fY[i]=Y;
366     return 1;
367   }
368   else return 0;
369 }
370 //____________________________________________________
371 Int_t AliMUONRawCluster::SetZ(Int_t i, Float_t Z)
372 {
373 /// Setting Z value of the cluste
374   if (i==0 || i==1) {
375     fZ[i]=Z;
376     return 1;
377   }
378   else return 0;
379 }
380 //____________________________________________________
381 Int_t AliMUONRawCluster::SetTrack(Int_t i, Int_t track)
382 {
383 /// Setting tracks contributing to the cluster
384   if (i==0 || i==1 || i==2) {
385     fTracks[i]=track;
386     return 1;
387   }
388   else return 0;
389 }
390 //____________________________________________________
391 Int_t AliMUONRawCluster::SetPeakSignal(Int_t i, Float_t peaksignal)
392 {
393 /// Setting PeakSignal of the cluster
394   if (i==0 || i==1 ) {
395     fPeakSignal[i]=peaksignal;
396     return 1;
397   }
398   else return 0;
399 }
400 //____________________________________________________
401 Int_t AliMUONRawCluster::SetMultiplicity(Int_t i, Int_t mul)
402 {
403 /// Setting multiplicity of the cluster
404   if (i==0 || i==1 ) {
405     fMultiplicity[i]=mul;
406     return 1;
407   }
408   else return 0;
409 }
410 //____________________________________________________
411 Int_t AliMUONRawCluster::SetClusterType(Int_t type)
412 {
413 /// Setting the cluster type
414   fClusterType=type;
415   return 1;
416 }
417 //____________________________________________________
418 Int_t AliMUONRawCluster::SetGhost(Int_t ghost)
419 {
420 /// Setting the ghost
421   fGhost=ghost;
422   return 1;
423 }
424 //____________________________________________________
425 Int_t AliMUONRawCluster::SetNcluster(Int_t i, Int_t ncluster)
426 {
427 /// Setting number the cluster
428   if (i==0 || i==1 ) {
429     fNcluster[i]=ncluster;
430     return 1;
431   }
432   else return 0;
433 }
434 //____________________________________________________
435 Int_t AliMUONRawCluster::SetChi2(Int_t i, Float_t chi2)
436 {
437 /// Setting chi2 of the cluster
438   if (i==0 || i==1) {
439     fChi2[i]=chi2;
440     return 1;
441   }
442   else return 0;
443 }
444