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