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