Default constructor added.
[u/mrichter/AliRoot.git] / RICH / AliRICHHitMapA1.cxx
CommitLineData
237c933d 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"
a2f7eaf6 22#include "AliSegmentation.h"
237c933d 23#include "AliRICHDigit.h"
24
25#include <TObjArray.h>
26#include <TMath.h>
27
28ClassImp(AliRICHHitMapA1)
29
59e2916d 30AliRICHHitMapA1::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
237c933d 42
a2f7eaf6 43AliRICHHitMapA1::AliRICHHitMapA1(AliSegmentation *seg, TObjArray *dig)
237c933d 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
60AliRICHHitMapA1::~AliRICHHitMapA1()
61{
62// Destructor
63// if (fDigits) delete fDigits;
64 if (fHitMap) delete[] fHitMap;
65}
66
6643ccf0 67void AliRICHHitMapA1::Clear(const char *opt)
237c933d 68{
69
70// Clear contents of hit map
71
72 memset(fHitMap,0,sizeof(int)*fMaxIndex);
73}
74
a2f7eaf6 75Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
237c933d 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
90void 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->fPadX,dig->fPadY,ndig);
103 }
104}
105
106
107void 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
115void 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
123void 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
a2f7eaf6 132Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
237c933d 133{
134
135// Return hit coordinates from index
136
f8de6569 137 //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy));
237c933d 138
139 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
140
141}
142
a2f7eaf6 143TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy) const
237c933d 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
153FlagType 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