]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONRawCluster.cxx
New MUON data container AliMUONData implementation
[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 #include "AliMUONRawCluster.h"
19 #include <TObjArray.h>
20 #include <TArrayF.h>
21
22 ClassImp(AliMUONRawCluster);
23
24
25 AliMUONRawCluster::AliMUONRawCluster() {
26 // Constructor
27     fTracks[0]=fTracks[1]=fTracks[2]=-1; 
28     for (int j=0;j<2;j++) {
29         fQ[j]=0;
30         fX[j]=0;
31         fY[j]=0;
32         fMultiplicity[j]=0;
33         fPeakSignal[j]=-1;
34         fChi2[j]=-1;
35         
36         for (int k=0;k<50;k++) {
37             fIndexMap[k][j]=-1;
38             fOffsetMap[k][j]=0;
39             fContMap[k][j]=0;
40             fPhysicsMap[k]=-1;
41         }
42     }
43     fNcluster[0]=fNcluster[1]=-1;
44     fGhost=0;
45 }
46
47 Int_t AliMUONRawCluster::Compare(const TObject *obj) const
48 {
49   /*
50          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
51          Float_t r=GetRadius();
52          Float_t ro=raw->GetRadius();
53          if (r>ro) return 1;
54          else if (r<ro) return -1;
55          else return 0;
56   */
57          AliMUONRawCluster *raw=(AliMUONRawCluster *)obj;
58          Float_t y=fY[0];
59          Float_t yo=raw->fY[0];
60          if (y>yo) return 1;
61          else if (y<yo) return -1;
62          else return 0;
63
64 }
65
66 Int_t AliMUONRawCluster::
67 BinarySearch(Float_t y, TArrayF coord, Int_t from, Int_t upto)
68 {
69    // Find object using a binary search. Array must first have been sorted.
70    // Search can be limited by setting upto to desired index.
71
72    Int_t low=from, high=upto-1, half;
73    while(high-low>1) {
74         half=(high+low)/2;
75         if(y>coord[half]) low=half;
76         else high=half;
77    }
78    return low;
79 }
80
81 void AliMUONRawCluster::SortMin(Int_t *idx,Float_t *xdarray,Float_t *xarray,Float_t *yarray,Float_t *qarray, Int_t ntr)
82 {
83   //
84   // Get the 3 closest points(cog) one can find on the second cathode 
85   // starting from a given cog on first cathode
86   //
87   
88   //
89   //  Loop over deltax, only 3 times
90   //
91   
92     Float_t xmin;
93     Int_t jmin;
94     Int_t id[3] = {-2,-2,-2};
95     Float_t jx[3] = {0.,0.,0.};
96     Float_t jy[3] = {0.,0.,0.};
97     Float_t jq[3] = {0.,0.,0.};
98     Int_t jid[3] = {-2,-2,-2};
99     Int_t i,j,imax;
100   
101     if (ntr<3) imax=ntr;
102     else imax=3;
103     for(i=0;i<imax;i++){
104         xmin=1001.;
105         jmin=0;
106     
107         for(j=0;j<ntr;j++){
108             if ((i == 1 && j == id[i-1]) 
109                   ||(i == 2 && (j == id[i-1] || j == id[i-2]))) continue;
110            if (TMath::Abs(xdarray[j]) < xmin) {
111               xmin = TMath::Abs(xdarray[j]);
112               jmin=j;
113            }       
114         } // j
115         if (xmin != 1001.) {    
116            id[i]=jmin;
117            jx[i]=xarray[jmin]; 
118            jy[i]=yarray[jmin]; 
119            jq[i]=qarray[jmin]; 
120            jid[i]=idx[jmin];
121         } 
122     
123     }  // i
124   
125     for (i=0;i<3;i++){
126         if (jid[i] == -2) {
127             xarray[i]=1001.;
128             yarray[i]=1001.;
129             qarray[i]=1001.;
130             idx[i]=-1;
131         } else {
132             xarray[i]=jx[i];
133             yarray[i]=jy[i];
134             qarray[i]=jq[i];
135             idx[i]=jid[i];
136         }
137     }
138
139 }
140
141
142 Int_t AliMUONRawCluster::PhysicsContribution()
143 {
144 // Evaluate physics contribution to cluster
145   Int_t iPhys=0;
146   Int_t iBg=0;
147   Int_t iMixed=0;
148   for (Int_t i=0; i<fMultiplicity[0]; i++) {
149     if (fPhysicsMap[i]==2) iPhys++;
150     if (fPhysicsMap[i]==1) iMixed++;
151     if (fPhysicsMap[i]==0) iBg++;
152   }
153   if (iMixed==0 && iBg==0) {
154     return 2;
155   } else if ((iPhys != 0 && iBg !=0) || iMixed != 0) {
156     return 1;
157   } else {
158     return 0;
159   }
160 }
161
162 //____________________________________________________
163 void AliMUONRawCluster::DumpIndex(void)
164 {
165     printf ("-----\n");
166     for (Int_t icat=0;icat<2;icat++) {
167         printf ("Mult %d\n",fMultiplicity[icat]);
168         for (Int_t idig=0;idig<fMultiplicity[icat];idig++){
169             printf("Index %d",fIndexMap[idig][icat]);
170         }
171         printf("\n");
172     }
173 }