]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHHitMap.cxx
Display macro with digits, clusters, reconstructed tracks (JB, AM)
[u/mrichter/AliRoot.git] / RICH / AliRICHHitMap.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 "AliRICHHitMap.h"
22
23 ClassImp(AliRICHHitMap)
24 ClassImp(AliRICHHitMapA1)
25
26
27 AliRICHHitMapA1::AliRICHHitMapA1(AliRICHSegmentation *seg, TObjArray *dig)
28 {
29     fSegmentation = seg;
30     fNpx  = fSegmentation->Npx();
31     fNpy  = fSegmentation->Npy();
32     fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
33     
34     fHitMap = new Int_t[fMaxIndex];
35     fDigits =  dig;
36     fNdigits = fDigits->GetEntriesFast();
37     Clear();
38 }
39
40
41 AliRICHHitMapA1::~AliRICHHitMapA1()
42 {
43 //    if (fDigits) delete   fDigits;
44     if (fHitMap) delete[] fHitMap;
45 }
46
47 void AliRICHHitMapA1::Clear()
48 {
49     memset(fHitMap,0,sizeof(int)*fMaxIndex);
50 }
51
52 Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy)
53 {
54     Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
55     if (index > fMaxIndex) {
56         printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy);
57         return  fMaxIndex-1;
58     } else {
59         return index;
60     }
61 }
62
63         
64 void  AliRICHHitMapA1::FillHits()
65 {
66     Int_t ndigits = fDigits->GetEntriesFast();
67     //printf("\n Filling hits into HitMap\n");
68     //printf("FindRawClusters -- ndigits %d \n",ndigits);
69     if (!ndigits) return;
70     AliRICHDigit *dig;
71     for (Int_t ndig=0; ndig<fNdigits; ndig++) {
72         dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
73         SetHit(dig->fPadX,dig->fPadY,ndig);
74     }
75 }
76
77
78 void  AliRICHHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
79 {
80 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
81     fHitMap[CheckedIndex(ix, iy)]=idigit+1;
82 }
83
84 void AliRICHHitMapA1::DeleteHit(Int_t ix, Int_t iy)
85 {
86 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
87     fHitMap[CheckedIndex(ix, iy)]=0;
88 }
89
90 void AliRICHHitMapA1::FlagHit(Int_t ix, Int_t iy)
91 {
92     fHitMap[CheckedIndex(ix, iy)]=
93         -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
94 }
95
96 Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy)
97 {
98     return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
99 }
100
101 TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy)
102 {
103     Int_t index=GetHitIndex(ix,iy);
104     // Force crash if index does not exist ! (Manu)
105     return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
106 }
107
108 Flag_t AliRICHHitMapA1::TestHit(Int_t ix, Int_t iy)
109 {
110     Int_t inf=fHitMap[CheckedIndex(ix, iy)];
111     if (inf < 0) {
112         return used;
113     } else if (inf == 0) {
114         return empty;
115     } else {
116         return unused;
117     }
118 }
119
120