]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDmatrix.cxx
Reconstruction of RAW data. Introduction of cluster finder (A. de Caro)
[u/mrichter/AliRoot.git] / TRD / AliTRDmatrix.cxx
index 22f95092b2bda2b2516cdbfb3cb6fbca55e36535..02a6f1749e45954386ecb638e0dedf366ddcbad5 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.3.4.1  2000/02/28 17:57:47  cblume
-GetTrack returns now -1 if no track is found
-
-Revision 1.3  1999/10/04 14:48:07  fca
-Avoid warnings on non-ansi compiler HP-UX CC
-
-Revision 1.2  1999/09/29 09:24:35  fca
-Introduction of the Copyright and cvs Log
-
-*/
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 //  Contains the pixel information for one TRD chamber                       //
 //                                                                           //
+//                                                                           //
 ///////////////////////////////////////////////////////////////////////////////
 
+#include <TObjArray.h>
+#include <TH2.h>
+#include <TH3.h>
+#include <TStyle.h>
+#include <TCanvas.h>
+
 #include "AliTRDmatrix.h"
+#include "AliTRDpixel.h"
 
 ClassImp(AliTRDmatrix)
 
@@ -78,9 +75,23 @@ AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
 
 }
 
+//_____________________________________________________________________________
+AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m):TObject(m)
+{
+  //
+  // AliTRDmatrix copy constructor
+  //
+
+  ((AliTRDmatrix &) m).Copy(*this);
+
+}
+
 //_____________________________________________________________________________
 AliTRDmatrix::~AliTRDmatrix()
 {
+  //
+  // AliTRDmatrix destructor
+  //
 
   if (fPixelArray) {
     fPixelArray->Delete();
@@ -89,6 +100,18 @@ AliTRDmatrix::~AliTRDmatrix()
 
 }
 
+//_____________________________________________________________________________
+AliTRDmatrix &AliTRDmatrix::operator=(const AliTRDmatrix &m)
+{
+  //
+  // Assignment operator
+  //
+
+  if (this != &m) ((AliTRDmatrix &) m).Copy(*this);
+  return *this;
+
+}
+
 //_____________________________________________________________________________
 void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
 {
@@ -104,6 +127,25 @@ void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal
 
 }
 
+//_____________________________________________________________________________
+void AliTRDmatrix::Copy(TObject &m) const
+{
+  //
+  // Copy function
+  //
+
+  ((AliTRDmatrix &) m).fRow        = fRow;
+  ((AliTRDmatrix &) m).fCol        = fCol;
+  ((AliTRDmatrix &) m).fTime       = fTime;
+  ((AliTRDmatrix &) m).fPixel      = fPixel;
+  ((AliTRDmatrix &) m).fSector     = fSector;
+  ((AliTRDmatrix &) m).fChamber    = fChamber;
+  ((AliTRDmatrix &) m).fPlane      = fPlane;
+
+  ((AliTRDmatrix &) m).fPixelArray = new TObjArray(*fPixelArray);
+
+}
+
 //_____________________________________________________________________________
 void AliTRDmatrix::Draw(Option_t *)
 {
@@ -114,15 +156,15 @@ void AliTRDmatrix::Draw(Option_t *)
   Char_t ctitle[50];
   sprintf(ctitle,"Matrix (Sector:%d Chamber:%d Plane:%d)"
                 ,fSector,fChamber,fPlane);
-  TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow +0.5
-                                           ,fCol ,-0.5,fCol +0.5
-                                           ,fTime,-0.5,fTime+0.5);
+  TH3F *hMatrix = new TH3F("hMatrix",ctitle,fRow ,-0.5,fRow -0.5
+                                           ,fCol ,-0.5,fCol -0.5
+                                           ,fTime,-0.5,fTime-0.5);
 
   for (Int_t iRow  = 0; iRow  < fRow;  iRow++ ) {
     for (Int_t iCol  = 0; iCol  < fCol;  iCol++ ) {
       for (Int_t iTime = 0; iTime < fTime; iTime++) {
         AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
-        if (pixel) hMatrix->Fill3(iRow,iCol,iTime,pixel->GetSignal());
+        if (pixel) hMatrix->Fill(iRow,iCol,iTime,pixel->GetSignal());
       }
     }
   }
@@ -154,8 +196,8 @@ void AliTRDmatrix::DrawRow(Int_t iRow)
   Char_t ctitle[50];
   sprintf(ctitle,"Pad-row %d (Sector:%d Chamber:%d Plane:%d)"
                 ,iRow,fSector,fChamber,fPlane);
-  TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol +0.5
-                                               ,fTime,-0.5,fTime+0.5);
+  TH2F *hSliceRow = new TH2F("hSliceRow",ctitle,fCol ,-0.5,fCol -0.5
+                                               ,fTime,-0.5,fTime-0.5);
 
   for (Int_t iCol  = 0; iCol  < fCol;  iCol++ ) {
     for (Int_t iTime = 0; iTime < fTime; iTime++) {
@@ -190,8 +232,8 @@ void AliTRDmatrix::DrawCol(Int_t iCol)
   Char_t ctitle[50];
   sprintf(ctitle,"Pad-column %d (Sector:%d Chamber:%d Plane:%d)"
                 ,iCol,fSector,fChamber,fPlane);
-  TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow +0.5
-                                               ,fTime,-0.5,fTime+0.5);
+  TH2F *hSliceCol = new TH2F("hSliceCol",ctitle,fRow ,-0.5,fRow -0.5
+                                               ,fTime,-0.5,fTime-0.5);
 
   for (Int_t iRow  = 0; iRow  < fRow;  iRow++ ) {
     for (Int_t iTime = 0; iTime < fTime; iTime++) {
@@ -226,8 +268,8 @@ void AliTRDmatrix::DrawTime(Int_t iTime)
   Char_t ctitle[50];
   sprintf(ctitle,"Time-slice %d (Sector:%d Chamber:%d Plane:%d)"
                 ,iTime,fSector,fChamber,fPlane);
-  TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow+0.5
-                                                 ,fCol,-0.5,fCol+0.5);
+  TH2F *hSliceTime = new TH2F("hSliceTime",ctitle,fRow,-0.5,fRow-0.5
+                                                 ,fCol,-0.5,fCol-0.5);
 
   for (Int_t iRow = 0; iRow < fRow; iRow++) {
     for (Int_t iCol = 0; iCol < fCol; iCol++) {
@@ -246,6 +288,102 @@ void AliTRDmatrix::DrawTime(Int_t iTime)
 
 }
 
+//_____________________________________________________________________________
+void AliTRDmatrix::ProjRow()
+{
+  //
+  // Projects the detector matrix along the row-axis
+  //
+
+  Char_t ctitle[60];
+  sprintf(ctitle,"Row-projection (Sector:%d Chamber:%d Plane:%d)"
+                ,fSector,fChamber,fPlane);
+  TH2F *hProjRow = new TH2F("hProjRow",ctitle,fCol ,-0.5,fCol -0.5
+                                             ,fTime,-0.5,fTime-0.5);
+
+  for (Int_t iRow  = 0; iRow  < fRow;  iRow++ ) {
+    for (Int_t iCol  = 0; iCol  < fCol;  iCol++ ) {
+      for (Int_t iTime = 0; iTime < fTime; iTime++) {
+        AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
+        if (pixel) hProjRow->Fill(iCol,iTime,pixel->GetSignal());
+      }
+    }
+  }
+
+  gStyle->SetOptStat(0);
+  TCanvas *cProjRow = new TCanvas("cProjRow","Detector matrix 2D-projection"
+                                            ,50,50,600,400);
+  cProjRow->ToggleEventStatus();
+  hProjRow->SetXTitle("Pad-column (rphi)");
+  hProjRow->SetYTitle("Timebucket");
+  hProjRow->Draw("COLZ");
+
+}
+
+//_____________________________________________________________________________
+void AliTRDmatrix::ProjCol()
+{
+  //
+  // Projects the detector matrix along the column-axis
+  //
+
+  Char_t ctitle[60];
+  sprintf(ctitle,"Column-projection (Sector:%d Chamber:%d Plane:%d)"
+                ,fSector,fChamber,fPlane);
+  TH2F *hProjCol = new TH2F("hProjCol",ctitle,fRow ,-0.5,fRow -0.5
+                                             ,fTime,-0.5,fTime-0.5);
+
+  for (Int_t iRow  = 0; iRow  < fRow;  iRow++ ) {
+    for (Int_t iCol  = 0; iCol  < fCol;  iCol++ ) {
+      for (Int_t iTime = 0; iTime < fTime; iTime++) {
+        AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
+        if (pixel) hProjCol->Fill(iRow,iTime,pixel->GetSignal());
+      }
+    }
+  }
+
+  gStyle->SetOptStat(0);
+  TCanvas *cProjCol = new TCanvas("cProjCol","Detector matrix 2D-projection"
+                                            ,50,50,600,400);
+  cProjCol->ToggleEventStatus();
+  hProjCol->SetXTitle("Pad-row (z)");
+  hProjCol->SetYTitle("Timebucket");
+  hProjCol->Draw("COLZ");
+
+}
+
+//_____________________________________________________________________________
+void AliTRDmatrix::ProjTime()
+{
+  //
+  // Projects the detector matrix along the time-axis
+  //
+
+  Char_t ctitle[60];
+  sprintf(ctitle,"Time-projection (Sector:%d Chamber:%d Plane:%d)"
+                ,fSector,fChamber,fPlane);
+  TH2F *hProjTime = new TH2F("hProjTime",ctitle,fRow,-0.5,fRow-0.5
+                                               ,fCol,-0.5,fCol-0.5);
+
+  for (Int_t iRow = 0; iRow < fRow; iRow++) {
+    for (Int_t iCol = 0; iCol < fCol; iCol++) {
+      for (Int_t iTime = 0; iTime < fTime; iTime++) {
+        AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
+        if (pixel) hProjTime->Fill(iRow,iCol,pixel->GetSignal());
+      }
+    }
+  }
+
+  gStyle->SetOptStat(0);
+  TCanvas *cProjTime = new TCanvas("cProjTime","Detector matrix 2D-projection"
+                                              ,50,50,600,400);
+  cProjTime->ToggleEventStatus();
+  hProjTime->SetXTitle("Pad-row (z)");
+  hProjTime->SetYTitle("Pad-column (rphi)");
+  hProjTime->Draw("COLZ");
+
+}
+
 //_____________________________________________________________________________
 void AliTRDmatrix::SetSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal)
 {
@@ -272,7 +410,7 @@ Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
   if (!(pixel)) return kTRUE;
 
   Bool_t trackSet = kFALSE;
-  for (Int_t i = 0; i < kTrackPixel; i++) {
+  for (Int_t i = 0; i < AliTRDpixel::NTrackPixel(); i++) {
     if (pixel->GetTrack(i) == track) {
       trackSet = kTRUE;
       break;
@@ -304,7 +442,7 @@ void AliTRDmatrix::SetTrack(Int_t iRow, Int_t iCol, Int_t iTime
 }
 
 //_____________________________________________________________________________
-Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime)
+Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime) const
 {
   //
   // Returns the amplitude of the signal for one specific pixel
@@ -321,13 +459,14 @@ Float_t AliTRDmatrix::GetSignal(Int_t iRow, Int_t iCol, Int_t iTime)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
+Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime
+                           , Int_t iTrack) const 
 {
   //
   // Returns the numbers of the tracks passing through one specific pixel
   //
 
-  if ((iTrack < 0) || (iTrack >= kTrackPixel)) {
+  if ((iTrack < 0) || (iTrack >= AliTRDpixel::NTrackPixel())) {
     printf("AliTRDmatrix::GetTrack -- ");
     printf("Index out of bounds (%d)\n",iTrack);
     return -1;
@@ -344,8 +483,11 @@ Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
 }
 
 //_____________________________________________________________________________
-Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime)
+Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime) const
 {
+  //
+  // Get the index of a given pixel
+  //
 
   if ((iRow  >= 0) && (iRow  < fRow ) &&
       (iCol  >= 0) && (iCol  < fCol ) &&
@@ -359,8 +501,11 @@ Int_t AliTRDmatrix::GetIndex(Int_t iRow, Int_t iCol, Int_t iTime)
 }
 
 //_____________________________________________________________________________
-AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime)
+AliTRDpixel *AliTRDmatrix::GetPixel(Int_t iRow, Int_t iCol, Int_t iTime) const
 {
+  //
+  // Get one pixel
+  //
 
   Int_t iPixel = GetIndex(iRow,iCol,iTime);
   if (iPixel < 0) {