]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHitMapA1.cxx
Logging of Debug, Info and Error Messages follwing AliRoot Standard http://aliweb...
[u/mrichter/AliRoot.git] / MUON / AliMUONHitMapA1.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
21 #include "AliMUONHitMapA1.h"
22 #include "AliSegmentation.h"
23 #include "AliMUONDigit.h"
24 #include "AliLog.h"
25
26 ClassImp(AliMUONHitMapA1)
27
28 AliMUONHitMapA1::AliMUONHitMapA1()
29   : AliHitMap()
30 {
31     // Default constructor
32     fNpx          = 0;
33     fNpy          = 0;
34     fMaxIndex     = 0;
35     
36     fHitMap       = 0;
37     fDigits       = 0;
38 }
39
40 AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig)
41   : AliHitMap()
42 {
43 // Constructor
44     fNpx  = seg->Npx()+1;
45     fNpy  = seg->Npy()+1;
46     fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
47     
48     fHitMap = new Int_t[fMaxIndex];
49     fDigits =  dig;
50     Clear();
51 }
52
53 AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap)
54   : AliHitMap(hitMap)
55 {
56 // Protected copy constructor
57
58   AliFatal("Not implemented.");
59 }
60
61  
62 AliMUONHitMapA1::~AliMUONHitMapA1()
63 {
64 // Destructor
65     if (fHitMap) delete[] fHitMap;
66 }
67
68 void AliMUONHitMapA1::Clear(const char *)
69 {
70 // Clear hitmap
71     memset(fHitMap,0,sizeof(int)*fMaxIndex);
72 }
73
74 Bool_t AliMUONHitMapA1::ValidateHit(Int_t ix, Int_t iy)
75 {
76     //
77     // Check if pad coordinates are within boundaries
78     //
79 //    printf("\n Validate %d %d %d %d", ix, iy, fNpx, fNpy);
80     
81     return (TMath::Abs(ix) <= fNpx && TMath::Abs(iy) <= fNpy); 
82 }
83
84 Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
85 {
86 // Return checked indices ix, iy
87     Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
88     if (index >= fMaxIndex) {
89 //      printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",
90 //             ix,iy, fMaxIndex, index, fNpx, fNpy);
91         return  fMaxIndex-1;
92     } else {
93         return index;
94     }
95 }
96
97         
98 void  AliMUONHitMapA1::FillHits()
99 {
100 // Fill hits from digits list  
101     Int_t ndigits = fDigits->GetEntriesFast();
102     //printf("\n Filling hits into HitMap\n");
103     //printf("FindRawClusters -- ndigits %d \n",ndigits);
104     if (!ndigits) return;
105     AliMUONDigit *dig;
106     for (Int_t ndig=0; ndig<ndigits; ndig++) {
107         dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
108         SetHit(dig->PadX(),dig->PadY(),ndig);
109     }
110 }
111
112
113 void  AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
114 {
115 // Assign digit to hit cell ix,iy
116 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
117     fHitMap[CheckedIndex(ix, iy)]=idigit+1;
118 }
119
120 void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy)
121 {
122 // Delete hit at cell ix,iy
123 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
124     fHitMap[CheckedIndex(ix, iy)]=0;
125 }
126
127 void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
128 {
129 // Flag hit as used
130     fHitMap[CheckedIndex(ix, iy)]=
131         -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
132 }
133
134 Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
135 {
136 // Get absolute value of contents of hit cell ix,iy
137     return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
138 }
139
140 TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const
141 {
142     // Get pointer to object at hit cell ix, iy
143     // Force crash if index does not exist ! (Manu)
144     Int_t index=GetHitIndex(ix,iy);
145     return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
146 }
147
148 FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
149 {
150 // Check if hit cell is empty, used or unused
151 //
152     Int_t inf=fHitMap[CheckedIndex(ix, iy)];
153     if (inf < 0) {
154         return kUsed;
155     } else if (inf == 0) {
156         return kEmpty;
157     } else {
158         return kUnused;
159     }
160 }
161
162 AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs) 
163 {
164 // Protected assignement operator
165
166   if (this == &rhs) return *this;
167
168   AliFatal( "Not implemented.");
169     
170   return *this;  
171 }
172
173
174
175
176