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.9 2000/11/01 14:53:21 cblume
19 Merge with TRD-develop
21 Revision 1.4.2.5 2000/10/17 02:27:34 cblume
22 Get rid of global constants
24 Revision 1.4.2.4 2000/10/06 16:49:46 cblume
27 Revision 1.4.2.3 2000/10/04 16:34:58 cblume
28 Replace include files by forward declarations
30 Revision 1.8 2000/06/09 11:10:07 cblume
31 Compiler warnings and coding conventions, next round
33 Revision 1.7 2000/06/08 18:32:58 cblume
34 Make code compliant to coding conventions
36 Revision 1.6 2000/05/08 15:48:30 cblume
37 Resolved merge conflict
39 Revision 1.4.2.2 2000/05/08 14:50:58 cblume
40 Add functions ProjRow(), ProjCol(), and ProjTime()
42 Revision 1.4.2.1 2000/04/27 12:47:02 cblume
43 Replace Fill3() by Fill()
45 Revision 1.4 2000/02/28 19:10:26 cblume
46 Include the new TRD classes
48 Revision 1.3.4.1 2000/02/28 17:57:47 cblume
49 GetTrack returns now -1 if no track is found
51 Revision 1.3 1999/10/04 14:48:07 fca
52 Avoid warnings on non-ansi compiler HP-UX CC
54 Revision 1.2 1999/09/29 09:24:35 fca
55 Introduction of the Copyright and cvs Log
59 ///////////////////////////////////////////////////////////////////////////////
61 // Contains the pixel information for one TRD chamber //
63 ///////////////////////////////////////////////////////////////////////////////
65 #include <TObjArray.h>
71 #include "AliTRDmatrix.h"
72 #include "AliTRDpixel.h"
74 ClassImp(AliTRDmatrix)
76 //_____________________________________________________________________________
77 AliTRDmatrix::AliTRDmatrix():TObject()
80 // Create a TRD detector matrix
94 //_____________________________________________________________________________
95 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
96 , Int_t iSec, Int_t iCha, Int_t iPla)
100 // Create a TRD detector matrix with a given size
106 fPixel = nRow * nCol * nTime;
110 fPixelArray = new TObjArray(fPixel);
111 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
112 AliTRDpixel *pixel = new AliTRDpixel();
113 fPixelArray->Add(pixel);
118 //_____________________________________________________________________________
119 AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m)
122 // AliTRDmatrix copy constructor
125 ((AliTRDmatrix &) m).Copy(*this);
129 //_____________________________________________________________________________
130 AliTRDmatrix::~AliTRDmatrix()
133 // AliTRDmatrix destructor
137 fPixelArray->Delete();
143 //_____________________________________________________________________________
144 AliTRDmatrix &AliTRDmatrix::operator=(const AliTRDmatrix &m)
147 // Assignment operator
150 if (this != &m) ((AliTRDmatrix &) m).Copy(*this);
155 //_____________________________________________________________________________
156 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
159 // Add a value to the amplitude of the signal for one specific pixel
162 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
164 signal += pixel->GetSignal();
165 pixel->SetSignal(signal);
170 //_____________________________________________________________________________
171 void AliTRDmatrix::Copy(TObject &m)
177 ((AliTRDmatrix &) m).fRow = fRow;
178 ((AliTRDmatrix &) m).fCol = fCol;
179 ((AliTRDmatrix &) m).fTime = fTime;
180 ((AliTRDmatrix &) m).fPixel = fPixel;
181 ((AliTRDmatrix &) m).fSector = fSector;
182 ((AliTRDmatrix &) m).fChamber = fChamber;
183 ((AliTRDmatrix &) m).fPlane = fPlane;
185 ((AliTRDmatrix &) m).fPixelArray = new TObjArray(*fPixelArray);
189 //_____________________________________________________________________________
190 void AliTRDmatrix::Draw(Option_t *)
193 // Draws a 3D view of the detector matrix
197 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
198 ,fSector,fChamber,fPlane);
199 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow -0.5
200 ,fCol ,-0.5,fCol -0.5
201 ,fTime,-0.5,fTime-0.5);
203 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
204 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
205 for (Int_t iTime = 0; iTime < fTime; iTime++) {
206 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
207 if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
212 gStyle->SetOptStat(0);
213 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
215 cMatrix->ToggleEventStatus();
216 hMatrix->SetXTitle("Pad-row (z)");
217 hMatrix->SetYTitle("Pad-column (rphi)");
218 hMatrix->SetZTitle("Timebucket");
219 hMatrix->Draw("BOX");
223 //_____________________________________________________________________________
224 void AliTRDmatrix::DrawRow(Int_t iRow)
227 // Draws a 2D slice of the detector matrix along one row
230 if ((iRow < 0) || (iRow >= fRow)) {
231 printf("AliTRDmatrix::DrawRow -- ");
232 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
237 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
238 ,iRow,fSector,fChamber,fPlane);
239 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol -0.5
240 ,fTime,-0.5,fTime-0.5);
242 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
243 for (Int_t iTime = 0; iTime < fTime; iTime++) {
244 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
245 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
249 gStyle->SetOptStat(0);
250 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
252 cSliceRow->ToggleEventStatus();
253 hSliceRow->SetXTitle("Pad-column (rphi)");
254 hSliceRow->SetYTitle("Timebucket");
255 hSliceRow->Draw("COLZ");
259 //_____________________________________________________________________________
260 void AliTRDmatrix::DrawCol(Int_t iCol)
263 // Draws a 2D slice of the detector matrix along one column
266 if ((iCol < 0) || (iCol >= fCol)) {
267 printf("AliTRDmatrix::DrawCol -- ");
268 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
273 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
274 ,iCol,fSector,fChamber,fPlane);
275 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow -0.5
276 ,fTime,-0.5,fTime-0.5);
278 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
279 for (Int_t iTime = 0; iTime < fTime; iTime++) {
280 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
281 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
285 gStyle->SetOptStat(0);
286 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
288 cSliceCol->ToggleEventStatus();
289 hSliceCol->SetXTitle("Pad-row (z)");
290 hSliceCol->SetYTitle("Timebucket");
291 hSliceCol->Draw("COLZ");
295 //_____________________________________________________________________________
296 void AliTRDmatrix::DrawTime(Int_t iTime)
299 // Draws a 2D slice of the detector matrix along one time slice
302 if ((iTime < 0) || (iTime >= fTime)) {
303 printf("AliTRDmatrix::DrawTime -- ");
304 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
309 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
310 ,iTime,fSector,fChamber,fPlane);
311 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow-0.5
312 ,fCol,-0.5,fCol-0.5);
314 for (Int_t iRow = 0; iRow < fRow; iRow++) {
315 for (Int_t iCol = 0; iCol < fCol; iCol++) {
316 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
317 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
321 gStyle->SetOptStat(0);
322 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
324 cSliceTime->ToggleEventStatus();
325 hSliceTime->SetXTitle("Pad-row (z)");
326 hSliceTime->SetYTitle("Pad-column (rphi)");
327 hSliceTime->Draw("COLZ");
331 //_____________________________________________________________________________
332 void AliTRDmatrix::ProjRow()
335 // Projects the detector matrix along the row-axis
339 sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)"
340 ,fSector,fChamber,fPlane);
341 TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol -0.5
342 ,fTime,-0.5,fTime-0.5);
344 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
345 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
346 for (Int_t iTime = 0; iTime < fTime; iTime++) {
347 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
348 if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal());
353 gStyle->SetOptStat(0);
354 TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection"
356 cProjRow->ToggleEventStatus();
357 hProjRow->SetXTitle("Pad-column (rphi)");
358 hProjRow->SetYTitle("Timebucket");
359 hProjRow->Draw("COLZ");
363 //_____________________________________________________________________________
364 void AliTRDmatrix::ProjCol()
367 // Projects the detector matrix along the column-axis
371 sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)"
372 ,fSector,fChamber,fPlane);
373 TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow -0.5
374 ,fTime,-0.5,fTime-0.5);
376 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
377 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
378 for (Int_t iTime = 0; iTime < fTime; iTime++) {
379 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
380 if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal());
385 gStyle->SetOptStat(0);
386 TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection"
388 cProjCol->ToggleEventStatus();
389 hProjCol->SetXTitle("Pad-row (z)");
390 hProjCol->SetYTitle("Timebucket");
391 hProjCol->Draw("COLZ");
395 //_____________________________________________________________________________
396 void AliTRDmatrix::ProjTime()
399 // Projects the detector matrix along the time-axis
403 sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)"
404 ,fSector,fChamber,fPlane);
405 TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow-0.5
406 ,fCol,-0.5,fCol-0.5);
408 for (Int_t iRow = 0; iRow < fRow; iRow++) {
409 for (Int_t iCol = 0; iCol < fCol; iCol++) {
410 for (Int_t iTime = 0; iTime < fTime; iTime++) {
411 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
412 if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal());
417 gStyle->SetOptStat(0);
418 TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection"
420 cProjTime->ToggleEventStatus();
421 hProjTime->SetXTitle("Pad-row (z)");
422 hProjTime->SetYTitle("Pad-column (rphi)");
423 hProjTime->Draw("COLZ");
427 //_____________________________________________________________________________
428 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
431 // Set the amplitude of the signal for one specific pixel
434 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
436 pixel->SetSignal(signal);
441 //_____________________________________________________________________________
442 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
445 // Add this track number to the stored tracks passing through this pixel.
446 // If there are already three stored the return status is FALSE.
449 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
450 if (!(pixel)) return kTRUE;
452 Bool_t trackSet = kFALSE;
453 for (Int_t i = 0; i < AliTRDpixel::NTrackPixel(); i++) {
454 if (pixel->GetTrack(i) == track) {
458 if (pixel->GetTrack(i) == -1) {
459 pixel->SetTrack(i,track);
469 //_____________________________________________________________________________
470 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
471 , Int_t iTrack, Int_t track)
474 // Store the number of a track which is passing through this pixel
477 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
479 pixel->SetTrack(iTrack,track);
484 //_____________________________________________________________________________
485 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime) const
488 // Returns the amplitude of the signal for one specific pixel
491 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
493 return (pixel->GetSignal());
501 //_____________________________________________________________________________
502 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime
503 , Int_t iTrack) const
506 // Returns the numbers of the tracks passing through one specific pixel
509 if ((iTrack < 0) || (iTrack >= AliTRDpixel::NTrackPixel())) {
510 printf("AliTRDmatrix::GetTrack -- ");
511 printf("Index out of bounds (%d)\n",iTrack);
515 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
517 return (pixel->GetTrack(iTrack));
525 //_____________________________________________________________________________
526 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime) const
529 if ((iRow >= 0) && (iRow < fRow ) &&
530 (iCol >= 0) && (iCol < fCol ) &&
531 (iTime >= 0) && (iTime < fTime)) {
532 return (iTime + iCol * fTime + iRow * fTime * fCol);
540 //_____________________________________________________________________________
541 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime) const
544 Int_t iPixel = GetIndex(iRow,iCol,iTime);
549 return ((AliTRDpixel *) fPixelArray->At(iPixel));