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