]>
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 // | |
21 | // AliTRDdataArray objects. // | |
22 | // // | |
23 | /////////////////////////////////////////////////////////////////////////////// | |
6244debe | 24 | |
a2cb5b3d | 25 | #include <Riostream.h> |
793ff80c | 26 | |
2ab0c725 | 27 | #include <TROOT.h> |
793ff80c | 28 | #include <TTree.h> |
2ab0c725 | 29 | #include <TFile.h> |
94de3818 | 30 | |
6f1e466d | 31 | #include "AliRun.h" |
32 | ||
33 | #include "AliTRDdigitsManager.h" | |
793ff80c | 34 | #include "AliTRDsegmentArray.h" |
35 | #include "AliTRDdataArrayI.h" | |
36 | #include "AliTRDdigit.h" | |
37 | #include "AliTRDgeometry.h" | |
6f1e466d | 38 | |
39 | ClassImp(AliTRDdigitsManager) | |
40 | ||
793ff80c | 41 | //_____________________________________________________________________________ |
42 | ||
43 | // Number of track dictionary arrays | |
44 | const Int_t AliTRDdigitsManager::fgkNDict = kNDict; | |
45 | ||
6f1e466d | 46 | //_____________________________________________________________________________ |
47 | AliTRDdigitsManager::AliTRDdigitsManager():TObject() | |
48 | { | |
49 | // | |
50 | // Default constructor | |
51 | // | |
52 | ||
abaf1f1d | 53 | fIsRaw = kFALSE; |
54 | fEvent = 0; | |
855bfffd | 55 | fDebug = 0; |
abaf1f1d | 56 | fSDigits = 0; |
6f1e466d | 57 | |
abaf1f1d | 58 | fTree = NULL; |
59 | fDigits = NULL; | |
6f1e466d | 60 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { |
abaf1f1d | 61 | fDictionary[iDict] = NULL; |
6f1e466d | 62 | } |
63 | ||
64 | } | |
65 | ||
8230f242 | 66 | //_____________________________________________________________________________ |
dd9a6ee3 | 67 | AliTRDdigitsManager::AliTRDdigitsManager(const AliTRDdigitsManager &m) |
73ae7b59 | 68 | :TObject(m) |
8230f242 | 69 | { |
70 | // | |
71 | // AliTRDdigitsManager copy constructor | |
72 | // | |
73 | ||
dd9a6ee3 | 74 | ((AliTRDdigitsManager &) m).Copy(*this); |
8230f242 | 75 | |
76 | } | |
77 | ||
6f1e466d | 78 | //_____________________________________________________________________________ |
79 | AliTRDdigitsManager::~AliTRDdigitsManager() | |
80 | { | |
8230f242 | 81 | // |
82 | // AliTRDdigitsManager destructor | |
83 | // | |
6f1e466d | 84 | |
85 | if (fDigits) { | |
86 | fDigits->Delete(); | |
87 | delete fDigits; | |
abaf1f1d | 88 | fDigits = NULL; |
6f1e466d | 89 | } |
90 | ||
91 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
92 | fDictionary[iDict]->Delete(); | |
93 | delete fDictionary[iDict]; | |
abaf1f1d | 94 | fDictionary[iDict] = NULL; |
6f1e466d | 95 | } |
96 | ||
97 | } | |
98 | ||
8230f242 | 99 | //_____________________________________________________________________________ |
e0d47c25 | 100 | void AliTRDdigitsManager::Copy(TObject &m) const |
8230f242 | 101 | { |
102 | // | |
103 | // Copy function | |
104 | // | |
105 | ||
abaf1f1d | 106 | ((AliTRDdigitsManager &) m).fIsRaw = fIsRaw; |
107 | ((AliTRDdigitsManager &) m).fEvent = fEvent; | |
855bfffd | 108 | ((AliTRDdigitsManager &) m).fDebug = fDebug; |
abaf1f1d | 109 | ((AliTRDdigitsManager &) m).fSDigits = fSDigits; |
8230f242 | 110 | |
111 | TObject::Copy(m); | |
112 | ||
113 | } | |
114 | ||
abaf1f1d | 115 | //_____________________________________________________________________________ |
116 | void AliTRDdigitsManager::CreateArrays() | |
117 | { | |
118 | // | |
119 | // Create the data arrays | |
120 | // | |
121 | ||
122 | fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); | |
123 | ||
124 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
125 | fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" | |
126 | ,AliTRDgeometry::Ndet()); | |
127 | } | |
128 | ||
17eee78a | 129 | } |
130 | //_____________________________________________________________________________ | |
131 | void AliTRDdigitsManager::ResetArrays() | |
132 | { | |
133 | // | |
134 | // Reset the data arrays | |
135 | // | |
136 | ||
137 | if (fDigits) { | |
138 | delete fDigits; | |
139 | } | |
140 | fDigits = new AliTRDsegmentArray("AliTRDdataArrayI",AliTRDgeometry::Ndet()); | |
141 | ||
142 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
143 | if (fDictionary[iDict]) { | |
144 | delete fDictionary[iDict]; | |
145 | } | |
146 | fDictionary[iDict] = new AliTRDsegmentArray("AliTRDdataArrayI" | |
147 | ,AliTRDgeometry::Ndet()); | |
148 | } | |
149 | ||
abaf1f1d | 150 | } |
151 | ||
6f1e466d | 152 | //_____________________________________________________________________________ |
153 | void AliTRDdigitsManager::SetRaw() | |
154 | { | |
0a29d0f1 | 155 | // |
156 | // Switch on the raw digits flag | |
157 | // | |
6f1e466d | 158 | |
159 | fIsRaw = kTRUE; | |
698b2e52 | 160 | if (fDigits) |
161 | fDigits->SetBit(AliTRDdigit::RawDigit()); | |
6f1e466d | 162 | |
163 | } | |
164 | ||
16bf9884 | 165 | //_____________________________________________________________________________ |
166 | Short_t AliTRDdigitsManager::GetDigitAmp(Int_t row, Int_t col,Int_t time | |
167 | , Int_t det) const | |
168 | { | |
169 | // | |
170 | // Returns the amplitude of a digit | |
171 | // | |
172 | ||
698b2e52 | 173 | if (!GetDigits(det)) return 0; |
16bf9884 | 174 | return ((Short_t) GetDigits(det)->GetData(row,col,time)); |
175 | ||
176 | } | |
177 | ||
6f1e466d | 178 | //_____________________________________________________________________________ |
88cb7938 | 179 | Bool_t AliTRDdigitsManager::MakeBranch(TTree *tree) |
855bfffd | 180 | { |
181 | // | |
182 | // Creates the tree and branches for the digits and the dictionary | |
183 | // | |
184 | ||
185 | Int_t buffersize = 64000; | |
186 | ||
187 | Bool_t status = kTRUE; | |
188 | ||
855bfffd | 189 | if (tree) { |
190 | fTree = tree; | |
191 | } | |
192 | ||
abaf1f1d | 193 | // Make the branch for the digits |
194 | if (fDigits) { | |
195 | const AliTRDdataArray *kDigits = (AliTRDdataArray *) fDigits->At(0); | |
196 | if (kDigits) { | |
bdbb05bb | 197 | if (!fTree) return kFALSE; |
198 | TBranch* branch = fTree->GetBranch("TRDdigits"); | |
199 | if (!branch) fTree->Branch("TRDdigits",kDigits->IsA()->GetName(), | |
200 | &kDigits,buffersize,99); | |
855bfffd | 201 | if (fDebug > 0) { |
202 | printf("<AliTRDdigitsManager::MakeBranch> "); | |
6f1e466d | 203 | printf("Making branch TRDdigits\n"); |
204 | } | |
6f1e466d | 205 | } |
206 | else { | |
207 | status = kFALSE; | |
208 | } | |
abaf1f1d | 209 | } |
210 | else { | |
211 | status = kFALSE; | |
212 | } | |
6f1e466d | 213 | |
abaf1f1d | 214 | // Make the branches for the dictionaries |
215 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
216 | Char_t branchname[15]; | |
217 | sprintf(branchname,"TRDdictionary%d",iDict); | |
218 | if (fDictionary[iDict]) { | |
219 | const AliTRDdataArray *kDictionary = | |
220 | (AliTRDdataArray *) fDictionary[iDict]->At(0); | |
221 | if (kDictionary) { | |
bdbb05bb | 222 | if (!fTree) return kFALSE; |
223 | TBranch* branch = fTree->GetBranch(branchname); | |
224 | if (!branch) fTree->Branch(branchname,kDictionary->IsA()->GetName(), | |
225 | &kDictionary,buffersize,99); | |
855bfffd | 226 | if (fDebug > 0) { |
227 | printf("<AliTRDdigitsManager::MakeBranch> "); | |
6f1e466d | 228 | printf("Making branch %s\n",branchname); |
6244debe | 229 | } |
6f1e466d | 230 | } |
231 | else { | |
232 | status = kFALSE; | |
233 | } | |
234 | } | |
abaf1f1d | 235 | else { |
236 | status = kFALSE; | |
237 | } | |
6f1e466d | 238 | } |
239 | ||
240 | return status; | |
241 | ||
242 | } | |
243 | ||
244 | //_____________________________________________________________________________ | |
855bfffd | 245 | Bool_t AliTRDdigitsManager::ReadDigits(TTree *tree) |
6f1e466d | 246 | { |
8230f242 | 247 | // |
248 | // Reads the digit information from the input file | |
249 | // | |
6f1e466d | 250 | |
251 | Bool_t status = kTRUE; | |
252 | ||
855bfffd | 253 | if (tree) { |
254 | ||
255 | fTree = tree; | |
256 | ||
abaf1f1d | 257 | } |
258 | ||
259 | if (!fDigits) { | |
855bfffd | 260 | if (fDebug > 0) { |
261 | printf("<AliTRDdigitsManager::ReadDigits> "); | |
abaf1f1d | 262 | printf("Create the data arrays.\n"); |
263 | } | |
264 | CreateArrays(); | |
265 | } | |
266 | ||
267 | status = fDigits->LoadArray("TRDdigits",fTree); | |
6f1e466d | 268 | |
269 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
270 | Char_t branchname[15]; | |
271 | sprintf(branchname,"TRDdictionary%d",iDict); | |
abaf1f1d | 272 | status = fDictionary[iDict]->LoadArray(branchname,fTree); |
6f1e466d | 273 | } |
274 | ||
793ff80c | 275 | if (fDigits->TestBit(AliTRDdigit::RawDigit())) { |
6f1e466d | 276 | fIsRaw = kTRUE; |
277 | } | |
278 | else { | |
279 | fIsRaw = kFALSE; | |
280 | } | |
281 | ||
282 | return kTRUE; | |
283 | ||
284 | } | |
285 | ||
286 | //_____________________________________________________________________________ | |
287 | Bool_t AliTRDdigitsManager::WriteDigits() | |
288 | { | |
289 | // | |
290 | // Writes out the TRD-digits and the dictionaries | |
291 | // | |
292 | ||
6f1e466d | 293 | // Store the contents of the segment array in the tree |
abaf1f1d | 294 | if (!fDigits->StoreArray("TRDdigits",fTree)) { |
855bfffd | 295 | printf("<AliTRDdigitsManager::WriteDigits> "); |
6f1e466d | 296 | printf("Error while storing digits in branch TRDdigits\n"); |
297 | return kFALSE; | |
298 | } | |
299 | for (Int_t iDict = 0; iDict < kNDict; iDict++) { | |
300 | Char_t branchname[15]; | |
301 | sprintf(branchname,"TRDdictionary%d",iDict); | |
abaf1f1d | 302 | if (!fDictionary[iDict]->StoreArray(branchname,fTree)) { |
855bfffd | 303 | printf("<AliTRDdigitsManager::WriteDigits> "); |
6f1e466d | 304 | printf("Error while storing dictionary in branch %s\n",branchname); |
305 | return kFALSE; | |
306 | } | |
307 | } | |
308 | ||
abaf1f1d | 309 | // Write the new tree to the output file |
8e64dd77 | 310 | //fTree->Write(); |
311 | fTree->AutoSave(); // Modification by Jiri | |
abaf1f1d | 312 | |
6f1e466d | 313 | return kTRUE; |
314 | ||
315 | } | |
9d0b222b | 316 | |
317 | //_____________________________________________________________________________ | |
318 | AliTRDdigit *AliTRDdigitsManager::GetDigit(Int_t row, Int_t col | |
793ff80c | 319 | , Int_t time, Int_t det) const |
9d0b222b | 320 | { |
321 | // | |
322 | // Creates a single digit object | |
323 | // | |
324 | ||
325 | Int_t digits[4]; | |
326 | Int_t amp[1]; | |
327 | ||
328 | digits[0] = det; | |
329 | digits[1] = row; | |
330 | digits[2] = col; | |
331 | digits[3] = time; | |
332 | ||
333 | amp[0] = GetDigits(det)->GetData(row,col,time); | |
334 | ||
335 | return (new AliTRDdigit(fIsRaw,digits,amp)); | |
336 | ||
337 | } | |
338 | ||
339 | //_____________________________________________________________________________ | |
340 | Int_t AliTRDdigitsManager::GetTrack(Int_t track | |
341 | , Int_t row, Int_t col, Int_t time | |
793ff80c | 342 | , Int_t det) const |
9d0b222b | 343 | { |
344 | // | |
345 | // Returns the MC-track numbers from the dictionary. | |
346 | // | |
347 | ||
348 | if ((track < 0) || (track >= kNDict)) { | |
349 | TObject::Error("GetTracks" | |
350 | ,"track %d out of bounds (size: %d, this: 0x%08x)" | |
351 | ,track,kNDict,this); | |
352 | return -1; | |
353 | } | |
354 | ||
355 | // Array contains index+1 to allow data compression | |
356 | return (GetDictionary(det,track)->GetData(row,col,time) - 1); | |
357 | ||
358 | } | |
359 | ||
dd9a6ee3 | 360 | //_____________________________________________________________________________ |
793ff80c | 361 | AliTRDdataArrayI *AliTRDdigitsManager::GetDigits(Int_t det) const |
dd9a6ee3 | 362 | { |
363 | // | |
364 | // Returns the digits array for one detector | |
365 | // | |
366 | ||
698b2e52 | 367 | if (!fDigits) return 0x0; |
dd9a6ee3 | 368 | return (AliTRDdataArrayI *) fDigits->At(det); |
369 | ||
370 | } | |
371 | ||
372 | //_____________________________________________________________________________ | |
793ff80c | 373 | AliTRDdataArrayI *AliTRDdigitsManager::GetDictionary(Int_t det, Int_t i) const |
dd9a6ee3 | 374 | { |
375 | // | |
376 | // Returns the dictionary for one detector | |
377 | // | |
378 | ||
379 | return (AliTRDdataArrayI *) fDictionary[i]->At(det); | |
380 | ||
381 | } | |
382 | ||
383 | //_____________________________________________________________________________ | |
793ff80c | 384 | Int_t AliTRDdigitsManager::GetTrack(Int_t track, AliTRDdigit *Digit) const |
dd9a6ee3 | 385 | { |
386 | // | |
387 | // Returns the MC-track numbers from the dictionary for a given digit | |
388 | // | |
389 | ||
390 | Int_t row = Digit->GetRow(); | |
391 | Int_t col = Digit->GetCol(); | |
392 | Int_t time = Digit->GetTime(); | |
393 | Int_t det = Digit->GetDetector(); | |
394 | ||
395 | return GetTrack(track,row,col,time,det); | |
396 | ||
397 | } | |
398 | ||
399 | //_____________________________________________________________________________ | |
400 | AliTRDdigitsManager &AliTRDdigitsManager::operator=(const AliTRDdigitsManager &m) | |
401 | { | |
402 | // | |
403 | // Assignment operator | |
404 | // | |
405 | ||
406 | if (this != &m) ((AliTRDdigitsManager &) m).Copy(*this); | |
407 | return *this; | |
408 | ||
409 | } |