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