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