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 "AliRICHTresholdMap.h"
22 #include "AliSegmentation.h"
23 #include "AliRICHDigit.h"
25 #include <TObjArray.h>
28 ClassImp(AliRICHTresholdMap)
31 AliRICHTresholdMap::AliRICHTresholdMap(AliSegmentation *seg)
34 // Constructor for AliRICHTresholdMap
37 fNpx = fSegmentation->Npx();
38 fNpy = fSegmentation->Npy();
39 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
41 fHitMap = new Int_t[fMaxIndex];
46 AliRICHTresholdMap::~AliRICHTresholdMap()
49 // if (fDigits) delete fDigits;
50 if (fHitMap) delete[] fHitMap;
53 void AliRICHTresholdMap::Clear(const char *opt)
56 // Clear contents of hit map
58 memset(fHitMap,0,sizeof(int)*fMaxIndex);
61 Int_t AliRICHTresholdMap::CheckedIndex(Int_t ix, Int_t iy) const
64 // Check if index is valid
66 Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
67 if (index > fMaxIndex) {
68 printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",ix,iy, fMaxIndex, index, fNpx, fNpy);
76 void AliRICHTresholdMap::FillHits()
83 void AliRICHTresholdMap::SetHit(Int_t ix, Int_t iy, Int_t charge)
87 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
89 fHitMap[CheckedIndex(ix, iy)]=charge;
92 void AliRICHTresholdMap::DeleteHit(Int_t ix, Int_t iy)
96 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
97 fHitMap[CheckedIndex(ix, iy)]=0;
100 void AliRICHTresholdMap::FlagHit(Int_t ix, Int_t iy)
105 fHitMap[CheckedIndex(ix, iy)]=
106 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
109 Int_t AliRICHTresholdMap::GetHitIndex(Int_t ix, Int_t iy) const
112 // Return hit coordinates from index
114 //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy));
116 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
120 TObject* AliRICHTresholdMap::GetHit(Int_t ix, Int_t iy) const
123 // Return index from coordinates
125 Int_t index=GetHitIndex(ix,iy);
127 return((TObject*) index);
129 return((TObject*) 0);
132 FlagType AliRICHTresholdMap::TestHit(Int_t ix, Int_t iy)
137 Int_t inf=fHitMap[CheckedIndex(ix, iy)];
140 } else if (inf == 0) {