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