]>
Commit | Line | Data |
---|---|---|
6f1e466d | 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$ | |
06754153 | 18 | Revision 1.7 2000/11/01 14:53:20 cblume |
19 | Merge with TRD-develop | |
20 | ||
793ff80c | 21 | Revision 1.1.2.5 2000/10/17 02:27:34 cblume |
22 | Get rid of global constants | |
23 | ||
24 | Revision 1.1.2.4 2000/10/15 23:40:01 cblume | |
25 | Remove AliTRDconst | |
26 | ||
27 | Revision 1.1.2.3 2000/10/06 16:49:46 cblume | |
28 | Made Getters const | |
29 | ||
30 | Revision 1.1.2.2 2000/10/04 16:34:58 cblume | |
31 | Replace include files by forward declarations | |
32 | ||
94de3818 | 33 | Revision 1.5 2000/06/09 11:10:07 cblume |
34 | Compiler warnings and coding conventions, next round | |
35 | ||
dd9a6ee3 | 36 | Revision 1.4 2000/06/08 18:32:58 cblume |
37 | Make code compliant to coding conventions | |
38 | ||
8230f242 | 39 | Revision 1.3 2000/06/07 16:27:01 cblume |
40 | Try to remove compiler warnings on Sun and HP | |
41 | ||
9d0b222b | 42 | Revision 1.2 2000/05/08 16:17:27 cblume |
43 | Merge TRD-develop | |
44 | ||
6f1e466d | 45 | Revision 1.1.2.1 2000/05/08 14:44:01 cblume |
46 | Add new class AliTRDdigitsManager | |
47 | ||
48 | */ | |
49 | ||
50 | /////////////////////////////////////////////////////////////////////////////// | |
51 | // // | |
52 | // Manages the digits and the track dictionary in the form of // | |
53 | // AliTRDdataArray objects. // | |
54 | // // | |
55 | /////////////////////////////////////////////////////////////////////////////// | |
793ff80c | 56 | |
57 | #include <TTree.h> | |
94de3818 | 58 | |
6f1e466d | 59 | #include "AliRun.h" |
60 | ||
61 | #include "AliTRDdigitsManager.h" | |
793ff80c | 62 | #include "AliTRDsegmentArray.h" |
63 | #include "AliTRDdataArrayI.h" | |
64 | #include "AliTRDdigit.h" | |
65 | #include "AliTRDgeometry.h" | |
6f1e466d | 66 | |
67 | ClassImp(AliTRDdigitsManager) | |
68 | ||
793ff80c | 69 | //_____________________________________________________________________________ |
70 | ||
71 | // Number of track dictionary arrays | |
72 | const Int_t AliTRDdigitsManager::fgkNDict = kNDict; | |
73 | ||
6f1e466d | 74 | //_____________________________________________________________________________ |
75 | AliTRDdigitsManager::AliTRDdigitsManager():TObject() | |
76 | { | |
77 | // | |
78 | // Default constructor | |
79 | // | |
80 | ||
81 | fIsRaw = kFALSE; | |
82 | ||
793ff80c | 83 | fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); |
6f1e466d | 84 | |
85 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
793ff80c | 86 | fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" |
87 | ,AliTRDgeometry::Ndet()); | |
6f1e466d | 88 | } |
89 | ||
90 | } | |
91 | ||
8230f242 | 92 | //_____________________________________________________________________________ |
dd9a6ee3 | 93 | AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) |
8230f242 | 94 | { |
95 | // | |
96 | // AliTRDdigitsManager copy constructor | |
97 | // | |
98 | ||
dd9a6ee3 | 99 | ((AliTRDdigitsManager &) m).Copy(*this); |
8230f242 | 100 | |
101 | } | |
102 | ||
6f1e466d | 103 | //_____________________________________________________________________________ |
104 | AliTRDdigitsManager::~AliTRDdigitsManager() | |
105 | { | |
8230f242 | 106 | // |
107 | // AliTRDdigitsManager destructor | |
108 | // | |
6f1e466d | 109 | |
110 | if (fDigits) { | |
111 | fDigits->Delete(); | |
112 | delete fDigits; | |
113 | } | |
114 | ||
115 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
116 | fDictionary[iDict]->Delete(); | |
117 | delete fDictionary[iDict]; | |
118 | } | |
119 | ||
120 | } | |
121 | ||
8230f242 | 122 | //_____________________________________________________________________________ |
dd9a6ee3 | 123 | void AliTRDdigitsManager::Copy(TObject &m) |
8230f242 | 124 | { |
125 | // | |
126 | // Copy function | |
127 | // | |
128 | ||
dd9a6ee3 | 129 | ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; |
8230f242 | 130 | |
131 | TObject::Copy(m); | |
132 | ||
133 | } | |
134 | ||
6f1e466d | 135 | //_____________________________________________________________________________ |
136 | void AliTRDdigitsManager::SetRaw() | |
137 | { | |
138 | ||
139 | fIsRaw = kTRUE; | |
140 | ||
793ff80c | 141 | fDigits->SetBit(AliTRDdigit::RawDigit()); |
6f1e466d | 142 | |
143 | } | |
144 | ||
145 | //_____________________________________________________________________________ | |
146 | Bool_t AliTRDdigitsManager::MakeBranch() | |
147 | { | |
148 | // | |
149 | // Creates the branches for the digits and the dictionary in the digits tree | |
150 | // | |
151 | ||
152 | Int_t buffersize = 64000; | |
153 | ||
154 | Bool_t status = kTRUE; | |
155 | ||
156 | if (gAlice->TreeD()) { | |
157 | ||
158 | // Make the branch for the digits | |
159 | if (fDigits) { | |
06754153 | 160 | //const AliTRDdataArrayI *kDigits = |
161 | // (AliTRDdataArrayI *) fDigits->At(0); | |
162 | const AliTRDdataArray *kDigits = | |
163 | (AliTRDdataArray *) fDigits->At(0); | |
8230f242 | 164 | if (kDigits) { |
165 | gAlice->TreeD()->Branch("TRDdigits",kDigits->IsA()->GetName() | |
166 | ,&kDigits,buffersize,1); | |
6f1e466d | 167 | printf("AliTRDdigitsManager::MakeBranch -- "); |
168 | printf("Making branch TRDdigits\n"); | |
169 | } | |
170 | else { | |
171 | status = kFALSE; | |
172 | } | |
173 | } | |
174 | else { | |
175 | status = kFALSE; | |
176 | } | |
177 | ||
178 | // Make the branches for the dictionaries | |
179 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
180 | ||
181 | Char_t branchname[15]; | |
182 | sprintf(branchname,"TRDdictionary%d",iDict); | |
183 | if (fDictionary[iDict]) { | |
8230f242 | 184 | const AliTRDdataArrayI *kDictionary = |
6f1e466d | 185 | (AliTRDdataArrayI *) fDictionary[iDict]->At(0); |
8230f242 | 186 | if (kDictionary) { |
187 | gAlice->TreeD()->Branch(branchname,kDictionary->IsA()->GetName() | |
188 | ,&kDictionary,buffersize,1); | |
6f1e466d | 189 | printf("AliTRDdigitsManager::MakeBranch -- "); |
190 | printf("Making branch %s\n",branchname); | |
191 | } | |
192 | else { | |
193 | status = kFALSE; | |
194 | } | |
195 | } | |
196 | else { | |
197 | status = kFALSE; | |
198 | } | |
199 | } | |
200 | ||
201 | } | |
202 | else { | |
203 | status = kFALSE; | |
204 | } | |
205 | ||
206 | return status; | |
207 | ||
208 | } | |
209 | ||
210 | //_____________________________________________________________________________ | |
211 | Bool_t AliTRDdigitsManager::ReadDigits() | |
212 | { | |
8230f242 | 213 | // |
214 | // Reads the digit information from the input file | |
215 | // | |
6f1e466d | 216 | |
217 | Bool_t status = kTRUE; | |
218 | ||
219 | status = fDigits->LoadArray("TRDdigits"); | |
220 | ||
221 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
222 | Char_t branchname[15]; | |
223 | sprintf(branchname,"TRDdictionary%d",iDict); | |
224 | status = fDictionary[iDict]->LoadArray(branchname); | |
225 | } | |
226 | ||
793ff80c | 227 | if (fDigits->TestBit(AliTRDdigit::RawDigit())) { |
6f1e466d | 228 | fIsRaw = kTRUE; |
229 | } | |
230 | else { | |
231 | fIsRaw = kFALSE; | |
232 | } | |
233 | ||
234 | return kTRUE; | |
235 | ||
236 | } | |
237 | ||
238 | //_____________________________________________________________________________ | |
239 | Bool_t AliTRDdigitsManager::WriteDigits() | |
240 | { | |
241 | // | |
242 | // Writes out the TRD-digits and the dictionaries | |
243 | // | |
244 | ||
245 | // Create the branches | |
246 | if (!(gAlice->TreeD()->GetBranch("TRDdigits"))) { | |
247 | if (!MakeBranch()) return kFALSE; | |
248 | } | |
249 | ||
250 | // Store the contents of the segment array in the tree | |
251 | if (!fDigits->StoreArray("TRDdigits")) { | |
252 | printf("AliTRDdigitsManager::WriteDigits -- "); | |
253 | printf("Error while storing digits in branch TRDdigits\n"); | |
254 | return kFALSE; | |
255 | } | |
256 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
257 | Char_t branchname[15]; | |
258 | sprintf(branchname,"TRDdictionary%d",iDict); | |
259 | if (!fDictionary[iDict]->StoreArray(branchname)) { | |
260 | printf("AliTRDdigitsManager::WriteDigits -- "); | |
261 | printf("Error while storing dictionary in branch %s\n",branchname); | |
262 | return kFALSE; | |
263 | } | |
264 | } | |
265 | ||
266 | return kTRUE; | |
267 | ||
268 | } | |
9d0b222b | 269 | |
270 | //_____________________________________________________________________________ | |
271 | AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col | |
793ff80c | 272 | , Int_t time, Int_t det) const |
9d0b222b | 273 | { |
274 | // | |
275 | // Creates a single digit object | |
276 | // | |
277 | ||
278 | Int_t digits[4]; | |
279 | Int_t amp[1]; | |
280 | ||
281 | digits[0] = det; | |
282 | digits[1] = row; | |
283 | digits[2] = col; | |
284 | digits[3] = time; | |
285 | ||
286 | amp[0] = GetDigits(det)->GetData(row,col,time); | |
287 | ||
288 | return (new AliTRDdigit(fIsRaw,digits,amp)); | |
289 | ||
290 | } | |
291 | ||
292 | //_____________________________________________________________________________ | |
293 | Int_t AliTRDdigitsManager::GetTrack(Int_t track | |
294 | , Int_t row, Int_t col, Int_t time | |
793ff80c | 295 | , Int_t det) const |
9d0b222b | 296 | { |
297 | // | |
298 | // Returns the MC-track numbers from the dictionary. | |
299 | // | |
300 | ||
301 | if ((track < 0) || (track >= kNDict)) { | |
302 | TObject::Error("GetTracks" | |
303 | ,"track %d out of bounds (size: %d, this: 0x%08x)" | |
304 | ,track,kNDict,this); | |
305 | return -1; | |
306 | } | |
307 | ||
308 | // Array contains index+1 to allow data compression | |
309 | return (GetDictionary(det,track)->GetData(row,col,time) - 1); | |
310 | ||
311 | } | |
312 | ||
dd9a6ee3 | 313 | //_____________________________________________________________________________ |
793ff80c | 314 | AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const |
dd9a6ee3 | 315 | { |
316 | // | |
317 | // Returns the digits array for one detector | |
318 | // | |
319 | ||
320 | return (AliTRDdataArrayI *) fDigits->At(det); | |
321 | ||
322 | } | |
323 | ||
324 | //_____________________________________________________________________________ | |
793ff80c | 325 | AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const |
dd9a6ee3 | 326 | { |
327 | // | |
328 | // Returns the dictionary for one detector | |
329 | // | |
330 | ||
331 | return (AliTRDdataArrayI *) fDictionary[i]->At(det); | |
332 | ||
333 | } | |
334 | ||
335 | //_____________________________________________________________________________ | |
793ff80c | 336 | Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const |
dd9a6ee3 | 337 | { |
338 | // | |
339 | // Returns the MC-track numbers from the dictionary for a given digit | |
340 | // | |
341 | ||
342 | Int_t row = Digit->GetRow(); | |
343 | Int_t col = Digit->GetCol(); | |
344 | Int_t time = Digit->GetTime(); | |
345 | Int_t det = Digit->GetDetector(); | |
346 | ||
347 | return GetTrack(track,row,col,time,det); | |
348 | ||
349 | } | |
350 | ||
351 | //_____________________________________________________________________________ | |
352 | AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m) | |
353 | { | |
354 | // | |
355 | // Assignment operator | |
356 | // | |
357 | ||
358 | if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this); | |
359 | return *this; | |
360 | ||
361 | } |