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 **************************************************************************/
18 // -----------------------
19 // Class AliMUONHitMapA1
20 // -----------------------
21 // Implements AliHitMap as a 1-dim array
24 #include "AliMUONHitMapA1.h"
25 #include "AliMUONDigit.h"
29 #include <TObjArray.h>
32 ClassImp(AliMUONHitMapA1)
34 AliMUONHitMapA1::AliMUONHitMapA1()
37 /// Default constructor
46 //________________________________________________________________________________
47 AliMUONHitMapA1::AliMUONHitMapA1(Int_t npx, Int_t npy, TObjArray* dig)
50 /// Standard constructor
54 fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
56 fHitMap = new Int_t[fMaxIndex];
60 //______________________________________________________________
61 AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap)
64 /// Protected copy constructor
66 AliFatal("Not implemented.");
68 //_________________________________
69 AliMUONHitMapA1::~AliMUONHitMapA1()
72 if (fHitMap) delete[] fHitMap;
74 //______________________________________
75 void AliMUONHitMapA1::Clear(const char *)
78 memset(fHitMap,0,sizeof(int)*fMaxIndex);
80 //___________________________________________________
81 Bool_t AliMUONHitMapA1::ValidateHit(Int_t ix, Int_t iy)
83 /// Check if pad coordinates are within boundaries
85 // printf("\n Validate %d %d %d %d", ix, iy, fNpx, fNpy);
87 return (TMath::Abs(ix) <= fNpx && TMath::Abs(iy) <= fNpy);
89 //_________________________________________________________
90 Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
92 /// Return checked indices ix, iy
93 Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
94 if ( index < 0 || index >= fMaxIndex ) {
95 AliWarning(Form("index outside array ix %d iy %d MaxIndex %d index %d Npx %d Npy %d",
96 ix, iy, fMaxIndex, index, fNpx, fNpy));
102 //_____________________________
103 void AliMUONHitMapA1::FillHits()
105 /// Fill hits from digits list
106 Int_t ndigits = fDigits->GetEntriesFast();
107 //printf("\n Filling hits into HitMap\n");
108 //printf("FindRawClusters -- ndigits %d \n",ndigits);
109 if (!ndigits) return;
111 for (Int_t ndig=0; ndig<ndigits; ndig++) {
112 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
113 SetHit(dig->PadX(),dig->PadY(),ndig);
116 //___________________________________________________________
117 void AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
119 /// Assign digit to hit cell ix,iy
121 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
122 fHitMap[CheckedIndex(ix, iy)]=idigit+1;
124 //_______________________________________________
125 void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy)
127 /// Delete hit at cell ix,iy
129 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
130 fHitMap[CheckedIndex(ix, iy)]=0;
132 //_____________________________________________
133 void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
136 fHitMap[CheckedIndex(ix, iy)]=
137 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
139 //________________________________________________________
140 Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
142 /// Get absolute value of contents of hit cell ix,iy
143 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
145 //_______________________________________________________
146 TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const
148 /// Get pointer to object at hit cell ix, iy
149 /// Force crash if index does not exist ! (Manu)
150 Int_t index=GetHitIndex(ix,iy);
151 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
153 //_________________________________________________
154 FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
156 /// Check if hit cell is empty, used or unused
158 Int_t index = CheckedIndex(ix, iy);
159 if (index<0 || index >= fMaxIndex) return kEmpty;
161 Int_t inf=fHitMap[index];
164 } else if (inf == 0) {
170 //________________________________________________________________________
171 AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs)
173 /// Protected assignement operator
175 if (this == &rhs) return *this;
177 AliFatal( "Not implemented.");