]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliSimDigits.cxx
Removing duplicate files
[u/mrichter/AliRoot.git] / TPC / AliSimDigits.cxx
index 32093fa093350d11faacede0fbf84d73f549eeba..6340493a62daa9c81edadd66998f64c0f10d02c9 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-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"
-#include "AliArrayI.h"
-#include "AliArrayS.h"
+#include "TArrayI.h"
 #include "AliDigits.h"
 #include "AliSimDigits.h"
-#include "AliTPC.h"
+#include "AliTPCdigit.h"
+#include <TClonesArray.h>
 
 
 
@@ -54,28 +44,59 @@ Digits handling in a new data structure
 ClassImp(AliSimDigits)
 
 AliSimDigits::AliSimDigits()
+             :AliDigits(),
+             fTracks(0),
+             fTrIndex(0),
+             fNlevel(0),
+             fTrBufType(0)  
 {
   //  AliDigits::Invalite();
-  fTracks = 0;
-  fTrIndex = 0;  
   InvalidateTrack();
 }
+//
+AliSimDigits::AliSimDigits(const AliSimDigits &param)
+             :AliDigits(),
+             fTracks(0),
+             fTrIndex(0),
+             fNlevel(0),
+             fTrBufType(0) 
+{
+  //
+  // dummy
+  //
+  fTrIndex = param.fTrIndex;
+}
+//
 AliSimDigits::~AliSimDigits()
 {
-  //  AliDigits::Invalidate();
-  if (fTracks != 0) fTracks->Delete();
-  if (fTrIndex != 0) fTrIndex->Delete();  
+
+  if (fTracks != 0) {
+    delete fTracks;
+  }
+  if (fTrIndex != 0) { 
+    delete fTrIndex;
+  } 
 
 }
+AliSimDigits & AliSimDigits::operator =(const AliSimDigits & param)
+{
+  //
+  // assignment operator - dummy
+  //
+  fTrIndex=param.fTrIndex;
+  return (*this);
+}
 
