get tables from the aliroot directory if they are not in the current one
[u/mrichter/AliRoot.git] / MUON / AliMUONHitMapA1.cxx
CommitLineData
a9e2aefa 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
88cb7938 16/* $Id$ */
a9e2aefa 17
18#include "AliMUONHitMapA1.h"
a30a000f 19#include "AliSegmentation.h"
a9e2aefa 20#include "AliMUONResponse.h"
21#include "AliMUONDigit.h"
22
23#include <TObjArray.h>
24#include <TMath.h>
25
26ClassImp(AliMUONHitMapA1)
27
0a5f9c41 28 AliMUONHitMapA1::AliMUONHitMapA1()
29{
30 // Default constructor
0a5f9c41 31 fNpx = 0;
32 fNpy = 0;
33 fMaxIndex = 0;
34
35 fHitMap = 0;
36 fDigits = 0;
0a5f9c41 37}
a9e2aefa 38
a30a000f 39AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig)
a9e2aefa 40{
41// Constructor
2186f543 42 fNpx = seg->Npx()+1;
43 fNpy = seg->Npy()+1;
a9e2aefa 44 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
45
46 fHitMap = new Int_t[fMaxIndex];
47 fDigits = dig;
a9e2aefa 48 Clear();
49}
50
d9a3473d 51AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap):AliHitMap(hitMap)
a9e2aefa 52{
53// Dummy copy constructor
54 ;
55}
56
57
58AliMUONHitMapA1::~AliMUONHitMapA1()
59{
60// Destructor
a9e2aefa 61 if (fHitMap) delete[] fHitMap;
62}
63
ef42d733 64void AliMUONHitMapA1::Clear(const char *)
a9e2aefa 65{
66// Clear hitmap
67 memset(fHitMap,0,sizeof(int)*fMaxIndex);
68}
69
d91b86b7 70Bool_t AliMUONHitMapA1::ValidateHit(Int_t ix, Int_t iy)
71{
72 //
73 // Check if pad coordinates are within boundaries
74 //
75// printf("\n Validate %d %d %d %d", ix, iy, fNpx, fNpy);
76
77 return (TMath::Abs(ix) <= fNpx && TMath::Abs(iy) <= fNpy);
78}
79
94de3818 80Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
a9e2aefa 81{
82// Return checked indices ix, iy
83 Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
654fdb44 84 if (index >= fMaxIndex) {
bad7e393 85 printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",
86 ix,iy, fMaxIndex, index, fNpx, fNpy);
a9e2aefa 87 return fMaxIndex-1;
88 } else {
89 return index;
90 }
91}
92
93
94void AliMUONHitMapA1::FillHits()
95{
96// Fill hits from digits list
97 Int_t ndigits = fDigits->GetEntriesFast();
98 //printf("\n Filling hits into HitMap\n");
99 //printf("FindRawClusters -- ndigits %d \n",ndigits);
100 if (!ndigits) return;
101 AliMUONDigit *dig;
2186f543 102 for (Int_t ndig=0; ndig<ndigits; ndig++) {
a9e2aefa 103 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
1939e822 104 SetHit(dig->PadX(),dig->PadY(),ndig);
a9e2aefa 105 }
106}
107
108
109void AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
110{
111// Assign digit to hit cell ix,iy
112// fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
113 fHitMap[CheckedIndex(ix, iy)]=idigit+1;
114}
115
116void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy)
117{
118// Delete hit at cell ix,iy
119// fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
120 fHitMap[CheckedIndex(ix, iy)]=0;
121}
122
123void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
124{
125// Flag hit as used
126 fHitMap[CheckedIndex(ix, iy)]=
127 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
128}
129
94de3818 130Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
a9e2aefa 131{
132// Get absolute value of contents of hit cell ix,iy
133 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
134}
135
94de3818 136TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const
a9e2aefa 137{
138 // Get pointer to object at hit cell ix, iy
139 // Force crash if index does not exist ! (Manu)
140 Int_t index=GetHitIndex(ix,iy);
141 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
142}
143
144FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
145{
146// Check if hit cell is empty, used or unused
147//
148 Int_t inf=fHitMap[CheckedIndex(ix, iy)];
149 if (inf < 0) {
150 return kUsed;
151 } else if (inf == 0) {
152 return kEmpty;
153 } else {
154 return kUnused;
155 }
156}
157
d9a3473d 158AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & /*rhs*/)
a9e2aefa 159{
160// Dummy assignment operator
161 return *this;
162}
163
164
bad7e393 165
166
167