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 **************************************************************************/
20 ///////////////////////////////////////////////////////////////////////////////
22 // Contains the pixel information for one TRD chamber //
24 ///////////////////////////////////////////////////////////////////////////////
26 #include "AliTRDmatrix.h"
28 ClassImp(AliTRDmatrix)
30 //_____________________________________________________________________________
31 AliTRDmatrix::AliTRDmatrix():TObject()
34 // Create a TRD detector matrix
48 //_____________________________________________________________________________
49 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
50 , Int_t iSec, Int_t iCha, Int_t iPla)
54 // Create a TRD detector matrix with a given size
60 fPixel = nRow * nCol * nTime;
64 fPixelArray = new TObjArray(fPixel);
65 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
66 AliTRDpixel *pixel = new AliTRDpixel();
67 fPixelArray->Add(pixel);
72 //_____________________________________________________________________________
73 AliTRDmatrix::~AliTRDmatrix()
77 fPixelArray->Delete();
83 //_____________________________________________________________________________
84 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
87 // Add a value to the amplitude of the signal for one specific pixel
90 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
92 signal += pixel->GetSignal();
93 pixel->SetSignal(signal);
98 //_____________________________________________________________________________
99 void AliTRDmatrix::Draw()
102 // Draws a 3D view of the detector matrix
106 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
107 ,fSector,fChamber,fPlane);
108 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5
109 ,fCol ,-0.5,fCol +0.5
110 ,fTime,-0.5,fTime+0.5);
112 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
113 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
114 for (Int_t iTime = 0; iTime < fTime; iTime++) {
115 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
116 if (pixel) hMatrix->Fill3(iRow,iCol,iTime,pixel->GetSignal());
121 gStyle->SetOptStat(0);
122 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
124 cMatrix->ToggleEventStatus();
125 hMatrix->SetXTitle("Pad-row (z)");
126 hMatrix->SetYTitle("Pad-column (rphi)");
127 hMatrix->SetZTitle("Timebucket");
128 hMatrix->Draw("BOX");
132 //_____________________________________________________________________________
133 void AliTRDmatrix::DrawRow(Int_t iRow)
136 // Draws a 2D slice of the detector matrix along one row
139 if ((iRow < 0) || (iRow >= fRow)) {
140 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
145 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
146 ,iRow,fSector,fChamber,fPlane);
147 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5
148 ,fTime,-0.5,fTime+0.5);
150 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
151 for (Int_t iTime = 0; iTime < fTime; iTime++) {
152 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
153 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
157 gStyle->SetOptStat(0);
158 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
160 cSliceRow->ToggleEventStatus();
161 hSliceRow->SetXTitle("Pad-column (rphi)");
162 hSliceRow->SetYTitle("Timebucket");
163 hSliceRow->Draw("COLZ");
167 //_____________________________________________________________________________
168 void AliTRDmatrix::DrawCol(Int_t iCol)
171 // Draws a 2D slice of the detector matrix along one column
174 if ((iCol < 0) || (iCol >= fCol)) {
175 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
180 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
181 ,iCol,fSector,fChamber,fPlane);
182 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5
183 ,fTime,-0.5,fTime+0.5);
185 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
186 for (Int_t iTime = 0; iTime < fTime; iTime++) {
187 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
188 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
192 gStyle->SetOptStat(0);
193 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
195 cSliceCol->ToggleEventStatus();
196 hSliceCol->SetXTitle("Pad-row (z)");
197 hSliceCol->SetYTitle("Timebucket");
198 hSliceCol->Draw("COLZ");
202 //_____________________________________________________________________________
203 void AliTRDmatrix::DrawTime(Int_t iTime)
206 // Draws a 2D slice of the detector matrix along one time slice
209 if ((iTime < 0) || (iTime >= fTime)) {
210 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
215 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
216 ,iTime,fSector,fChamber,fPlane);
217 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5
218 ,fCol,-0.5,fCol+0.5);
220 for (Int_t iRow = 0; iRow < fRow; iRow++) {
221 for (Int_t iCol = 0; iCol < fCol; iCol++) {
222 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
223 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
227 gStyle->SetOptStat(0);
228 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
230 cSliceTime->ToggleEventStatus();
231 hSliceTime->SetXTitle("Pad-row (z)");
232 hSliceTime->SetYTitle("Pad-column (rphi)");
233 hSliceTime->Draw("COLZ");
237 //_____________________________________________________________________________
238 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
241 // Set the amplitude of the signal for one specific pixel
244 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
246 pixel->SetSignal(signal);
251 //_____________________________________________________________________________
252 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
255 // Add this track number to the stored tracks passing through this pixel.
256 // If there are already three stored the return status is FALSE.
259 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
260 if (!(pixel)) return kTRUE;
262 Bool_t trackSet = kFALSE;
263 for (Int_t i = 0; i < kTrackPixel; i++) {
264 if (pixel->GetTrack(i) == track) {
268 if (pixel->GetTrack(i) == 0) {
269 pixel->SetTrack(i,track);
279 //_____________________________________________________________________________
280 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
281 , Int_t iTrack, Int_t track)
284 // Store the number of a track which is passing through this pixel
287 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
289 pixel->SetTrack(iTrack,track);
294 //_____________________________________________________________________________
295 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime)
298 // Returns the amplitude of the signal for one specific pixel
301 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
303 return (pixel->GetSignal());
311 //_____________________________________________________________________________
312 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
315 // Returns the numbers of the tracks passing through one specific pixel
318 if ((iTrack < 0) || (iTrack >= kTrackPixel)) {
319 printf("GetTrack: Index out of bounds (%d)\n",iTrack);
323 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
325 return (pixel->GetTrack(iTrack));
333 //_____________________________________________________________________________
334 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime)
337 if ((iRow >= 0) && (iRow < fRow ) &&
338 (iCol >= 0) && (iCol < fCol ) &&
339 (iTime >= 0) && (iTime < fTime)) {
340 return (iTime + iCol * fTime + iRow * fTime * fCol);
348 //_____________________________________________________________________________
349 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime)
352 Int_t iPixel = GetIndex(iRow,iCol,iTime);
357 return ((AliTRDpixel *) fPixelArray->At(iPixel));