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 "AliRICHTresholdMap.h"
20 #include "AliSegmentation.h"
21 #include "AliRICHDigit.h"
23 #include <TObjArray.h>
26 ClassImp(AliRICHTresholdMap)
29 AliRICHTresholdMap::AliRICHTresholdMap(AliSegmentation *seg)
32 // Constructor for AliRICHTresholdMap
35 fNpx = fSegmentation->Npx();
36 fNpy = fSegmentation->Npy();
37 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
39 fHitMap = new Int_t[fMaxIndex];
44 AliRICHTresholdMap::~AliRICHTresholdMap()
47 // if (fDigits) delete fDigits;
48 if (fHitMap) delete[] fHitMap;
51 void AliRICHTresholdMap::Clear(const char */*opt*/)
54 // Clear contents of hit map
56 memset(fHitMap,0,sizeof(int)*fMaxIndex);
59 Int_t AliRICHTresholdMap::CheckedIndex(Int_t ix, Int_t iy) const
62 // Check if index is valid
64 Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
65 if (index > fMaxIndex) {
66 printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy);
74 void AliRICHTresholdMap::FillHits()
81 void AliRICHTresholdMap::SetHit(Int_t ix, Int_t iy, Int_t charge)
85 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
87 fHitMap[CheckedIndex(ix, iy)]=charge;
90 void AliRICHTresholdMap::DeleteHit(Int_t ix, Int_t iy)
94 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
95 fHitMap[CheckedIndex(ix, iy)]=0;
98 void AliRICHTresholdMap::FlagHit(Int_t ix, Int_t iy)
103 fHitMap[CheckedIndex(ix, iy)]=
104 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
107 Int_t AliRICHTresholdMap::GetHitIndex(Int_t ix, Int_t iy) const
110 // Return hit coordinates from index
112 //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy));
114 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
118 TObject* AliRICHTresholdMap::GetHit(Int_t ix, Int_t iy) const
121 // Return index from coordinates
123 Int_t index=GetHitIndex(ix,iy);
125 return((TObject*) index);
127 return((TObject*) 0);
130 FlagType AliRICHTresholdMap::TestHit(Int_t ix, Int_t iy)
135 Int_t inf=fHitMap[CheckedIndex(ix, iy)];
138 } else if (inf == 0) {