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