]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawCluster.cxx
Removing coding convention violations mainly due to public data member
[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 // Class for the MUON RecPoint
19 // It contains the propeorties of the physics cluters found in the tracking chambers
20 // RawCluster contains also the information from the both cathode of the chambers.
21
22
23 #include "AliMUONRawCluster.h"
24 #include <TArrayF.h>
25
26 ClassImp(AliMUONRawCluster);
27
28
29 AliMUONRawCluster::AliMUONRawCluster() {
30 // Constructor
31     fTracks[0]=fTracks[1]=fTracks[2]=-1; 
32     for (int j=0;j<2;j++) {
33         fQ[j]=0;
34         fX[j]=0;
35         fY[j]=0;
36         fMultiplicity[j]=0;
37         fPeakSignal[j]=-1;
38         fChi2[j]=-1;
39         
40         for (int k=0;k<50;k++) {
41             fIndexMap[k][j]=-1;
42             fOffsetMap[k][j]=0;
43             fContMap[k][j]=0;
44             fPhysicsMap[k]=-1;
45         }
46     }
47     fNcluster[0]=fNcluster[1]=-1;
48     fGhost=0;
49 }
50 //____________________________________________________
51 Int_t AliMUONRawCluster::Compare(const TObject *obj) const
52 {
53   /*
54          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
55          Float_t r=GetRadius();
56          Float_t ro=raw->GetRadius();
57          if (r>ro) return 1;
58          else if (r<ro) return -1;
59          else return 0;
60   */
61          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
62          Float_t y=fY[0];
63          Float_t yo=raw->fY[0];
64          if (y>yo) return 1;
65          else if (y<yo) return -1;
66          else return 0;
67
68 }
69 //____________________________________________________
70 Int_t AliMUONRawCluster::BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
71 {
72    // Find object using a binary search. Array must first have been sorted.
73    // Search can be limited by setting upto to desired index.
74
75    Int_t low=from, high=upto-1, half;
76    while(high-low>1) {
77         half=(high+low)/2;
78         if(y>coord[half]) low=half;
79         else high=half;
80    }
81    return low;
82 }
83 //____________________________________________________
84 void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
85 {
86   //
87   // Get the 3 closest points(cog) one can find on the second cathode 
88   // starting from a given cog on first cathode
89   //
90   
91   //
92   //  Loop over deltax, only 3 times
93   //
94   
95     Float_t xmin;
96     Int_t jmin;
97     Int_t id[3] = {-2,-2,-2};
98     Float_t jx[3] = {0.,0.,0.};
99     Float_t jy[3] = {0.,0.,0.};
100     Float_t jq[3] = {0.,0.,0.};
101     Int_t jid[3] = {-2,-2,-2};
102     Int_t i,j,imax;
103   
104     if (ntr<3) imax=ntr;
105     else imax=3;
106     for(i=0;i<imax;i++){
107         xmin=1001.;
108         jmin=0;
109     
110         for(j=0;j<ntr;j++){
111             if ((i == 1 && j == id[i-1]) 
112                   ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
113            if (TMath::Abs(xdarray[j]) < xmin) {
114               xmin = TMath::Abs(xdarray[j]);
115               jmin=j;
116            }       
117         } // j
118         if (xmin != 1001.) {    
119            id[i]=jmin;
120            jx[i]=xarray[jmin]; 
121            jy[i]=yarray[jmin]; 
122            jq[i]=qarray[jmin]; 
123            jid[i]=idx[jmin];
124         } 
125     
126     }  // i
127   
128     for (i=0;i<3;i++){
129         if (jid[i] == -2) {
130             xarray[i]=1001.;
131             yarray[i]=1001.;
132             qarray[i]=1001.;
133             idx[i]=-1;
134         } else {
135             xarray[i]=jx[i];
136             yarray[i]=jy[i];
137             qarray[i]=jq[i];
138             idx[i]=jid[i];
139         }
140     }
141
142 }
143
144 //____________________________________________________
145 Int_t AliMUONRawCluster::PhysicsContribution() const
146 {
147 // Evaluate physics contribution to cluster
148   Int_t iPhys=0;
149   Int_t iBg=0;
150   Int_t iMixed=0;
151   for (Int_t i=0; i<fMultiplicity[0]; i++) {
152     if (fPhysicsMap[i]==2) iPhys++;
153     if (fPhysicsMap[i]==1) iMixed++;
154     if (fPhysicsMap[i]==0) iBg++;
155   }
156   if (iMixed==0 && iBg==0) {
157     return 2;
158   } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
159     return 1;
160   } else {
161     return 0;
162   }
163 }
164
165
166
167 //____________________________________________________
168 void AliMUONRawCluster::DumpIndex(void)
169 {
170     printf ("-----\n");
171     for (Int_t icat=0;icat<2;icat++) {
172         printf ("Mult %d\n",fMultiplicity[icat]);
173         for (Int_t idig=0;idig<fMultiplicity[icat];idig++){
174             printf("Index %d",fIndexMap[idig][icat]);
175         }
176         printf("\n");
177     }
178 }
179
180 //____________________________________________________
181 Int_t AliMUONRawCluster::AddCharge(Int_t i, Int_t Q)
182 {
183   if (i==0 || i==1) {
184     fQ[i]+=Q;
185     return 1;
186   }
187   else  return 0;
188 }
189 //____________________________________________________
190 Int_t AliMUONRawCluster::AddX(Int_t i, Float_t X)
191 {
192   if (i==0 || i==1) {
193     fX[i]+=X;
194     return 1;
195   }
196   else  return 0;
197 }
198 //____________________________________________________
199 Int_t AliMUONRawCluster::AddY(Int_t i, Float_t Y)
200 {
201   if (i==0 || i==1) {
202     fY[i]+=Y;
203     return 1;
204   }
205   else return 0;
206 }
207 //____________________________________________________
208 Int_t AliMUONRawCluster::AddZ(Int_t i, Float_t Z)
209 {
210   if (i==0 || i==1) {
211     fZ[i]+=Z;
212     return 1;
213   }
214   else return 0;
215 }
216 //____________________________________________________
217 Int_t AliMUONRawCluster::GetCharge(Int_t i) const
218 {
219   if (i==0 || i==1) return fQ[i];
220   else  return 99999;
221 }
222 //____________________________________________________
223 Float_t AliMUONRawCluster::GetX(Int_t i)  const
224 {
225   if (i==0 || i==1) return fX[i];
226   else  return 99999.;
227 }
228 //____________________________________________________
229 Float_t AliMUONRawCluster::GetY(Int_t i) const 
230 {
231   if (i==0 || i==1) return fY[i];
232   else  return 99999.;
233 }
234 //____________________________________________________
235 Float_t AliMUONRawCluster::GetZ(Int_t i) const 
236 {
237   if (i==0 || i==1) return fZ[i];
238   else  return 99999.;
239 }
240 //____________________________________________________
241 Int_t AliMUONRawCluster::SetCharge(Int_t i, Int_t Q)
242 {
243   if (i==0 || i==1) {
244     fQ[i]=Q;
245     return 1;
246   }
247   else  return 0;
248 }
249 //____________________________________________________
250 Int_t AliMUONRawCluster::SetX(Int_t i, Float_t X)
251 {
252   if (i==0 || i==1) {
253     fX[i]=X;
254     return 1;
255   }
256   else  return 0;
257 }
258 //____________________________________________________
259 Int_t AliMUONRawCluster::SetY(Int_t i, Float_t Y)
260 {
261   if (i==0 || i==1) {
262     fY[i]=Y;
263     return 1;
264   }
265   else return 0;
266 }
267 //____________________________________________________
268 Int_t AliMUONRawCluster::SetZ(Int_t i, Float_t Z)
269 {
270   if (i==0 || i==1) {
271     fZ[i]=Z;
272     return 1;
273   }
274   else return 0;
275 }