]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDigitMapA1.cxx
New class for managing buspatch<>DDL<>DE maps separated from
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitMapA1.cxx
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
16 /* $Id$ */
17
18 #include <TObjArray.h>
19 #include <TMath.h>
20 #include "AliMpVSegmentation.h"
21 #include "AliMUONSegmentationManager.h"
22 #include "AliMUONDigitMapA1.h"
23 #include "AliMUONDigit.h"
24 #include "AliLog.h"
25
26 ClassImp(AliMUONDigitMapA1)
27
28 AliMUONDigitMapA1::AliMUONDigitMapA1() 
29   : fIdDE(0),
30     fNpx(0),
31     fNpy(0),
32     fDigits(0),
33     fMaxIndex(0),
34     fHitMap(0)
35 {
36     // Default constructor
37
38 }
39 //________________________________________________________________________________
40 AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE,  AliMpPlaneType plane)
41 {
42 // Constructor with new segmentation
43
44    AliMpVSegmentation* seg = AliMUONSegmentationManager::Segmentation(idDE, plane);
45
46    fIdDE = idDE;
47    fNpx  = seg->MaxPadIndexX()+1;
48    fNpy  = seg->MaxPadIndexY()+1;
49    fMaxIndex = fNpx * fNpy + fNpx ;
50     
51    fHitMap = new Int_t[fMaxIndex];
52    Clear();
53
54 }
55 //______________________________________________________________
56 AliMUONDigitMapA1::AliMUONDigitMapA1(const AliMUONDigitMapA1& hitMap)
57   : TObject(hitMap)
58 {
59 // Protected copy constructor
60
61   AliFatal("Not implemented.");
62 }
63 //_________________________________
64 AliMUONDigitMapA1::~AliMUONDigitMapA1()
65 {
66 // Destructor
67     if (fHitMap) delete[] fHitMap;
68 }
69 //______________________________________
70 void AliMUONDigitMapA1::Clear(const char *)
71 {
72 // Clear hitmap
73     memset(fHitMap,0,sizeof(int)*fMaxIndex);
74 }
75
76 //_________________________________________________________
77 Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
78 {
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));
84         return  fMaxIndex-1;
85     } else {
86         return index;
87     }
88 }
89 //_____________________________
90 void  AliMUONDigitMapA1::FillHits(TObjArray* digits)
91 {
92 // Fill hits from digits list  
93     fDigits = digits;
94     Int_t ndigits = fDigits->GetEntriesFast();
95     if (!ndigits) return;
96     AliMUONDigit *dig;
97     for (Int_t ndig = 0; ndig < ndigits; ndig++) {
98         dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
99         SetHit(dig->PadX(),dig->PadY(),ndig);
100     }
101 }
102 //___________________________________________________________
103 void  AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
104 {
105 // Assign digit to hit cell ix,iy
106
107     fHitMap[CheckedIndex(ix, iy)] = idigit + 1;
108 }
109 //_______________________________________________
110 void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy)
111 {
112 // Delete hit at cell ix,iy
113
114     fHitMap[CheckedIndex(ix, iy)]=0;
115 }
116 //_____________________________________________
117 void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy)
118 {
119 // Flag hit as used
120     fHitMap[CheckedIndex(ix, iy)]=
121         -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
122 }
123 //________________________________________________________
124 Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
125 {
126 // Get absolute value of contents of hit cell ix,iy
127     return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
128 }
129 //_______________________________________________________
130 TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const
131 {
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));
136 }
137 //_________________________________________________
138 FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy)
139 {
140 // Check if hit cell is empty, used or unused
141 //
142     Int_t index = CheckedIndex(ix, iy);
143     if (index<0 || index >= fMaxIndex) return kEmpty;
144
145     Int_t inf = fHitMap[index];
146     if (inf < 0) {
147         return kUsed;
148     } else if (inf == 0) {
149         return kEmpty;
150     } else {
151         return kUnused;
152     }
153 }
154 //________________________________________________________________________
155 AliMUONDigitMapA1 & AliMUONDigitMapA1::operator = (const AliMUONDigitMapA1 & rhs) 
156 {
157 // Protected assignement operator
158
159   if (this == &rhs) return *this;
160
161   AliFatal( "Not implemented.");
162     
163   return *this;  
164 }
165
166
167
168
169