1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // Alice segment manager object //
21 // AliSimDigits object (derived from AliDigits) //
22 // provide additional track information to digit //
23 // Origin: Marian Ivanov GSI Darmstadt //
26 ///////////////////////////////////////////////////////////////////////////////
29 #include <Riostream.h>
31 #include "AliSegmentID.h"
34 #include "AliDigits.h"
35 #include "AliSimDigits.h"
36 #include <TClonesArray.h>
40 //_____________________________________________________________________________
41 //_____________________________________________________________________________
42 //_____________________________________________________________________________
43 ClassImp(AliSimDigits)
45 AliSimDigits::AliSimDigits()
52 // AliDigits::Invalite();
57 AliSimDigits::AliSimDigits(const AliSimDigits ¶m)
67 fTrIndex = param.fTrIndex;
70 AliSimDigits::~AliSimDigits()
81 AliSimDigits & AliSimDigits::operator =(const AliSimDigits & param)
84 // assignment operator - dummy
87 fTrIndex=param.fTrIndex;
92 //__________________________________________________________________
93 void AliSimDigits::InvalidateTrack()
96 //set default (invalid parameters)
97 if ( fTracks != 0) delete fTracks;
98 fTracks = new TArrayI;
99 if ( fTrIndex != 0) delete fTrIndex;
100 fTrIndex = new TArrayI;
102 for (Int_t i = 0; i<3; i++){
108 void AliSimDigits::AllocateTrack(Int_t length)
111 //construct empty buffer fElements and fTracks with size fNrows x fNcols x
115 fTracks->Set(fNcols*fNrows*fNlevel);
120 Int_t AliSimDigits::GetTrackID(Int_t row, Int_t column, Int_t level)
124 if (fTrBufType == 0) return GetTrackIDFast(row, column,level);
125 if (fTrBufType == 1) return GetTrackID1(row, column,level);
126 if (fTrBufType == 2) return GetTrackID2(row, column,level);
130 void AliSimDigits::ExpandTrackBuffer()
133 //expand buffer to two dimensional array
135 Error("ExpandBuffer", "buffer doesn't exist");
138 if (fTrBufType==0) return; //buffer expanded
139 if (fTrBufType==1) {ExpandTrackBuffer1(); return;}
140 if (fTrBufType==2) ExpandTrackBuffer2();
144 void AliSimDigits::CompresTrackBuffer(Int_t bufType)
147 //compres buffer according buffertype algorithm
150 Error("CompressBuffer", "buffer doesn't exist");
153 if (fTrBufType == bufType) return;
155 if (fTrBufType>0) ExpandTrackBuffer();
156 if (fTrBufType !=0) {
157 Error("CompressBuffer", "buffer doesn't exist");
160 //compress buffer of type 1
162 if (bufType==1) {CompresTrackBuffer1();return;}
163 if (bufType==2) CompresTrackBuffer2();
167 Int_t AliSimDigits::GetTrackID1(Int_t row, Int_t column, Int_t level)
169 //return track ID of digits - for buffer compresion 2
171 i = level*fNcols+column;
172 if ( (i+1)>=fTrIndex->fN) n2 = fTracks->fN;
174 n2 = fTrIndex->At(i+1);
175 n1 = fTrIndex->At(i);
179 for (i = n1;(i<n2);i++){
181 Int_t num = fTracks->At(i);
187 num = fTracks->At(i);
200 if ( (row>=rowold) && (row<rownew) ) return id;
201 if (row < rownew ) return -2; //empty track
206 void AliSimDigits::ExpandTrackBuffer1()
209 //expand track compressed according algorithm 1 (track id comression independent to the digit compression)
210 // !!in expanded tracks we don't use fTrIndex array
214 Int_t all = fNrows*fNcols; //total number of digits
215 Int_t elems = all*fNlevel; //length of the buffer
217 TArrayI * buf = new TArrayI;
227 //oposite signa means how many unwrited (under threshold) values
228 Int_t num = fTracks->At(i);
229 if (num<0) row-=num; //negative number mean number of zeroes (no tracks of gibven level no need to write to array)
231 num %= 10000000; //PH: take into account the case of underlying events
233 Int_t id = fTracks->At(i);
234 for (j = 0; j<num; j++,row++) {
235 if (level*all+col*fNrows+row<elems) (*buf)[level*all+col*fNrows+row]=id;
246 }//end of loop over digits
251 void AliSimDigits::CompresTrackBuffer1()
254 //comress track according algorithm 1 (track id comression independent to the digit compression)
258 TArrayI * buf = new TArrayI; //create new buffer
259 buf->Set(fNrows*fNcols*fNlevel); //lets have the nearly the "worst case"
260 TArrayI * index = new TArrayI;
261 index->Set(fNcols*fNlevel);
265 Int_t icurrent=-1; //current index
266 Int_t izero; //number of zero
267 Int_t inum; //number of digits with the same current track id
268 Int_t lastID =0; //last track id
270 Int_t *cbuff=fTracks->GetArray(); //MI change
272 for (Int_t lev =0; lev<fNlevel; lev++){ //loop over levels
273 for (Int_t col = 0; col<fNcols; col++){ //loop over columns
277 (*index)[lev*fNcols+col]=icurrent+1;//set collumn pointer
278 Int_t id=0; //current id
279 for (Int_t row = 0; row< fNrows;row++){ //loop over rows
280 id = *cbuff; //MI change
281 // id = GetTrackIDFast(row,col,lev);
283 if ( inum> 0 ) { //if we have some tracks in buffer
285 if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2+1); //MI change - allocate +1
286 (*buf)[icurrent] = inum;
288 (*buf)[icurrent] = lastID;
297 //if we have currently izero count of non tracks digits
299 if (icurrent>=buf->fN) buf->Set(icurrent*2+1);
300 (*buf)[icurrent]= -izero; //write how many under zero
306 //if we change track id from another track id
308 if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2+1);
309 (*buf)[icurrent] = inum;
311 (*buf)[icurrent] = lastID;
320 }//end of loop over row
322 //if we have currently izero count of non tracks digits
324 if (icurrent>=buf->fN) buf->Set(icurrent*2);
325 (*buf)[icurrent]= -izero; //write how many under zero
327 if ( inum> 0 ) { //if we have some tracks in buffer
329 if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2);
330 (*buf)[icurrent] = inum;
332 (*buf)[icurrent] = id;
334 }//end of loop over columns
335 }//end of loop over differnet track level
336 buf->Set(icurrent+1);
345 void AliSimDigits::ExpandTrackBuffer2()
348 //comress track according algorithm 2 (track id comression according digit compression)
352 void AliSimDigits::CompresTrackBuffer2()
355 //comress track according algorithm 2 (track id comression according digit compression)
360 Int_t AliSimDigits::GetTrackID2(Int_t /*row*/, Int_t /*column*/, Int_t /*level*/)
362 //returnb track id of digits - for buffer compresion 2
368 AliH2F * AliSimDigits::DrawTracks( const char *option,Int_t level,
369 Float_t x1, Float_t x2, Float_t y1, Float_t y2)
372 //draw digits in given array
376 //sprintf(ch,"Track Segment_%d level %d ",GetID(),level );
377 snprintf(ch,30,"Track Segment_%d level %d ",GetID(),level );
378 if ( (fNrows<1)|| (fNcols<1)) {
381 AliH2F * his = new AliH2F("Track histo",ch,fNrows,0,fNrows,fNcols,0,fNcols);
383 //set histogram values
384 for (Int_t i = 0; i<fNrows;i++)
385 for (Int_t j = 0; j<fNcols;j++)
386 his->Fill(i,j,GetTrackIDFast(i,j,level));
388 AliH2F *h2fsub = his->GetSubrange2d(x1,x2,y1,y2);
392 if (his==0) return 0;
393 if (option!=0) his->Draw(option);
398 void AliSimDigits::GlitchFilter(){
400 // glitch filter, optionally
403 for (Int_t i=0;i<fNcols;i++){ //pads
404 for(Int_t j=1;j<fNrows-1;j++){ //time bins
405 // first and last time bins are checked separately
406 if(GetDigitFast(j,i)){// nonzero digit
407 if (!GetDigitFast(j-1,i) && !GetDigitFast(j+1,i)) {
409 SetTrackIDFast(-2,j,i,0);
410 SetTrackIDFast(-2,j,i,1);
411 SetTrackIDFast(-2,j,i,2);
416 if(GetDigitFast(0,i) && !GetDigitFast(1,i)) {
418 SetTrackIDFast(-2,0,i,0);
419 SetTrackIDFast(-2,0,i,1);
420 SetTrackIDFast(-2,0,i,2);
422 if(GetDigitFast(fNrows-1,i) && !GetDigitFast(fNrows-2,i)){
423 SetDigitFast(0,fNrows-1,i);
424 SetTrackIDFast(-2,fNrows-1,i,0);
425 SetTrackIDFast(-2,fNrows-1,i,1);
426 SetTrackIDFast(-2,fNrows-1,i,2);