]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFDigitMap.cxx
cluster information
[u/mrichter/AliRoot.git] / TOF / AliTOFDigitMap.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
17 ////////////////////////////////////////////////////////////////////////
18 //
19 // AliTOFDigitMap class
20 //
21 // digitmap enables fast check if the pad was already hit
22 // The index of a AliTOFdigit is saved in the each hitmap "cell"
23 // (there is an offset +1, because the index can be zero and 
24 // zero means empty cell. 
25 // In TOF, number of strips varies according plate type, the highest
26 // number is in plate C. For all plates is used this number, so
27 // the size of the digitmap is a little bit greater than necessary, but
28 // it simplifies the access algorithm. 
29 // 
30 //
31 // Author: F. Pierella based on AliTOFHitMap
32 //
33 ////////////////////////////////////////////////////////////////////////
34
35 #include <Riostream.h>
36 #include <TMath.h>
37
38 #include "AliTOFDigitMap.h"
39 #include "AliTOFdigit.h"
40 #include "AliTOFConstants.h"
41
42
43 #include <TClonesArray.h>
44
45 ClassImp(AliTOFDigitMap)
46
47 AliTOFDigitMap::AliTOFDigitMap()
48 {
49 //
50 // Default ctor
51 //
52   fDigitMap = 0;
53   fDigits = 0;
54 }
55
56 ////////////////////////////////////////////////////////////////////////
57 AliTOFDigitMap::AliTOFDigitMap(TClonesArray *dig)
58 {
59   //
60   // ctor
61   //  
62   // of course, these constants must not be hardwired
63   // change later
64   
65   fNSector = AliTOFConstants::fgkNSectors;
66   fNplate = AliTOFConstants::fgkNPlates;
67   fNstrip = AliTOFConstants::fgkNStripC;
68   fNpx  = AliTOFConstants::fgkNpadX;
69   fNpy  = AliTOFConstants::fgkNpadZ;
70   fMaxIndex=fNSector*fNplate*fNstrip*fNpx*fNpy;
71   fDigitMap = new Int_t[fMaxIndex];
72   fDigits =  dig;
73   Clear();
74 }
75
76 ////////////////////////////////////////////////////////////////////////
77 AliTOFDigitMap::AliTOFDigitMap(const AliTOFDigitMap & /*digitMap*/)
78 :TObject()
79 {
80 //
81 // Dummy copy constructor
82 //
83     ;
84 }
85
86  
87 ////////////////////////////////////////////////////////////////////////
88 AliTOFDigitMap::~AliTOFDigitMap()
89 {
90 //
91 // Destructor
92 //
93     if (fDigitMap) delete[] fDigitMap;
94 }
95
96 ////////////////////////////////////////////////////////////////////////
97 void AliTOFDigitMap::Clear(const char *)
98 {
99 //
100 // Clear hitmap
101 //
102     memset(fDigitMap,0,sizeof(int)*fMaxIndex);
103 }
104
105 ////////////////////////////////////////////////////////////////////////
106 Int_t AliTOFDigitMap::CheckedIndex(Int_t *vol) const
107 {
108 //
109 // Return checked indices for vol
110 //
111   Int_t index=
112     (vol[0]-1)*fNplate*fNstrip*fNpx*fNpy+             // sector
113     (vol[1]-1)*fNstrip*fNpx*fNpy+                     // plate
114     (vol[2]-1)*fNpx*fNpy+                             // strip
115     (vol[3]-1)*fNpy+                                  // padx
116     (vol[4]-1);                                        // pady (=padz)
117
118     if (index >= fMaxIndex) {
119       Error("AliTOFDigitMap","CheckedIndex - input outside bounds");
120         return -1;
121     } else {
122         return index;
123     }
124 }
125
126 ////////////////////////////////////////////////////////////////////////
127 void  AliTOFDigitMap::SetHit(Int_t *vol, Int_t idigit)
128 {
129 //
130 // Assign digit to pad vol
131 //
132
133 // 0 means empty pad, we need to shift indeces by 1
134     fDigitMap[CheckedIndex(vol)]=idigit+1;
135 }
136
137 ////////////////////////////////////////////////////////////////////////
138 void  AliTOFDigitMap::SetHit(Int_t *vol)
139 {
140 //
141 // Assign last digit to pad vol 
142 //
143
144 // 0 means empty pad, we need to shift indeces by 1
145     fDigitMap[CheckedIndex(vol)]=fDigits->GetLast()+1;
146 }
147
148 ////////////////////////////////////////////////////////////////////////
149 Int_t AliTOFDigitMap::GetHitIndex(Int_t *vol) const
150 {
151 //
152 // Get contents of pad vol
153 //
154
155 // 0 means empty pad, we need to shift indeces by 1
156     return fDigitMap[CheckedIndex(vol)]-1;
157 }
158
159 ////////////////////////////////////////////////////////////////////////
160 TObject* AliTOFDigitMap::GetHit(Int_t *vol) const
161 {
162 //
163 // Get pointer to object at vol
164 // return 0 if vol out of bounds
165     Int_t index=GetHitIndex(vol);
166     return (index <0) ? 0 : fDigits->UncheckedAt(index);
167 }
168
169 ////////////////////////////////////////////////////////////////////////
170 FlagType AliTOFDigitMap::TestHit(Int_t *vol) const
171 {
172 //
173 // Check if hit cell is empty, used or unused
174 //
175     Int_t inf=fDigitMap[CheckedIndex(vol)];
176     if (inf > 0) {
177         return kUsed;
178     } else if (inf == 0) {
179         return kEmpty;
180     } else {
181         return kUnused;
182     }
183 }
184
185 ////////////////////////////////////////////////////////////////////////
186 AliTOFDigitMap & AliTOFDigitMap::operator = (const AliTOFDigitMap & /*rhs*/) 
187 {
188 // Dummy assignment operator
189     return *this;
190 }
191
192
193
194
195