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