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 **************************************************************************/
19 #include "AliRICHHitMapA1.h"
20 #include "AliSegmentation.h"
21 #include "AliRICHDigit.h"
23 #include <TObjArray.h>
26 ClassImp(AliRICHHitMapA1)
28 AliRICHHitMapA1::AliRICHHitMapA1()
30 // Default constructor
41 AliRICHHitMapA1::AliRICHHitMapA1(AliSegmentation *seg, TObjArray *dig)
44 // Constructor for AliRICHMapA1
47 fNpx = fSegmentation->Npx();
48 fNpy = fSegmentation->Npy();
49 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
51 fHitMap = new Int_t[fMaxIndex];
53 fNdigits = fDigits->GetEntriesFast();
58 AliRICHHitMapA1::~AliRICHHitMapA1()
61 // if (fDigits) delete fDigits;
62 if (fHitMap) delete[] fHitMap;
65 void AliRICHHitMapA1::Clear(const char */*opt*/)
68 // Clear contents of hit map
70 memset(fHitMap,0,sizeof(int)*fMaxIndex);
73 Int_t AliRICHHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
76 // Check if index is valid
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);
88 void AliRICHHitMapA1::FillHits()
91 // Fill hits into HitMap
93 Int_t ndigits = fDigits->GetEntriesFast();
94 //printf("\n Filling hits into HitMap\n");
95 //printf("FindRawClusters -- ndigits %d \n",ndigits);
98 for (Int_t ndig=0; ndig<fNdigits; ndig++) {
99 dig = (AliRICHDigit*)fDigits->UncheckedAt(ndig);
100 SetHit(dig->PadX(),dig->PadY(),ndig);
105 void AliRICHHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
109 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
110 fHitMap[CheckedIndex(ix, iy)]=idigit+1;
113 void AliRICHHitMapA1::DeleteHit(Int_t ix, Int_t iy)
117 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
118 fHitMap[CheckedIndex(ix, iy)]=0;
121 void AliRICHHitMapA1::FlagHit(Int_t ix, Int_t iy)
126 fHitMap[CheckedIndex(ix, iy)]=
127 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
130 Int_t AliRICHHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
133 // Return hit coordinates from index
135 //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy));
137 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
141 TObject* AliRICHHitMapA1::GetHit(Int_t ix, Int_t iy) const
144 // Return index from coordinates
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));
151 FlagType AliRICHHitMapA1::TestHit(Int_t ix, Int_t iy)
156 Int_t inf=fHitMap[CheckedIndex(ix, iy)];
159 } else if (inf == 0) {