]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawCluster.cxx
J.Chudoba's changes merged correctly with the HEAD
[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 /*
17 $Log$
18 Revision 1.3  2001/02/05 14:49:29  hristov
19 Compare() declared const (R.Brun)
20
21 Revision 1.2  2000/06/15 07:58:48  morsch
22 Code from MUON-dev joined
23
24 Revision 1.1.2.1  2000/06/09 22:04:50  morsch
25 Was before in DataStructures.cxx
26
27 */
28
29 #include "AliMUONRawCluster.h"
30 #include <TObjArray.h>
31 #include <TArrayF.h>
32
33 ClassImp(AliMUONRawCluster);
34
35
36 AliMUONRawCluster::AliMUONRawCluster() {
37 // Constructor
38     fTracks[0]=fTracks[1]=fTracks[2]=-1; 
39     for (int j=0;j<2;j++) {
40         fQ[j]=0;
41         fX[j]=0;
42         fY[j]=0;
43         fMultiplicity[j]=0;
44         fPeakSignal[j]=-1;
45         fChi2[j]=-1;
46         
47         for (int k=0;k<50;k++) {
48             fIndexMap[k][j]=-1;
49             fOffsetMap[k][j]=0;
50             fContMap[k][j]=0;
51             fPhysicsMap[k]=-1;
52         }
53     }
54     fNcluster[0]=fNcluster[1]=-1;
55     fGhost=0;
56 }
57
58 Int_t AliMUONRawCluster::Compare(const TObject *obj) const
59 {
60   /*
61          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
62          Float_t r=GetRadius();
63          Float_t ro=raw->GetRadius();
64          if (r>ro) return 1;
65          else if (r<ro) return -1;
66          else return 0;
67   */
68          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
69          Float_t y=fY[0];
70          Float_t yo=raw->fY[0];
71          if (y>yo) return 1;
72          else if (y<yo) return -1;
73          else return 0;
74
75 }
76
77 Int_t AliMUONRawCluster::
78 BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
79 {
80    // Find object using a binary search. Array must first have been sorted.
81    // Search can be limited by setting upto to desired index.
82
83    Int_t low=from, high=upto-1, half;
84    while(high-low>1) {
85         half=(high+low)/2;
86         if(y>coord[half]) low=half;
87         else high=half;
88    }
89    return low;
90 }
91
92 void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
93 {
94   //
95   // Get the 3 closest points(cog) one can find on the second cathode 
96   // starting from a given cog on first cathode
97   //
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()
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 //____________________________________________________
174 void AliMUONRawCluster::DumpIndex(void)
175 {
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 }