]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliSimDigits.cxx
Improved cuts for the reconstruction of V0s (M.Ivanov)
[u/mrichter/AliRoot.git] / TPC / AliSimDigits.cxx
index 338ff2e0fc633bbb5dfb08bb014d786aaea3176b..3edbdfbe5b8307559adae4252fc4192ba1539f2f 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.2.4.3  2000/06/26 07:39:42  kowal2
-Changes to obey the coding rules
-
-Revision 1.2.4.2  2000/06/25 08:38:41  kowal2
-Splitted from AliTPCtracking
-
-Revision 1.2.4.1  2000/06/14 16:45:13  kowal2
-Improved algorithms. Compiler warnings removed.
-
-Revision 1.2  2000/04/17 09:37:33  kowal2
-removed obsolete AliTPCDigitsDisplay.C
-
-Revision 1.1.4.2  2000/04/10 11:37:42  kowal2
-
-Digits handling in a new data structure
-
-*/
-
-//
+/* $Id$ */
 
 ///////////////////////////////////////////////////////////////////////////////
 //                                                                           //
 //  Alice segment manager object                                             //
-//                                
-//  AliSimDigits object   (derived from AliDigits)                            //
+//  AliSimDigits object   (derived from AliDigits)                           //
 //  provide additional track information to digit                            //
-//  
-//   Origin: Marian Ivanov  GSI Darmstadt                                     //
-//
+//   Origin: Marian Ivanov  GSI Darmstadt                                    //
+//                                                                           //
 //                                                                           //
-//                                                                          //
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "TClass.h"
-#include <iostream.h>
+#include <Riostream.h>
 #include "TError.h"
 #include "AliSegmentID.h"
 #include "AliH2F.h"
@@ -58,6 +35,7 @@ Digits handling in a new data structure
 #include "AliDigits.h"
 #include "AliSimDigits.h"
 #include "AliTPC.h"
+#include <TClonesArray.h>
 
 
 
@@ -75,9 +53,13 @@ AliSimDigits::AliSimDigits()
 }
 AliSimDigits::~AliSimDigits()
 {
-  //  AliDigits::Invalidate();
-  if (fTracks != 0) fTracks->Delete();
-  if (fTrIndex != 0) fTrIndex->Delete();  
+
+  if (fTracks != 0) {
+    delete fTracks;
+  }
+  if (fTrIndex != 0) { 
+    delete fTrIndex;
+  } 
 
 }
 
@@ -188,7 +170,7 @@ Int_t  AliSimDigits::GetTrackID1(Int_t row, Int_t column, Int_t level)
       id = fTracks->At(i);
     }
     id-=2;
-    if ( (row>=rowold) && (row<=rownew) ) return id;
+    if ( (row>=rowold) && (row<rownew) ) return id;
     if (row < rownew ) return -2; //empty track
   }
   return -2;
@@ -219,6 +201,7 @@ void  AliSimDigits::ExpandTrackBuffer1()
     Int_t num = fTracks->At(i);
     if (num<0) row-=num;   //negative number mean number of zeroes (no tracks of gibven level no need to write to array) 
     else {
+      num %= 10000000; //PH: take into account the case of underlying events
       i++;
       Int_t id =  fTracks->At(i);
       for (j = 0; j<num; j++,row++) (*buf)[level*all+col*fNrows+row]=id;       
@@ -247,11 +230,16 @@ void  AliSimDigits::CompresTrackBuffer1()
   buf->Set(fNrows*fNcols*fNlevel); //lets have the nearly the "worst case"
   AliArrayI *  index = new AliArrayI;
   index->Set(fNcols*fNlevel);
+  //  Int_t * pindex = 
 
+  
   Int_t icurrent=-1;  //current index
   Int_t izero;      //number of zero
   Int_t inum;      //number of digits  with the same current track id  
-  Int_t lastID =0;  //last track id
+  Int_t lastID =0;  //last track id  
+  
+  Int_t *cbuff=fTracks->GetArray(); //MI change
+
   for (Int_t lev =0; lev<fNlevel; lev++){    //loop over levels 
     for (Int_t col = 0; col<fNcols; col++){    //loop over columns
       izero = 0;
@@ -259,12 +247,13 @@ void  AliSimDigits::CompresTrackBuffer1()
       lastID = 0;
       (*index)[lev*fNcols+col]=icurrent+1;//set collumn pointer
       Int_t id=0;  //current id
-      for (Int_t row = 0; row< fNrows;row++){ //loop over rows
-       id = GetTrackIDFast(row,col,lev);
+      for (Int_t row = 0; row< fNrows;row++){ //loop over rows        
+       id = *cbuff;  //MI change
+       //      id = GetTrackIDFast(row,col,lev);
        if (id <= 0) {
          if ( inum> 0 ) { //if we have some tracks in buffer
            icurrent++;
-           if ((icurrent+1)>=buf->fN) buf->Expand(icurrent*2);
+           if ((icurrent+1)>=buf->fN) buf->Expand(icurrent*2+1); //MI change - allocate +1
            (*buf)[icurrent] = inum;
            icurrent++;
            (*buf)[icurrent] = lastID;  
@@ -278,7 +267,7 @@ void  AliSimDigits::CompresTrackBuffer1()
            if ( izero > 0 ) { 
              //if we have currently izero count of non tracks digits
              icurrent++;         
-             if (icurrent>=buf->fN) buf->Expand(icurrent*2);
+             if (icurrent>=buf->fN) buf->Expand(icurrent*2+1);
              (*buf)[icurrent]= -izero;  //write how many under zero
              inum++;
              izero = 0;             
@@ -287,7 +276,7 @@ void  AliSimDigits::CompresTrackBuffer1()
            else{ 
              //if we change track id from another track id         
              icurrent++;         
-             if ((icurrent+1)>=buf->fN) buf->Expand(icurrent*2);
+             if ((icurrent+1)>=buf->fN) buf->Expand(icurrent*2+1);
              (*buf)[icurrent] = inum;
              icurrent++;
              (*buf)[icurrent] = lastID;        
@@ -298,8 +287,8 @@ void  AliSimDigits::CompresTrackBuffer1()
          else {          
            inum++;
          }
-       
-      }//end of loop over rows
+       cbuff++;  //MI change
+      }//end of loop over row
       if ( izero > 0 ) { 
        //if we have currently izero count of non tracks digits
        icurrent++;       
@@ -339,7 +328,7 @@ void  AliSimDigits::CompresTrackBuffer2()
 }
 
 
-Int_t  AliSimDigits::GetTrackID2(Int_t row, Int_t column, Int_t level)
+Int_t  AliSimDigits::GetTrackID2(Int_t /*row*/, Int_t /*column*/, Int_t /*level*/)
 {
   //returnb track id of digits - for buffer compresion 2
   return -2;
@@ -395,9 +384,9 @@ TClonesArray *  AliSimDigits::GenerTPCClonesArray(TClonesArray * arr)
        dig.fSignal= amp;
        dig.fPadRow =fSegmentID;
        dig.fSector =fSegmentID;
-       dig.fTracks[0]= GetTrackID(row,col,0);
-       dig.fTracks[1]= GetTrackID(row,col,1);
-       dig.fTracks[2]= GetTrackID(row,col,2);
+       dig.GetTracks()[0]= GetTrackID(row,col,0);
+       dig.GetTracks()[1]= GetTrackID(row,col,1);
+       dig.GetTracks()[2]= GetTrackID(row,col,2);
        TClonesArray &ldigits = *digits;
        new(ldigits[index++]) AliTPCdigit(dig);
       }