]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliSimDigits.cxx
Add macro to create OCDB entry for ion tail
[u/mrichter/AliRoot.git] / TPC / AliSimDigits.cxx
index 479df5748ac50d0fade3c68783f5c9e80fe7c276..0ebe639593771336a2f62adb41801a08079d8c22 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
-/*
-$Log$
-Revision 1.7  2002/10/23 07:17:33  alibrary
-Introducing Riostream.h
-
-Revision 1.6  2002/01/21 17:15:23  kowal2
-Better protection.
-
-Revision 1.5  2001/11/24 16:10:22  kowal2
-Faster algorithms.
-
-Revision 1.4  2000/10/05 16:01:49  kowal2
-Corrected for memory leaks.
-
-Revision 1.3  2000/06/30 12:07:49  kowal2
-Updated from the TPC-PreRelease branch
-
-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"
@@ -68,11 +30,10 @@ Digits handling in a new data structure
 #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>
 
 
@@ -83,12 +44,30 @@ 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()
 {
 
@@ -100,15 +79,26 @@ AliSimDigits::~AliSimDigits()
   } 
 
 }
+AliSimDigits & AliSimDigits::operator =(const AliSimDigits & param)
+{
+  //
+  // assignment operator - dummy
+  //
+  if(this!=&param){
+    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);
@@ -208,7 +198,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;
@@ -225,7 +215,7 @@ 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);
   //
@@ -239,9 +229,12 @@ 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;       
+      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;
@@ -263,9 +256,9 @@ void  AliSimDigits::CompresTrackBuffer1()
   //
   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 = 
 
@@ -290,7 +283,7 @@ void  AliSimDigits::CompresTrackBuffer1()
        if (id <= 0) {
          if ( inum> 0 ) { //if we have some tracks in buffer
            icurrent++;
-           if ((icurrent+1)>=buf->fN) buf->Expand(icurrent*2+1); //MI change - allocate +1
+           if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2+1); //MI change - allocate +1
            (*buf)[icurrent] = inum;
            icurrent++;
            (*buf)[icurrent] = lastID;  
@@ -304,7 +297,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+1);
+             if (icurrent>=buf->fN) buf->Set(icurrent*2+1);
              (*buf)[icurrent]= -izero;  //write how many under zero
              inum++;
              izero = 0;             
@@ -313,7 +306,7 @@ void  AliSimDigits::CompresTrackBuffer1()
            else{ 
              //if we change track id from another track id         
              icurrent++;         
-             if ((icurrent+1)>=buf->fN) buf->Expand(icurrent*2+1);
+             if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2+1);
              (*buf)[icurrent] = inum;
              icurrent++;
              (*buf)[icurrent] = lastID;        
@@ -329,19 +322,19 @@ 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->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;  
       }      
     }//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;
@@ -365,7 +358,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;
@@ -381,7 +374,8 @@ AliH2F *  AliSimDigits::DrawTracks( const char *option,Int_t level,
   //  
   //make digits histo 
   char ch[30];
-  sprintf(ch,"Track Segment_%d level %d ",GetID(),level );
+  //sprintf(ch,"Track Segment_%d level %d ",GetID(),level );
+  snprintf(ch,30,"Track Segment_%d level %d ",GetID(),level );
   if ( (fNrows<1)|| (fNcols<1)) {
     return 0;
   }
@@ -430,4 +424,37 @@ TClonesArray *  AliSimDigits::GenerTPCClonesArray(TClonesArray * arr)
     }    
   return digits;
 }
+void AliSimDigits::GlitchFilter(){
+  //
+  //  glitch filter, optionally
+  //
+  
+  for (Int_t i=0;i<fNcols;i++){ //pads
+    for(Int_t j=1;j<fNrows-1;j++){ //time bins
+      // first and last time bins are checked separately
+      if(GetDigitFast(j,i)){// nonzero digit
+        if (!GetDigitFast(j-1,i) && !GetDigitFast(j+1,i)) {
+          SetDigitFast(0,j,i);
+          SetTrackIDFast(-2,j,i,0);
+          SetTrackIDFast(-2,j,i,1);
+          SetTrackIDFast(-2,j,i,2);
+       }
+      }
+    }//time
+   
+    if(GetDigitFast(0,i) && !GetDigitFast(1,i)) {
+        SetDigitFast(0,0,i);
+        SetTrackIDFast(-2,0,i,0);
+        SetTrackIDFast(-2,0,i,1);
+        SetTrackIDFast(-2,0,i,2);
+    }
+    if(GetDigitFast(fNrows-1,i) && !GetDigitFast(fNrows-2,i)){ 
+       SetDigitFast(0,fNrows-1,i);
+       SetTrackIDFast(-2,fNrows-1,i,0);
+       SetTrackIDFast(-2,fNrows-1,i,1);
+       SetTrackIDFast(-2,fNrows-1,i,2);    
+    }
+  }//pads
+}