]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDcluster.cxx
Move to numbers of atoms for gas mixture
[u/mrichter/AliRoot.git] / TRD / AliTRDcluster.cxx
index bd1954abe379d3f51d86eee549dbe8f9744598ef..2010ab8758224dac640ab1de35c6fbfb09bc5120 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() { 
+  //
+  // default constructor
+  //
+  fQ=0; 
+  fTimeBin=0; 
+  fDetector=0; 
+  fNPads=0; 
+  fX    =0;
+  for (Int_t i = 0;i<7; i++) fSignals[i]=0;
+}
 //_____________________________________________________________________________
-AliTRDcluster::AliTRDcluster() {
-  //default constructor
+  AliTRDcluster::AliTRDcluster(const AliTRDrecPoint &p):AliCluster()
+{
+  //
+  // Constructor from AliTRDrecPoint
+  //
+
+  fDetector   = p.GetDetector();
+  fTimeBin    = p.GetLocalTimeBin();
+
+  fTracks[0]  = p.GetTrackIndex(0);
+  fTracks[1]  = p.GetTrackIndex(1);
+  fTracks[2]  = p.GetTrackIndex(2);
+
+  fQ          = p.GetEnergy();
+
+  fY          = p.GetY();
+  fZ          = p.GetZ();
+  fSigmaY2    = p.GetSigmaY2();
+  fSigmaZ2    = p.GetSigmaZ2();  
 
-  fDetector = fTimeBin = 0;
-  fTracks[0]=fTracks[1]=fTracks[2]=0; 
-  fY=fZ=fQ=fSigmaY2=fSigmaZ2=0.;
+  fSigmaY2    = 0.2;
+  fSigmaZ2    = 5.;  
+  fNPads      =0;
+  fCenter     = 0;
 }
 
 //_____________________________________________________________________________
-AliTRDcluster::AliTRDcluster(AliTRDrecPoint *rp)
+AliTRDcluster::AliTRDcluster(const AliTRDcluster &c):AliCluster()
 {
   //
-  // constructor from AliTRDrecPoint
+  // Copy constructor 
   //
 
-  fDetector   = rp->GetDetector();
-  fTimeBin    = rp->GetLocalTimeBin();
+  fTracks[0]  = c.GetLabel(0);
+  fTracks[1]  = c.GetLabel(1);
+  fTracks[2]  = c.GetLabel(2);
 
-  fTracks[0]  = rp->GetTrackIndex(0);
-  fTracks[1]  = rp->GetTrackIndex(1);
-  fTracks[2]  = rp->GetTrackIndex(2);
+  fX          = c.GetX();
+  fY          = c.GetY();
+  fZ          = c.GetZ();
+  fSigmaY2    = c.GetSigmaY2();
+  fSigmaZ2    = c.GetSigmaZ2();  
 
-  fQ          = rp->GetEnergy();
+  fDetector   = c.GetDetector();
+  fTimeBin    = c.GetLocalTimeBin();
+  fQ          = c.GetQ();
+  fNPads      = c.fNPads;
+  fCenter     = c.fCenter;
+  for (Int_t i=0;i<7;i++) fSignals[i] = c.fSignals[i];
+}
 
-  fY          = rp->GetY();
-  fZ          = rp->GetZ();
-  fSigmaY2    = rp->GetSigmaY2();
-  fSigmaZ2    = rp->GetSigmaZ2();  
+//_____________________________________________________________________________
+void AliTRDcluster::AddTrackIndex(Int_t *track)
+{
+  //
+  // 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;
+  //
 
-  fSigmaY2    = 1;
-  fSigmaZ2    = 5;  
+  const Int_t kSize = 9;
 
+  Int_t entries[kSize][2], i, j, index;
+
+  Bool_t indexAdded;
+
+  for (i=0; i<kSize; i++) {
+    entries[i][0]=-1;
+    entries[i][1]=0;
+  }                                 
+
+  for (Int_t k=0; k<kSize; k++) {
+    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, tmp0, 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;
+
+}          
+
+void AliTRDcluster::SetSignals(Short_t*signals){
+  //
+  // write signals in the cluster
+  //
+  for (Int_t i = 0;i<7;i++) fSignals[i]=signals[i];
 }
 
+Float_t AliTRDcluster::GetSumS() const
+{
+  //
+  // return total charge in non unfolded cluster
+  //
+  Float_t sum=0;
+  for (Int_t i = 0;i<7;i++) sum+=fSignals[i];
+  return sum;
+}
+Float_t AliTRDcluster::GetCenterS() const
+{
+  //
+  //
+  //
+  Float_t sum=0;
+  Float_t sum2=0;
+  for (Int_t i = 0;i<7;i++) {    
+    sum+=fSignals[i];
+    sum2+=i*fSignals[i];
+  }
+  if (sum>0) return sum2/sum-2;
+  return 0;
+
+}