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 #include <TObjArray.h>
21 #include "AliMUONHitMapA1.h"
22 #include "AliMUONGeometrySegmentation.h"
23 #include "AliMUONDigit.h"
26 ClassImp(AliMUONHitMapA1)
28 AliMUONHitMapA1::AliMUONHitMapA1()
31 // Default constructor
40 //________________________________________________________________________________
41 AliMUONHitMapA1::AliMUONHitMapA1(Int_t idDE, AliMUONGeometrySegmentation* seg, TObjArray* dig)
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;
49 fHitMap = new Int_t[fMaxIndex];
53 //______________________________________________________________
54 AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap)
57 // Protected copy constructor
59 AliFatal("Not implemented.");
61 //_________________________________
62 AliMUONHitMapA1::~AliMUONHitMapA1()
65 if (fHitMap) delete[] fHitMap;
67 //______________________________________
68 void AliMUONHitMapA1::Clear(const char *)
71 memset(fHitMap,0,sizeof(int)*fMaxIndex);
73 //___________________________________________________
74 Bool_t AliMUONHitMapA1::ValidateHit(Int_t ix, Int_t iy)
77 // Check if pad coordinates are within boundaries
79 // printf("\n Validate %d %d %d %d", ix, iy, fNpx, fNpy);
81 return (TMath::Abs(ix) <= fNpx && TMath::Abs(iy) <= fNpy);
83 //_________________________________________________________
84 Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
86 // Return checked indices ix, iy
87 Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
88 if (index >= fMaxIndex) {
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);
96 //_____________________________
97 void AliMUONHitMapA1::FillHits()
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;
105 for (Int_t ndig=0; ndig<ndigits; ndig++) {
106 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
107 SetHit(dig->PadX(),dig->PadY(),ndig);
110 //___________________________________________________________
111 void AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
113 // Assign digit to hit cell ix,iy
114 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
115 fHitMap[CheckedIndex(ix, iy)]=idigit+1;
117 //_______________________________________________
118 void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy)
120 // Delete hit at cell ix,iy
121 // fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
122 fHitMap[CheckedIndex(ix, iy)]=0;
124 //_____________________________________________
125 void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
128 fHitMap[CheckedIndex(ix, iy)]=
129 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
131 //________________________________________________________
132 Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
134 // Get absolute value of contents of hit cell ix,iy
135 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
137 //_______________________________________________________
138 TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const
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));
145 //_________________________________________________
146 FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
148 // Check if hit cell is empty, used or unused
150 Int_t index = CheckedIndex(ix, iy);
151 if (index<0 || index >= fMaxIndex) return kEmpty;
153 Int_t inf=fHitMap[index];
156 } else if (inf == 0) {
162 //________________________________________________________________________
163 AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs)
165 // Protected assignement operator
167 if (this == &rhs) return *this;
169 AliFatal( "Not implemented.");