]> git.uio.no Git - u/mrichter/AliRoot.git/blame - RICH/AliRICHTresholdMap.cxx
Functions renamed to get a prefix PHOS
[u/mrichter/AliRoot.git] / RICH / AliRICHTresholdMap.cxx
CommitLineData
2da3485f 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 "AliRICHTresholdMap.h"
a2f7eaf6 22#include "AliSegmentation.h"
2da3485f 23#include "AliRICHDigit.h"
24
25#include <TObjArray.h>
26#include <TMath.h>
27
28ClassImp(AliRICHTresholdMap)
29
30
a2f7eaf6 31AliRICHTresholdMap::AliRICHTresholdMap(AliSegmentation *seg)
2da3485f 32{
33
34// Constructor for AliRICHTresholdMap
35
36 fSegmentation = seg;
37 fNpx = fSegmentation->Npx();
38 fNpy = fSegmentation->Npy();
39 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
40
41 fHitMap = new Int_t[fMaxIndex];
42 Clear();
43}
44
45
46AliRICHTresholdMap::~AliRICHTresholdMap()
47{
48// Destructor
49// if (fDigits) delete fDigits;
50 if (fHitMap) delete[] fHitMap;
51}
52
6643ccf0 53void AliRICHTresholdMap::Clear(const char *opt)
2da3485f 54{
55
56// Clear contents of hit map
57
58 memset(fHitMap,0,sizeof(int)*fMaxIndex);
59}
60
a2f7eaf6 61Int_t AliRICHTresholdMap::CheckedIndex(Int_t ix, Int_t iy) const
2da3485f 62{
63
64// Check if index is valid
65
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);
69 return fMaxIndex-1;
70 } else {
71 return index;
72 }
73}
74
75
76void AliRICHTresholdMap::FillHits()
77{
78
79// Dummy
80}
81
82
83void AliRICHTresholdMap::SetHit(Int_t ix, Int_t iy, Int_t charge)
84{
85//
86// Set current hit
87// fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
88
89 fHitMap[CheckedIndex(ix, iy)]=charge;
90}
91
92void AliRICHTresholdMap::DeleteHit(Int_t ix, Int_t iy)
93{
94// Delete hit
95//
96// fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
97 fHitMap[CheckedIndex(ix, iy)]=0;
98}
99
100void AliRICHTresholdMap::FlagHit(Int_t ix, Int_t iy)
101{
102//
103// Flag hit
104
105 fHitMap[CheckedIndex(ix, iy)]=
106 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
107}
108
a2f7eaf6 109Int_t AliRICHTresholdMap::GetHitIndex(Int_t ix, Int_t iy) const
2da3485f 110{
111
112// Return hit coordinates from index
113
114 //printf("ix:%d, iy:%d, index:%d\n",ix,iy,CheckedIndex(ix, iy));
115
116 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
117
118}
119
a2f7eaf6 120TObject* AliRICHTresholdMap::GetHit(Int_t ix, Int_t iy) const
2da3485f 121{
122
123// Return index from coordinates
124
125 Int_t index=GetHitIndex(ix,iy);
126 if (index>0)
127 return((TObject*) index);
128 else
129 return((TObject*) 0);
130}
131
132FlagType AliRICHTresholdMap::TestHit(Int_t ix, Int_t iy)
133{
134
135// Is there a hit?
136
137 Int_t inf=fHitMap[CheckedIndex(ix, iy)];
138 if (inf < 0) {
139 return kUsed;
140 } else if (inf == 0) {
141 return kEmpty;
142 } else {
143 return kUnused;
144 }
145}
146