1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 #include "AliRICHHitMapA1.h"
22 #include "AliSegmentation.h"
23 #include "AliRICHDigit.h"
25 #include <TObjArray.h>
28 ClassImp(AliRICHHitMapA1)
30 AliRICHHitMapA1::AliRICHHitMapA1()
32 // Default constructor
43 AliRICHHitMapA1::AliRICHHitMapA1(AliSegmentation *seg, TObjArray *dig)
46 // Constructor for AliRICHMapA1
49 fNpx = fSegmentation->Npx();
50 fNpy = fSegmentation->Npy();
51 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
53 fHitMap = new Int_t[fMaxIndex];
55 fNdigits = fDigits->GetEntriesFast();
60 AliRICHHitMapA1::~AliRICHHitMapA1()
63 // if (fDigits) delete fDigits;
64 if (fHitMap) delete[] fHitMap;
67 void AliRICHHitMapA1::Clear(const char *opt)
70 // Clear contents of hit map
72 memset(fHitMap,0,sizeof(int)*fMaxIndex);
75 Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
78 // Check if index is valid
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);
90 void AliRICHHitMapA1::FillHits()
93 // Fill hits into HitMap
95 Int_t ndigits = fDigits->GetEntriesFast();
96 //printf("\n Filling hits into HitMap\n");
97 //printf("FindRawClusters -- ndigits %d \n",ndigits);
100 for (Int_t ndig=0; ndig<fNdigits; ndig++) {
101 dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
102 SetHit(dig->fPadX,dig->fPadY,ndig);
107 void AliRICHHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
111 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
112 fHitMap[CheckedIndex(ix, iy)]=idigit+1;
115 void AliRICHHitMapA1::DeleteHit(Int_t ix, Int_t iy)
119 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
120 fHitMap[CheckedIndex(ix, iy)]=0;
123 void AliRICHHitMapA1::FlagHit(Int_t ix, Int_t iy)
128 fHitMap[CheckedIndex(ix, iy)]=
129 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
132 Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
135 // Return hit coordinates from index
137 //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy));
139 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
143 TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy) const
146 // Return index from coordinates
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));
153 FlagType AliRICHHitMapA1::TestHit(Int_t ix, Int_t iy)
158 Int_t inf=fHitMap[CheckedIndex(ix, iy)];
161 } else if (inf == 0) {