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