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