]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDmatrix.cxx
New digitisation per particle type
[u/mrichter/AliRoot.git] / TRD / AliTRDmatrix.cxx
index b429bade5695c155801c0ee5d2be6a305776d632..137841d1c5d17f651acf34b831742f0e2a541410 100644 (file)
@@ -1,3 +1,46 @@
+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ *                                                                        *
+ * Author: The ALICE Off-line Project.                                    *
+ * Contributors are mentioned in the code where appropriate.              *
+ *                                                                        *
+ * Permission to use, copy, modify and distribute this software and its   *
+ * documentation strictly for non-commercial purposes is hereby granted   *
+ * without fee, provided that the above copyright notice appears in all   *
+ * copies and that both the copyright notice and this permission notice   *
+ * appear in the supporting documentation. The authors make no claims     *
+ * about the suitability of this software for any purpose. It is          *
+ * provided "as is" without express or implied warranty.                  *
+ **************************************************************************/
+
+/*
+$Log$
+Revision 1.7  2000/06/08 18:32:58  cblume
+Make code compliant to coding conventions
+
+Revision 1.6  2000/05/08 15:48:30  cblume
+Resolved merge conflict
+
+Revision 1.4.2.2  2000/05/08 14:50:58  cblume
+Add functions ProjRow(), ProjCol(), and ProjTime()
+
+Revision 1.4.2.1  2000/04/27 12:47:02  cblume
+Replace Fill3() by Fill()
+
+Revision 1.4  2000/02/28 19:10:26  cblume
+Include the new TRD classes
+
+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
+
+*/
+
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 //  Contains the pixel information for one TRD chamber                       //
@@ -50,9 +93,23 @@ AliTRDmatrix::AliTRDmatrix(Int_t nRow, Int_t nCol, Int_t nTime
 
 }
 
+//_____________________________________________________________________________
+AliTRDmatrix::AliTRDmatrix(const AliTRDmatrix &m)
+{
+  //
+  // AliTRDmatrix copy constructor
+  //
+
+  ((AliTRDmatrix &) m).Copy(*this);
+
+}
+
 //_____________________________________________________________________________
 AliTRDmatrix::~AliTRDmatrix()
 {
+  //
+  // AliTRDmatrix destructor
+  //
 
   if (fPixelArray) {
     fPixelArray->Delete();
@@ -61,6 +118,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)
 {
@@ -77,7 +146,26 @@ void AliTRDmatrix::AddSignal(Int_t iRow, Int_t iCol, Int_t iTime, Float_t signal
 }
 
 //_____________________________________________________________________________
-void AliTRDmatrix::Draw()
+void AliTRDmatrix::Copy(TObject &m)
+{
+  //
+  // 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 *)
 {
   //
   // Draws a 3D view of the detector matrix
@@ -94,7 +182,7 @@ void AliTRDmatrix::Draw()
     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());
       }
     }
   }
@@ -118,6 +206,7 @@ void AliTRDmatrix::DrawRow(Int_t iRow)
   //
 
   if ((iRow < 0) || (iRow >= fRow)) {
+    printf("AliTRDmatrix::DrawRow -- ");
     printf("Index out of bounds (%d/%d)\n",iRow,fRow);
     return;
   }
@@ -153,6 +242,7 @@ void AliTRDmatrix::DrawCol(Int_t iCol)
   //
 
   if ((iCol < 0) || (iCol >= fCol)) {
+    printf("AliTRDmatrix::DrawCol -- ");
     printf("Index out of bounds (%d/%d)\n",iCol,fCol);
     return;
   }
@@ -188,6 +278,7 @@ void AliTRDmatrix::DrawTime(Int_t iTime)
   //
 
   if ((iTime < 0) || (iTime >= fTime)) {
+    printf("AliTRDmatrix::DrawTime -- ");
     printf("Index out of bounds (%d/%d)\n",iTime,fTime);
     return;
   }
@@ -215,6 +306,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)
 {
@@ -246,7 +433,7 @@ Bool_t AliTRDmatrix::AddTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t track)
       trackSet = kTRUE;
       break;
     }
-    if (pixel->GetTrack(i) ==     0) {
+    if (pixel->GetTrack(i) ==    -1) {
       pixel->SetTrack(i,track);
       trackSet = kTRUE;
       break;
@@ -297,8 +484,9 @@ Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
   //
 
   if ((iTrack < 0) || (iTrack >= kTrackPixel)) {
-    printf("GetTrack: Index out of bounds (%d)\n",iTrack);
-    return 0;
+    printf("AliTRDmatrix::GetTrack -- ");
+    printf("Index out of bounds (%d)\n",iTrack);
+    return -1;
   }
 
   AliTRDpixel *pixel = GetPixel(iRow,iCol,iTime);
@@ -306,7 +494,7 @@ Int_t AliTRDmatrix::GetTrack(Int_t iRow, Int_t iCol, Int_t iTime, Int_t iTrack)
     return (pixel->GetTrack(iTrack));
   }
   else {
-    return 0;
+    return -1;
   }
 
 }