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>
33 ClassImp(AliMUONDigitMapA1)
36 AliMUONDigitMapA1::AliMUONDigitMapA1()
44 /// Default constructor
47 //________________________________________________________________________________
48 AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, Int_t npx, Int_t npy )
53 fMaxIndex(fNpx * fNpy + fNpx),
54 fHitMap(new Int_t[fMaxIndex])
56 /// Standard constructor
60 //_________________________________
61 AliMUONDigitMapA1::~AliMUONDigitMapA1()
64 if (fHitMap) delete[] fHitMap;
66 //______________________________________
67 void AliMUONDigitMapA1::Clear(const char *)
70 memset(fHitMap,0,sizeof(int)*fMaxIndex);
73 //_________________________________________________________
74 Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
76 /// Return checked indices ix, iy
77 Int_t index = iy * fNpx + ix;
78 if ( index < 0 || index >= fMaxIndex ) {
79 AliWarning(Form("index outside array idDE %d ix %d iy %d MaxIndex %d index %d Npx %d Npy %d",
80 fIdDE, ix,iy, fMaxIndex, index, fNpx, fNpy));
86 //_____________________________
87 void AliMUONDigitMapA1::FillHits(TObjArray* digits)
89 /// Fill hits from digits list
91 Int_t ndigits = fDigits->GetEntriesFast();
94 for (Int_t ndig = 0; ndig < ndigits; ndig++) {
95 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
96 SetHit(dig->PadX(),dig->PadY(),ndig);
99 //___________________________________________________________
100 void AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
102 /// Assign digit to hit cell ix,iy
104 fHitMap[CheckedIndex(ix, iy)] = idigit + 1;
106 //_______________________________________________
107 void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy)
109 /// Delete hit at cell ix,iy
111 fHitMap[CheckedIndex(ix, iy)]=0;
113 //_____________________________________________
114 void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy)
117 fHitMap[CheckedIndex(ix, iy)]=
118 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
120 //________________________________________________________
121 Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
123 /// Get absolute value of contents of hit cell ix,iy
124 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
126 //_______________________________________________________
127 TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const
129 /// Get pointer to object at hit cell ix, iy
130 /// Force crash if index does not exist ! (Manu)
131 Int_t index = GetHitIndex(ix,iy);
132 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
134 //_________________________________________________
135 FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy) const
137 /// Check if hit cell is empty, used or unused
139 Int_t index = CheckedIndex(ix, iy);
140 if (index<0 || index >= fMaxIndex) return kEmpty;
142 Int_t inf = fHitMap[index];
145 } else if (inf == 0) {