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