]> git.uio.no Git - u/mrichter/AliRoot.git/blob - RICH/AliRICHHitMapA1.cxx
Rotation Angle is +60 deg.
[u/mrichter/AliRoot.git] / RICH / AliRICHHitMapA1.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 "AliRICHHitMapA1.h"
22 #include "AliSegmentation.h"
23 #include "AliRICHDigit.h"
24
25 #include <TObjArray.h>
26 #include <TMath.h>
27
28 ClassImp(AliRICHHitMapA1)
29
30 AliRICHHitMapA1::AliRICHHitMapA1()
31 {
32 // Default constructor
33     fSegmentation = 0;
34     fNpx          = 0;
35     fNpy          = 0;
36     fMaxIndex     = 0;
37     
38     fHitMap       = 0;
39     fDigits       = 0;
40 }
41
42
43 AliRICHHitMapA1::AliRICHHitMapA1(AliSegmentation *seg, TObjArray *dig)
44 {
45
46 // Constructor for AliRICHMapA1
47
48     fSegmentation = seg;
49     fNpx  = fSegmentation->Npx();
50     fNpy  = fSegmentation->Npy();
51     fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
52     
53     fHitMap = new Int_t[fMaxIndex];
54     fDigits =  dig;
55     fNdigits = fDigits->GetEntriesFast();
56     Clear();
57 }
58
59
60 AliRICHHitMapA1::~AliRICHHitMapA1()
61 {
62 // Destructor
63 //    if (fDigits) delete   fDigits;
64     if (fHitMap) delete[] fHitMap;
65 }
66
67 void AliRICHHitMapA1::Clear(const char *opt)
68 {
69
70 // Clear contents of hit map
71
72     memset(fHitMap,0,sizeof(int)*fMaxIndex);
73 }
74
75 Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
76 {
77
78 // Check if index is valid
79
80     Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
81     if (index > fMaxIndex) {
82         printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy);
83         return  fMaxIndex-1;
84     } else {
85         return index;
86     }
87 }
88
89         
90 void  AliRICHHitMapA1::FillHits()
91 {
92
93 // Fill hits into HitMap
94
95     Int_t ndigits = fDigits->GetEntriesFast();
96     //printf("\n Filling hits into HitMap\n");
97     //printf("FindRawClusters -- ndigits %d \n",ndigits);
98     if (!ndigits) return;
99     AliRICHDigit *dig;
100     for (Int_t ndig=0; ndig<fNdigits; ndig++) {
101         dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
102         SetHit(dig->PadX(),dig->PadY(),ndig);
103     }
104 }
105
106
107 void  AliRICHHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
108 {
109 //
110 // Set current hit
111 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
112     fHitMap[CheckedIndex(ix, iy)]=idigit+1;
113 }
114
115 void AliRICHHitMapA1::DeleteHit(Int_t ix, Int_t iy)
116 {
117 // Delete hit
118 //
119 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
120     fHitMap[CheckedIndex(ix, iy)]=0;
121 }
122
123 void AliRICHHitMapA1::FlagHit(Int_t ix, Int_t iy)
124 {
125 //
126 // Flag hit
127
128     fHitMap[CheckedIndex(ix, iy)]=
129         -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
130 }
131
132 Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
133 {
134
135 // Return hit coordinates from index
136
137   //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy));
138    
139   return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
140     
141 }
142
143 TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy) const
144 {
145
146 // Return index from coordinates
147
148     Int_t index=GetHitIndex(ix,iy);
149     // Force crash if index does not exist ! (Manu)
150     return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
151 }
152
153 FlagType AliRICHHitMapA1::TestHit(Int_t ix, Int_t iy)
154 {
155
156 // Is there a hit?
157
158     Int_t inf=fHitMap[CheckedIndex(ix, iy)];
159     if (inf < 0) {
160         return kUsed;
161     } else if (inf == 0) {
162         return kEmpty;
163     } else {
164         return kUnused;
165     }
166 }
167
168