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.7 2000/06/08 18:32:58 cblume
19 Make code compliant to coding conventions
21 Revision 1.6 2000/05/08 15:48:30 cblume
22 Resolved merge conflict
24 Revision 1.4.2.2 2000/05/08 14:50:58 cblume
25 Add functions ProjRow(), ProjCol(), and ProjTime()
27 Revision 1.4.2.1 2000/04/27 12:47:02 cblume
28 Replace Fill3() by Fill()
30 Revision 1.4 2000/02/28 19:10:26 cblume
31 Include the new TRD classes
33 Revision 1.3.4.1 2000/02/28 17:57:47 cblume
34 GetTrack returns now -1 if no track is found
36 Revision 1.3 1999/10/04 14:48:07 fca
37 Avoid warnings on non-ansi compiler HP-UX CC
39 Revision 1.2 1999/09/29 09:24:35 fca
40 Introduction of the Copyright and cvs Log
44 ///////////////////////////////////////////////////////////////////////////////
46 // Contains the pixel information for one TRD chamber //
48 ///////////////////////////////////////////////////////////////////////////////
50 #include "AliTRDmatrix.h"
52 ClassImp(AliTRDmatrix)
54 //_____________________________________________________________________________
55 AliTRDmatrix::AliTRDmatrix():TObject()
58 // Create a TRD detector matrix
72 //_____________________________________________________________________________
73 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
74 , Int_t iSec, Int_t iCha, Int_t iPla)
78 // Create a TRD detector matrix with a given size
84 fPixel = nRow * nCol * nTime;
88 fPixelArray = new TObjArray(fPixel);
89 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
90 AliTRDpixel *pixel = new AliTRDpixel();
91 fPixelArray->Add(pixel);
96 //_____________________________________________________________________________
97 AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m)
100 // AliTRDmatrix copy constructor
103 ((AliTRDmatrix &) m).Copy(*this);
107 //_____________________________________________________________________________
108 AliTRDmatrix::~AliTRDmatrix()
111 // AliTRDmatrix destructor
115 fPixelArray->Delete();
121 //_____________________________________________________________________________
122 AliTRDmatrix &AliTRDmatrix::operator=(const AliTRDmatrix &m)
125 // Assignment operator
128 if (this != &m) ((AliTRDmatrix &) m).Copy(*this);
133 //_____________________________________________________________________________
134 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
137 // Add a value to the amplitude of the signal for one specific pixel
140 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
142 signal += pixel->GetSignal();
143 pixel->SetSignal(signal);
148 //_____________________________________________________________________________
149 void AliTRDmatrix::Copy(TObject &m)
155 ((AliTRDmatrix &) m).fRow = fRow;
156 ((AliTRDmatrix &) m).fCol = fCol;
157 ((AliTRDmatrix &) m).fTime = fTime;
158 ((AliTRDmatrix &) m).fPixel = fPixel;
159 ((AliTRDmatrix &) m).fSector = fSector;
160 ((AliTRDmatrix &) m).fChamber = fChamber;
161 ((AliTRDmatrix &) m).fPlane = fPlane;
163 ((AliTRDmatrix &) m).fPixelArray = new TObjArray(*fPixelArray);
167 //_____________________________________________________________________________
168 void AliTRDmatrix::Draw(Option_t *)
171 // Draws a 3D view of the detector matrix
175 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
176 ,fSector,fChamber,fPlane);
177 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5
178 ,fCol ,-0.5,fCol +0.5
179 ,fTime,-0.5,fTime+0.5);
181 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
182 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
183 for (Int_t iTime = 0; iTime < fTime; iTime++) {
184 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
185 if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
190 gStyle->SetOptStat(0);
191 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
193 cMatrix->ToggleEventStatus();
194 hMatrix->SetXTitle("Pad-row (z)");
195 hMatrix->SetYTitle("Pad-column (rphi)");
196 hMatrix->SetZTitle("Timebucket");
197 hMatrix->Draw("BOX");
201 //_____________________________________________________________________________
202 void AliTRDmatrix::DrawRow(Int_t iRow)
205 // Draws a 2D slice of the detector matrix along one row
208 if ((iRow < 0) || (iRow >= fRow)) {
209 printf("AliTRDmatrix::DrawRow -- ");
210 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
215 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
216 ,iRow,fSector,fChamber,fPlane);
217 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5
218 ,fTime,-0.5,fTime+0.5);
220 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
221 for (Int_t iTime = 0; iTime < fTime; iTime++) {
222 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
223 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
227 gStyle->SetOptStat(0);
228 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
230 cSliceRow->ToggleEventStatus();
231 hSliceRow->SetXTitle("Pad-column (rphi)");
232 hSliceRow->SetYTitle("Timebucket");
233 hSliceRow->Draw("COLZ");
237 //_____________________________________________________________________________
238 void AliTRDmatrix::DrawCol(Int_t iCol)
241 // Draws a 2D slice of the detector matrix along one column
244 if ((iCol < 0) || (iCol >= fCol)) {
245 printf("AliTRDmatrix::DrawCol -- ");
246 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
251 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
252 ,iCol,fSector,fChamber,fPlane);
253 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5
254 ,fTime,-0.5,fTime+0.5);
256 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
257 for (Int_t iTime = 0; iTime < fTime; iTime++) {
258 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
259 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
263 gStyle->SetOptStat(0);
264 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
266 cSliceCol->ToggleEventStatus();
267 hSliceCol->SetXTitle("Pad-row (z)");
268 hSliceCol->SetYTitle("Timebucket");
269 hSliceCol->Draw("COLZ");
273 //_____________________________________________________________________________
274 void AliTRDmatrix::DrawTime(Int_t iTime)
277 // Draws a 2D slice of the detector matrix along one time slice
280 if ((iTime < 0) || (iTime >= fTime)) {
281 printf("AliTRDmatrix::DrawTime -- ");
282 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
287 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
288 ,iTime,fSector,fChamber,fPlane);
289 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5
290 ,fCol,-0.5,fCol+0.5);
292 for (Int_t iRow = 0; iRow < fRow; iRow++) {
293 for (Int_t iCol = 0; iCol < fCol; iCol++) {
294 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
295 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
299 gStyle->SetOptStat(0);
300 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
302 cSliceTime->ToggleEventStatus();
303 hSliceTime->SetXTitle("Pad-row (z)");
304 hSliceTime->SetYTitle("Pad-column (rphi)");
305 hSliceTime->Draw("COLZ");
309 //_____________________________________________________________________________
310 void AliTRDmatrix::ProjRow()
313 // Projects the detector matrix along the row-axis
317 sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)"
318 ,fSector,fChamber,fPlane);
319 TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol +0.5
320 ,fTime,-0.5,fTime+0.5);
322 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
323 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
324 for (Int_t iTime = 0; iTime < fTime; iTime++) {
325 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
326 if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal());
331 gStyle->SetOptStat(0);
332 TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection"
334 cProjRow->ToggleEventStatus();
335 hProjRow->SetXTitle("Pad-column (rphi)");
336 hProjRow->SetYTitle("Timebucket");
337 hProjRow->Draw("COLZ");
341 //_____________________________________________________________________________
342 void AliTRDmatrix::ProjCol()
345 // Projects the detector matrix along the column-axis
349 sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)"
350 ,fSector,fChamber,fPlane);
351 TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow +0.5
352 ,fTime,-0.5,fTime+0.5);
354 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
355 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
356 for (Int_t iTime = 0; iTime < fTime; iTime++) {
357 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
358 if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal());
363 gStyle->SetOptStat(0);
364 TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection"
366 cProjCol->ToggleEventStatus();
367 hProjCol->SetXTitle("Pad-row (z)");
368 hProjCol->SetYTitle("Timebucket");
369 hProjCol->Draw("COLZ");
373 //_____________________________________________________________________________
374 void AliTRDmatrix::ProjTime()
377 // Projects the detector matrix along the time-axis
381 sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)"
382 ,fSector,fChamber,fPlane);
383 TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow+0.5
384 ,fCol,-0.5,fCol+0.5);
386 for (Int_t iRow = 0; iRow < fRow; iRow++) {
387 for (Int_t iCol = 0; iCol < fCol; iCol++) {
388 for (Int_t iTime = 0; iTime < fTime; iTime++) {
389 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
390 if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal());
395 gStyle->SetOptStat(0);
396 TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection"
398 cProjTime->ToggleEventStatus();
399 hProjTime->SetXTitle("Pad-row (z)");
400 hProjTime->SetYTitle("Pad-column (rphi)");
401 hProjTime->Draw("COLZ");
405 //_____________________________________________________________________________
406 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
409 // Set the amplitude of the signal for one specific pixel
412 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
414 pixel->SetSignal(signal);
419 //_____________________________________________________________________________
420 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
423 // Add this track number to the stored tracks passing through this pixel.
424 // If there are already three stored the return status is FALSE.
427 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
428 if (!(pixel)) return kTRUE;
430 Bool_t trackSet = kFALSE;
431 for (Int_t i = 0; i < kTrackPixel; i++) {
432 if (pixel->GetTrack(i) == track) {
436 if (pixel->GetTrack(i) == -1) {
437 pixel->SetTrack(i,track);
447 //_____________________________________________________________________________
448 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
449 , Int_t iTrack, Int_t track)
452 // Store the number of a track which is passing through this pixel
455 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
457 pixel->SetTrack(iTrack,track);
462 //_____________________________________________________________________________
463 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime)
466 // Returns the amplitude of the signal for one specific pixel
469 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
471 return (pixel->GetSignal());
479 //_____________________________________________________________________________
480 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
483 // Returns the numbers of the tracks passing through one specific pixel
486 if ((iTrack < 0) || (iTrack >= kTrackPixel)) {
487 printf("AliTRDmatrix::GetTrack -- ");
488 printf("Index out of bounds (%d)\n",iTrack);
492 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
494 return (pixel->GetTrack(iTrack));
502 //_____________________________________________________________________________
503 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime)
506 if ((iRow >= 0) && (iRow < fRow ) &&
507 (iCol >= 0) && (iCol < fCol ) &&
508 (iTime >= 0) && (iTime < fTime)) {
509 return (iTime + iCol * fTime + iRow * fTime * fCol);
517 //_____________________________________________________________________________
518 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime)
521 Int_t iPixel = GetIndex(iRow,iCol,iTime);
526 return ((AliTRDpixel *) fPixelArray->At(iPixel));