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 "AliMUONDigitMapA1.h"
19 #include "AliMUONDigit.h"
23 #include <TObjArray.h>
26 ClassImp(AliMUONDigitMapA1)
28 AliMUONDigitMapA1::AliMUONDigitMapA1()
36 // Default constructor
39 //________________________________________________________________________________
40 AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, Int_t npx, Int_t npy )
42 // Constructor with new segmentation
47 fMaxIndex = fNpx * fNpy + fNpx ;
49 fHitMap = new Int_t[fMaxIndex];
53 //______________________________________________________________
54 AliMUONDigitMapA1::AliMUONDigitMapA1(const AliMUONDigitMapA1& hitMap)
57 // Protected copy constructor
59 AliFatal("Not implemented.");
61 //_________________________________
62 AliMUONDigitMapA1::~AliMUONDigitMapA1()
65 if (fHitMap) delete[] fHitMap;
67 //______________________________________
68 void AliMUONDigitMapA1::Clear(const char *)
71 memset(fHitMap,0,sizeof(int)*fMaxIndex);
74 //_________________________________________________________
75 Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
77 // Return checked indices ix, iy
78 Int_t index = iy * fNpx + ix;
79 if ( index < 0 || index >= fMaxIndex ) {
80 AliWarning(Form("index outside array idDE %d ix %d iy %d MaxIndex %d index %d Npx %d Npy %d",
81 fIdDE, ix,iy, fMaxIndex, index, fNpx, fNpy));
87 //_____________________________
88 void AliMUONDigitMapA1::FillHits(TObjArray* digits)
90 // Fill hits from digits list
92 Int_t ndigits = fDigits->GetEntriesFast();
95 for (Int_t ndig = 0; ndig < ndigits; ndig++) {
96 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
97 SetHit(dig->PadX(),dig->PadY(),ndig);
100 //___________________________________________________________
101 void AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
103 // Assign digit to hit cell ix,iy
105 fHitMap[CheckedIndex(ix, iy)] = idigit + 1;
107 //_______________________________________________
108 void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy)
110 // Delete hit at cell ix,iy
112 fHitMap[CheckedIndex(ix, iy)]=0;
114 //_____________________________________________
115 void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy)
118 fHitMap[CheckedIndex(ix, iy)]=
119 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
121 //________________________________________________________
122 Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
124 // Get absolute value of contents of hit cell ix,iy
125 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
127 //_______________________________________________________
128 TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const
130 // Get pointer to object at hit cell ix, iy
131 // Force crash if index does not exist ! (Manu)
132 Int_t index = GetHitIndex(ix,iy);
133 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
135 //_________________________________________________
136 FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy)
138 // Check if hit cell is empty, used or unused
140 Int_t index = CheckedIndex(ix, iy);
141 if (index<0 || index >= fMaxIndex) return kEmpty;
143 Int_t inf = fHitMap[index];
146 } else if (inf == 0) {
152 //________________________________________________________________________
153 AliMUONDigitMapA1 & AliMUONDigitMapA1::operator = (const AliMUONDigitMapA1 & rhs)
155 // Protected assignement operator
157 if (this == &rhs) return *this;
159 AliFatal( "Not implemented.");