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 ///////////////////////////////////////////////////////////////////////////////
20 // Contains the pixel information for one TRD chamber //
23 ///////////////////////////////////////////////////////////////////////////////
25 #include <TObjArray.h>
31 #include "AliTRDmatrix.h"
32 #include "AliTRDpixel.h"
34 ClassImp(AliTRDmatrix)
36 //_____________________________________________________________________________
37 AliTRDmatrix::AliTRDmatrix():TObject()
40 // Create a TRD detector matrix
54 //_____________________________________________________________________________
55 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
56 , Int_t iSec, Int_t iCha, Int_t iPla)
60 // Create a TRD detector matrix with a given size
66 fPixel = nRow * nCol * nTime;
70 fPixelArray = new TObjArray(fPixel);
71 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
72 AliTRDpixel *pixel = new AliTRDpixel();
73 fPixelArray->Add(pixel);
78 //_____________________________________________________________________________
79 AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m):TObject(m)
82 // AliTRDmatrix copy constructor
85 ((AliTRDmatrix &) m).Copy(*this);
89 //_____________________________________________________________________________
90 AliTRDmatrix::~AliTRDmatrix()
93 // AliTRDmatrix destructor
97 fPixelArray->Delete();
103 //_____________________________________________________________________________
104 AliTRDmatrix &AliTRDmatrix::operator=(const AliTRDmatrix &m)
107 // Assignment operator
110 if (this != &m) ((AliTRDmatrix &) m).Copy(*this);
115 //_____________________________________________________________________________
116 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
119 // Add a value to the amplitude of the signal for one specific pixel
122 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
124 signal += pixel->GetSignal();
125 pixel->SetSignal(signal);
130 //_____________________________________________________________________________
131 void AliTRDmatrix::Copy(TObject &m) const
137 ((AliTRDmatrix &) m).fRow = fRow;
138 ((AliTRDmatrix &) m).fCol = fCol;
139 ((AliTRDmatrix &) m).fTime = fTime;
140 ((AliTRDmatrix &) m).fPixel = fPixel;
141 ((AliTRDmatrix &) m).fSector = fSector;
142 ((AliTRDmatrix &) m).fChamber = fChamber;
143 ((AliTRDmatrix &) m).fPlane = fPlane;
145 ((AliTRDmatrix &) m).fPixelArray = new TObjArray(*fPixelArray);
149 //_____________________________________________________________________________
150 void AliTRDmatrix::Draw(Option_t *)
153 // Draws a 3D view of the detector matrix
157 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
158 ,fSector,fChamber,fPlane);
159 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow -0.5
160 ,fCol ,-0.5,fCol -0.5
161 ,fTime,-0.5,fTime-0.5);
163 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
164 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
165 for (Int_t iTime = 0; iTime < fTime; iTime++) {
166 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
167 if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
172 gStyle->SetOptStat(0);
173 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
175 cMatrix->ToggleEventStatus();
176 hMatrix->SetXTitle("Pad-row (z)");
177 hMatrix->SetYTitle("Pad-column (rphi)");
178 hMatrix->SetZTitle("Timebucket");
179 hMatrix->Draw("BOX");
183 //_____________________________________________________________________________
184 void AliTRDmatrix::DrawRow(Int_t iRow)
187 // Draws a 2D slice of the detector matrix along one row
190 if ((iRow < 0) || (iRow >= fRow)) {
191 printf("AliTRDmatrix::DrawRow -- ");
192 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
197 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
198 ,iRow,fSector,fChamber,fPlane);
199 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol -0.5
200 ,fTime,-0.5,fTime-0.5);
202 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
203 for (Int_t iTime = 0; iTime < fTime; iTime++) {
204 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
205 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
209 gStyle->SetOptStat(0);
210 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
212 cSliceRow->ToggleEventStatus();
213 hSliceRow->SetXTitle("Pad-column (rphi)");
214 hSliceRow->SetYTitle("Timebucket");
215 hSliceRow->Draw("COLZ");
219 //_____________________________________________________________________________
220 void AliTRDmatrix::DrawCol(Int_t iCol)
223 // Draws a 2D slice of the detector matrix along one column
226 if ((iCol < 0) || (iCol >= fCol)) {
227 printf("AliTRDmatrix::DrawCol -- ");
228 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
233 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
234 ,iCol,fSector,fChamber,fPlane);
235 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow -0.5
236 ,fTime,-0.5,fTime-0.5);
238 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
239 for (Int_t iTime = 0; iTime < fTime; iTime++) {
240 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
241 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
245 gStyle->SetOptStat(0);
246 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
248 cSliceCol->ToggleEventStatus();
249 hSliceCol->SetXTitle("Pad-row (z)");
250 hSliceCol->SetYTitle("Timebucket");
251 hSliceCol->Draw("COLZ");
255 //_____________________________________________________________________________
256 void AliTRDmatrix::DrawTime(Int_t iTime)
259 // Draws a 2D slice of the detector matrix along one time slice
262 if ((iTime < 0) || (iTime >= fTime)) {
263 printf("AliTRDmatrix::DrawTime -- ");
264 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
269 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
270 ,iTime,fSector,fChamber,fPlane);
271 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow-0.5
272 ,fCol,-0.5,fCol-0.5);
274 for (Int_t iRow = 0; iRow < fRow; iRow++) {
275 for (Int_t iCol = 0; iCol < fCol; iCol++) {
276 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
277 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
281 gStyle->SetOptStat(0);
282 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
284 cSliceTime->ToggleEventStatus();
285 hSliceTime->SetXTitle("Pad-row (z)");
286 hSliceTime->SetYTitle("Pad-column (rphi)");
287 hSliceTime->Draw("COLZ");
291 //_____________________________________________________________________________
292 void AliTRDmatrix::ProjRow()
295 // Projects the detector matrix along the row-axis
299 sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)"
300 ,fSector,fChamber,fPlane);
301 TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol -0.5
302 ,fTime,-0.5,fTime-0.5);
304 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
305 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
306 for (Int_t iTime = 0; iTime < fTime; iTime++) {
307 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
308 if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal());
313 gStyle->SetOptStat(0);
314 TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection"
316 cProjRow->ToggleEventStatus();
317 hProjRow->SetXTitle("Pad-column (rphi)");
318 hProjRow->SetYTitle("Timebucket");
319 hProjRow->Draw("COLZ");
323 //_____________________________________________________________________________
324 void AliTRDmatrix::ProjCol()
327 // Projects the detector matrix along the column-axis
331 sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)"
332 ,fSector,fChamber,fPlane);
333 TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow -0.5
334 ,fTime,-0.5,fTime-0.5);
336 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
337 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
338 for (Int_t iTime = 0; iTime < fTime; iTime++) {
339 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
340 if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal());
345 gStyle->SetOptStat(0);
346 TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection"
348 cProjCol->ToggleEventStatus();
349 hProjCol->SetXTitle("Pad-row (z)");
350 hProjCol->SetYTitle("Timebucket");
351 hProjCol->Draw("COLZ");
355 //_____________________________________________________________________________
356 void AliTRDmatrix::ProjTime()
359 // Projects the detector matrix along the time-axis
363 sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)"
364 ,fSector,fChamber,fPlane);
365 TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow-0.5
366 ,fCol,-0.5,fCol-0.5);
368 for (Int_t iRow = 0; iRow < fRow; iRow++) {
369 for (Int_t iCol = 0; iCol < fCol; iCol++) {
370 for (Int_t iTime = 0; iTime < fTime; iTime++) {
371 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
372 if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal());
377 gStyle->SetOptStat(0);
378 TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection"
380 cProjTime->ToggleEventStatus();
381 hProjTime->SetXTitle("Pad-row (z)");
382 hProjTime->SetYTitle("Pad-column (rphi)");
383 hProjTime->Draw("COLZ");
387 //_____________________________________________________________________________
388 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
391 // Set the amplitude of the signal for one specific pixel
394 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
396 pixel->SetSignal(signal);
401 //_____________________________________________________________________________
402 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
405 // Add this track number to the stored tracks passing through this pixel.
406 // If there are already three stored the return status is FALSE.
409 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
410 if (!(pixel)) return kTRUE;
412 Bool_t trackSet = kFALSE;
413 for (Int_t i = 0; i < AliTRDpixel::NTrackPixel(); i++) {
414 if (pixel->GetTrack(i) == track) {
418 if (pixel->GetTrack(i) == -1) {
419 pixel->SetTrack(i,track);
429 //_____________________________________________________________________________
430 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
431 , Int_t iTrack, Int_t track)
434 // Store the number of a track which is passing through this pixel
437 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
439 pixel->SetTrack(iTrack,track);
444 //_____________________________________________________________________________
445 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime) const
448 // Returns the amplitude of the signal for one specific pixel
451 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
453 return (pixel->GetSignal());
461 //_____________________________________________________________________________
462 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime
463 , Int_t iTrack) const
466 // Returns the numbers of the tracks passing through one specific pixel
469 if ((iTrack < 0) || (iTrack >= AliTRDpixel::NTrackPixel())) {
470 printf("AliTRDmatrix::GetTrack -- ");
471 printf("Index out of bounds (%d)\n",iTrack);
475 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
477 return (pixel->GetTrack(iTrack));
485 //_____________________________________________________________________________
486 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime) const
489 // Get the index of a given pixel
492 if ((iRow >= 0) && (iRow < fRow ) &&
493 (iCol >= 0) && (iCol < fCol ) &&
494 (iTime >= 0) && (iTime < fTime)) {
495 return (iTime + iCol * fTime + iRow * fTime * fCol);
503 //_____________________________________________________________________________
504 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime) const
510 Int_t iPixel = GetIndex(iRow,iCol,iTime);
515 return ((AliTRDpixel *) fPixelArray->At(iPixel));