]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TOF/AliTOFRawMap.cxx
d5fee233868b6dedcd6e0d0a92556a59836581b2
[u/mrichter/AliRoot.git] / TOF / AliTOFRawMap.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 //                                                                     //
20 // AliTOFRawMap class                                                  //
21 //                                                                     //
22 // It enables fast check if the TDC channel was already engaged        //
23 // for a measurement.                                                  //
24 // The index of a AliTOFrawData is saved in the each rawdatamap "cell" //
25 // (there is an offset +1, because the index can be zero and           //
26 // zero means empty cell.                                              //
27 //                                                                     //
28 /////////////////////////////////////////////////////////////////////////
29
30 #include "TClonesArray.h"
31
32 #include "AliLog.h"
33
34 #include "AliTOFGeometry.h"
35 #include "AliTOFRawMap.h"
36
37 ClassImp(AliTOFRawMap)
38
39 AliTOFRawMap::AliTOFRawMap():
40   fNtrm(-1),
41   fNtrmChain(-1),
42   fNtdc(-1),
43   fNtdcChannel(-1),
44   fRawData(0x0),
45   fMaxIndex(-1),
46   fRawMap(0x0)
47 {
48 //
49 // Default ctor
50 //
51 }
52
53 ////////////////////////////////////////////////////////////////////////
54 AliTOFRawMap::AliTOFRawMap(TClonesArray *dig)://, AliTOFGeometry *tofGeom):
55   fNtrm(-1),
56   fNtrmChain(-1),
57   fNtdc(-1),
58   fNtdcChannel(-1),
59   fRawData(dig),
60   fMaxIndex(-1),
61   fRawMap(0x0)
62 {
63 //
64 // ctor
65 //
66
67 // of course, these constants must not be hardwired
68 // change later
69
70   fNtrm = AliTOFGeometry::NTRM()+2;
71   fNtrmChain = AliTOFGeometry::NChain();
72   fNtdc = AliTOFGeometry::NTdc();
73   fNtdcChannel = AliTOFGeometry::NCh();
74   fMaxIndex = fNtrm*fNtrmChain*fNtdc*fNtdcChannel;
75   fRawMap = new Int_t[fMaxIndex];
76   Clear();
77 }
78
79 ////////////////////////////////////////////////////////////////////////
80 AliTOFRawMap::AliTOFRawMap(const AliTOFRawMap & /*rawMap*/)
81   :TObject(),
82   fNtrm(-1),
83   fNtrmChain(-1),
84   fNtdc(-1),
85   fNtdcChannel(-1),
86   fRawData(0x0),
87   fMaxIndex(-1),
88   fRawMap(0x0)
89 {
90 //
91 // Dummy copy constructor
92 //
93
94 }
95
96  
97 ////////////////////////////////////////////////////////////////////////
98 AliTOFRawMap::~AliTOFRawMap()
99 {
100 //
101 // Destructor
102 //
103   delete[] fRawMap;
104
105 }
106
107 ////////////////////////////////////////////////////////////////////////
108 void AliTOFRawMap::Clear(const char *)
109 {
110 //
111 // Clear hitmap
112 //
113     memset(fRawMap,0,sizeof(int)*fMaxIndex);
114 }
115
116 ////////////////////////////////////////////////////////////////////////
117 Int_t AliTOFRawMap::CheckedIndex(Int_t *slot) const
118 {
119 //
120 // Return checked indices for vol
121 //
122   Int_t index =
123     slot[0]*fNtrmChain*fNtdc*fNtdcChannel + // TRM
124     slot[1]*fNtdc*fNtdcChannel +            // TRM chain
125     slot[2]*fNtdcChannel +                  // TDC
126     slot[3];                                // TDC channel
127
128     if (index >= fMaxIndex) {
129       AliError("CheckedIndex - input outside bounds");
130         return -1;
131     } else {
132         return index;
133     }
134 }
135
136 ////////////////////////////////////////////////////////////////////////
137 void  AliTOFRawMap::SetHit(Int_t *slot, Int_t idigit)
138 {
139 //
140 // Assign digit to pad vol
141 //
142
143 // 0 means empty pad, we need to shift indeces by 1
144     fRawMap[CheckedIndex(slot)]=idigit+1;
145 }
146
147 ////////////////////////////////////////////////////////////////////////
148 void  AliTOFRawMap::SetHit(Int_t *slot)
149 {
150 //
151 // Assign last digit to channel slot
152 //
153
154 // 0 means empty pad, we need to shift indeces by 1
155     fRawMap[CheckedIndex(slot)]=fRawData->GetLast()+1;
156 }
157
158 ////////////////////////////////////////////////////////////////////////
159 Int_t AliTOFRawMap::GetHitIndex(Int_t *slot) const
160 {
161 //
162 // Get contents of channel slot
163 //
164
165 // 0 means empty pad, we need to shift indeces by 1
166     return fRawMap[CheckedIndex(slot)]-1;
167 }
168
169 ////////////////////////////////////////////////////////////////////////
170 TObject* AliTOFRawMap::GetHit(Int_t *slot) const
171 {
172 //
173 // Get pointer to object at alot
174 // return 0 if vol out of bounds
175     Int_t index = GetHitIndex(slot);
176     return (index <0) ? 0 : fRawData->UncheckedAt(index);
177 }
178
179 ////////////////////////////////////////////////////////////////////////
180 FlagType AliTOFRawMap::TestHit(Int_t *slot) const
181 {
182 //
183 // Check if hit cell is empty, used or unused
184 //
185     Int_t inf = fRawMap[CheckedIndex(slot)];
186     if (inf > 0) {
187         return kUsed;
188     } else if (inf == 0) {
189         return kEmpty;
190     } else {
191         return kUnused;
192     }
193 }
194
195 ////////////////////////////////////////////////////////////////////////
196 AliTOFRawMap & AliTOFRawMap::operator = (const AliTOFRawMap & /*rhs*/) 
197 {
198 // Dummy assignment operator
199     return *this;
200 }