]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHRawCluster.cxx
Cleaned up version.
[u/mrichter/AliRoot.git] / RICH / AliRICHRawCluster.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 /*
17   $Log$
18 */
19
20
21 #include "AliRICHRawCluster.h"
22
23
24 ClassImp(AliRICHRawCluster)
25 Int_t AliRICHRawCluster::Compare(TObject *obj)
26 {
27
28 // Compare two clusters
29
30          AliRICHRawCluster *raw=(AliRICHRawCluster *)obj;
31          Float_t y=fY;
32          Float_t yo=raw->fY;
33          if (y>yo) return 1;
34          else if (y<yo) return -1;
35          else return 0;
36
37 }
38
39 Int_t AliRICHRawCluster::
40 BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
41 {
42    // Find object using a binary search. Array must first have been sorted.
43    // Search can be limited by setting upto to desired index.
44
45    Int_t low=from, high=upto-1, half;
46    while(high-low>1) {
47         half=(high+low)/2;
48         if(y>coord[half]) low=half;
49         else high=half;
50    }
51    return low;
52 }
53
54 void AliRICHRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
55 {
56   //
57   // Get the 3 closest points(cog) one can find on the second cathode 
58   // starting from a given cog on first cathode
59   //
60   
61   //
62   //  Loop over deltax, only 3 times
63   //
64   
65     Float_t xmin;
66     Int_t jmin;
67     Int_t id[3] = {-2,-2,-2};
68     Float_t jx[3] = {0.,0.,0.};
69     Float_t jy[3] = {0.,0.,0.};
70     Float_t jq[3] = {0.,0.,0.};
71     Int_t jid[3] = {-2,-2,-2};
72     Int_t i,j,imax;
73   
74     if (ntr<3) imax=ntr;
75     else imax=3;
76     for(i=0;i<imax;i++){
77         xmin=1001.;
78         jmin=0;
79     
80         for(j=0;j<ntr;j++){
81             if ((i == 1 && j == id[i-1]) 
82                   ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
83            if (TMath::Abs(xdarray[j]) < xmin) {
84               xmin = TMath::Abs(xdarray[j]);
85               jmin=j;
86            }       
87         } // j
88         if (xmin != 1001.) {    
89            id[i]=jmin;
90            jx[i]=xarray[jmin]; 
91            jy[i]=yarray[jmin]; 
92            jq[i]=qarray[jmin]; 
93            jid[i]=idx[jmin];
94         } 
95     
96     }  // i
97   
98     for (i=0;i<3;i++){
99         if (jid[i] == -2) {
100             xarray[i]=1001.;
101             yarray[i]=1001.;
102             qarray[i]=1001.;
103             idx[i]=-1;
104         } else {
105             xarray[i]=jx[i];
106             yarray[i]=jy[i];
107             qarray[i]=jq[i];
108             idx[i]=jid[i];
109         }
110     }
111
112 }
113
114
115 Int_t AliRICHRawCluster::PhysicsContribution()
116 {
117
118 // Type of physics processes
119
120     Int_t iPhys=0;
121     Int_t iBg=0;
122     Int_t iMixed=0;
123     for (Int_t i=0; i<fMultiplicity; i++) {
124         if (fPhysicsMap[i]==2) iPhys++;
125         if (fPhysicsMap[i]==1) iMixed++;
126         if (fPhysicsMap[i]==0) iBg++;
127     }
128     if (iMixed==0 && iBg==0) {
129         return 2;
130     } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
131         return 1;
132     } else {
133         return 0;
134     }
135 }