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 AliMUONDigitMapA1
20 // ---------------------------
21 // Implements cluster Map as a 1-dim array
22 // Author: Christian Finck
24 #include "AliMUONDigitMapA1.h"
25 #include "AliMUONDigit.h"
29 #include <TObjArray.h>
32 ClassImp(AliMUONDigitMapA1)
34 AliMUONDigitMapA1::AliMUONDigitMapA1()
42 /// Default constructor
45 //________________________________________________________________________________
46 AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, Int_t npx, Int_t npy )
48 /// Standard constructor
53 fMaxIndex = fNpx * fNpy + fNpx ;
55 fHitMap = new Int_t[fMaxIndex];
59 //______________________________________________________________
60 AliMUONDigitMapA1::AliMUONDigitMapA1(const AliMUONDigitMapA1& hitMap)
63 /// Protected copy constructor
65 AliFatal("Not implemented.");
67 //_________________________________
68 AliMUONDigitMapA1::~AliMUONDigitMapA1()
71 if (fHitMap) delete[] fHitMap;
73 //______________________________________
74 void AliMUONDigitMapA1::Clear(const char *)
77 memset(fHitMap,0,sizeof(int)*fMaxIndex);
80 //_________________________________________________________
81 Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
83 /// Return checked indices ix, iy
84 Int_t index = iy * fNpx + ix;
85 if ( index < 0 || index >= fMaxIndex ) {
86 AliWarning(Form("index outside array idDE %d ix %d iy %d MaxIndex %d index %d Npx %d Npy %d",
87 fIdDE, ix,iy, fMaxIndex, index, fNpx, fNpy));
93 //_____________________________
94 void AliMUONDigitMapA1::FillHits(TObjArray* digits)
96 /// Fill hits from digits list
98 Int_t ndigits = fDigits->GetEntriesFast();
101 for (Int_t ndig = 0; ndig < ndigits; ndig++) {
102 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
103 SetHit(dig->PadX(),dig->PadY(),ndig);
106 //___________________________________________________________
107 void AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
109 /// Assign digit to hit cell ix,iy
111 fHitMap[CheckedIndex(ix, iy)] = idigit + 1;
113 //_______________________________________________
114 void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy)
116 /// Delete hit at cell ix,iy
118 fHitMap[CheckedIndex(ix, iy)]=0;
120 //_____________________________________________
121 void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy)
124 fHitMap[CheckedIndex(ix, iy)]=
125 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
127 //________________________________________________________
128 Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
130 /// Get absolute value of contents of hit cell ix,iy
131 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
133 //_______________________________________________________
134 TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const
136 /// Get pointer to object at hit cell ix, iy
137 /// Force crash if index does not exist ! (Manu)
138 Int_t index = GetHitIndex(ix,iy);
139 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
141 //_________________________________________________
142 FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy) const
144 /// Check if hit cell is empty, used or unused
146 Int_t index = CheckedIndex(ix, iy);
147 if (index<0 || index >= fMaxIndex) return kEmpty;
149 Int_t inf = fHitMap[index];
152 } else if (inf == 0) {
158 //________________________________________________________________________
159 AliMUONDigitMapA1 & AliMUONDigitMapA1::operator = (const AliMUONDigitMapA1 & rhs)
161 /// Protected assignement operator
163 if (this == &rhs) return *this;
165 AliFatal( "Not implemented.");