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 <TObjArray.h>
20 #include "AliMpVSegmentation.h"
21 #include "AliMUONSegmentationManager.h"
22 #include "AliMUONDigitMapA1.h"
23 #include "AliMUONDigit.h"
26 ClassImp(AliMUONDigitMapA1)
28 AliMUONDigitMapA1::AliMUONDigitMapA1()
36 // Default constructor
39 //________________________________________________________________________________
40 AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, AliMpPlaneType plane)
42 // Constructor with new segmentation
44 AliMpVSegmentation* seg = AliMUONSegmentationManager::Segmentation(idDE, plane);
47 fNpx = seg->MaxPadIndexX()+1;
48 fNpy = seg->MaxPadIndexY()+1;
49 fMaxIndex = fNpx * fNpy + fNpx ;
51 fHitMap = new Int_t[fMaxIndex];
55 //______________________________________________________________
56 AliMUONDigitMapA1::AliMUONDigitMapA1(const AliMUONDigitMapA1& hitMap)
59 // Protected copy constructor
61 AliFatal("Not implemented.");
63 //_________________________________
64 AliMUONDigitMapA1::~AliMUONDigitMapA1()
67 if (fHitMap) delete[] fHitMap;
69 //______________________________________
70 void AliMUONDigitMapA1::Clear(const char *)
73 memset(fHitMap,0,sizeof(int)*fMaxIndex);
76 //_________________________________________________________
77 Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
79 // Return checked indices ix, iy
80 Int_t index = iy * fNpx + ix;
81 if ( index < 0 || index >= fMaxIndex ) {
82 AliWarning(Form("index outside array idDE %d ix %d iy %d MaxIndex %d index %d Npx %d Npy %d",
83 fIdDE, ix,iy, fMaxIndex, index, fNpx, fNpy));
89 //_____________________________
90 void AliMUONDigitMapA1::FillHits(TObjArray* digits)
92 // Fill hits from digits list
94 Int_t ndigits = fDigits->GetEntriesFast();
97 for (Int_t ndig = 0; ndig < ndigits; ndig++) {
98 dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
99 SetHit(dig->PadX(),dig->PadY(),ndig);
102 //___________________________________________________________
103 void AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
105 // Assign digit to hit cell ix,iy
107 fHitMap[CheckedIndex(ix, iy)] = idigit + 1;
109 //_______________________________________________
110 void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy)
112 // Delete hit at cell ix,iy
114 fHitMap[CheckedIndex(ix, iy)]=0;
116 //_____________________________________________
117 void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy)
120 fHitMap[CheckedIndex(ix, iy)]=
121 -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
123 //________________________________________________________
124 Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
126 // Get absolute value of contents of hit cell ix,iy
127 return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
129 //_______________________________________________________
130 TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const
132 // Get pointer to object at hit cell ix, iy
133 // Force crash if index does not exist ! (Manu)
134 Int_t index = GetHitIndex(ix,iy);
135 return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
137 //_________________________________________________
138 FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy)
140 // Check if hit cell is empty, used or unused
142 Int_t index = CheckedIndex(ix, iy);
143 if (index<0 || index >= fMaxIndex) return kEmpty;
145 Int_t inf = fHitMap[index];
148 } else if (inf == 0) {
154 //________________________________________________________________________
155 AliMUONDigitMapA1 & AliMUONDigitMapA1::operator = (const AliMUONDigitMapA1 & rhs)
157 // Protected assignement operator
159 if (this == &rhs) return *this;
161 AliFatal( "Not implemented.");