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