1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.4.2.5 2000/10/17 02:27:34 cblume
19 Get rid of global constants
21 Revision 1.4.2.4 2000/10/06 16:49:46 cblume
24 Revision 1.4.2.3 2000/10/04 16:34:58 cblume
25 Replace include files by forward declarations
27 Revision 1.8 2000/06/09 11:10:07 cblume
28 Compiler warnings and coding conventions, next round
30 Revision 1.7 2000/06/08 18:32:58 cblume
31 Make code compliant to coding conventions
33 Revision 1.6 2000/05/08 15:48:30 cblume
34 Resolved merge conflict
36 Revision 1.4.2.2 2000/05/08 14:50:58 cblume
37 Add functions ProjRow(), ProjCol(), and ProjTime()
39 Revision 1.4.2.1 2000/04/27 12:47:02 cblume
40 Replace Fill3() by Fill()
42 Revision 1.4 2000/02/28 19:10:26 cblume
43 Include the new TRD classes
45 Revision 1.3.4.1 2000/02/28 17:57:47 cblume
46 GetTrack returns now -1 if no track is found
48 Revision 1.3 1999/10/04 14:48:07 fca
49 Avoid warnings on non-ansi compiler HP-UX CC
51 Revision 1.2 1999/09/29 09:24:35 fca
52 Introduction of the Copyright and cvs Log
56 ///////////////////////////////////////////////////////////////////////////////
58 // Contains the pixel information for one TRD chamber //
60 ///////////////////////////////////////////////////////////////////////////////
62 #include <TObjArray.h>
68 #include "AliTRDmatrix.h"
69 #include "AliTRDpixel.h"
71 ClassImp(AliTRDmatrix)
73 //_____________________________________________________________________________
74 AliTRDmatrix::AliTRDmatrix():TObject()
77 // Create a TRD detector matrix
91 //_____________________________________________________________________________
92 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
93 , Int_t iSec, Int_t iCha, Int_t iPla)
97 // Create a TRD detector matrix with a given size
103 fPixel = nRow * nCol * nTime;
107 fPixelArray = new TObjArray(fPixel);
108 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
109 AliTRDpixel *pixel = new AliTRDpixel();
110 fPixelArray->Add(pixel);
115 //_____________________________________________________________________________
116 AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m)
119 // AliTRDmatrix copy constructor
122 ((AliTRDmatrix &) m).Copy(*this);
126 //_____________________________________________________________________________
127 AliTRDmatrix::~AliTRDmatrix()
130 // AliTRDmatrix destructor
134 fPixelArray->Delete();
140 //_____________________________________________________________________________
141 AliTRDmatrix &AliTRDmatrix::operator=(const AliTRDmatrix &m)
144 // Assignment operator
147 if (this != &m) ((AliTRDmatrix &) m).Copy(*this);
152 //_____________________________________________________________________________
153 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
156 // Add a value to the amplitude of the signal for one specific pixel
159 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
161 signal += pixel->GetSignal();
162 pixel->SetSignal(signal);
167 //_____________________________________________________________________________
168 void AliTRDmatrix::Copy(TObject &m)
174 ((AliTRDmatrix &) m).fRow = fRow;
175 ((AliTRDmatrix &) m).fCol = fCol;
176 ((AliTRDmatrix &) m).fTime = fTime;
177 ((AliTRDmatrix &) m).fPixel = fPixel;
178 ((AliTRDmatrix &) m).fSector = fSector;
179 ((AliTRDmatrix &) m).fChamber = fChamber;
180 ((AliTRDmatrix &) m).fPlane = fPlane;
182 ((AliTRDmatrix &) m).fPixelArray = new TObjArray(*fPixelArray);
186 //_____________________________________________________________________________
187 void AliTRDmatrix::Draw(Option_t *)
190 // Draws a 3D view of the detector matrix
194 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
195 ,fSector,fChamber,fPlane);
196 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5
197 ,fCol ,-0.5,fCol +0.5
198 ,fTime,-0.5,fTime+0.5);
200 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
201 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
202 for (Int_t iTime = 0; iTime < fTime; iTime++) {
203 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
204 if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
209 gStyle->SetOptStat(0);
210 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
212 cMatrix->ToggleEventStatus();
213 hMatrix->SetXTitle("Pad-row (z)");
214 hMatrix->SetYTitle("Pad-column (rphi)");
215 hMatrix->SetZTitle("Timebucket");
216 hMatrix->Draw("BOX");
220 //_____________________________________________________________________________
221 void AliTRDmatrix::DrawRow(Int_t iRow)
224 // Draws a 2D slice of the detector matrix along one row
227 if ((iRow < 0) || (iRow >= fRow)) {
228 printf("AliTRDmatrix::DrawRow -- ");
229 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
234 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
235 ,iRow,fSector,fChamber,fPlane);
236 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5
237 ,fTime,-0.5,fTime+0.5);
239 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
240 for (Int_t iTime = 0; iTime < fTime; iTime++) {
241 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
242 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
246 gStyle->SetOptStat(0);
247 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
249 cSliceRow->ToggleEventStatus();
250 hSliceRow->SetXTitle("Pad-column (rphi)");
251 hSliceRow->SetYTitle("Timebucket");
252 hSliceRow->Draw("COLZ");
256 //_____________________________________________________________________________
257 void AliTRDmatrix::DrawCol(Int_t iCol)
260 // Draws a 2D slice of the detector matrix along one column
263 if ((iCol < 0) || (iCol >= fCol)) {
264 printf("AliTRDmatrix::DrawCol -- ");
265 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
270 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
271 ,iCol,fSector,fChamber,fPlane);
272 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5
273 ,fTime,-0.5,fTime+0.5);
275 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
276 for (Int_t iTime = 0; iTime < fTime; iTime++) {
277 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
278 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
282 gStyle->SetOptStat(0);
283 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
285 cSliceCol->ToggleEventStatus();
286 hSliceCol->SetXTitle("Pad-row (z)");
287 hSliceCol->SetYTitle("Timebucket");
288 hSliceCol->Draw("COLZ");
292 //_____________________________________________________________________________
293 void AliTRDmatrix::DrawTime(Int_t iTime)
296 // Draws a 2D slice of the detector matrix along one time slice
299 if ((iTime < 0) || (iTime >= fTime)) {
300 printf("AliTRDmatrix::DrawTime -- ");
301 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
306 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
307 ,iTime,fSector,fChamber,fPlane);
308 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5
309 ,fCol,-0.5,fCol+0.5);
311 for (Int_t iRow = 0; iRow < fRow; iRow++) {
312 for (Int_t iCol = 0; iCol < fCol; iCol++) {
313 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
314 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
318 gStyle->SetOptStat(0);
319 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
321 cSliceTime->ToggleEventStatus();
322 hSliceTime->SetXTitle("Pad-row (z)");
323 hSliceTime->SetYTitle("Pad-column (rphi)");
324 hSliceTime->Draw("COLZ");
328 //_____________________________________________________________________________
329 void AliTRDmatrix::ProjRow()
332 // Projects the detector matrix along the row-axis
336 sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)"
337 ,fSector,fChamber,fPlane);
338 TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol +0.5
339 ,fTime,-0.5,fTime+0.5);
341 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
342 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
343 for (Int_t iTime = 0; iTime < fTime; iTime++) {
344 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
345 if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal());
350 gStyle->SetOptStat(0);
351 TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection"
353 cProjRow->ToggleEventStatus();
354 hProjRow->SetXTitle("Pad-column (rphi)");
355 hProjRow->SetYTitle("Timebucket");
356 hProjRow->Draw("COLZ");
360 //_____________________________________________________________________________
361 void AliTRDmatrix::ProjCol()
364 // Projects the detector matrix along the column-axis
368 sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)"
369 ,fSector,fChamber,fPlane);
370 TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow +0.5
371 ,fTime,-0.5,fTime+0.5);
373 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
374 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
375 for (Int_t iTime = 0; iTime < fTime; iTime++) {
376 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
377 if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal());
382 gStyle->SetOptStat(0);
383 TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection"
385 cProjCol->ToggleEventStatus();
386 hProjCol->SetXTitle("Pad-row (z)");
387 hProjCol->SetYTitle("Timebucket");
388 hProjCol->Draw("COLZ");
392 //_____________________________________________________________________________
393 void AliTRDmatrix::ProjTime()
396 // Projects the detector matrix along the time-axis
400 sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)"
401 ,fSector,fChamber,fPlane);
402 TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow+0.5
403 ,fCol,-0.5,fCol+0.5);
405 for (Int_t iRow = 0; iRow < fRow; iRow++) {
406 for (Int_t iCol = 0; iCol < fCol; iCol++) {
407 for (Int_t iTime = 0; iTime < fTime; iTime++) {
408 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
409 if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal());
414 gStyle->SetOptStat(0);
415 TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection"
417 cProjTime->ToggleEventStatus();
418 hProjTime->SetXTitle("Pad-row (z)");
419 hProjTime->SetYTitle("Pad-column (rphi)");
420 hProjTime->Draw("COLZ");
424 //_____________________________________________________________________________
425 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
428 // Set the amplitude of the signal for one specific pixel
431 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
433 pixel->SetSignal(signal);
438 //_____________________________________________________________________________
439 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
442 // Add this track number to the stored tracks passing through this pixel.
443 // If there are already three stored the return status is FALSE.
446 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
447 if (!(pixel)) return kTRUE;
449 Bool_t trackSet = kFALSE;
450 for (Int_t i = 0; i < AliTRDpixel::NTrackPixel(); i++) {
451 if (pixel->GetTrack(i) == track) {
455 if (pixel->GetTrack(i) == -1) {
456 pixel->SetTrack(i,track);
466 //_____________________________________________________________________________
467 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
468 , Int_t iTrack, Int_t track)
471 // Store the number of a track which is passing through this pixel
474 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
476 pixel->SetTrack(iTrack,track);
481 //_____________________________________________________________________________
482 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime) const
485 // Returns the amplitude of the signal for one specific pixel
488 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
490 return (pixel->GetSignal());
498 //_____________________________________________________________________________
499 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime
500 , Int_t iTrack) const
503 // Returns the numbers of the tracks passing through one specific pixel
506 if ((iTrack < 0) || (iTrack >= AliTRDpixel::NTrackPixel())) {
507 printf("AliTRDmatrix::GetTrack -- ");
508 printf("Index out of bounds (%d)\n",iTrack);
512 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
514 return (pixel->GetTrack(iTrack));
522 //_____________________________________________________________________________
523 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime) const
526 if ((iRow >= 0) && (iRow < fRow ) &&
527 (iCol >= 0) && (iCol < fCol ) &&
528 (iTime >= 0) && (iTime < fTime)) {
529 return (iTime + iCol * fTime + iRow * fTime * fCol);
537 //_____________________________________________________________________________
538 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime) const
541 Int_t iPixel = GetIndex(iRow,iCol,iTime);
546 return ((AliTRDpixel *) fPixelArray->At(iPixel));