]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONDigitMapA1.cxx
- Adding handling of track info in digits.
[u/mrichter/AliRoot.git] / MUON / AliMUONDigitMapA1.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 /* $Id$ */
17
18 #include "AliMUONDigitMapA1.h"
19 #include "AliMUONDigit.h"
20
21 #include "AliLog.h"
22
23 #include <TObjArray.h>
24 #include <TMath.h>
25
26 ClassImp(AliMUONDigitMapA1)
27
28 AliMUONDigitMapA1::AliMUONDigitMapA1() 
29   : fIdDE(0),
30     fNpx(0),
31     fNpy(0),
32     fDigits(0),
33     fMaxIndex(0),
34     fHitMap(0)
35 {
36     // Default constructor
37
38 }
39 //________________________________________________________________________________
40 AliMUONDigitMapA1::AliMUONDigitMapA1(Int_t idDE, Int_t npx, Int_t npy )
41 {
42 // Constructor with new segmentation
43
44    fIdDE = idDE;
45    fNpx = npx;
46    fNpy = npy;
47    fMaxIndex = fNpx * fNpy + fNpx ;
48     
49    fHitMap = new Int_t[fMaxIndex];
50    Clear();
51
52 }
53 //______________________________________________________________
54 AliMUONDigitMapA1::AliMUONDigitMapA1(const AliMUONDigitMapA1& hitMap)
55   : TObject(hitMap)
56 {
57 // Protected copy constructor
58
59   AliFatal("Not implemented.");
60 }
61 //_________________________________
62 AliMUONDigitMapA1::~AliMUONDigitMapA1()
63 {
64 // Destructor
65     if (fHitMap) delete[] fHitMap;
66 }
67 //______________________________________
68 void AliMUONDigitMapA1::Clear(const char *)
69 {
70 // Clear hitmap
71     memset(fHitMap,0,sizeof(int)*fMaxIndex);
72 }
73
74 //_________________________________________________________
75 Int_t AliMUONDigitMapA1::CheckedIndex(Int_t ix, Int_t iy) const
76 {
77 // Return checked indices ix, iy
78   Int_t index =  iy * fNpx + ix;
79     if ( index < 0 || index >= fMaxIndex ) {
80       AliWarning(Form("index outside array idDE %d ix %d iy %d MaxIndex %d index %d Npx %d Npy %d",
81                       fIdDE, ix,iy, fMaxIndex, index, fNpx, fNpy));
82         return  fMaxIndex-1;
83     } else {
84         return index;
85     }
86 }
87 //_____________________________
88 void  AliMUONDigitMapA1::FillHits(TObjArray* digits)
89 {
90 // Fill hits from digits list  
91     fDigits = digits;
92     Int_t ndigits = fDigits->GetEntriesFast();
93     if (!ndigits) return;
94     AliMUONDigit *dig;
95     for (Int_t ndig = 0; ndig < ndigits; ndig++) {
96         dig = (AliMUONDigit*)fDigits->UncheckedAt(ndig);
97         SetHit(dig->PadX(),dig->PadY(),ndig);
98     }
99 }
100 //___________________________________________________________
101 void  AliMUONDigitMapA1::SetHit(Int_t ix, Int_t iy, Int_t idigit)
102 {
103 // Assign digit to hit cell ix,iy
104
105     fHitMap[CheckedIndex(ix, iy)] = idigit + 1;
106 }
107 //_______________________________________________
108 void AliMUONDigitMapA1::DeleteHit(Int_t ix, Int_t iy)
109 {
110 // Delete hit at cell ix,iy
111
112     fHitMap[CheckedIndex(ix, iy)]=0;
113 }
114 //_____________________________________________
115 void AliMUONDigitMapA1::FlagHit(Int_t ix, Int_t iy)
116 {
117 // Flag hit as used
118     fHitMap[CheckedIndex(ix, iy)]=
119         -TMath::Abs(fHitMap[CheckedIndex(ix, iy)]);
120 }
121 //________________________________________________________
122 Int_t AliMUONDigitMapA1::GetHitIndex(Int_t ix, Int_t iy) const
123 {
124 // Get absolute value of contents of hit cell ix,iy
125     return TMath::Abs(fHitMap[CheckedIndex(ix, iy)])-1;
126 }
127 //_______________________________________________________
128 TObject* AliMUONDigitMapA1::GetHit(Int_t ix, Int_t iy) const
129 {
130     // Get pointer to object at hit cell ix, iy
131     // Force crash if index does not exist ! (Manu)
132     Int_t index = GetHitIndex(ix,iy);
133     return (index <0) ? 0 : fDigits->UncheckedAt(GetHitIndex(ix,iy));
134 }
135 //_________________________________________________
136 FlagType AliMUONDigitMapA1::TestHit(Int_t ix, Int_t iy)
137 {
138 // Check if hit cell is empty, used or unused
139 //
140     Int_t index = CheckedIndex(ix, iy);
141     if (index<0 || index >= fMaxIndex) return kEmpty;
142
143     Int_t inf = fHitMap[index];
144     if (inf < 0) {
145         return kUsed;
146     } else if (inf == 0) {
147         return kEmpty;
148     } else {
149         return kUnused;
150     }
151 }
152 //________________________________________________________________________
153 AliMUONDigitMapA1 & AliMUONDigitMapA1::operator = (const AliMUONDigitMapA1 & rhs) 
154 {
155 // Protected assignement operator
156
157   if (this == &rhs) return *this;
158
159   AliFatal( "Not implemented.");
160     
161   return *this;  
162 }
163
164
165
166
167