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.6 2000/05/08 15:48:30 cblume
19 Resolved merge conflict
21 Revision 1.4.2.2 2000/05/08 14:50:58 cblume
22 Add functions ProjRow(), ProjCol(), and ProjTime()
24 Revision 1.4.2.1 2000/04/27 12:47:02 cblume
25 Replace Fill3() by Fill()
27 Revision 1.4 2000/02/28 19:10:26 cblume
28 Include the new TRD classes
30 Revision 1.3.4.1 2000/02/28 17:57:47 cblume
31 GetTrack returns now -1 if no track is found
33 Revision 1.3 1999/10/04 14:48:07 fca
34 Avoid warnings on non-ansi compiler HP-UX CC
36 Revision 1.2 1999/09/29 09:24:35 fca
37 Introduction of the Copyright and cvs Log
41 ///////////////////////////////////////////////////////////////////////////////
43 // Contains the pixel information for one TRD chamber //
45 ///////////////////////////////////////////////////////////////////////////////
47 #include "AliTRDmatrix.h"
49 ClassImp(AliTRDmatrix)
51 //_____________________________________________________________________________
52 AliTRDmatrix::AliTRDmatrix():TObject()
55 // Create a TRD detector matrix
69 //_____________________________________________________________________________
70 AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
71 , Int_t iSec, Int_t iCha, Int_t iPla)
75 // Create a TRD detector matrix with a given size
81 fPixel = nRow * nCol * nTime;
85 fPixelArray = new TObjArray(fPixel);
86 for (Int_t iPixel = 0; iPixel < fPixel; iPixel++) {
87 AliTRDpixel *pixel = new AliTRDpixel();
88 fPixelArray->Add(pixel);
93 //_____________________________________________________________________________
94 AliTRDmatrix::AliTRDmatrix(AliTRDmatrix &m)
97 // AliTRDmatrix copy constructor
104 //_____________________________________________________________________________
105 AliTRDmatrix::~AliTRDmatrix()
108 // AliTRDmatrix destructor
112 fPixelArray->Delete();
118 //_____________________________________________________________________________
119 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
122 // Add a value to the amplitude of the signal for one specific pixel
125 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
127 signal += pixel->GetSignal();
128 pixel->SetSignal(signal);
133 //_____________________________________________________________________________
134 void AliTRDmatrix::Copy(AliTRDmatrix &m)
145 m.fChamber = fChamber;
148 m.fPixelArray = new TObjArray(*fPixelArray);
152 //_____________________________________________________________________________
153 void AliTRDmatrix::Draw(Option_t *)
156 // Draws a 3D view of the detector matrix
160 sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
161 ,fSector,fChamber,fPlane);
162 TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5
163 ,fCol ,-0.5,fCol +0.5
164 ,fTime,-0.5,fTime+0.5);
166 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
167 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
168 for (Int_t iTime = 0; iTime < fTime; iTime++) {
169 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
170 if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
175 gStyle->SetOptStat(0);
176 TCanvas *cMatrix = new TCanvas("cMatrix","Detector matrix 3D-view"
178 cMatrix->ToggleEventStatus();
179 hMatrix->SetXTitle("Pad-row (z)");
180 hMatrix->SetYTitle("Pad-column (rphi)");
181 hMatrix->SetZTitle("Timebucket");
182 hMatrix->Draw("BOX");
186 //_____________________________________________________________________________
187 void AliTRDmatrix::DrawRow(Int_t iRow)
190 // Draws a 2D slice of the detector matrix along one row
193 if ((iRow < 0) || (iRow >= fRow)) {
194 printf("AliTRDmatrix::DrawRow -- ");
195 printf("Index out of bounds (%d/%d)\n",iRow,fRow);
200 sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
201 ,iRow,fSector,fChamber,fPlane);
202 TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5
203 ,fTime,-0.5,fTime+0.5);
205 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
206 for (Int_t iTime = 0; iTime < fTime; iTime++) {
207 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
208 if (pixel) hSliceRow->Fill(iCol,iTime,pixel->GetSignal());
212 gStyle->SetOptStat(0);
213 TCanvas *cSliceRow = new TCanvas("cSliceRow","Detector matrix 2D-slice"
215 cSliceRow->ToggleEventStatus();
216 hSliceRow->SetXTitle("Pad-column (rphi)");
217 hSliceRow->SetYTitle("Timebucket");
218 hSliceRow->Draw("COLZ");
222 //_____________________________________________________________________________
223 void AliTRDmatrix::DrawCol(Int_t iCol)
226 // Draws a 2D slice of the detector matrix along one column
229 if ((iCol < 0) || (iCol >= fCol)) {
230 printf("AliTRDmatrix::DrawCol -- ");
231 printf("Index out of bounds (%d/%d)\n",iCol,fCol);
236 sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
237 ,iCol,fSector,fChamber,fPlane);
238 TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5
239 ,fTime,-0.5,fTime+0.5);
241 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
242 for (Int_t iTime = 0; iTime < fTime; iTime++) {
243 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
244 if (pixel) hSliceCol->Fill(iRow,iTime,pixel->GetSignal());
248 gStyle->SetOptStat(0);
249 TCanvas *cSliceCol = new TCanvas("cSliceCol","Detector matrix 2D-slice"
251 cSliceCol->ToggleEventStatus();
252 hSliceCol->SetXTitle("Pad-row (z)");
253 hSliceCol->SetYTitle("Timebucket");
254 hSliceCol->Draw("COLZ");
258 //_____________________________________________________________________________
259 void AliTRDmatrix::DrawTime(Int_t iTime)
262 // Draws a 2D slice of the detector matrix along one time slice
265 if ((iTime < 0) || (iTime >= fTime)) {
266 printf("AliTRDmatrix::DrawTime -- ");
267 printf("Index out of bounds (%d/%d)\n",iTime,fTime);
272 sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
273 ,iTime,fSector,fChamber,fPlane);
274 TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5
275 ,fCol,-0.5,fCol+0.5);
277 for (Int_t iRow = 0; iRow < fRow; iRow++) {
278 for (Int_t iCol = 0; iCol < fCol; iCol++) {
279 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
280 if (pixel) hSliceTime->Fill(iRow,iCol,pixel->GetSignal());
284 gStyle->SetOptStat(0);
285 TCanvas *cSliceTime = new TCanvas("cSliceTime","Detector matrix 2D-slice"
287 cSliceTime->ToggleEventStatus();
288 hSliceTime->SetXTitle("Pad-row (z)");
289 hSliceTime->SetYTitle("Pad-column (rphi)");
290 hSliceTime->Draw("COLZ");
294 //_____________________________________________________________________________
295 void AliTRDmatrix::ProjRow()
298 // Projects the detector matrix along the row-axis
302 sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)"
303 ,fSector,fChamber,fPlane);
304 TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol +0.5
305 ,fTime,-0.5,fTime+0.5);
307 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
308 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
309 for (Int_t iTime = 0; iTime < fTime; iTime++) {
310 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
311 if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal());
316 gStyle->SetOptStat(0);
317 TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection"
319 cProjRow->ToggleEventStatus();
320 hProjRow->SetXTitle("Pad-column (rphi)");
321 hProjRow->SetYTitle("Timebucket");
322 hProjRow->Draw("COLZ");
326 //_____________________________________________________________________________
327 void AliTRDmatrix::ProjCol()
330 // Projects the detector matrix along the column-axis
334 sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)"
335 ,fSector,fChamber,fPlane);
336 TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow +0.5
337 ,fTime,-0.5,fTime+0.5);
339 for (Int_t iRow = 0; iRow < fRow; iRow++ ) {
340 for (Int_t iCol = 0; iCol < fCol; iCol++ ) {
341 for (Int_t iTime = 0; iTime < fTime; iTime++) {
342 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
343 if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal());
348 gStyle->SetOptStat(0);
349 TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection"
351 cProjCol->ToggleEventStatus();
352 hProjCol->SetXTitle("Pad-row (z)");
353 hProjCol->SetYTitle("Timebucket");
354 hProjCol->Draw("COLZ");
358 //_____________________________________________________________________________
359 void AliTRDmatrix::ProjTime()
362 // Projects the detector matrix along the time-axis
366 sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)"
367 ,fSector,fChamber,fPlane);
368 TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow+0.5
369 ,fCol,-0.5,fCol+0.5);
371 for (Int_t iRow = 0; iRow < fRow; iRow++) {
372 for (Int_t iCol = 0; iCol < fCol; iCol++) {
373 for (Int_t iTime = 0; iTime < fTime; iTime++) {
374 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
375 if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal());
380 gStyle->SetOptStat(0);
381 TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection"
383 cProjTime->ToggleEventStatus();
384 hProjTime->SetXTitle("Pad-row (z)");
385 hProjTime->SetYTitle("Pad-column (rphi)");
386 hProjTime->Draw("COLZ");
390 //_____________________________________________________________________________
391 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
394 // Set the amplitude of the signal for one specific pixel
397 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
399 pixel->SetSignal(signal);
404 //_____________________________________________________________________________
405 Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
408 // Add this track number to the stored tracks passing through this pixel.
409 // If there are already three stored the return status is FALSE.
412 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
413 if (!(pixel)) return kTRUE;
415 Bool_t trackSet = kFALSE;
416 for (Int_t i = 0; i < kTrackPixel; i++) {
417 if (pixel->GetTrack(i) == track) {
421 if (pixel->GetTrack(i) == -1) {
422 pixel->SetTrack(i,track);
432 //_____________________________________________________________________________
433 void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
434 , Int_t iTrack, Int_t track)
437 // Store the number of a track which is passing through this pixel
440 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
442 pixel->SetTrack(iTrack,track);
447 //_____________________________________________________________________________
448 Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime)
451 // Returns the amplitude of the signal for one specific pixel
454 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
456 return (pixel->GetSignal());
464 //_____________________________________________________________________________
465 Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
468 // Returns the numbers of the tracks passing through one specific pixel
471 if ((iTrack < 0) || (iTrack >= kTrackPixel)) {
472 printf("AliTRDmatrix::GetTrack -- ");
473 printf("Index out of bounds (%d)\n",iTrack);
477 AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
479 return (pixel->GetTrack(iTrack));
487 //_____________________________________________________________________________
488 Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime)
491 if ((iRow >= 0) && (iRow < fRow ) &&
492 (iCol >= 0) && (iCol < fCol ) &&
493 (iTime >= 0) && (iTime < fTime)) {
494 return (iTime + iCol * fTime + iRow * fTime * fCol);
502 //_____________________________________________________________________________
503 AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime)
506 Int_t iPixel = GetIndex(iRow,iCol,iTime);
511 return ((AliTRDpixel *) fPixelArray->At(iPixel));