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.10 2000/11/20 08:56:51 cblume
19 Fix the binning of the histograms
21 Revision 1.9 2000/11/01 14:53:21 cblume
22 Merge with TRD-develop
24 Revision 1.4.2.5 2000/10/17 02:27:34 cblume
25 Get rid of global constants
27 Revision 1.4.2.4 2000/10/06 16:49:46 cblume
30 Revision 1.4.2.3 2000/10/04 16:34:58 cblume
31 Replace include files by forward declarations
33 Revision 1.8 2000/06/09 11:10:07 cblume
34 Compiler warnings and coding conventions, next round
36 Revision 1.7 2000/06/08 18:32:58 cblume
37 Make code compliant to coding conventions
39 Revision 1.6 2000/05/08 15:48:30 cblume
40 Resolved merge conflict
42 Revision 1.4.2.2 2000/05/08 14:50:58 cblume
43 Add functions ProjRow(), ProjCol(), and ProjTime()
45 Revision 1.4.2.1 2000/04/27 12:47:02 cblume
46 Replace Fill3() by Fill()
48 Revision 1.4 2000/02/28 19:10:26 cblume
49 Include the new TRD classes
51 Revision 1.3.4.1 2000/02/28 17:57:47 cblume
52 GetTrack returns now -1 if no track is found
54 Revision 1.3 1999/10/04 14:48:07 fca
55 Avoid warnings on non-ansi compiler HP-UX CC
57 Revision 1.2 1999/09/29 09:24:35 fca
58 Introduction of the Copyright and cvs Log
62 ///////////////////////////////////////////////////////////////////////////////
64 // Contains the pixel information for one TRD chamber //
67 ///////////////////////////////////////////////////////////////////////////////
69 #include <TObjArray.h>
75 #include "AliTRDmatrix.h"
76 #include "AliTRDpixel.h"
78 ClassImp(AliTRDmatrix)
80 //_____________________________________________________________________________
81 AliTRDmatrix::AliTRDmatrix():TObject()
84 // Create a TRD detector matrix
98 //_____________________________________________________________________________
99 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
100 , Int_t iSec, Int_t iCha, Int_t iPla)
104 // Create a TRD detector matrix with a given size
110 fPixel = nRow * nCol * nTime;
114 fPixelArray = new TObjArray(fPixel);
115 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
116 AliTRDpixel *pixel = new AliTRDpixel();
117 fPixelArray->Add(pixel);
122 //_____________________________________________________________________________
123 AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m)
126 // AliTRDmatrix copy constructor
129 ((AliTRDmatrix &) m).Copy(*this);
133 //_____________________________________________________________________________
134 AliTRDmatrix::~AliTRDmatrix()
137 // AliTRDmatrix destructor
141 fPixelArray->Delete();
147 //_____________________________________________________________________________
148 AliTRDmatrix &AliTRDmatrix::operator=(const AliTRDmatrix &m)
151 // Assignment operator
154 if (this != &m) ((AliTRDmatrix &) m).Copy(*this);
159 //_____________________________________________________________________________
160 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
163 // Add a value to the amplitude of the signal for one specific pixel
166 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
168 signal += pixel->GetSignal();
169 pixel->SetSignal(signal);
174 //_____________________________________________________________________________
175 void AliTRDmatrix::Copy(TObject &m)
181 ((AliTRDmatrix &) m).fRow = fRow;
182 ((AliTRDmatrix &) m).fCol = fCol;
183 ((AliTRDmatrix &) m).fTime = fTime;
184 ((AliTRDmatrix &) m).fPixel = fPixel;
185 ((AliTRDmatrix &) m).fSector = fSector;
186 ((AliTRDmatrix &) m).fChamber = fChamber;
187 ((AliTRDmatrix &) m).fPlane = fPlane;
189 ((AliTRDmatrix &) m).fPixelArray = new TObjArray(*fPixelArray);
193 //_____________________________________________________________________________
194 void AliTRDmatrix::Draw(Option_t *)
197 // Draws a 3D view of the detector matrix
201 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
202 ,fSector,fChamber,fPlane);
203 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow -0.5
204 ,fCol ,-0.5,fCol -0.5
205 ,fTime,-0.5,fTime-0.5);
207 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
208 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
209 for (Int_t iTime = 0; iTime < fTime; iTime++) {
210 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
211 if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
216 gStyle->SetOptStat(0);
217 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
219 cMatrix->ToggleEventStatus();
220 hMatrix->SetXTitle("Pad-row (z)");
221 hMatrix->SetYTitle("Pad-column (rphi)");
222 hMatrix->SetZTitle("Timebucket");
223 hMatrix->Draw("BOX");
227 //_____________________________________________________________________________
228 void AliTRDmatrix::DrawRow(Int_t iRow)
231 // Draws a 2D slice of the detector matrix along one row
234 if ((iRow < 0) || (iRow >= fRow)) {
235 printf("AliTRDmatrix::DrawRow -- ");
236 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
241 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
242 ,iRow,fSector,fChamber,fPlane);
243 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol -0.5
244 ,fTime,-0.5,fTime-0.5);
246 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
247 for (Int_t iTime = 0; iTime < fTime; iTime++) {
248 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
249 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
253 gStyle->SetOptStat(0);
254 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
256 cSliceRow->ToggleEventStatus();
257 hSliceRow->SetXTitle("Pad-column (rphi)");
258 hSliceRow->SetYTitle("Timebucket");
259 hSliceRow->Draw("COLZ");
263 //_____________________________________________________________________________
264 void AliTRDmatrix::DrawCol(Int_t iCol)
267 // Draws a 2D slice of the detector matrix along one column
270 if ((iCol < 0) || (iCol >= fCol)) {
271 printf("AliTRDmatrix::DrawCol -- ");
272 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
277 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
278 ,iCol,fSector,fChamber,fPlane);
279 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow -0.5
280 ,fTime,-0.5,fTime-0.5);
282 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
283 for (Int_t iTime = 0; iTime < fTime; iTime++) {
284 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
285 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
289 gStyle->SetOptStat(0);
290 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
292 cSliceCol->ToggleEventStatus();
293 hSliceCol->SetXTitle("Pad-row (z)");
294 hSliceCol->SetYTitle("Timebucket");
295 hSliceCol->Draw("COLZ");
299 //_____________________________________________________________________________
300 void AliTRDmatrix::DrawTime(Int_t iTime)
303 // Draws a 2D slice of the detector matrix along one time slice
306 if ((iTime < 0) || (iTime >= fTime)) {
307 printf("AliTRDmatrix::DrawTime -- ");
308 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
313 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
314 ,iTime,fSector,fChamber,fPlane);
315 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow-0.5
316 ,fCol,-0.5,fCol-0.5);
318 for (Int_t iRow = 0; iRow < fRow; iRow++) {
319 for (Int_t iCol = 0; iCol < fCol; iCol++) {
320 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
321 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
325 gStyle->SetOptStat(0);
326 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
328 cSliceTime->ToggleEventStatus();
329 hSliceTime->SetXTitle("Pad-row (z)");
330 hSliceTime->SetYTitle("Pad-column (rphi)");
331 hSliceTime->Draw("COLZ");
335 //_____________________________________________________________________________
336 void AliTRDmatrix::ProjRow()
339 // Projects the detector matrix along the row-axis
343 sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)"
344 ,fSector,fChamber,fPlane);
345 TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol -0.5
346 ,fTime,-0.5,fTime-0.5);
348 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
349 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
350 for (Int_t iTime = 0; iTime < fTime; iTime++) {
351 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
352 if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal());
357 gStyle->SetOptStat(0);
358 TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection"
360 cProjRow->ToggleEventStatus();
361 hProjRow->SetXTitle("Pad-column (rphi)");
362 hProjRow->SetYTitle("Timebucket");
363 hProjRow->Draw("COLZ");
367 //_____________________________________________________________________________
368 void AliTRDmatrix::ProjCol()
371 // Projects the detector matrix along the column-axis
375 sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)"
376 ,fSector,fChamber,fPlane);
377 TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow -0.5
378 ,fTime,-0.5,fTime-0.5);
380 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
381 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
382 for (Int_t iTime = 0; iTime < fTime; iTime++) {
383 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
384 if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal());
389 gStyle->SetOptStat(0);
390 TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection"
392 cProjCol->ToggleEventStatus();
393 hProjCol->SetXTitle("Pad-row (z)");
394 hProjCol->SetYTitle("Timebucket");
395 hProjCol->Draw("COLZ");
399 //_____________________________________________________________________________
400 void AliTRDmatrix::ProjTime()
403 // Projects the detector matrix along the time-axis
407 sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)"
408 ,fSector,fChamber,fPlane);
409 TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow-0.5
410 ,fCol,-0.5,fCol-0.5);
412 for (Int_t iRow = 0; iRow < fRow; iRow++) {
413 for (Int_t iCol = 0; iCol < fCol; iCol++) {
414 for (Int_t iTime = 0; iTime < fTime; iTime++) {
415 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
416 if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal());
421 gStyle->SetOptStat(0);
422 TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection"
424 cProjTime->ToggleEventStatus();
425 hProjTime->SetXTitle("Pad-row (z)");
426 hProjTime->SetYTitle("Pad-column (rphi)");
427 hProjTime->Draw("COLZ");
431 //_____________________________________________________________________________
432 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
435 // Set the amplitude of the signal for one specific pixel
438 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
440 pixel->SetSignal(signal);
445 //_____________________________________________________________________________
446 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
449 // Add this track number to the stored tracks passing through this pixel.
450 // If there are already three stored the return status is FALSE.
453 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
454 if (!(pixel)) return kTRUE;
456 Bool_t trackSet = kFALSE;
457 for (Int_t i = 0; i < AliTRDpixel::NTrackPixel(); i++) {
458 if (pixel->GetTrack(i) == track) {
462 if (pixel->GetTrack(i) == -1) {
463 pixel->SetTrack(i,track);
473 //_____________________________________________________________________________
474 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
475 , Int_t iTrack, Int_t track)
478 // Store the number of a track which is passing through this pixel
481 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
483 pixel->SetTrack(iTrack,track);
488 //_____________________________________________________________________________
489 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime) const
492 // Returns the amplitude of the signal for one specific pixel
495 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
497 return (pixel->GetSignal());
505 //_____________________________________________________________________________
506 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime
507 , Int_t iTrack) const
510 // Returns the numbers of the tracks passing through one specific pixel
513 if ((iTrack < 0) || (iTrack >= AliTRDpixel::NTrackPixel())) {
514 printf("AliTRDmatrix::GetTrack -- ");
515 printf("Index out of bounds (%d)\n",iTrack);
519 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
521 return (pixel->GetTrack(iTrack));
529 //_____________________________________________________________________________
530 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime) const
533 // Get the index of a given pixel
536 if ((iRow >= 0) && (iRow < fRow ) &&
537 (iCol >= 0) && (iCol < fCol ) &&
538 (iTime >= 0) && (iTime < fTime)) {
539 return (iTime + iCol * fTime + iRow * fTime * fCol);
547 //_____________________________________________________________________________
548 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime) const
554 Int_t iPixel = GetIndex(iRow,iCol,iTime);
559 return ((AliTRDpixel *) fPixelArray->At(iPixel));