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