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