]>
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$ | |
abaf1f1d | 18 | Revision 1.13 2001/11/06 17:19:41 cblume |
19 | Add detailed geometry and simple simulator | |
20 | ||
16bf9884 | 21 | Revision 1.12 2001/05/16 14:57:28 alibrary |
22 | New files for folders and Stack | |
23 | ||
9e1a0ddb | 24 | Revision 1.11 2001/03/13 09:30:35 cblume |
25 | Update of digitization. Moved digit branch definition to AliTRD | |
26 | ||
6244debe | 27 | Revision 1.10 2001/01/26 19:56:57 hristov |
28 | Major upgrade of AliRoot code | |
29 | ||
2ab0c725 | 30 | Revision 1.9 2000/11/02 09:25:53 cblume |
31 | Change also the dictionary to AliTRDdataArray | |
32 | ||
4d6586ef | 33 | Revision 1.8 2000/11/01 15:20:13 cblume |
34 | Change AliTRDdataArrayI to AliTRDdataArray in MakeBranch() | |
35 | ||
06754153 | 36 | Revision 1.7 2000/11/01 14:53:20 cblume |
37 | Merge with TRD-develop | |
38 | ||
793ff80c | 39 | Revision 1.1.2.5 2000/10/17 02:27:34 cblume |
40 | Get rid of global constants | |
41 | ||
42 | Revision 1.1.2.4 2000/10/15 23:40:01 cblume | |
43 | Remove AliTRDconst | |
44 | ||
45 | Revision 1.1.2.3 2000/10/06 16:49:46 cblume | |
46 | Made Getters const | |
47 | ||
48 | Revision 1.1.2.2 2000/10/04 16:34:58 cblume | |
49 | Replace include files by forward declarations | |
50 | ||
94de3818 | 51 | Revision 1.5 2000/06/09 11:10:07 cblume |
52 | Compiler warnings and coding conventions, next round | |
53 | ||
dd9a6ee3 | 54 | Revision 1.4 2000/06/08 18:32:58 cblume |
55 | Make code compliant to coding conventions | |
56 | ||
8230f242 | 57 | Revision 1.3 2000/06/07 16:27:01 cblume |
58 | Try to remove compiler warnings on Sun and HP | |
59 | ||
9d0b222b | 60 | Revision 1.2 2000/05/08 16:17:27 cblume |
61 | Merge TRD-develop | |
62 | ||
6f1e466d | 63 | Revision 1.1.2.1 2000/05/08 14:44:01 cblume |
64 | Add new class AliTRDdigitsManager | |
65 | ||
66 | */ | |
67 | ||
68 | /////////////////////////////////////////////////////////////////////////////// | |
69 | // // | |
70 | // Manages the digits and the track dictionary in the form of // | |
71 | // AliTRDdataArray objects. // | |
72 | // // | |
73 | /////////////////////////////////////////////////////////////////////////////// | |
6244debe | 74 | |
2ab0c725 | 75 | #include <iostream.h> |
793ff80c | 76 | |
2ab0c725 | 77 | #include <TROOT.h> |
793ff80c | 78 | #include <TTree.h> |
2ab0c725 | 79 | #include <TFile.h> |
94de3818 | 80 | |
6f1e466d | 81 | #include "AliRun.h" |
82 | ||
83 | #include "AliTRDdigitsManager.h" | |
793ff80c | 84 | #include "AliTRDsegmentArray.h" |
85 | #include "AliTRDdataArrayI.h" | |
86 | #include "AliTRDdigit.h" | |
87 | #include "AliTRDgeometry.h" | |
9e1a0ddb | 88 | #include "AliTRD.h" |
6f1e466d | 89 | |
90 | ClassImp(AliTRDdigitsManager) | |
91 | ||
793ff80c | 92 | //_____________________________________________________________________________ |
93 | ||
94 | // Number of track dictionary arrays | |
95 | const Int_t AliTRDdigitsManager::fgkNDict = kNDict; | |
96 | ||
6f1e466d | 97 | //_____________________________________________________________________________ |
98 | AliTRDdigitsManager::AliTRDdigitsManager():TObject() | |
99 | { | |
100 | // | |
101 | // Default constructor | |
102 | // | |
103 | ||
abaf1f1d | 104 | fIsRaw = kFALSE; |
105 | fEvent = 0; | |
106 | fVerbose = 0; | |
107 | fSDigits = 0; | |
6f1e466d | 108 | |
abaf1f1d | 109 | fFile = NULL; |
110 | fTree = NULL; | |
111 | fDigits = NULL; | |
6f1e466d | 112 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { |
abaf1f1d | 113 | fDictionary[iDict] = NULL; |
6f1e466d | 114 | } |
115 | ||
116 | } | |
117 | ||
8230f242 | 118 | //_____________________________________________________________________________ |
dd9a6ee3 | 119 | AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) |
8230f242 | 120 | { |
121 | // | |
122 | // AliTRDdigitsManager copy constructor | |
123 | // | |
124 | ||
dd9a6ee3 | 125 | ((AliTRDdigitsManager &) m).Copy(*this); |
8230f242 | 126 | |
127 | } | |
128 | ||
6f1e466d | 129 | //_____________________________________________________________________________ |
130 | AliTRDdigitsManager::~AliTRDdigitsManager() | |
131 | { | |
8230f242 | 132 | // |
133 | // AliTRDdigitsManager destructor | |
134 | // | |
6f1e466d | 135 | |
abaf1f1d | 136 | if (fFile) { |
137 | fFile->Close(); | |
138 | delete fFile; | |
139 | fFile = NULL; | |
140 | } | |
141 | ||
142 | if (fTree) { | |
143 | delete fTree; | |
144 | fTree = NULL; | |
145 | } | |
146 | ||
6f1e466d | 147 | if (fDigits) { |
148 | fDigits->Delete(); | |
149 | delete fDigits; | |
abaf1f1d | 150 | fDigits = NULL; |
6f1e466d | 151 | } |
152 | ||
153 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
154 | fDictionary[iDict]->Delete(); | |
155 | delete fDictionary[iDict]; | |
abaf1f1d | 156 | fDictionary[iDict] = NULL; |
6f1e466d | 157 | } |
158 | ||
159 | } | |
160 | ||
8230f242 | 161 | //_____________________________________________________________________________ |
dd9a6ee3 | 162 | void AliTRDdigitsManager::Copy(TObject &m) |
8230f242 | 163 | { |
164 | // | |
165 | // Copy function | |
166 | // | |
167 | ||
abaf1f1d | 168 | ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; |
169 | ((AliTRDdigitsManager &) m).fEvent = fEvent; | |
170 | ((AliTRDdigitsManager &) m).fVerbose = fVerbose; | |
171 | ((AliTRDdigitsManager &) m).fSDigits = fSDigits; | |
8230f242 | 172 | |
173 | TObject::Copy(m); | |
174 | ||
175 | } | |
176 | ||
abaf1f1d | 177 | //_____________________________________________________________________________ |
178 | void AliTRDdigitsManager::CreateArrays() | |
179 | { | |
180 | // | |
181 | // Create the data arrays | |
182 | // | |
183 | ||
184 | fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); | |
185 | ||
186 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
187 | fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" | |
188 | ,AliTRDgeometry::Ndet()); | |
189 | } | |
190 | ||
191 | } | |
192 | ||
6f1e466d | 193 | //_____________________________________________________________________________ |
194 | void AliTRDdigitsManager::SetRaw() | |
195 | { | |
196 | ||
197 | fIsRaw = kTRUE; | |
198 | ||
793ff80c | 199 | fDigits->SetBit(AliTRDdigit::RawDigit()); |
6f1e466d | 200 | |
201 | } | |
202 | ||
16bf9884 | 203 | //_____________________________________________________________________________ |
204 | Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time | |
205 | , Int_t det) const | |
206 | { | |
207 | // | |
208 | // Returns the amplitude of a digit | |
209 | // | |
210 | ||
211 | return ((Short_t) GetDigits(det)->GetData(row,col,time)); | |
212 | ||
213 | } | |
214 | ||
6f1e466d | 215 | //_____________________________________________________________________________ |
abaf1f1d | 216 | Bool_t AliTRDdigitsManager::Open(const Char_t *name) |
6f1e466d | 217 | { |
218 | // | |
abaf1f1d | 219 | // Opens the file for the TRD digits |
220 | // | |
221 | ||
222 | fFile = (TFile*) gROOT->GetListOfFiles()->FindObject(name); | |
223 | if (!fFile) { | |
224 | if (fVerbose > 0) { | |
225 | printf("AliTRDdigitsManager::Open -- "); | |
226 | printf("Open the AliROOT-file %s.\n",name); | |
227 | } | |
228 | fFile = new TFile(name,"UPDATE"); | |
229 | if (!fFile) return kFALSE; | |
230 | } | |
231 | else { | |
232 | if (fVerbose > 0) { | |
233 | printf("AliTRDdigitsManager::Open -- "); | |
234 | printf("%s is already open.\n",name); | |
235 | } | |
236 | } | |
237 | ||
238 | return kTRUE; | |
239 | ||
240 | } | |
241 | ||
242 | //_____________________________________________________________________________ | |
243 | Bool_t AliTRDdigitsManager::MakeBranch(const Char_t *file) | |
244 | { | |
245 | // | |
246 | // Creates the tree and branches for the digits and the dictionary | |
6f1e466d | 247 | // |
248 | ||
249 | Int_t buffersize = 64000; | |
250 | ||
251 | Bool_t status = kTRUE; | |
252 | ||
abaf1f1d | 253 | AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD") ; |
2ab0c725 | 254 | |
abaf1f1d | 255 | // Create the TRD digits tree |
256 | Char_t treeName[12]; | |
257 | if (fSDigits) { | |
258 | sprintf(treeName,"TreeS%d_TRD",fEvent); | |
259 | fTree = new TTree(treeName,"TRD SDigits"); | |
260 | } | |
261 | else { | |
262 | sprintf(treeName,"TreeD%d_TRD",fEvent); | |
263 | fTree = new TTree(treeName,"TRD Digits"); | |
264 | } | |
9e1a0ddb | 265 | |
abaf1f1d | 266 | if (fVerbose > 0) { |
267 | printf("AliTRDdigitsManager::MakeBranch -- "); | |
268 | printf("Creating tree %s\n",treeName); | |
269 | } | |
6f1e466d | 270 | |
abaf1f1d | 271 | // Make the branch for the digits |
272 | if (fDigits) { | |
273 | const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0); | |
274 | if (kDigits) { | |
275 | trd->MakeBranchInTree(fTree,"TRDdigits",kDigits->IsA()->GetName() | |
276 | ,&kDigits,buffersize,99,file); | |
277 | if (fVerbose > 0) { | |
6f1e466d | 278 | printf("AliTRDdigitsManager::MakeBranch -- "); |
279 | printf("Making branch TRDdigits\n"); | |
280 | } | |
6f1e466d | 281 | } |
282 | else { | |
283 | status = kFALSE; | |
284 | } | |
abaf1f1d | 285 | } |
286 | else { | |
287 | status = kFALSE; | |
288 | } | |
6f1e466d | 289 | |
abaf1f1d | 290 | // Make the branches for the dictionaries |
291 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
292 | Char_t branchname[15]; | |
293 | sprintf(branchname,"TRDdictionary%d",iDict); | |
294 | if (fDictionary[iDict]) { | |
295 | const AliTRDdataArray *kDictionary = | |
296 | (AliTRDdataArray *) fDictionary[iDict]->At(0); | |
297 | if (kDictionary) { | |
298 | trd->MakeBranchInTree(fTree,branchname,kDictionary->IsA()->GetName() | |
299 | ,&kDictionary,buffersize,99,file); | |
300 | if (fVerbose > 0) { | |
6f1e466d | 301 | printf("AliTRDdigitsManager::MakeBranch -- "); |
302 | printf("Making branch %s\n",branchname); | |
6244debe | 303 | } |
6f1e466d | 304 | } |
305 | else { | |
306 | status = kFALSE; | |
307 | } | |
308 | } | |
abaf1f1d | 309 | else { |
310 | status = kFALSE; | |
311 | } | |
6f1e466d | 312 | } |
313 | ||
314 | return status; | |
315 | ||
316 | } | |
317 | ||
318 | //_____________________________________________________________________________ | |
319 | Bool_t AliTRDdigitsManager::ReadDigits() | |
320 | { | |
8230f242 | 321 | // |
322 | // Reads the digit information from the input file | |
323 | // | |
6f1e466d | 324 | |
325 | Bool_t status = kTRUE; | |
326 | ||
abaf1f1d | 327 | // Get the digits tree |
328 | Char_t treeName[12]; | |
329 | if (fSDigits) { | |
330 | sprintf(treeName,"TreeS%d_TRD",fEvent); | |
331 | } | |
332 | else { | |
333 | sprintf(treeName,"TreeD%d_TRD",fEvent); | |
334 | } | |
335 | if (fFile) { | |
336 | fTree = (TTree *) fFile->Get(treeName); | |
337 | } | |
338 | else { | |
339 | fTree = (TTree *) gDirectory->Get(treeName); | |
340 | } | |
341 | if (!fTree) { | |
342 | if (fVerbose > 0) { | |
343 | printf("AliTRDdigitsManager::ReadDigits -- "); | |
344 | printf("Could not find tree %s.\n",treeName); | |
345 | } | |
346 | return kFALSE; | |
347 | } | |
348 | ||
349 | if (!fDigits) { | |
350 | if (fVerbose > 0) { | |
351 | printf("AliTRDdigitsManager::ReadDigits -- "); | |
352 | printf("Create the data arrays.\n"); | |
353 | } | |
354 | CreateArrays(); | |
355 | } | |
356 | ||
357 | status = fDigits->LoadArray("TRDdigits",fTree); | |
6f1e466d | 358 | |
359 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
360 | Char_t branchname[15]; | |
361 | sprintf(branchname,"TRDdictionary%d",iDict); | |
abaf1f1d | 362 | status = fDictionary[iDict]->LoadArray(branchname,fTree); |
6f1e466d | 363 | } |
364 | ||
793ff80c | 365 | if (fDigits->TestBit(AliTRDdigit::RawDigit())) { |
6f1e466d | 366 | fIsRaw = kTRUE; |
367 | } | |
368 | else { | |
369 | fIsRaw = kFALSE; | |
370 | } | |
371 | ||
372 | return kTRUE; | |
373 | ||
374 | } | |
375 | ||
376 | //_____________________________________________________________________________ | |
377 | Bool_t AliTRDdigitsManager::WriteDigits() | |
378 | { | |
379 | // | |
380 | // Writes out the TRD-digits and the dictionaries | |
381 | // | |
382 | ||
6f1e466d | 383 | // Store the contents of the segment array in the tree |
abaf1f1d | 384 | if (!fDigits->StoreArray("TRDdigits",fTree)) { |
6f1e466d | 385 | printf("AliTRDdigitsManager::WriteDigits -- "); |
386 | printf("Error while storing digits in branch TRDdigits\n"); | |
387 | return kFALSE; | |
388 | } | |
389 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
390 | Char_t branchname[15]; | |
391 | sprintf(branchname,"TRDdictionary%d",iDict); | |
abaf1f1d | 392 | if (!fDictionary[iDict]->StoreArray(branchname,fTree)) { |
6f1e466d | 393 | printf("AliTRDdigitsManager::WriteDigits -- "); |
394 | printf("Error while storing dictionary in branch %s\n",branchname); | |
395 | return kFALSE; | |
396 | } | |
397 | } | |
398 | ||
abaf1f1d | 399 | // Write the new tree to the output file |
400 | fTree->Write(); | |
401 | ||
6f1e466d | 402 | return kTRUE; |
403 | ||
404 | } | |
9d0b222b | 405 | |
406 | //_____________________________________________________________________________ | |
407 | AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col | |
793ff80c | 408 | , Int_t time, Int_t det) const |
9d0b222b | 409 | { |
410 | // | |
411 | // Creates a single digit object | |
412 | // | |
413 | ||
414 | Int_t digits[4]; | |
415 | Int_t amp[1]; | |
416 | ||
417 | digits[0] = det; | |
418 | digits[1] = row; | |
419 | digits[2] = col; | |
420 | digits[3] = time; | |
421 | ||
422 | amp[0] = GetDigits(det)->GetData(row,col,time); | |
423 | ||
424 | return (new AliTRDdigit(fIsRaw,digits,amp)); | |
425 | ||
426 | } | |
427 | ||
428 | //_____________________________________________________________________________ | |
429 | Int_t AliTRDdigitsManager::GetTrack(Int_t track | |
430 | , Int_t row, Int_t col, Int_t time | |
793ff80c | 431 | , Int_t det) const |
9d0b222b | 432 | { |
433 | // | |
434 | // Returns the MC-track numbers from the dictionary. | |
435 | // | |
436 | ||
437 | if ((track < 0) || (track >= kNDict)) { | |
438 | TObject::Error("GetTracks" | |
439 | ,"track %d out of bounds (size: %d, this: 0x%08x)" | |
440 | ,track,kNDict,this); | |
441 | return -1; | |
442 | } | |
443 | ||
444 | // Array contains index+1 to allow data compression | |
445 | return (GetDictionary(det,track)->GetData(row,col,time) - 1); | |
446 | ||
447 | } | |
448 | ||
dd9a6ee3 | 449 | //_____________________________________________________________________________ |
793ff80c | 450 | AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const |
dd9a6ee3 | 451 | { |
452 | // | |
453 | // Returns the digits array for one detector | |
454 | // | |
455 | ||
456 | return (AliTRDdataArrayI *) fDigits->At(det); | |
457 | ||
458 | } | |
459 | ||
460 | //_____________________________________________________________________________ | |
793ff80c | 461 | AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const |
dd9a6ee3 | 462 | { |
463 | // | |
464 | // Returns the dictionary for one detector | |
465 | // | |
466 | ||
467 | return (AliTRDdataArrayI *) fDictionary[i]->At(det); | |
468 | ||
469 | } | |
470 | ||
471 | //_____________________________________________________________________________ | |
793ff80c | 472 | Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const |
dd9a6ee3 | 473 | { |
474 | // | |
475 | // Returns the MC-track numbers from the dictionary for a given digit | |
476 | // | |
477 | ||
478 | Int_t row = Digit->GetRow(); | |
479 | Int_t col = Digit->GetCol(); | |
480 | Int_t time = Digit->GetTime(); | |
481 | Int_t det = Digit->GetDetector(); | |
482 | ||
483 | return GetTrack(track,row,col,time,det); | |
484 | ||
485 | } | |
486 | ||
487 | //_____________________________________________________________________________ | |
488 | AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m) | |
489 | { | |
490 | // | |
491 | // Assignment operator | |
492 | // | |
493 | ||
494 | if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this); | |
495 | return *this; | |
496 | ||
497 | } |