]>
Commit | Line | Data |
---|---|---|
4c039060 | 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$ | |
dd9a6ee3 | 18 | Revision 1.7 2000/06/08 18:32:58 cblume |
19 | Make code compliant to coding conventions | |
20 | ||
8230f242 | 21 | Revision 1.6 2000/05/08 15:48:30 cblume |
22 | Resolved merge conflict | |
23 | ||
9583ab1c | 24 | Revision 1.4.2.2 2000/05/08 14:50:58 cblume |
25 | Add functions ProjRow(), ProjCol(), and ProjTime() | |
26 | ||
27 | Revision 1.4.2.1 2000/04/27 12:47:02 cblume | |
28 | Replace Fill3() by Fill() | |
29 | ||
1befd3b2 | 30 | Revision 1.4 2000/02/28 19:10:26 cblume |
31 | Include the new TRD classes | |
32 | ||
851d3db9 | 33 | Revision 1.3.4.1 2000/02/28 17:57:47 cblume |
34 | GetTrack returns now -1 if no track is found | |
35 | ||
36 | Revision 1.3 1999/10/04 14:48:07 fca | |
37 | Avoid warnings on non-ansi compiler HP-UX CC | |
38 | ||
7d83513f | 39 | Revision 1.2 1999/09/29 09:24:35 fca |
40 | Introduction of the Copyright and cvs Log | |
41 | ||
4c039060 | 42 | */ |
43 | ||
99d5402e | 44 | /////////////////////////////////////////////////////////////////////////////// |
45 | // // | |
46 | // Contains the pixel information for one TRD chamber // | |
47 | // // | |
48 | /////////////////////////////////////////////////////////////////////////////// | |
49 | ||
50 | #include "AliTRDmatrix.h" | |
51 | ||
52 | ClassImp(AliTRDmatrix) | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | AliTRDmatrix::AliTRDmatrix():TObject() | |
56 | { | |
57 | // | |
58 | // Create a TRD detector matrix | |
59 | // | |
60 | ||
61 | fRow = 0; | |
62 | fCol = 0; | |
63 | fTime = 0; | |
64 | fPixel = 0; | |
65 | fSector = 0; | |
66 | fChamber = 0; | |
67 | fPlane = 0; | |
68 | fPixelArray = NULL; | |
69 | ||
70 | } | |
71 | ||
72 | //_____________________________________________________________________________ | |
73 | AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime | |
74 | , Int_t iSec, Int_t iCha, Int_t iPla) | |
75 | :TObject() | |
76 | { | |
77 | // | |
78 | // Create a TRD detector matrix with a given size | |
79 | // | |
80 | ||
81 | fRow = nRow; | |
82 | fCol = nCol; | |
83 | fTime = nTime; | |
84 | fPixel = nRow * nCol * nTime; | |
85 | fSector = iSec; | |
86 | fChamber = iCha; | |
87 | fPlane = iPla; | |
88 | fPixelArray = new TObjArray(fPixel); | |
89 | for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) { | |
90 | AliTRDpixel *pixel = new AliTRDpixel(); | |
91 | fPixelArray->Add(pixel); | |
92 | } | |
93 | ||
94 | } | |
95 | ||
8230f242 | 96 | //_____________________________________________________________________________ |
dd9a6ee3 | 97 | AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m) |
8230f242 | 98 | { |
99 | // | |
100 | // AliTRDmatrix copy constructor | |
101 | // | |
102 | ||
dd9a6ee3 | 103 | ((AliTRDmatrix &) m).Copy(*this); |
8230f242 | 104 | |
105 | } | |
106 | ||
99d5402e | 107 | //_____________________________________________________________________________ |
108 | AliTRDmatrix::~AliTRDmatrix() | |
109 | { | |
8230f242 | 110 | // |
111 | // AliTRDmatrix destructor | |
112 | // | |
99d5402e | 113 | |
114 | if (fPixelArray) { | |
115 | fPixelArray->Delete(); | |
116 | delete fPixelArray; | |
117 | } | |
118 | ||
119 | } | |
120 | ||
dd9a6ee3 | 121 | //_____________________________________________________________________________ |
122 | AliTRDmatrix &AliTRDmatrix::operator=(const AliTRDmatrix &m) | |
123 | { | |
124 | // | |
125 | // Assignment operator | |
126 | // | |
127 | ||
128 | if (this != &m) ((AliTRDmatrix &) m).Copy(*this); | |
129 | return *this; | |
130 | ||
131 | } | |
132 | ||
99d5402e | 133 | //_____________________________________________________________________________ |
134 | void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal) | |
135 | { | |
136 | // | |
137 | // Add a value to the amplitude of the signal for one specific pixel | |
138 | // | |
139 | ||
140 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
141 | if (pixel) { | |
142 | signal += pixel->GetSignal(); | |
143 | pixel->SetSignal(signal); | |
144 | } | |
145 | ||
146 | } | |
147 | ||
8230f242 | 148 | //_____________________________________________________________________________ |
dd9a6ee3 | 149 | void AliTRDmatrix::Copy(TObject &m) |
8230f242 | 150 | { |
151 | // | |
152 | // Copy function | |
153 | // | |
154 | ||
dd9a6ee3 | 155 | ((AliTRDmatrix &) m).fRow = fRow; |
156 | ((AliTRDmatrix &) m).fCol = fCol; | |
157 | ((AliTRDmatrix &) m).fTime = fTime; | |
158 | ((AliTRDmatrix &) m).fPixel = fPixel; | |
159 | ((AliTRDmatrix &) m).fSector = fSector; | |
160 | ((AliTRDmatrix &) m).fChamber = fChamber; | |
161 | ((AliTRDmatrix &) m).fPlane = fPlane; | |
8230f242 | 162 | |
dd9a6ee3 | 163 | ((AliTRDmatrix &) m).fPixelArray = new TObjArray(*fPixelArray); |
8230f242 | 164 | |
165 | } | |
166 | ||
99d5402e | 167 | //_____________________________________________________________________________ |
7d83513f | 168 | void AliTRDmatrix::Draw(Option_t *) |
99d5402e | 169 | { |
170 | // | |
171 | // Draws a 3D view of the detector matrix | |
172 | // | |
173 | ||
174 | Char_t ctitle[50]; | |
175 | sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)" | |
176 | ,fSector,fChamber,fPlane); | |
177 | TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5 | |
178 | ,fCol ,-0.5,fCol +0.5 | |
179 | ,fTime,-0.5,fTime+0.5); | |
180 | ||
181 | for (Int_t iRow = 0; iRow < fRow; iRow++ ) { | |
182 | for (Int_t iCol = 0; iCol < fCol; iCol++ ) { | |
183 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
184 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
1befd3b2 | 185 | if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal()); |
99d5402e | 186 | } |
187 | } | |
188 | } | |
189 | ||
190 | gStyle->SetOptStat(0); | |
191 | TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view" | |
192 | ,50,50,600,400); | |
193 | cMatrix->ToggleEventStatus(); | |
194 | hMatrix->SetXTitle("Pad-row (z)"); | |
195 | hMatrix->SetYTitle("Pad-column (rphi)"); | |
196 | hMatrix->SetZTitle("Timebucket"); | |
197 | hMatrix->Draw("BOX"); | |
198 | ||
199 | } | |
200 | ||
201 | //_____________________________________________________________________________ | |
202 | void AliTRDmatrix::DrawRow(Int_t iRow) | |
203 | { | |
204 | // | |
205 | // Draws a 2D slice of the detector matrix along one row | |
206 | // | |
207 | ||
208 | if ((iRow < 0) || (iRow >= fRow)) { | |
851d3db9 | 209 | printf("AliTRDmatrix::DrawRow -- "); |
99d5402e | 210 | printf("Index out of bounds (%d/%d)\n",iRow,fRow); |
211 | return; | |
212 | } | |
213 | ||
214 | Char_t ctitle[50]; | |
215 | sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)" | |
216 | ,iRow,fSector,fChamber,fPlane); | |
217 | TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5 | |
218 | ,fTime,-0.5,fTime+0.5); | |
219 | ||
220 | for (Int_t iCol = 0; iCol < fCol; iCol++ ) { | |
221 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
222 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
223 | if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal()); | |
224 | } | |
225 | } | |
226 | ||
227 | gStyle->SetOptStat(0); | |
228 | TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice" | |
229 | ,50,50,600,400); | |
230 | cSliceRow->ToggleEventStatus(); | |
231 | hSliceRow->SetXTitle("Pad-column (rphi)"); | |
232 | hSliceRow->SetYTitle("Timebucket"); | |
233 | hSliceRow->Draw("COLZ"); | |
234 | ||
235 | } | |
236 | ||
237 | //_____________________________________________________________________________ | |
238 | void AliTRDmatrix::DrawCol(Int_t iCol) | |
239 | { | |
240 | // | |
241 | // Draws a 2D slice of the detector matrix along one column | |
242 | // | |
243 | ||
244 | if ((iCol < 0) || (iCol >= fCol)) { | |
851d3db9 | 245 | printf("AliTRDmatrix::DrawCol -- "); |
99d5402e | 246 | printf("Index out of bounds (%d/%d)\n",iCol,fCol); |
247 | return; | |
248 | } | |
249 | ||
250 | Char_t ctitle[50]; | |
251 | sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)" | |
252 | ,iCol,fSector,fChamber,fPlane); | |
253 | TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5 | |
254 | ,fTime,-0.5,fTime+0.5); | |
255 | ||
256 | for (Int_t iRow = 0; iRow < fRow; iRow++ ) { | |
257 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
258 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
259 | if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal()); | |
260 | } | |
261 | } | |
262 | ||
263 | gStyle->SetOptStat(0); | |
264 | TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice" | |
265 | ,50,50,600,400); | |
266 | cSliceCol->ToggleEventStatus(); | |
267 | hSliceCol->SetXTitle("Pad-row (z)"); | |
268 | hSliceCol->SetYTitle("Timebucket"); | |
269 | hSliceCol->Draw("COLZ"); | |
270 | ||
271 | } | |
272 | ||
273 | //_____________________________________________________________________________ | |
274 | void AliTRDmatrix::DrawTime(Int_t iTime) | |
275 | { | |
276 | // | |
277 | // Draws a 2D slice of the detector matrix along one time slice | |
278 | // | |
279 | ||
280 | if ((iTime < 0) || (iTime >= fTime)) { | |
851d3db9 | 281 | printf("AliTRDmatrix::DrawTime -- "); |
99d5402e | 282 | printf("Index out of bounds (%d/%d)\n",iTime,fTime); |
283 | return; | |
284 | } | |
285 | ||
286 | Char_t ctitle[50]; | |
287 | sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)" | |
288 | ,iTime,fSector,fChamber,fPlane); | |
289 | TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5 | |
290 | ,fCol,-0.5,fCol+0.5); | |
291 | ||
292 | for (Int_t iRow = 0; iRow < fRow; iRow++) { | |
293 | for (Int_t iCol = 0; iCol < fCol; iCol++) { | |
294 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
295 | if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal()); | |
296 | } | |
297 | } | |
298 | ||
299 | gStyle->SetOptStat(0); | |
300 | TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice" | |
301 | ,50,50,600,400); | |
302 | cSliceTime->ToggleEventStatus(); | |
303 | hSliceTime->SetXTitle("Pad-row (z)"); | |
304 | hSliceTime->SetYTitle("Pad-column (rphi)"); | |
305 | hSliceTime->Draw("COLZ"); | |
306 | ||
307 | } | |
308 | ||
9583ab1c | 309 | //_____________________________________________________________________________ |
310 | void AliTRDmatrix::ProjRow() | |
311 | { | |
312 | // | |
313 | // Projects the detector matrix along the row-axis | |
314 | // | |
315 | ||
316 | Char_t ctitle[60]; | |
317 | sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)" | |
318 | ,fSector,fChamber,fPlane); | |
319 | TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol +0.5 | |
320 | ,fTime,-0.5,fTime+0.5); | |
321 | ||
322 | for (Int_t iRow = 0; iRow < fRow; iRow++ ) { | |
323 | for (Int_t iCol = 0; iCol < fCol; iCol++ ) { | |
324 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
325 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
326 | if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal()); | |
327 | } | |
328 | } | |
329 | } | |
330 | ||
331 | gStyle->SetOptStat(0); | |
332 | TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection" | |
333 | ,50,50,600,400); | |
334 | cProjRow->ToggleEventStatus(); | |
335 | hProjRow->SetXTitle("Pad-column (rphi)"); | |
336 | hProjRow->SetYTitle("Timebucket"); | |
337 | hProjRow->Draw("COLZ"); | |
338 | ||
339 | } | |
340 | ||
341 | //_____________________________________________________________________________ | |
342 | void AliTRDmatrix::ProjCol() | |
343 | { | |
344 | // | |
345 | // Projects the detector matrix along the column-axis | |
346 | // | |
347 | ||
348 | Char_t ctitle[60]; | |
349 | sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)" | |
350 | ,fSector,fChamber,fPlane); | |
351 | TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow +0.5 | |
352 | ,fTime,-0.5,fTime+0.5); | |
353 | ||
354 | for (Int_t iRow = 0; iRow < fRow; iRow++ ) { | |
355 | for (Int_t iCol = 0; iCol < fCol; iCol++ ) { | |
356 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
357 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
358 | if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal()); | |
359 | } | |
360 | } | |
361 | } | |
362 | ||
363 | gStyle->SetOptStat(0); | |
364 | TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection" | |
365 | ,50,50,600,400); | |
366 | cProjCol->ToggleEventStatus(); | |
367 | hProjCol->SetXTitle("Pad-row (z)"); | |
368 | hProjCol->SetYTitle("Timebucket"); | |
369 | hProjCol->Draw("COLZ"); | |
370 | ||
371 | } | |
372 | ||
373 | //_____________________________________________________________________________ | |
374 | void AliTRDmatrix::ProjTime() | |
375 | { | |
376 | // | |
377 | // Projects the detector matrix along the time-axis | |
378 | // | |
379 | ||
380 | Char_t ctitle[60]; | |
381 | sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)" | |
382 | ,fSector,fChamber,fPlane); | |
383 | TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow+0.5 | |
384 | ,fCol,-0.5,fCol+0.5); | |
385 | ||
386 | for (Int_t iRow = 0; iRow < fRow; iRow++) { | |
387 | for (Int_t iCol = 0; iCol < fCol; iCol++) { | |
388 | for (Int_t iTime = 0; iTime < fTime; iTime++) { | |
389 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
390 | if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal()); | |
391 | } | |
392 | } | |
393 | } | |
394 | ||
395 | gStyle->SetOptStat(0); | |
396 | TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection" | |
397 | ,50,50,600,400); | |
398 | cProjTime->ToggleEventStatus(); | |
399 | hProjTime->SetXTitle("Pad-row (z)"); | |
400 | hProjTime->SetYTitle("Pad-column (rphi)"); | |
401 | hProjTime->Draw("COLZ"); | |
402 | ||
403 | } | |
404 | ||
99d5402e | 405 | //_____________________________________________________________________________ |
406 | void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal) | |
407 | { | |
408 | // | |
409 | // Set the amplitude of the signal for one specific pixel | |
410 | // | |
411 | ||
412 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
413 | if (pixel) { | |
414 | pixel->SetSignal(signal); | |
415 | } | |
416 | ||
417 | } | |
418 | ||
419 | //_____________________________________________________________________________ | |
420 | Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track) | |
421 | { | |
422 | // | |
423 | // Add this track number to the stored tracks passing through this pixel. | |
424 | // If there are already three stored the return status is FALSE. | |
425 | // | |
426 | ||
427 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
428 | if (!(pixel)) return kTRUE; | |
429 | ||
430 | Bool_t trackSet = kFALSE; | |
431 | for (Int_t i = 0; i < kTrackPixel; i++) { | |
432 | if (pixel->GetTrack(i) == track) { | |
433 | trackSet = kTRUE; | |
434 | break; | |
435 | } | |
851d3db9 | 436 | if (pixel->GetTrack(i) == -1) { |
99d5402e | 437 | pixel->SetTrack(i,track); |
438 | trackSet = kTRUE; | |
439 | break; | |
440 | } | |
441 | } | |
442 | ||
443 | return trackSet; | |
444 | ||
445 | } | |
446 | ||
447 | //_____________________________________________________________________________ | |
448 | void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime | |
449 | , Int_t iTrack, Int_t track) | |
450 | { | |
451 | // | |
452 | // Store the number of a track which is passing through this pixel | |
453 | // | |
454 | ||
455 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
456 | if (pixel) { | |
457 | pixel->SetTrack(iTrack,track); | |
458 | } | |
459 | ||
460 | } | |
461 | ||
462 | //_____________________________________________________________________________ | |
463 | Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime) | |
464 | { | |
465 | // | |
466 | // Returns the amplitude of the signal for one specific pixel | |
467 | // | |
468 | ||
469 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
470 | if (pixel) { | |
471 | return (pixel->GetSignal()); | |
472 | } | |
473 | else { | |
474 | return 0; | |
475 | } | |
476 | ||
477 | } | |
478 | ||
479 | //_____________________________________________________________________________ | |
480 | Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack) | |
481 | { | |
482 | // | |
483 | // Returns the numbers of the tracks passing through one specific pixel | |
484 | // | |
485 | ||
486 | if ((iTrack < 0) || (iTrack >= kTrackPixel)) { | |
851d3db9 | 487 | printf("AliTRDmatrix::GetTrack -- "); |
488 | printf("Index out of bounds (%d)\n",iTrack); | |
489 | return -1; | |
99d5402e | 490 | } |
491 | ||
492 | AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime); | |
493 | if (pixel) { | |
494 | return (pixel->GetTrack(iTrack)); | |
495 | } | |
496 | else { | |
851d3db9 | 497 | return -1; |
99d5402e | 498 | } |
499 | ||
500 | } | |
501 | ||
502 | //_____________________________________________________________________________ | |
503 | Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime) | |
504 | { | |
505 | ||
506 | if ((iRow >= 0) && (iRow < fRow ) && | |
507 | (iCol >= 0) && (iCol < fCol ) && | |
508 | (iTime >= 0) && (iTime < fTime)) { | |
509 | return (iTime + iCol * fTime + iRow * fTime * fCol); | |
510 | } | |
511 | else { | |
512 | return -1; | |
513 | } | |
514 | ||
515 | } | |
516 | ||
517 | //_____________________________________________________________________________ | |
518 | AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime) | |
519 | { | |
520 | ||
521 | Int_t iPixel = GetIndex(iRow,iCol,iTime); | |
522 | if (iPixel < 0) { | |
523 | return NULL; | |
524 | } | |
525 | else { | |
526 | return ((AliTRDpixel *) fPixelArray->At(iPixel)); | |
527 | } | |
528 | ||
529 | } |