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