]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDcluster.cxx
Tentative version of the new raw-reader class which will handle the online reconstruc...
[u/mrichter/AliRoot.git] / TRD / AliTRDcluster.cxx
index bd1954abe379d3f51d86eee549dbe8f9744598ef..0cc0a225ad687b4c3da4ca20070b1d18614f8ae7 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.1.2.1  2000/09/22 14:47:52  cblume
-Add the tracking code
+/* $Id$ */
 
-*/
+///////////////////////////////////////////////////////////////////////////////
+//                                                                           //
+//  TRD cluster                                                              //
+//                                                                           //
+/////////////////////////////////////////////////////////////////////////////// 
 
 #include "AliTRDcluster.h"
-#include "AliTRDgeometry.h"
-#include "AliTRDrecPoint.h"
-
 
 ClassImp(AliTRDcluster)
+
+//___________________________________________________________________________
+AliTRDcluster::AliTRDcluster() 
+  :AliCluster() 
+  ,fDetector(0)
+  ,fLocalTimeBin(0)
+  ,fQ(0)
+  ,fNPads(0)
+  ,fCenter(0)
+  ,fPadCol(0)
+  ,fPadRow(0)
+  ,fPadTime(0)
+{ 
+  //
+  // Default constructor
+  //
+
+  for (Int_t i = 0; i < 7; i++) {
+    fSignals[i] = 0;
+  }
+
+}
+
+//___________________________________________________________________________
+AliTRDcluster::AliTRDcluster(Int_t det, Float_t q
+                           , Float_t *pos, Float_t *sig
+                           , Int_t *tracks, Char_t npads, Short_t *signals
+                           , UChar_t col, UChar_t row, UChar_t time
+                           , Char_t timebin, Float_t center, UShort_t volid)
+  :AliCluster(volid,pos[0],pos[1],pos[2],sig[0],sig[1],0.0,0x0) 
+  ,fDetector(det)
+  ,fLocalTimeBin(timebin)
+  ,fQ(q)
+  ,fNPads(npads)
+  ,fCenter(center)
+  ,fPadCol(col)
+  ,fPadRow(row)
+  ,fPadTime(time)
+{ 
+  //
+  // Constructor
+  //
+
+  for (Int_t i = 0; i < 7; i++) {
+    fSignals[i] = signals[i];
+  }
+
+  if (tracks) {
+    AddTrackIndex(tracks);
+  }
+
+}
+
 //_____________________________________________________________________________
-AliTRDcluster::AliTRDcluster() {
-  //default constructor
+AliTRDcluster::AliTRDcluster(const AliTRDcluster &c)
+  :AliCluster(c)
+  ,fDetector(c.fDetector)
+  ,fLocalTimeBin(c.fLocalTimeBin)
+  ,fQ(c.fQ)
+  ,fNPads(c.fNPads)
+  ,fCenter(c.fCenter)
+  ,fPadCol(c.fPadCol)
+  ,fPadRow(c.fPadRow)
+  ,fPadTime(c.fPadTime)
+{
+  //
+  // Copy constructor 
+  //
+
+  SetBit(1, c.IsInChamber());
+  SetLabel(c.GetLabel(0),0);
+  SetLabel(c.GetLabel(1),1);
+  SetLabel(c.GetLabel(2),2);
+
+  SetY(c.GetY());
+  SetZ(c.GetZ());
+  SetSigmaY2(c.GetSigmaY2());
+  SetSigmaZ2(c.GetSigmaZ2());  
+
+  for (Int_t i = 0; i < 7; i++) {
+    fSignals[i] = c.fSignals[i];
+  }
 
-  fDetector = fTimeBin = 0;
-  fTracks[0]=fTracks[1]=fTracks[2]=0; 
-  fY=fZ=fQ=fSigmaY2=fSigmaZ2=0.;
 }
 
 //_____________________________________________________________________________
-AliTRDcluster::AliTRDcluster(AliTRDrecPoint *rp)
+void AliTRDcluster::AddTrackIndex(Int_t *track)
 {
   //
-  // constructor from AliTRDrecPoint
+  // Adds track index. Currently assumed that track is an array of
+  // size 9, and up to 3 track indexes are stored in fTracks[3].
+  // Indexes are sorted according to:
+  //  1) index of max number of appearances is stored first
+  //  2) if two or more indexes appear equal number of times, the lowest
+  //     ones are stored first;
   //
 
-  fDetector   = rp->GetDetector();
-  fTimeBin    = rp->GetLocalTimeBin();
+  const Int_t kSize = 9;
+  Int_t  entries[kSize][2];
 
-  fTracks[0]  = rp->GetTrackIndex(0);
-  fTracks[1]  = rp->GetTrackIndex(1);
-  fTracks[2]  = rp->GetTrackIndex(2);
+  Int_t  i = 0;
+  Int_t  j = 0;
+  Int_t  k = 0;
+  Int_t  index;
+  Bool_t indexAdded;
 
-  fQ          = rp->GetEnergy();
+  for (i = 0; i < kSize; i++) {
+    entries[i][0] = -1;
+    entries[i][1] =  0;
+  }                                 
 
-  fY          = rp->GetY();
-  fZ          = rp->GetZ();
-  fSigmaY2    = rp->GetSigmaY2();
-  fSigmaZ2    = rp->GetSigmaZ2();  
+  for (k = 0; k < kSize; k++) {
 
-  fSigmaY2    = 1;
-  fSigmaZ2    = 5;  
+    index      = track[k];
+    indexAdded = kFALSE; 
 
-}
+    j = 0;
+    if (index >= 0) {
+      while ((!indexAdded) && (j < kSize)) {
+        if ((entries[j][0] == index) || 
+            (entries[j][1] ==     0)) {
+          entries[j][0] = index;
+          entries[j][1] = entries[j][1] + 1;
+          indexAdded    = kTRUE;
+        }
+        j++;
+      }
+    }
+
+  }
+
+  // Sort by number of appearances and index value
+  Int_t swap = 1;
+  Int_t tmp0;
+  Int_t tmp1;
+  while (swap > 0) {
+    swap = 0;
+    for (i = 0; i < (kSize - 1); i++) {
+      if ((entries[i][0]   >= 0) && 
+          (entries[i+1][0] >= 0)) {
+        if ((entries[i][1] < entries[i+1][1]) ||
+            ((entries[i][1] == entries[i+1][1]) &&
+             (entries[i][0] >  entries[i+1][0]))) {
+          tmp0            = entries[i][0];
+          tmp1            = entries[i][1];
+          entries[i][0]   = entries[i+1][0];
+          entries[i][1]   = entries[i+1][1];
+          entries[i+1][0] = tmp0;
+          entries[i+1][1] = tmp1;
+          swap++;
+        }
+      }
+    }
+  }               
+
+  // Set track indexes
+  for (i = 0; i < 3; i++) {
+    SetLabel(entries[i][0],i);
+  }
+
+  return;
 
+}          
+
+//_____________________________________________________________________________
+Float_t AliTRDcluster::GetSumS() const
+{
+  //
+  // Returns the total charge from a not unfolded cluster
+  //
+
+  Float_t sum = 0.0;
+  for (Int_t i = 0; i < 7; i++) {
+    sum += fSignals[i];
+  }
+
+  return sum;
+
+}