+//__________________________________________________________________
 void AliSimDigits::InvalidateTrack() 
 { 
   //
   //set default (invalid parameters)
   if ( fTracks != 0) delete fTracks;
-  fTracks = new AliArrayI;
+  fTracks = new TArrayI;
   if ( fTrIndex  != 0) delete fTrIndex;
-  fTrIndex = new AliArrayI;
+  fTrIndex = new TArrayI;
 
   for (Int_t i = 0; i<3; i++){
     fTracks->Set(0);
@@ -153,9 +174,9 @@ Int_t  AliSimDigits::GetTrackID1(Int_t row, Int_t column, Int_t level)
   n1 = fTrIndex->At(i);
   Int_t rownew = 0;
   Int_t rowold=0;
-  Int_t ID;
+  Int_t id;
   for (i = n1;(i<n2);i++){
-    ID = 0;
+    id = 0;
     Int_t num = fTracks->At(i);
     if (num<0) {
       rownew-=num;  
@@ -165,17 +186,17 @@ Int_t  AliSimDigits::GetTrackID1(Int_t row, Int_t column, Int_t level)
        num = fTracks->At(i);
        rownew+=num;
        i++;
-       ID = fTracks->At(i);
+       id = fTracks->At(i);
       }
     }
     else {
       rowold = rownew;
       rownew+=num;
       i++;
-      ID = fTracks->At(i);
+      id = fTracks->At(i);
     }
-ID-=2;
-    if ( (row>=rowold) && (row<=rownew) ) return ID;
+    id-=2;
+    if ( (row>=rowold) && (row<rownew) ) return id;
     if (row < rownew ) return -2; //empty track
   }
   return -2;
@@ -184,7 +205,7 @@ ID-=2;
 void  AliSimDigits::ExpandTrackBuffer1()
 {
   //
-  //expand  track compressed according algorithm 1 (track ID comression independent to the digit compression)
+  //expand  track compressed according algorithm 1 (track id comression independent to the digit compression)
   // !!in expanded tracks we don't use fTrIndex array
   //  
   fTrBufType = 0;
@@ -192,23 +213,26 @@ void  AliSimDigits::ExpandTrackBuffer1()
   Int_t all   = fNrows*fNcols;  //total number of digits
   Int_t elems = all*fNlevel;  //length of the buffer
 
-  AliArrayI * buf = new AliArrayI;
+  TArrayI * buf = new TArrayI;
   buf->Set(elems);
   fTrIndex->Set(0);
   //
   Int_t level = 0;
   Int_t col=0;
   Int_t row = 0;
-  Int_t N=fTracks->fN;
+  Int_t n=fTracks->fN;
   //
-  for (i=0;i<N;i++){
+  for (i=0;i<n;i++){
     //oposite signa means how many unwrited (under threshold) values
     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;       
+      Int_t id =  fTracks->At(i);
+      for (j = 0; j<num; j++,row++) {
+       if (level*all+col*fNrows+row<elems) (*buf)[level*all+col*fNrows+row]=id;       
+      }
     }
     if (row>=fNrows) {
       row=0;
@@ -226,32 +250,38 @@ void  AliSimDigits::ExpandTrackBuffer1()
 void  AliSimDigits::CompresTrackBuffer1()
 {
   //
-  //comress track according algorithm 1 (track ID comression independent to the digit compression)
+  //comress track according algorithm 1 (track id comression independent to the digit compression)
   //
   fTrBufType = 1;  
 
-  AliArrayI *  buf = new AliArrayI;   //create  new buffer 
+  TArrayI *  buf = new TArrayI;   //create  new buffer 
   buf->Set(fNrows*fNcols*fNlevel); //lets have the nearly the "worst case"
-  AliArrayI *  index = new AliArrayI;
+  TArrayI *  index = new TArrayI;
   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 inum;      //number of digits  with the same current 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;
       inum =  0;
       lastID = 0;
       (*index)[lev*fNcols+col]=icurrent+1;//set collumn pointer
-      Int_t ID;  //current ID
-      for (Int_t row = 0; row< fNrows;row++){ //loop over rows
-       ID = GetTrackIDFast(row,col,lev);
-       if (ID <= 0) {
+      Int_t id=0;  //current id
+      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->Set(icurrent*2+1); //MI change - allocate +1
            (*buf)[icurrent] = inum;
            icurrent++;
            (*buf)[icurrent] = lastID;  
@@ -261,48 +291,48 @@ void  AliSimDigits::CompresTrackBuffer1()
          izero++;
        }
        else
-          if (ID != lastID) 
+          if (id != lastID) 
            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->Set(icurrent*2+1);
              (*buf)[icurrent]= -izero;  //write how many under zero
              inum++;
              izero = 0;             
-             lastID = ID;
+             lastID = id;
            }
            else{ 
-             //if we change track ID from another track ID         
+             //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->Set(icurrent*2+1);
              (*buf)[icurrent] = inum;
              icurrent++;
              (*buf)[icurrent] = lastID;        
-             lastID = ID;
+             lastID = id;
              inum = 1;      
              izero = 0;
            }   
          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++;       
-       if (icurrent>=buf->fN) buf->Expand(icurrent*2);
+       if (icurrent>=buf->fN) buf->Set(icurrent*2);
        (*buf)[icurrent]= -izero;  //write how many under zero  
       }
       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->Set(icurrent*2);
        (*buf)[icurrent] = inum;
        icurrent++;
-       (*buf)[icurrent] = ID;  
+       (*buf)[icurrent] = id;  
       }      
     }//end of loop over columns
   }//end of loop over differnet track level  
-  buf->Expand(icurrent+1);
+  buf->Set(icurrent+1);
   delete fTracks;
   fTracks = buf;
   delete fTrIndex;
@@ -314,21 +344,21 @@ void  AliSimDigits::CompresTrackBuffer1()
 void  AliSimDigits::ExpandTrackBuffer2()
 {
   //
-  //comress track according algorithm 2 (track ID comression according  digit compression)
+  //comress track according algorithm 2 (track id comression according  digit compression)
   fTrBufType = 0;
 }
 
 void  AliSimDigits::CompresTrackBuffer2()
 {
   //
-  //comress track according algorithm 2 (track ID comression according  digit compression)
+  //comress track according algorithm 2 (track id comression according  digit compression)
   fTrBufType = 2;
 }
 
 
-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
+  //returnb track id of digits - for buffer compresion 2
   return -2;
 }
 
@@ -382,9 +412,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);
       }