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