]>
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 | ||
88cb7938 | 16 | /* $Id$ */ |
6f1e466d | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Manages the digits and the track dictionary in the form of // | |
b65e5048 | 21 | // TObjArray objects // |
6f1e466d | 22 | // // |
23 | /////////////////////////////////////////////////////////////////////////////// | |
6244debe | 24 | |
793ff80c | 25 | #include <TTree.h> |
77ad13f4 | 26 | |
2745a409 | 27 | #include "AliLog.h" |
77ad13f4 | 28 | |
6f1e466d | 29 | #include "AliTRDdigitsManager.h" |
b65e5048 | 30 | #include "AliTRDarrayDictionary.h" |
31 | #include "AliTRDarrayADC.h" | |
32 | #include "AliTRDarraySignal.h" | |
793ff80c | 33 | #include "AliTRDdigit.h" |
966f6939 | 34 | #include "AliTRDdigitsParam.h" |
35 | #include "AliTRDSimParam.h" | |
793ff80c | 36 | #include "AliTRDgeometry.h" |
ca21baaa | 37 | #include "AliTRDSignalIndex.h" |
38 | ||
6f1e466d | 39 | ClassImp(AliTRDdigitsManager) |
40 | ||
793ff80c | 41 | //_____________________________________________________________________________ |
42 | ||
43 | // Number of track dictionary arrays | |
44 | const Int_t AliTRDdigitsManager::fgkNDict = kNDict; | |
45 | ||
6f1e466d | 46 | //_____________________________________________________________________________ |
3d0c7d6d | 47 | AliTRDdigitsManager::AliTRDdigitsManager(Bool_t rawRec) |
2745a409 | 48 | :TObject() |
49 | ,fEvent(0) | |
50 | ,fTree(0) | |
b65e5048 | 51 | ,fDigits(0) |
625f5260 | 52 | ,fHasSDigits(0) |
ca21baaa | 53 | ,fSignalIndexes(NULL) |
001be664 | 54 | ,fUseDictionaries(kTRUE) |
486c2339 | 55 | ,fDets(AliTRDgeometry::Ndet()) |
3d0c7d6d | 56 | ,fRawRec(rawRec) |
966f6939 | 57 | ,fDigitsParam(0) |
6f1e466d | 58 | { |
59 | // | |
60 | // Default constructor | |
61 | // | |
486c2339 | 62 | |
966f6939 | 63 | if (fRawRec) |
486c2339 | 64 | { |
966f6939 | 65 | fDets = 1; |
66 | fRawRec = kTRUE; | |
486c2339 | 67 | } |
6f1e466d | 68 | |
b65e5048 | 69 | for (Int_t iDict = 0; iDict < kNDict; iDict++) |
70 | { | |
71 | fDict[iDict] = NULL; | |
966f6939 | 72 | } |
73 | ||
6f1e466d | 74 | } |
75 | ||
8230f242 | 76 | //_____________________________________________________________________________ |
dd9a6ee3 | 77 | AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) |
2745a409 | 78 | :TObject(m) |
79 | ,fEvent(m.fEvent) | |
80 | ,fTree(0) | |
b65e5048 | 81 | ,fDigits(0) |
625f5260 | 82 | ,fHasSDigits(m.fHasSDigits) |
ca21baaa | 83 | ,fSignalIndexes(NULL) |
001be664 | 84 | ,fUseDictionaries(kTRUE) |
486c2339 | 85 | ,fDets(m.fDets) |
86 | ,fRawRec(m.fRawRec) | |
966f6939 | 87 | ,fDigitsParam(NULL) |
8230f242 | 88 | { |
89 | // | |
90 | // AliTRDdigitsManager copy constructor | |
91 | // | |
92 | ||
8230f242 | 93 | } |
94 | ||
6f1e466d | 95 | //_____________________________________________________________________________ |
96 | AliTRDdigitsManager::~AliTRDdigitsManager() | |
97 | { | |
8230f242 | 98 | // |
99 | // AliTRDdigitsManager destructor | |
100 | // | |
6f1e466d | 101 | |
b37bf997 | 102 | |
b65e5048 | 103 | if (fDigits) |
104 | { | |
105 | fDigits->Delete(); | |
106 | delete fDigits; | |
107 | fDigits = NULL; | |
108 | } | |
6f1e466d | 109 | |
b65e5048 | 110 | for (Int_t iDict = 0; iDict < kNDict; iDict++) |
111 | { | |
486c2339 | 112 | if(fDict[iDict]) |
113 | { | |
114 | fDict[iDict]->Delete(); | |
115 | delete fDict[iDict]; | |
116 | fDict[iDict] = NULL; | |
117 | } | |
b65e5048 | 118 | } |
6f1e466d | 119 | |
b65e5048 | 120 | if (fSignalIndexes) |
121 | { | |
122 | fSignalIndexes->Delete(); | |
123 | delete fSignalIndexes; | |
124 | fSignalIndexes = NULL; | |
125 | } | |
ca21baaa | 126 | |
966f6939 | 127 | if (fDigitsParam) |
128 | { | |
129 | delete fDigitsParam; | |
130 | fDigitsParam = NULL; | |
131 | } | |
132 | ||
6f1e466d | 133 | } |
134 | ||
2745a409 | 135 | //_____________________________________________________________________________ |
136 | AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m) | |
137 | { | |
138 | // | |
139 | // Assignment operator | |
140 | // | |
141 | ||
b65e5048 | 142 | if (this != &m) |
143 | { | |
144 | ((AliTRDdigitsManager &) m).Copy(*this); | |
145 | } | |
625f5260 | 146 | |
2745a409 | 147 | return *this; |
148 | ||
149 | } | |
150 | ||
8230f242 | 151 | //_____________________________________________________________________________ |
e0d47c25 | 152 | void AliTRDdigitsManager::Copy(TObject &m) const |
8230f242 | 153 | { |
154 | // | |
155 | // Copy function | |
156 | // | |
157 | ||
625f5260 | 158 | ((AliTRDdigitsManager &) m).fEvent = fEvent; |
159 | ((AliTRDdigitsManager &) m).fHasSDigits = fHasSDigits; | |
966f6939 | 160 | ((AliTRDdigitsManager &) m).fDigits = NULL; |
161 | for(Int_t i = 0; i < kNDict; i++) | |
b65e5048 | 162 | { |
966f6939 | 163 | ((AliTRDdigitsManager &) m).fDict[i] = NULL; |
b65e5048 | 164 | } |
966f6939 | 165 | ((AliTRDdigitsManager &) m).fSignalIndexes = NULL; |
001be664 | 166 | ((AliTRDdigitsManager &) m).fUseDictionaries = fUseDictionaries; |
486c2339 | 167 | ((AliTRDdigitsManager &) m).fDets = fDets; |
966f6939 | 168 | ((AliTRDdigitsManager &) m).fRawRec = fRawRec; |
169 | ((AliTRDdigitsManager &) m).fDigitsParam = NULL; | |
001be664 | 170 | |
8230f242 | 171 | TObject::Copy(m); |
172 | ||
173 | } | |
174 | ||
abaf1f1d | 175 | //_____________________________________________________________________________ |
176 | void AliTRDdigitsManager::CreateArrays() | |
177 | { | |
178 | // | |
179 | // Create the data arrays | |
180 | // | |
181 | ||
b65e5048 | 182 | if (fHasSDigits) |
183 | { | |
966f6939 | 184 | if (fDigits) |
b65e5048 | 185 | { |
186 | fDigits->Delete(); | |
187 | delete fDigits; | |
188 | } | |
486c2339 | 189 | fDigits = new TObjArray(fDets); |
190 | for (Int_t index = 0; index < fDets; index++) | |
966f6939 | 191 | { |
192 | fDigits->AddAt(new AliTRDarraySignal(),index); | |
193 | } | |
b65e5048 | 194 | } |
195 | else | |
196 | { | |
966f6939 | 197 | if (fDigits) |
b65e5048 | 198 | { |
199 | fDigits->Delete(); | |
200 | delete fDigits; | |
201 | } | |
486c2339 | 202 | fDigits = new TObjArray(fDets); |
966f6939 | 203 | for (Int_t index = 0; index < fDets; index++) |
204 | { | |
205 | fDigits->AddAt(new AliTRDarrayADC(),index); | |
206 | } | |
b65e5048 | 207 | } |
208 | ||
209 | if (fUseDictionaries) | |
210 | { | |
b65e5048 | 211 | for (Int_t iDict = 0; iDict < kNDict; iDict++) |
966f6939 | 212 | { |
213 | if (fDict[iDict]) | |
214 | { | |
215 | fDict[iDict]->Delete(); | |
216 | delete fDict[iDict]; | |
217 | } | |
218 | fDict[iDict] = new TObjArray(fDets); | |
219 | for (Int_t index = 0; index < fDets; index++) | |
220 | { | |
221 | fDict[iDict]->AddAt(new AliTRDarrayDictionary(),index); | |
222 | } | |
223 | } | |
001be664 | 224 | } |
486c2339 | 225 | |
966f6939 | 226 | if (fSignalIndexes) |
b65e5048 | 227 | { |
486c2339 | 228 | fSignalIndexes->Delete(); |
229 | delete fSignalIndexes; | |
230 | } | |
231 | fSignalIndexes = new TObjArray(fDets); | |
966f6939 | 232 | for (Int_t i = 0; i < fDets; i++) |
233 | { | |
234 | fSignalIndexes->AddLast(new AliTRDSignalIndex()); | |
235 | } | |
236 | ||
237 | if (fDigitsParam) | |
238 | { | |
239 | delete fDigitsParam; | |
240 | } | |
241 | fDigitsParam = new AliTRDdigitsParam(); | |
242 | fDigitsParam->SetNTimeBins(AliTRDSimParam::Instance()->GetNTimeBins()); | |
683855ce | 243 | fDigitsParam->SetADCbaseline(AliTRDSimParam::Instance()->GetADCbaseline()); |
abaf1f1d | 244 | |
17eee78a | 245 | } |
625f5260 | 246 | |
16bf9884 | 247 | //_____________________________________________________________________________ |
534529cb | 248 | void AliTRDdigitsManager::ClearArrays(Int_t det) |
249 | { | |
250 | // | |
251 | // Reset the data arrays | |
252 | // | |
253 | ||
254 | Int_t recoDet = fRawRec ? 0 : det; | |
255 | ||
256 | if (fHasSDigits) | |
257 | { | |
258 | ((AliTRDarraySignal*)fDigits->At(recoDet))->Reset(); | |
259 | } | |
260 | else | |
261 | { | |
262 | ((AliTRDarrayADC*)fDigits->At(recoDet))->ConditionalReset((AliTRDSignalIndex*)fSignalIndexes->At(recoDet)); | |
263 | } | |
264 | ||
265 | if (fUseDictionaries) | |
266 | { | |
267 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
268 | { | |
269 | ((AliTRDarrayDictionary*)fDict[iDict]->At(recoDet))->Reset(); | |
270 | } | |
271 | } | |
272 | ||
273 | ((AliTRDSignalIndex*)fSignalIndexes->At(recoDet))->ResetContent(); | |
274 | ||
275 | } | |
276 | ||
277 | //_____________________________________________________________________________ | |
b65e5048 | 278 | Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time, Int_t det) const |
16bf9884 | 279 | { |
280 | // | |
281 | // Returns the amplitude of a digit | |
282 | // | |
283 | ||
486c2339 | 284 | if (!GetDigits(det)) return 0; |
b65e5048 | 285 | |
da43c135 | 286 | return ((Short_t) ((AliTRDarrayADC *) GetDigits(det))->GetDataBits(row,col,time)); |
16bf9884 | 287 | |
288 | } | |
b65e5048 | 289 | |
d739fd4e | 290 | //_____________________________________________________________________________ |
b65e5048 | 291 | UChar_t AliTRDdigitsManager::GetPadStatus(Int_t row, Int_t col, Int_t time, Int_t det) const |
d739fd4e | 292 | { |
c10bf383 | 293 | // |
294 | // Returns the pad status for the requested pad | |
295 | // | |
d739fd4e | 296 | |
486c2339 | 297 | if (!GetDigits(det)) return 0; |
d739fd4e | 298 | |
b65e5048 | 299 | return ((UChar_t) ((AliTRDarrayADC *) GetDigits(det))->GetPadStatus(row,col,time)); |
300 | ||
d739fd4e | 301 | } |
302 | ||
6f1e466d | 303 | //_____________________________________________________________________________ |
77ad13f4 | 304 | Bool_t AliTRDdigitsManager::MakeBranch(TTree * const tree) |
855bfffd | 305 | { |
306 | // | |
307 | // Creates the tree and branches for the digits and the dictionary | |
308 | // | |
309 | ||
b65e5048 | 310 | Int_t buffersize = 64000; |
311 | Bool_t status = kTRUE; | |
855bfffd | 312 | |
b65e5048 | 313 | if (tree) |
314 | { | |
315 | fTree = tree; | |
316 | } | |
855bfffd | 317 | |
abaf1f1d | 318 | // Make the branch for the digits |
b65e5048 | 319 | if (fDigits) |
320 | { | |
966f6939 | 321 | if (fHasSDigits) |
b65e5048 | 322 | { |
323 | const AliTRDarraySignal *kDigits = (AliTRDarraySignal *) fDigits->At(0); | |
324 | if (kDigits) | |
325 | { | |
326 | if (!fTree) return kFALSE; | |
327 | AliDebug(1,"Making branch for SDigits!\n"); | |
966f6939 | 328 | TBranch *branch = fTree->GetBranch("TRDdigits"); |
329 | if (!branch) | |
330 | { | |
331 | fTree->Branch("TRDdigits","AliTRDarraySignal",&kDigits,buffersize,99); | |
332 | } | |
b65e5048 | 333 | AliDebug(1,"Making branch TRDdigits\n"); |
334 | } | |
335 | else | |
336 | { | |
337 | status = kFALSE; | |
338 | } | |
339 | } | |
340 | ||
966f6939 | 341 | if (!fHasSDigits) |
b65e5048 | 342 | { |
343 | const AliTRDarrayADC *kDigits = (AliTRDarrayADC *) fDigits->At(0); | |
344 | if (kDigits) | |
345 | { | |
346 | if (!fTree) return kFALSE; | |
347 | AliDebug(1,"Making branch for Digits!\n"); | |
966f6939 | 348 | TBranch *branch = fTree->GetBranch("TRDdigits"); |
349 | if (!branch) | |
350 | { | |
351 | fTree->Branch("TRDdigits","AliTRDarrayADC",&kDigits,buffersize,99); | |
352 | } | |
b65e5048 | 353 | AliDebug(1,"Making branch TRDdigits\n"); |
354 | } | |
355 | else | |
356 | { | |
357 | status = kFALSE; | |
358 | } | |
359 | } | |
360 | ||
966f6939 | 361 | } |
b65e5048 | 362 | else |
363 | { | |
966f6939 | 364 | |
6f1e466d | 365 | status = kFALSE; |
966f6939 | 366 | |
6f1e466d | 367 | } |
b65e5048 | 368 | |
369 | if (fUseDictionaries) | |
370 | { | |
371 | // Make the branches for the dictionaries | |
372 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
373 | { | |
374 | Char_t branchname[15]; | |
375 | sprintf(branchname,"TRDdictionary%d",iDict); | |
376 | if (fDict[iDict]) | |
377 | { | |
378 | const AliTRDarrayDictionary *kDictionary = (AliTRDarrayDictionary *) fDict[iDict]->At(0); | |
379 | if (kDictionary) | |
380 | { | |
381 | if (!fTree) return kFALSE; | |
382 | AliDebug(2,"Making branch for dictionary!\n"); | |
966f6939 | 383 | TBranch *branch = fTree->GetBranch(branchname); |
384 | if (!branch) | |
385 | { | |
386 | fTree->Branch(branchname,"AliTRDarrayDictionary",&kDictionary,buffersize,99); | |
387 | } | |
b65e5048 | 388 | AliDebug(1,Form("Making branch %s\n",branchname)); |
389 | } | |
390 | else | |
391 | { | |
392 | status = kFALSE; | |
393 | } | |
394 | } | |
395 | else | |
396 | { | |
397 | status = kFALSE; | |
398 | } | |
001be664 | 399 | } |
abaf1f1d | 400 | } |
966f6939 | 401 | |
402 | if (fDigitsParam) | |
403 | { | |
404 | const AliTRDdigitsParam *kDigitsParam = fDigitsParam; | |
405 | if (!fTree) return kFALSE; | |
406 | TBranch *branch = fTree->GetBranch("TRDdigitsParam"); | |
407 | if (!branch) | |
408 | { | |
409 | fTree->Branch("TRDdigitsParam","AliTRDdigitsParam",&kDigitsParam,buffersize,99); | |
410 | } | |
411 | AliDebug(1,"Making branch AliTRDdigitsParam\n"); | |
412 | } | |
413 | ||
6f1e466d | 414 | return status; |
415 | ||
416 | } | |
417 | ||
418 | //_____________________________________________________________________________ | |
77ad13f4 | 419 | Bool_t AliTRDdigitsManager::ReadDigits(TTree * const tree) |
6f1e466d | 420 | { |
8230f242 | 421 | // |
422 | // Reads the digit information from the input file | |
423 | // | |
6f1e466d | 424 | |
425 | Bool_t status = kTRUE; | |
426 | ||
b65e5048 | 427 | if (tree) |
428 | { | |
429 | fTree = tree; | |
430 | } | |
431 | ||
432 | if (!fDigits) | |
433 | { | |
434 | AliDebug(1,"Create the data arrays.\n"); | |
435 | CreateArrays(); | |
436 | } | |
437 | ||
966f6939 | 438 | status = LoadArrayDigits(); |
b65e5048 | 439 | |
440 | if (fUseDictionaries) | |
441 | { | |
966f6939 | 442 | status = LoadArrayDict(); |
443 | if (status == kFALSE) | |
b65e5048 | 444 | { |
966f6939 | 445 | fUseDictionaries = kFALSE; |
446 | AliWarning("Unable to load dict arrays. Will not use them.\n"); | |
447 | } | |
448 | } | |
449 | ||
450 | if (!LoadDigitsParam()) { | |
451 | AliWarning("Could not read digits parameter."); | |
452 | if (fDigitsParam) { | |
453 | delete fDigitsParam; | |
b65e5048 | 454 | } |
966f6939 | 455 | AliWarning(Form("Create default version of digits parameter (NTimeBin=%d).\n" |
456 | ,AliTRDSimParam::Instance()->GetNTimeBins())); | |
457 | fDigitsParam = new AliTRDdigitsParam(); | |
458 | fDigitsParam->SetNTimeBins(AliTRDSimParam::Instance()->GetNTimeBins()); | |
683855ce | 459 | fDigitsParam->SetADCbaseline(AliTRDSimParam::Instance()->GetADCbaseline()); |
966f6939 | 460 | } |
6f1e466d | 461 | |
966f6939 | 462 | return status; |
6f1e466d | 463 | |
464 | } | |
465 | ||
466 | //_____________________________________________________________________________ | |
467 | Bool_t AliTRDdigitsManager::WriteDigits() | |
468 | { | |
469 | // | |
470 | // Writes out the TRD-digits and the dictionaries | |
471 | // | |
472 | ||
966f6939 | 473 | if (!StoreArrayDigits()) |
b65e5048 | 474 | { |
966f6939 | 475 | AliError("Error while storing digits\n"); |
b65e5048 | 476 | return kFALSE; |
6f1e466d | 477 | } |
6f1e466d | 478 | |
b65e5048 | 479 | if (fUseDictionaries) |
480 | { | |
966f6939 | 481 | if (!StoreArrayDict()) |
b65e5048 | 482 | { |
966f6939 | 483 | AliError("Error while storing dictionaries in branch\n"); |
484 | return kFALSE; | |
b65e5048 | 485 | } |
486 | } | |
487 | ||
abaf1f1d | 488 | // Write the new tree to the output file |
b65e5048 | 489 | fTree->AutoSave(); |
abaf1f1d | 490 | |
6f1e466d | 491 | return kTRUE; |
492 | ||
493 | } | |
9d0b222b | 494 | |
495 | //_____________________________________________________________________________ | |
b65e5048 | 496 | AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row |
497 | , Int_t col | |
498 | , Int_t time | |
499 | , Int_t det) const | |
9d0b222b | 500 | { |
501 | // | |
502 | // Creates a single digit object | |
503 | // | |
504 | ||
b65e5048 | 505 | Int_t digits[4]; |
9d0b222b | 506 | Int_t amp[1]; |
507 | ||
508 | digits[0] = det; | |
509 | digits[1] = row; | |
510 | digits[2] = col; | |
511 | digits[3] = time; | |
512 | ||
b65e5048 | 513 | amp[0] = ((AliTRDarrayADC *) GetDigits(det))->GetData(row,col,time); |
9d0b222b | 514 | |
625f5260 | 515 | return (new AliTRDdigit(digits,amp)); |
9d0b222b | 516 | |
517 | } | |
518 | ||
519 | //_____________________________________________________________________________ | |
520 | Int_t AliTRDdigitsManager::GetTrack(Int_t track | |
b65e5048 | 521 | , Int_t row |
522 | , Int_t col | |
523 | , Int_t time | |
793ff80c | 524 | , Int_t det) const |
9d0b222b | 525 | { |
526 | // | |
527 | // Returns the MC-track numbers from the dictionary. | |
528 | // | |
529 | ||
b65e5048 | 530 | if ((track < 0) || (track >= kNDict)) |
531 | { | |
532 | AliError(Form("track %d out of bounds (size: %d, this: 0x%08x)",track,kNDict,this)); | |
533 | return -1; | |
534 | } | |
9d0b222b | 535 | |
b65e5048 | 536 | if (fUseDictionaries == kFALSE) |
537 | { | |
538 | return -1; | |
539 | } | |
625f5260 | 540 | |
b65e5048 | 541 | // Array contains index+1 to allow data compression--->Changed |
542 | return (((AliTRDarrayDictionary *) GetDictionary(det,track))->GetData(row,col,time) ); | |
9d0b222b | 543 | |
544 | } | |
545 | ||
b65e5048 | 546 | //________________________________________________________________________________ |
547 | AliTRDarrayADC *AliTRDdigitsManager::GetDigits(Int_t det) const | |
dd9a6ee3 | 548 | { |
549 | // | |
550 | // Returns the digits array for one detector | |
551 | // | |
552 | ||
4f5f1ae2 | 553 | Int_t recoDet = fRawRec ? 0 : det; |
486c2339 | 554 | |
b65e5048 | 555 | if (!fDigits) |
556 | { | |
557 | return 0x0; | |
558 | } | |
625f5260 | 559 | |
b65e5048 | 560 | if (!fHasSDigits) |
561 | { | |
4f5f1ae2 | 562 | ((AliTRDarrayADC *) fDigits->At(recoDet))->SetNdet(det); |
563 | return (AliTRDarrayADC *) fDigits->At(recoDet); | |
b65e5048 | 564 | } |
565 | else | |
566 | { | |
567 | AliDebug(2,"ERROR IN DATA TYPE!!!!"); | |
568 | return 0x0; | |
569 | } | |
dd9a6ee3 | 570 | |
571 | } | |
572 | ||
573 | //_____________________________________________________________________________ | |
b65e5048 | 574 | AliTRDarraySignal *AliTRDdigitsManager::GetSDigits(Int_t det) const |
dd9a6ee3 | 575 | { |
576 | // | |
b65e5048 | 577 | // Returns the sdigits array for one detector |
dd9a6ee3 | 578 | // |
579 | ||
4f5f1ae2 | 580 | Int_t recoDet = fRawRec ? 0 : det; |
486c2339 | 581 | |
b65e5048 | 582 | if (!fDigits) |
583 | { | |
584 | // AliDebug(1,"NO FDIGITS!"); | |
585 | return 0x0; | |
586 | } | |
587 | ||
588 | if (fHasSDigits) | |
589 | { | |
4f5f1ae2 | 590 | ((AliTRDarraySignal *) fDigits->At(recoDet))->SetNdet(det); |
591 | return (AliTRDarraySignal *) fDigits->At(recoDet); | |
b65e5048 | 592 | } |
593 | else | |
594 | { | |
595 | AliDebug(2,"ERROR IN DATA TYPE!!!!"); | |
596 | return 0x0; | |
597 | } | |
598 | ||
599 | } | |
600 | ||
601 | //_____________________________________________________________________________ | |
602 | AliTRDarrayDictionary *AliTRDdigitsManager::GetDictionary(Int_t det | |
603 | , Int_t i) const | |
604 | { | |
605 | // | |
606 | // Returns the dictionary for one detector | |
607 | // | |
625f5260 | 608 | |
4f5f1ae2 | 609 | Int_t recoDet = fRawRec ? 0 : det; |
486c2339 | 610 | |
b65e5048 | 611 | if (fUseDictionaries == kFALSE) |
612 | { | |
613 | return 0x0; | |
614 | } | |
dd9a6ee3 | 615 | |
4f5f1ae2 | 616 | ((AliTRDarrayDictionary *) fDigits->At(recoDet))->SetNdet(det); |
617 | return (AliTRDarrayDictionary *) fDict[i]->At(recoDet); | |
b65e5048 | 618 | |
dd9a6ee3 | 619 | } |
620 | ||
621 | //_____________________________________________________________________________ | |
77ad13f4 | 622 | Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit * const digit) const |
dd9a6ee3 | 623 | { |
624 | // | |
625 | // Returns the MC-track numbers from the dictionary for a given digit | |
626 | // | |
627 | ||
b65e5048 | 628 | Int_t row = digit->GetRow(); |
629 | Int_t col = digit->GetCol(); | |
630 | Int_t time = digit->GetTime(); | |
631 | Int_t det = digit->GetDetector(); | |
dd9a6ee3 | 632 | |
633 | return GetTrack(track,row,col,time,det); | |
634 | ||
635 | } | |
ca21baaa | 636 | |
637 | //_____________________________________________________________________________ | |
638 | AliTRDSignalIndex *AliTRDdigitsManager::GetIndexes(Int_t det) | |
639 | { | |
640 | // | |
641 | // Returns indexes of active pads | |
642 | // | |
643 | ||
4f5f1ae2 | 644 | Int_t recoDet = fRawRec ? 0 : det; |
486c2339 | 645 | |
4f5f1ae2 | 646 | return (AliTRDSignalIndex *) fSignalIndexes->At(recoDet); |
ca21baaa | 647 | |
648 | } | |
649 | ||
650 | //_____________________________________________________________________________ | |
651 | void AliTRDdigitsManager::RemoveDigits(Int_t det) | |
652 | { | |
b65e5048 | 653 | // |
654 | // Clear memory at det for Digits | |
655 | // | |
ca21baaa | 656 | |
4f5f1ae2 | 657 | Int_t recoDet = fRawRec ? 0 : det; |
486c2339 | 658 | |
4f5f1ae2 | 659 | if (fDigits->At(recoDet)) |
b65e5048 | 660 | { |
b37bf997 | 661 | if (fHasSDigits) |
662 | { | |
4f5f1ae2 | 663 | AliTRDarraySignal *arr = (AliTRDarraySignal *) fDigits->RemoveAt(recoDet); |
b37bf997 | 664 | delete arr; |
665 | } | |
666 | else | |
667 | { | |
4f5f1ae2 | 668 | AliTRDarrayADC *arr = (AliTRDarrayADC *) fDigits->RemoveAt(recoDet); |
b37bf997 | 669 | delete arr; |
670 | } | |
b65e5048 | 671 | } |
ca21baaa | 672 | |
673 | } | |
674 | ||
675 | //_____________________________________________________________________________ | |
676 | void AliTRDdigitsManager::RemoveDictionaries(Int_t det) | |
677 | { | |
678 | // | |
679 | // Clear memory | |
680 | // | |
625f5260 | 681 | |
4f5f1ae2 | 682 | Int_t recoDet = fRawRec ? 0 : det; |
486c2339 | 683 | |
b65e5048 | 684 | if (fUseDictionaries == kFALSE) |
685 | { | |
686 | return; | |
687 | } | |
ca21baaa | 688 | |
b65e5048 | 689 | for (Int_t i = 0; i < kNDict; i++) |
690 | { | |
4f5f1ae2 | 691 | if (fDict[i]->At(recoDet)) |
b65e5048 | 692 | { |
4f5f1ae2 | 693 | AliTRDarrayDictionary *arr = (AliTRDarrayDictionary *) fDict[i]->RemoveAt(recoDet); |
b37bf997 | 694 | delete arr; |
b65e5048 | 695 | } |
696 | } | |
ca21baaa | 697 | |
698 | } | |
699 | ||
486c2339 | 700 | //_____________________________________________________________________________ |
701 | void AliTRDdigitsManager::RemoveIndexes(Int_t det) | |
702 | { | |
703 | // | |
704 | // Clear memory | |
705 | // | |
706 | ||
4f5f1ae2 | 707 | Int_t recoDet = fRawRec ? 0 : det; |
486c2339 | 708 | |
4f5f1ae2 | 709 | if (fSignalIndexes->At(recoDet)) |
486c2339 | 710 | { |
4f5f1ae2 | 711 | AliTRDSignalIndex *arr = (AliTRDSignalIndex *) fSignalIndexes->RemoveAt(recoDet); |
486c2339 | 712 | delete arr; |
713 | } | |
714 | ||
715 | } | |
716 | ||
ca21baaa | 717 | //_____________________________________________________________________________ |
718 | void AliTRDdigitsManager::ClearIndexes(Int_t det) | |
719 | { | |
720 | // | |
721 | // Clear memory | |
722 | // | |
486c2339 | 723 | |
4f5f1ae2 | 724 | Int_t recoDet = fRawRec ? 0 : det; |
625f5260 | 725 | |
4f5f1ae2 | 726 | ((AliTRDSignalIndex *) fSignalIndexes->At(recoDet))->ClearAll(); |
ca21baaa | 727 | |
625f5260 | 728 | } |
ca21baaa | 729 | |
730 | //_____________________________________________________________________________ | |
731 | Bool_t AliTRDdigitsManager::BuildIndexes(Int_t det) | |
732 | { | |
733 | // | |
734 | // Build the list of indices | |
735 | // | |
736 | ||
b65e5048 | 737 | Int_t nRows = 0; |
738 | Int_t nCols = 0; | |
ca21baaa | 739 | Int_t nTbins = 0; |
740 | ||
b65e5048 | 741 | AliTRDgeometry geom; |
742 | AliTRDarrayADC *digits = 0x0; | |
625f5260 | 743 | |
b65e5048 | 744 | if (fHasSDigits) |
745 | { | |
746 | return kFALSE; | |
747 | } | |
748 | else | |
749 | { | |
750 | digits = (AliTRDarrayADC *) GetDigits(det); | |
751 | } | |
625f5260 | 752 | |
966f6939 | 753 | // digits should be expanded by now!!! |
b65e5048 | 754 | if (digits->GetNtime() > 0) |
755 | { | |
756 | digits->Expand(); | |
757 | nRows = digits->GetNrow(); | |
758 | nCols = digits->GetNcol(); | |
759 | nTbins = digits->GetNtime(); | |
760 | ||
761 | AliTRDSignalIndex *indexes = GetIndexes(det); | |
762 | indexes->SetSM(geom.GetSector(det)); | |
763 | indexes->SetStack(geom.GetStack(det)); | |
764 | indexes->SetLayer(geom.GetLayer(det)); | |
765 | indexes->SetDetNumber(det); | |
766 | ||
767 | if (indexes->IsAllocated() == kFALSE) | |
768 | { | |
769 | indexes->Allocate(nRows,nCols,nTbins); | |
770 | } | |
625f5260 | 771 | |
b65e5048 | 772 | for (Int_t ir = 0; ir < nRows; ir++) |
773 | { | |
774 | for (Int_t ic = 0; ic < nCols; ic++) | |
775 | { | |
776 | for (Int_t it = 0; it < nTbins; it++) | |
777 | { | |
da43c135 | 778 | Int_t isig = digits->GetDataBits(ir,ic,it); |
b65e5048 | 779 | if (isig > 0) |
780 | { | |
ae63fafc | 781 | indexes->AddIndexRC(ir,ic); |
b65e5048 | 782 | } |
783 | } // tbins | |
784 | } // cols | |
785 | } // rows | |
786 | ||
787 | } // if GetNtime | |
788 | else | |
789 | { | |
790 | return kFALSE; | |
791 | } | |
792 | ||
793 | return kTRUE; | |
625f5260 | 794 | |
b65e5048 | 795 | } |
625f5260 | 796 | |
b65e5048 | 797 | //_____________________________________________________________________________ |
966f6939 | 798 | Bool_t AliTRDdigitsManager::LoadArrayDigits() |
b65e5048 | 799 | { |
800 | // | |
966f6939 | 801 | // Loads the (s-)digits arrays for all detectors |
b65e5048 | 802 | // |
803 | ||
966f6939 | 804 | if (!fTree) |
b65e5048 | 805 | { |
806 | AliError("Digits tree is not defined\n"); | |
807 | return kFALSE; | |
ca21baaa | 808 | } |
625f5260 | 809 | |
966f6939 | 810 | Bool_t status = kTRUE; |
811 | ||
b65e5048 | 812 | // Get the branch |
966f6939 | 813 | TBranch *branch = fTree->GetBranch("TRDdigits"); |
814 | if (!branch) | |
b65e5048 | 815 | { |
966f6939 | 816 | AliError("Branch TRDdigits is not defined\n"); |
b65e5048 | 817 | return kFALSE; |
818 | } | |
625f5260 | 819 | |
b65e5048 | 820 | // Loop through all detectors and read them from the tree |
486c2339 | 821 | for (Int_t iDet = 0; iDet < fDets; iDet++) |
b65e5048 | 822 | { |
966f6939 | 823 | if (fHasSDigits) |
b65e5048 | 824 | { |
966f6939 | 825 | AliTRDarraySignal *dataArray = (AliTRDarraySignal *) fDigits->At(iDet); |
b65e5048 | 826 | if (!dataArray) |
827 | { | |
828 | status = kFALSE; | |
829 | break; | |
830 | } | |
966f6939 | 831 | branch->SetAddress(&dataArray); |
832 | branch->GetEntry(iDet); | |
b65e5048 | 833 | } |
834 | else | |
835 | { | |
966f6939 | 836 | AliTRDarrayADC *dataArray = (AliTRDarrayADC *) fDigits->At(iDet); |
b65e5048 | 837 | if (!dataArray) |
838 | { | |
839 | status = kFALSE; | |
966f6939 | 840 | break; |
b65e5048 | 841 | } |
966f6939 | 842 | branch->SetAddress(&dataArray); |
843 | branch->GetEntry(iDet); | |
b65e5048 | 844 | } |
845 | } | |
625f5260 | 846 | |
b65e5048 | 847 | return status; |
848 | ||
849 | } | |
850 | ||
851 | //________________________________________________________________________________________________ | |
966f6939 | 852 | Bool_t AliTRDdigitsManager::LoadArrayDict() |
b65e5048 | 853 | { |
854 | // | |
966f6939 | 855 | // Loads dictionary arrays for all detectors |
b65e5048 | 856 | // |
857 | ||
966f6939 | 858 | if (!fTree) |
859 | { | |
860 | AliError("Digits tree is not defined\n"); | |
861 | return kFALSE; | |
862 | } | |
863 | ||
864 | Bool_t status = kTRUE; | |
865 | ||
866 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
867 | { | |
868 | ||
869 | // Get the branch | |
870 | Char_t branchname[15]; | |
871 | sprintf(branchname,"TRDdictionary%d",iDict); | |
872 | TBranch *branch = fTree->GetBranch(branchname); | |
873 | if (!branch) | |
874 | { | |
875 | AliError(Form("Branch %s is not defined\n",branchname)); | |
876 | return kFALSE; | |
877 | } | |
878 | ||
879 | // Loop through all detectors and read them from the tree | |
880 | for (Int_t iDet = 0; iDet < fDets; iDet++) | |
881 | { | |
882 | AliTRDarrayDictionary *dataArray = (AliTRDarrayDictionary *) fDict[iDict]->At(iDet); | |
883 | if (!dataArray) | |
884 | { | |
885 | status = kFALSE; | |
886 | break; | |
887 | } | |
888 | branch->SetAddress(&dataArray); | |
889 | branch->GetEntry(iDet); | |
890 | } | |
891 | ||
892 | } | |
893 | ||
894 | return status; | |
895 | ||
896 | } | |
897 | ||
898 | //_____________________________________________________________________________ | |
899 | Bool_t AliTRDdigitsManager::LoadDigitsParam() | |
900 | { | |
901 | // | |
902 | // Loads the digits parameter object from the digits tree | |
903 | // | |
b65e5048 | 904 | |
966f6939 | 905 | if (!fTree) |
b65e5048 | 906 | { |
907 | AliError("Digits tree is not defined\n"); | |
908 | return kFALSE; | |
909 | } | |
910 | ||
911 | // Get the branch | |
966f6939 | 912 | TBranch *branch = fTree->GetBranch("TRDdigitsParam"); |
913 | if (!branch) | |
b65e5048 | 914 | { |
966f6939 | 915 | AliError("Branch TRDdigitsParam is not defined\n"); |
b65e5048 | 916 | return kFALSE; |
917 | } | |
918 | ||
966f6939 | 919 | // Read the parameter object |
920 | AliTRDdigitsParam *digitsParam = fDigitsParam; | |
921 | if (!digitsParam) | |
b65e5048 | 922 | { |
966f6939 | 923 | return kFALSE; |
b65e5048 | 924 | } |
925 | ||
966f6939 | 926 | branch->SetAddress(&digitsParam); |
927 | branch->GetEntry(); | |
928 | ||
929 | return kTRUE; | |
b65e5048 | 930 | |
931 | } | |
932 | ||
933 | //_____________________________________________________________________________ | |
966f6939 | 934 | Bool_t AliTRDdigitsManager::StoreArrayDigits() |
b65e5048 | 935 | { |
936 | // | |
966f6939 | 937 | // Stores the digit arrays for all detectors |
b65e5048 | 938 | // |
939 | ||
b65e5048 | 940 | if (!fTree) |
941 | { | |
942 | AliError("Digits tree is not defined\n"); | |
943 | return kFALSE; | |
944 | } | |
945 | ||
946 | // Get the branch | |
966f6939 | 947 | TBranch *branch = fTree->GetBranch("TRDdigits"); |
948 | if (!branch) | |
b65e5048 | 949 | { |
966f6939 | 950 | AliError("Branch TRDdigits is not defined\n"); |
b65e5048 | 951 | return kFALSE; |
952 | } | |
953 | ||
954 | // Loop through all detectors and fill them into the tree | |
955 | Bool_t status = kTRUE; | |
486c2339 | 956 | for (Int_t iDet = 0; iDet < fDets; iDet++) |
b65e5048 | 957 | { |
958 | if (fHasSDigits) | |
959 | { | |
966f6939 | 960 | const AliTRDarraySignal *kDataArray = (AliTRDarraySignal *) fDigits->At(iDet); |
b65e5048 | 961 | if (!kDataArray) |
962 | { | |
963 | status = kFALSE; | |
964 | break; | |
965 | } | |
966f6939 | 966 | branch->SetAddress(&kDataArray); |
967 | branch->Fill(); | |
b65e5048 | 968 | } |
969 | else | |
970 | { | |
966f6939 | 971 | const AliTRDarrayADC *kDataArray = (AliTRDarrayADC *) fDigits->At(iDet); |
b65e5048 | 972 | if (!kDataArray) |
973 | { | |
974 | status = kFALSE; | |
975 | break; | |
976 | } | |
966f6939 | 977 | branch->SetAddress(&kDataArray); |
978 | branch->Fill(); | |
b65e5048 | 979 | } |
980 | } | |
981 | ||
982 | return status; | |
983 | ||
984 | } | |
985 | ||
986 | //_____________________________________________________________________________ | |
966f6939 | 987 | Bool_t AliTRDdigitsManager::StoreArrayDict() |
b65e5048 | 988 | { |
989 | // | |
966f6939 | 990 | // Stores the dictionary arrays for all detectors |
b65e5048 | 991 | // |
992 | ||
966f6939 | 993 | if (!fTree) |
994 | { | |
995 | AliError("Digits tree is not defined\n"); | |
996 | return kFALSE; | |
997 | } | |
998 | ||
999 | Bool_t status = kTRUE; | |
1000 | ||
1001 | for (Int_t iDict = 0; iDict < kNDict; iDict++) | |
1002 | { | |
1003 | ||
1004 | // Get the branch | |
1005 | Char_t branchname[15]; | |
1006 | sprintf(branchname,"TRDdictionary%d",iDict); | |
1007 | TBranch *branch = fTree->GetBranch(branchname); | |
1008 | if (!branch) | |
1009 | { | |
1010 | AliError(Form("Branch %s is not defined\n",branchname)); | |
1011 | return kFALSE; | |
1012 | } | |
1013 | ||
1014 | // Loop through all detectors and fill them into the tree | |
1015 | for (Int_t iDet = 0; iDet < fDets; iDet++) | |
1016 | { | |
1017 | const AliTRDarrayDictionary *kDataArray = (AliTRDarrayDictionary *) fDict[iDict]->At(iDet); | |
1018 | if (!kDataArray) | |
1019 | { | |
1020 | status = kFALSE; | |
1021 | break; | |
1022 | } | |
1023 | branch->SetAddress(&kDataArray); | |
1024 | branch->Fill(); | |
1025 | } | |
1026 | ||
1027 | } | |
1028 | ||
1029 | return status; | |
1030 | ||
1031 | } | |
1032 | ||
1033 | //_____________________________________________________________________________ | |
1034 | Bool_t AliTRDdigitsManager::StoreDigitsParam() | |
1035 | { | |
1036 | // | |
1037 | // Stores the digits parameter object from the digits tree | |
1038 | // | |
b65e5048 | 1039 | |
1040 | if (!fTree) | |
1041 | { | |
1042 | AliError("Digits tree is not defined\n"); | |
1043 | return kFALSE; | |
1044 | } | |
1045 | ||
1046 | // Get the branch | |
966f6939 | 1047 | TBranch *branch = fTree->GetBranch("TRDdigitsParam"); |
1048 | if (!branch) | |
b65e5048 | 1049 | { |
966f6939 | 1050 | AliError("Branch TRDdigitsParam is not defined\n"); |
b65e5048 | 1051 | return kFALSE; |
1052 | } | |
1053 | ||
966f6939 | 1054 | // Fill the digits object in the tree |
1055 | const AliTRDdigitsParam *kDigitsParam = fDigitsParam; | |
1056 | if (!kDigitsParam) | |
b65e5048 | 1057 | { |
966f6939 | 1058 | return kFALSE; |
b65e5048 | 1059 | } |
966f6939 | 1060 | branch->SetAddress(&kDigitsParam); |
1061 | branch->Fill(); | |
b65e5048 | 1062 | |
966f6939 | 1063 | return kTRUE; |
ca21baaa | 1064 | |
1065 | } | |
966f6939 | 1066 |