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.3.4.1 2000/02/28 17:57:47 cblume
19 GetTrack returns now -1 if no track is found
21 Revision 1.3 1999/10/04 14:48:07 fca
22 Avoid warnings on non-ansi compiler HP-UX CC
24 Revision 1.2 1999/09/29 09:24:35 fca
25 Introduction of the Copyright and cvs Log
29 ///////////////////////////////////////////////////////////////////////////////
31 // Contains the pixel information for one TRD chamber //
33 ///////////////////////////////////////////////////////////////////////////////
35 #include "AliTRDmatrix.h"
37 ClassImp(AliTRDmatrix)
39 //_____________________________________________________________________________
40 AliTRDmatrix::AliTRDmatrix():TObject()
43 // Create a TRD detector matrix
57 //_____________________________________________________________________________
58 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
59 , Int_t iSec, Int_t iCha, Int_t iPla)
63 // Create a TRD detector matrix with a given size
69 fPixel = nRow * nCol * nTime;
73 fPixelArray = new TObjArray(fPixel);
74 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
75 AliTRDpixel *pixel = new AliTRDpixel();
76 fPixelArray->Add(pixel);
81 //_____________________________________________________________________________
82 AliTRDmatrix::~AliTRDmatrix()
86 fPixelArray->Delete();
92 //_____________________________________________________________________________
93 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
96 // Add a value to the amplitude of the signal for one specific pixel
99 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
101 signal += pixel->GetSignal();
102 pixel->SetSignal(signal);
107 //_____________________________________________________________________________
108 void AliTRDmatrix::Draw(Option_t *)
111 // Draws a 3D view of the detector matrix
115 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
116 ,fSector,fChamber,fPlane);
117 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5
118 ,fCol ,-0.5,fCol +0.5
119 ,fTime,-0.5,fTime+0.5);
121 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
122 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
123 for (Int_t iTime = 0; iTime < fTime; iTime++) {
124 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
125 if (pixel) hMatrix->Fill3(iRow,iCol,iTime,pixel->GetSignal());
130 gStyle->SetOptStat(0);
131 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
133 cMatrix->ToggleEventStatus();
134 hMatrix->SetXTitle("Pad-row (z)");
135 hMatrix->SetYTitle("Pad-column (rphi)");
136 hMatrix->SetZTitle("Timebucket");
137 hMatrix->Draw("BOX");
141 //_____________________________________________________________________________
142 void AliTRDmatrix::DrawRow(Int_t iRow)
145 // Draws a 2D slice of the detector matrix along one row
148 if ((iRow < 0) || (iRow >= fRow)) {
149 printf("AliTRDmatrix::DrawRow -- ");
150 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
155 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
156 ,iRow,fSector,fChamber,fPlane);
157 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5
158 ,fTime,-0.5,fTime+0.5);
160 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
161 for (Int_t iTime = 0; iTime < fTime; iTime++) {
162 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
163 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
167 gStyle->SetOptStat(0);
168 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
170 cSliceRow->ToggleEventStatus();
171 hSliceRow->SetXTitle("Pad-column (rphi)");
172 hSliceRow->SetYTitle("Timebucket");
173 hSliceRow->Draw("COLZ");
177 //_____________________________________________________________________________
178 void AliTRDmatrix::DrawCol(Int_t iCol)
181 // Draws a 2D slice of the detector matrix along one column
184 if ((iCol < 0) || (iCol >= fCol)) {
185 printf("AliTRDmatrix::DrawCol -- ");
186 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
191 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
192 ,iCol,fSector,fChamber,fPlane);
193 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5
194 ,fTime,-0.5,fTime+0.5);
196 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
197 for (Int_t iTime = 0; iTime < fTime; iTime++) {
198 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
199 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
203 gStyle->SetOptStat(0);
204 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
206 cSliceCol->ToggleEventStatus();
207 hSliceCol->SetXTitle("Pad-row (z)");
208 hSliceCol->SetYTitle("Timebucket");
209 hSliceCol->Draw("COLZ");
213 //_____________________________________________________________________________
214 void AliTRDmatrix::DrawTime(Int_t iTime)
217 // Draws a 2D slice of the detector matrix along one time slice
220 if ((iTime < 0) || (iTime >= fTime)) {
221 printf("AliTRDmatrix::DrawTime -- ");
222 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
227 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
228 ,iTime,fSector,fChamber,fPlane);
229 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5
230 ,fCol,-0.5,fCol+0.5);
232 for (Int_t iRow = 0; iRow < fRow; iRow++) {
233 for (Int_t iCol = 0; iCol < fCol; iCol++) {
234 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
235 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
239 gStyle->SetOptStat(0);
240 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
242 cSliceTime->ToggleEventStatus();
243 hSliceTime->SetXTitle("Pad-row (z)");
244 hSliceTime->SetYTitle("Pad-column (rphi)");
245 hSliceTime->Draw("COLZ");
249 //_____________________________________________________________________________
250 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
253 // Set the amplitude of the signal for one specific pixel
256 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
258 pixel->SetSignal(signal);
263 //_____________________________________________________________________________
264 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
267 // Add this track number to the stored tracks passing through this pixel.
268 // If there are already three stored the return status is FALSE.
271 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
272 if (!(pixel)) return kTRUE;
274 Bool_t trackSet = kFALSE;
275 for (Int_t i = 0; i < kTrackPixel; i++) {
276 if (pixel->GetTrack(i) == track) {
280 if (pixel->GetTrack(i) == -1) {
281 pixel->SetTrack(i,track);
291 //_____________________________________________________________________________
292 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
293 , Int_t iTrack, Int_t track)
296 // Store the number of a track which is passing through this pixel
299 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
301 pixel->SetTrack(iTrack,track);
306 //_____________________________________________________________________________
307 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime)
310 // Returns the amplitude of the signal for one specific pixel
313 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
315 return (pixel->GetSignal());
323 //_____________________________________________________________________________
324 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
327 // Returns the numbers of the tracks passing through one specific pixel
330 if ((iTrack < 0) || (iTrack >= kTrackPixel)) {
331 printf("AliTRDmatrix::GetTrack -- ");
332 printf("Index out of bounds (%d)\n",iTrack);
336 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
338 return (pixel->GetTrack(iTrack));
346 //_____________________________________________________________________________
347 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime)
350 if ((iRow >= 0) && (iRow < fRow ) &&
351 (iCol >= 0) && (iCol < fCol ) &&
352 (iTime >= 0) && (iTime < fTime)) {
353 return (iTime + iCol * fTime + iRow * fTime * fCol);
361 //_____________________________________________________________________________
362 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime)
365 Int_t iPixel = GetIndex(iRow,iCol,iTime);
370 return ((AliTRDpixel *) fPixelArray->At(iPixel));