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 2000/02/28 19:10:26 cblume
19 Include the new TRD classes
21 Revision 1.3.4.1 2000/02/28 17:57:47 cblume
22 GetTrack returns now -1 if no track is found
24 Revision 1.3 1999/10/04 14:48:07 fca
25 Avoid warnings on non-ansi compiler HP-UX CC
27 Revision 1.2 1999/09/29 09:24:35 fca
28 Introduction of the Copyright and cvs Log
32 ///////////////////////////////////////////////////////////////////////////////
34 // Contains the pixel information for one TRD chamber //
36 ///////////////////////////////////////////////////////////////////////////////
38 #include "AliTRDmatrix.h"
40 ClassImp(AliTRDmatrix)
42 //_____________________________________________________________________________
43 AliTRDmatrix::AliTRDmatrix():TObject()
46 // Create a TRD detector matrix
60 //_____________________________________________________________________________
61 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
62 , Int_t iSec, Int_t iCha, Int_t iPla)
66 // Create a TRD detector matrix with a given size
72 fPixel = nRow * nCol * nTime;
76 fPixelArray = new TObjArray(fPixel);
77 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
78 AliTRDpixel *pixel = new AliTRDpixel();
79 fPixelArray->Add(pixel);
84 //_____________________________________________________________________________
85 AliTRDmatrix::~AliTRDmatrix()
89 fPixelArray->Delete();
95 //_____________________________________________________________________________
96 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
99 // Add a value to the amplitude of the signal for one specific pixel
102 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
104 signal += pixel->GetSignal();
105 pixel->SetSignal(signal);
110 //_____________________________________________________________________________
111 void AliTRDmatrix::Draw(Option_t *)
114 // Draws a 3D view of the detector matrix
118 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
119 ,fSector,fChamber,fPlane);
120 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5
121 ,fCol ,-0.5,fCol +0.5
122 ,fTime,-0.5,fTime+0.5);
124 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
125 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
126 for (Int_t iTime = 0; iTime < fTime; iTime++) {
127 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
128 if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
133 gStyle->SetOptStat(0);
134 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
136 cMatrix->ToggleEventStatus();
137 hMatrix->SetXTitle("Pad-row (z)");
138 hMatrix->SetYTitle("Pad-column (rphi)");
139 hMatrix->SetZTitle("Timebucket");
140 hMatrix->Draw("BOX");
144 //_____________________________________________________________________________
145 void AliTRDmatrix::DrawRow(Int_t iRow)
148 // Draws a 2D slice of the detector matrix along one row
151 if ((iRow < 0) || (iRow >= fRow)) {
152 printf("AliTRDmatrix::DrawRow -- ");
153 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
158 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
159 ,iRow,fSector,fChamber,fPlane);
160 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5
161 ,fTime,-0.5,fTime+0.5);
163 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
164 for (Int_t iTime = 0; iTime < fTime; iTime++) {
165 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
166 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
170 gStyle->SetOptStat(0);
171 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
173 cSliceRow->ToggleEventStatus();
174 hSliceRow->SetXTitle("Pad-column (rphi)");
175 hSliceRow->SetYTitle("Timebucket");
176 hSliceRow->Draw("COLZ");
180 //_____________________________________________________________________________
181 void AliTRDmatrix::DrawCol(Int_t iCol)
184 // Draws a 2D slice of the detector matrix along one column
187 if ((iCol < 0) || (iCol >= fCol)) {
188 printf("AliTRDmatrix::DrawCol -- ");
189 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
194 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
195 ,iCol,fSector,fChamber,fPlane);
196 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5
197 ,fTime,-0.5,fTime+0.5);
199 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
200 for (Int_t iTime = 0; iTime < fTime; iTime++) {
201 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
202 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
206 gStyle->SetOptStat(0);
207 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
209 cSliceCol->ToggleEventStatus();
210 hSliceCol->SetXTitle("Pad-row (z)");
211 hSliceCol->SetYTitle("Timebucket");
212 hSliceCol->Draw("COLZ");
216 //_____________________________________________________________________________
217 void AliTRDmatrix::DrawTime(Int_t iTime)
220 // Draws a 2D slice of the detector matrix along one time slice
223 if ((iTime < 0) || (iTime >= fTime)) {
224 printf("AliTRDmatrix::DrawTime -- ");
225 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
230 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
231 ,iTime,fSector,fChamber,fPlane);
232 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5
233 ,fCol,-0.5,fCol+0.5);
235 for (Int_t iRow = 0; iRow < fRow; iRow++) {
236 for (Int_t iCol = 0; iCol < fCol; iCol++) {
237 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
238 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
242 gStyle->SetOptStat(0);
243 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
245 cSliceTime->ToggleEventStatus();
246 hSliceTime->SetXTitle("Pad-row (z)");
247 hSliceTime->SetYTitle("Pad-column (rphi)");
248 hSliceTime->Draw("COLZ");
252 //_____________________________________________________________________________
253 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
256 // Set the amplitude of the signal for one specific pixel
259 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
261 pixel->SetSignal(signal);
266 //_____________________________________________________________________________
267 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
270 // Add this track number to the stored tracks passing through this pixel.
271 // If there are already three stored the return status is FALSE.
274 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
275 if (!(pixel)) return kTRUE;
277 Bool_t trackSet = kFALSE;
278 for (Int_t i = 0; i < kTrackPixel; i++) {
279 if (pixel->GetTrack(i) == track) {
283 if (pixel->GetTrack(i) == -1) {
284 pixel->SetTrack(i,track);
294 //_____________________________________________________________________________
295 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
296 , Int_t iTrack, Int_t track)
299 // Store the number of a track which is passing through this pixel
302 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
304 pixel->SetTrack(iTrack,track);
309 //_____________________________________________________________________________
310 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime)
313 // Returns the amplitude of the signal for one specific pixel
316 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
318 return (pixel->GetSignal());
326 //_____________________________________________________________________________
327 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
330 // Returns the numbers of the tracks passing through one specific pixel
333 if ((iTrack < 0) || (iTrack >= kTrackPixel)) {
334 printf("AliTRDmatrix::GetTrack -- ");
335 printf("Index out of bounds (%d)\n",iTrack);
339 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
341 return (pixel->GetTrack(iTrack));
349 //_____________________________________________________________________________
350 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime)
353 if ((iRow >= 0) && (iRow < fRow ) &&
354 (iCol >= 0) && (iCol < fCol ) &&
355 (iTime >= 0) && (iTime < fTime)) {
356 return (iTime + iCol * fTime + iRow * fTime * fCol);
364 //_____________________________________________________________________________
365 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime)
368 Int_t iPixel = GetIndex(iRow,iCol,iTime);
373 return ((AliTRDpixel *) fPixelArray->At(iPixel));