]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONHitMapA1.cxx
Add a "real" default constructor.
[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 /*
17 $Log$
18 Revision 1.6  2000/10/06 09:05:42  morsch
19 Correction on upper limits for x- and y- coordinates to make code work with slat chambers.
20
21 Revision 1.5  2000/10/02 21:28:09  fca
22 Removal of useless dependecies via forward declarations
23
24 Revision 1.4  2000/07/13 16:19:44  fca
25 Mainly coding conventions + some small bug fixes
26
27 Revision 1.3  2000/07/03 11:54:57  morsch
28 AliMUONSegmentation and AliMUONHitMap have been replaced by AliSegmentation and AliHitMap in STEER
29 The methods GetPadIxy and GetPadXxy of AliMUONSegmentation have changed name to GetPadI and GetPadC.
30
31 Revision 1.2  2000/06/15 07:58:48  morsch
32 Code from MUON-dev joined
33
34 Revision 1.1.2.2  2000/06/12 07:58:06  morsch
35 include TMath.h
36
37 Revision 1.1.2.1  2000/06/09 22:01:09  morsch
38 Code from AliMUONHitMap.h
39 Most coding rule violations corrected.
40
41 */
42
43 #include "AliMUONHitMapA1.h"
44 #include "AliSegmentation.h"
45 #include "AliMUONResponse.h"
46 #include "AliMUONDigit.h"
47
48 #include <TObjArray.h>
49 #include <TMath.h>
50
51 ClassImp(AliMUONHitMapA1)
52
53     AliMUONHitMapA1::AliMUONHitMapA1()
54 {
55     // Default constructor
56     fSegmentation = 0;
57     fNpx          = 0;
58     fNpy          = 0;
59     fMaxIndex     = 0;
60     
61     fHitMap       = 0;
62     fDigits       = 0;
63     fNdigits      = 0;
64 }
65
66 AliMUONHitMapA1::AliMUONHitMapA1(AliSegmentation *seg, TObjArray *dig)
67 {
68 // Constructor
69     fSegmentation = seg;
70     fNpx  = fSegmentation->Npx()+1;
71     fNpy  = fSegmentation->Npy()+1;
72     fMaxIndex=2*(fNpx+1)*2*(fNpy+1)+2*fNpy;
73     
74     fHitMap = new Int_t[fMaxIndex];
75     fDigits =  dig;
76     fNdigits = fDigits->GetEntriesFast();
77     Clear();
78 }
79
80 AliMUONHitMapA1::AliMUONHitMapA1(const AliMUONHitMapA1 & hitMap)
81 {
82 // Dummy copy constructor
83     ;
84 }
85
86  
87 AliMUONHitMapA1::~AliMUONHitMapA1()
88 {
89 // Destructor
90 //    if (fDigits) delete   fDigits;
91     if (fHitMap) delete[] fHitMap;
92 }
93
94 void AliMUONHitMapA1::Clear(const char *)
95 {
96 // Clear hitmap
97     memset(fHitMap,0,sizeof(int)*fMaxIndex);
98 }
99
100 Int_t AliMUONHitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
101 {
102 // Return checked indices ix, iy
103     Int_t index=2*fNpy*(ix+fNpx)+(iy+fNpy);
104     if (index > fMaxIndex) {
105         printf("\n \n \n Try to read/write outside array !!!! \n \n %d %d %d %d %d %d",
106                ix,iy, fMaxIndex, index, fNpx, fNpy);
107         return  fMaxIndex-1;
108     } else {
109         return index;
110     }
111 }
112
113         
114 void  AliMUONHitMapA1::FillHits()
115 {
116 // Fill hits from digits list  
117     Int_t ndigits = fDigits->GetEntriesFast();
118     //printf("\n Filling hits into HitMap\n");
119     //printf("FindRawClusters -- ndigits %d \n",ndigits);
120     if (!ndigits) return;
121     AliMUONDigit *dig;
122     for (Int_t ndig=0; ndig<fNdigits; ndig++) {
123         dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
124         SetHit(dig->fPadX,dig->fPadY,ndig);
125     }
126 }
127
128
129 void  AliMUONHitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
130 {
131 // Assign digit to hit cell ix,iy
132 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=idigit+1;
133     fHitMap[CheckedIndex(ix, iy)]=idigit+1;
134 }
135
136 void AliMUONHitMapA1::DeleteHit(Int_t ix, Int_t iy)
137 {
138 // Delete hit at cell ix,iy
139 //    fHitMap[kMaxNpady*(ix+fNpx)+(iy+fNpy)]=0;
140     fHitMap[CheckedIndex(ix, iy)]=0;
141 }
142
143 void AliMUONHitMapA1::FlagHit(Int_t ix, Int_t iy)
144 {
145 // Flag hit as used
146     fHitMap[CheckedIndex(ix, iy)]=
147         -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
148 }
149
150 Int_t AliMUONHitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
151 {
152 // Get absolute value of contents of hit cell ix,iy
153     return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
154 }
155
156 TObject* AliMUONHitMapA1::GetHit(Int_t ix, Int_t iy) const
157 {
158     // Get pointer to object at hit cell ix, iy
159     // Force crash if index does not exist ! (Manu)
160     Int_t index=GetHitIndex(ix,iy);
161     return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
162 }
163
164 FlagType AliMUONHitMapA1::TestHit(Int_t ix, Int_t iy)
165 {
166 // Check if hit cell is empty, used or unused
167 //
168     Int_t inf=fHitMap[CheckedIndex(ix, iy)];
169     if (inf < 0) {
170         return kUsed;
171     } else if (inf == 0) {
172         return kEmpty;
173     } else {
174         return kUnused;
175     }
176 }
177
178 AliMUONHitMapA1 & AliMUONHitMapA1::operator = (const AliMUONHitMapA1 & rhs) 
179 {
180 // Dummy assignment operator
181     return *this;
182 }
183
184
185
186
187