]>
Commit | Line | Data |
---|---|---|
cc80f89e | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
88cb7938 | 16 | /* $Id$ */ |
cc80f89e | 17 | |
18 | /////////////////////////////////////////////////////////////////////////////// | |
19 | // // | |
20 | // Alice segment manager object // | |
88cb7938 | 21 | // AliSimDigits object (derived from AliDigits) // |
cc80f89e | 22 | // provide additional track information to digit // |
88cb7938 | 23 | // Origin: Marian Ivanov GSI Darmstadt // |
24 | // // | |
cc80f89e | 25 | // // |
cc80f89e | 26 | /////////////////////////////////////////////////////////////////////////////// |
27 | ||
28 | #include "TClass.h" | |
19364939 | 29 | #include <Riostream.h> |
cc80f89e | 30 | #include "TError.h" |
31 | #include "AliSegmentID.h" | |
32 | #include "AliH2F.h" | |
e756ece8 | 33 | #include "TArrayI.h" |
cc80f89e | 34 | #include "AliDigits.h" |
35 | #include "AliSimDigits.h" | |
6d75e4b6 | 36 | #include "AliTPCdigit.h" |
c4aa8648 | 37 | #include <TClonesArray.h> |
cc80f89e | 38 | |
39 | ||
40 | ||
41 | //_____________________________________________________________________________ | |
42 | //_____________________________________________________________________________ | |
43 | //_____________________________________________________________________________ | |
44 | ClassImp(AliSimDigits) | |
45 | ||
46 | AliSimDigits::AliSimDigits() | |
179c6296 | 47 | :AliDigits(), |
48 | fTracks(0), | |
49 | fTrIndex(0), | |
50 | fNlevel(0), | |
51 | fTrBufType(0) | |
cc80f89e | 52 | { |
53 | // AliDigits::Invalite(); | |
179c6296 | 54 | |
cc80f89e | 55 | InvalidateTrack(); |
56 | } | |
179c6296 | 57 | // |
58 | AliSimDigits::AliSimDigits(const AliSimDigits ¶m) | |
59 | :AliDigits(), | |
60 | fTracks(0), | |
61 | fTrIndex(0), | |
62 | fNlevel(0), | |
63 | fTrBufType(0) | |
64 | { | |
65 | // | |
66 | // dummy | |
67 | // | |
68 | fTrIndex = param.fTrIndex; | |
69 | } | |
70 | // | |
cc80f89e | 71 | AliSimDigits::~AliSimDigits() |
72 | { | |
c4aa8648 | 73 | |
74 | if (fTracks != 0) { | |
75 | delete fTracks; | |
76 | } | |
77 | if (fTrIndex != 0) { | |
78 | delete fTrIndex; | |
79 | } | |
cc80f89e | 80 | |
81 | } | |
179c6296 | 82 | AliSimDigits & AliSimDigits::operator =(const AliSimDigits & param) |
83 | { | |
84 | // | |
85 | // assignment operator - dummy | |
86 | // | |
87 | fTrIndex=param.fTrIndex; | |
88 | return (*this); | |
89 | } | |
cc80f89e | 90 | |
179c6296 | 91 | //__________________________________________________________________ |
cc80f89e | 92 | void AliSimDigits::InvalidateTrack() |
93 | { | |
94 | // | |
95 | //set default (invalid parameters) | |
96 | if ( fTracks != 0) delete fTracks; | |
e756ece8 | 97 | fTracks = new TArrayI; |
cc80f89e | 98 | if ( fTrIndex != 0) delete fTrIndex; |
e756ece8 | 99 | fTrIndex = new TArrayI; |
cc80f89e | 100 | |
101 | for (Int_t i = 0; i<3; i++){ | |
102 | fTracks->Set(0); | |
103 | fTrIndex->Set(0); | |
104 | } | |
105 | } | |
106 | ||
107 | void AliSimDigits::AllocateTrack(Int_t length) | |
108 | { | |
109 | // | |
110 | //construct empty buffer fElements and fTracks with size fNrows x fNcols x | |
111 | //length | |
112 | InvalidateTrack(); | |
113 | fNlevel = length; | |
114 | fTracks->Set(fNcols*fNrows*fNlevel); | |
115 | fTrIndex->Set(0); | |
116 | fTrBufType =0; | |
117 | } | |
118 | ||
119 | Int_t AliSimDigits::GetTrackID(Int_t row, Int_t column, Int_t level) | |
120 | { | |
121 | // | |
122 | //Get track ID | |
123 | if (fTrBufType == 0) return GetTrackIDFast(row, column,level); | |
124 | if (fTrBufType == 1) return GetTrackID1(row, column,level); | |
125 | if (fTrBufType == 2) return GetTrackID2(row, column,level); | |
126 | return 0; | |
127 | } | |
128 | ||
129 | void AliSimDigits::ExpandTrackBuffer() | |
130 | { | |
131 | // | |
132 | //expand buffer to two dimensional array | |
133 | if (fTrBufType<0) { | |
134 | Error("ExpandBuffer", "buffer doesn't exist"); | |
135 | return; | |
136 | } | |
137 | if (fTrBufType==0) return; //buffer expanded | |
138 | if (fTrBufType==1) {ExpandTrackBuffer1(); return;} | |
139 | if (fTrBufType==2) ExpandTrackBuffer2(); | |
140 | ||
141 | } | |
142 | ||
143 | void AliSimDigits::CompresTrackBuffer(Int_t bufType) | |
144 | { | |
145 | // | |
146 | //compres buffer according buffertype algorithm | |
147 | // | |
148 | if (fTrBufType<0) { | |
149 | Error("CompressBuffer", "buffer doesn't exist"); | |
150 | return; | |
151 | } | |
152 | if (fTrBufType == bufType) return; | |
153 | // | |
154 | if (fTrBufType>0) ExpandTrackBuffer(); | |
155 | if (fTrBufType !=0) { | |
156 | Error("CompressBuffer", "buffer doesn't exist"); | |
157 | return; | |
158 | } | |
159 | //compress buffer of type 1 | |
160 | ||
161 | if (bufType==1) {CompresTrackBuffer1();return;} | |
162 | if (bufType==2) CompresTrackBuffer2(); | |
163 | ||
164 | } | |
165 | ||
166 | Int_t AliSimDigits::GetTrackID1(Int_t row, Int_t column, Int_t level) | |
167 | { | |
168 | //return track ID of digits - for buffer compresion 2 | |
169 | Int_t i,n1,n2; | |
170 | i = level*fNcols+column; | |
171 | if ( (i+1)>=fTrIndex->fN) n2 = fTracks->fN; | |
172 | else | |
173 | n2 = fTrIndex->At(i+1); | |
174 | n1 = fTrIndex->At(i); | |
175 | Int_t rownew = 0; | |
176 | Int_t rowold=0; | |
73042f01 | 177 | Int_t id; |
cc80f89e | 178 | for (i = n1;(i<n2);i++){ |
73042f01 | 179 | id = 0; |
cc80f89e | 180 | Int_t num = fTracks->At(i); |
181 | if (num<0) { | |
182 | rownew-=num; | |
183 | rowold = rownew; | |
184 | i++; | |
185 | if (i<n2){ | |
186 | num = fTracks->At(i); | |
187 | rownew+=num; | |
188 | i++; | |
73042f01 | 189 | id = fTracks->At(i); |
cc80f89e | 190 | } |
191 | } | |
192 | else { | |
193 | rowold = rownew; | |
194 | rownew+=num; | |
195 | i++; | |
73042f01 | 196 | id = fTracks->At(i); |
cc80f89e | 197 | } |
73042f01 | 198 | id-=2; |
babd135a | 199 | if ( (row>=rowold) && (row<rownew) ) return id; |
cc80f89e | 200 | if (row < rownew ) return -2; //empty track |
201 | } | |
202 | return -2; | |
203 | } | |
204 | ||
205 | void AliSimDigits::ExpandTrackBuffer1() | |
206 | { | |
207 | // | |
73042f01 | 208 | //expand track compressed according algorithm 1 (track id comression independent to the digit compression) |
cc80f89e | 209 | // !!in expanded tracks we don't use fTrIndex array |
210 | // | |
211 | fTrBufType = 0; | |
212 | Int_t i,j; | |
213 | Int_t all = fNrows*fNcols; //total number of digits | |
214 | Int_t elems = all*fNlevel; //length of the buffer | |
215 | ||
e756ece8 | 216 | TArrayI * buf = new TArrayI; |
cc80f89e | 217 | buf->Set(elems); |
218 | fTrIndex->Set(0); | |
219 | // | |
220 | Int_t level = 0; | |
221 | Int_t col=0; | |
222 | Int_t row = 0; | |
73042f01 | 223 | Int_t n=fTracks->fN; |
cc80f89e | 224 | // |
73042f01 | 225 | for (i=0;i<n;i++){ |
cc80f89e | 226 | //oposite signa means how many unwrited (under threshold) values |
227 | Int_t num = fTracks->At(i); | |
228 | if (num<0) row-=num; //negative number mean number of zeroes (no tracks of gibven level no need to write to array) | |
229 | else { | |
a97dda3d | 230 | num %= 10000000; //PH: take into account the case of underlying events |
cc80f89e | 231 | i++; |
73042f01 | 232 | Int_t id = fTracks->At(i); |
3789f4fd | 233 | for (j = 0; j<num; j++,row++) { |
234 | if (level*all+col*fNrows+row<elems) (*buf)[level*all+col*fNrows+row]=id; | |
235 | } | |
cc80f89e | 236 | } |
237 | if (row>=fNrows) { | |
238 | row=0; | |
239 | col++; | |
240 | } | |
241 | if (col>=fNcols) { | |
242 | col=0; | |
243 | level++; | |
244 | } | |
245 | }//end of loop over digits | |
246 | delete fTracks; | |
247 | fTracks = buf; | |
248 | } | |
249 | ||
250 | void AliSimDigits::CompresTrackBuffer1() | |
251 | { | |
252 | // | |
73042f01 | 253 | //comress track according algorithm 1 (track id comression independent to the digit compression) |
cc80f89e | 254 | // |
255 | fTrBufType = 1; | |
256 | ||
e756ece8 | 257 | TArrayI * buf = new TArrayI; //create new buffer |
cc80f89e | 258 | buf->Set(fNrows*fNcols*fNlevel); //lets have the nearly the "worst case" |
e756ece8 | 259 | TArrayI * index = new TArrayI; |
cc80f89e | 260 | index->Set(fNcols*fNlevel); |
407ff276 | 261 | // Int_t * pindex = |
cc80f89e | 262 | |
407ff276 | 263 | |
cc80f89e | 264 | Int_t icurrent=-1; //current index |
265 | Int_t izero; //number of zero | |
73042f01 | 266 | Int_t inum; //number of digits with the same current track id |
407ff276 | 267 | Int_t lastID =0; //last track id |
268 | ||
269 | Int_t *cbuff=fTracks->GetArray(); //MI change | |
270 | ||
cc80f89e | 271 | for (Int_t lev =0; lev<fNlevel; lev++){ //loop over levels |
272 | for (Int_t col = 0; col<fNcols; col++){ //loop over columns | |
273 | izero = 0; | |
274 | inum = 0; | |
275 | lastID = 0; | |
276 | (*index)[lev*fNcols+col]=icurrent+1;//set collumn pointer | |
73042f01 | 277 | Int_t id=0; //current id |
407ff276 | 278 | for (Int_t row = 0; row< fNrows;row++){ //loop over rows |
279 | id = *cbuff; //MI change | |
280 | // id = GetTrackIDFast(row,col,lev); | |
73042f01 | 281 | if (id <= 0) { |
cc80f89e | 282 | if ( inum> 0 ) { //if we have some tracks in buffer |
283 | icurrent++; | |
e756ece8 | 284 | if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2+1); //MI change - allocate +1 |
cc80f89e | 285 | (*buf)[icurrent] = inum; |
286 | icurrent++; | |
287 | (*buf)[icurrent] = lastID; | |
288 | inum = 0; | |
289 | lastID = 0; | |
290 | } | |
291 | izero++; | |
292 | } | |
293 | else | |
73042f01 | 294 | if (id != lastID) |
cc80f89e | 295 | if ( izero > 0 ) { |
296 | //if we have currently izero count of non tracks digits | |
297 | icurrent++; | |
e756ece8 | 298 | if (icurrent>=buf->fN) buf->Set(icurrent*2+1); |
cc80f89e | 299 | (*buf)[icurrent]= -izero; //write how many under zero |
300 | inum++; | |
301 | izero = 0; | |
73042f01 | 302 | lastID = id; |
cc80f89e | 303 | } |
304 | else{ | |
73042f01 | 305 | //if we change track id from another track id |
cc80f89e | 306 | icurrent++; |
e756ece8 | 307 | if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2+1); |
cc80f89e | 308 | (*buf)[icurrent] = inum; |
309 | icurrent++; | |
310 | (*buf)[icurrent] = lastID; | |
73042f01 | 311 | lastID = id; |
cc80f89e | 312 | inum = 1; |
313 | izero = 0; | |
314 | } | |
315 | else { | |
316 | inum++; | |
317 | } | |
407ff276 | 318 | cbuff++; //MI change |
319 | }//end of loop over row | |
cc80f89e | 320 | if ( izero > 0 ) { |
321 | //if we have currently izero count of non tracks digits | |
322 | icurrent++; | |
e756ece8 | 323 | if (icurrent>=buf->fN) buf->Set(icurrent*2); |
cc80f89e | 324 | (*buf)[icurrent]= -izero; //write how many under zero |
325 | } | |
326 | if ( inum> 0 ) { //if we have some tracks in buffer | |
327 | icurrent++; | |
e756ece8 | 328 | if ((icurrent+1)>=buf->fN) buf->Set(icurrent*2); |
cc80f89e | 329 | (*buf)[icurrent] = inum; |
330 | icurrent++; | |
73042f01 | 331 | (*buf)[icurrent] = id; |
cc80f89e | 332 | } |
333 | }//end of loop over columns | |
334 | }//end of loop over differnet track level | |
e756ece8 | 335 | buf->Set(icurrent+1); |
cc80f89e | 336 | delete fTracks; |
337 | fTracks = buf; | |
338 | delete fTrIndex; | |
339 | fTrIndex = index; | |
340 | } | |
341 | ||
342 | ||
343 | ||
344 | void AliSimDigits::ExpandTrackBuffer2() | |
345 | { | |
346 | // | |
73042f01 | 347 | //comress track according algorithm 2 (track id comression according digit compression) |
cc80f89e | 348 | fTrBufType = 0; |
349 | } | |
350 | ||
351 | void AliSimDigits::CompresTrackBuffer2() | |
352 | { | |
353 | // | |
73042f01 | 354 | //comress track according algorithm 2 (track id comression according digit compression) |
cc80f89e | 355 | fTrBufType = 2; |
356 | } | |
357 | ||
358 | ||
176aff27 | 359 | Int_t AliSimDigits::GetTrackID2(Int_t /*row*/, Int_t /*column*/, Int_t /*level*/) |
cc80f89e | 360 | { |
73042f01 | 361 | //returnb track id of digits - for buffer compresion 2 |
cc80f89e | 362 | return -2; |
363 | } | |
364 | ||
365 | ||
366 | ||
367 | AliH2F * AliSimDigits::DrawTracks( const char *option,Int_t level, | |
368 | Float_t x1, Float_t x2, Float_t y1, Float_t y2) | |
369 | { | |
370 | // | |
371 | //draw digits in given array | |
372 | // | |
373 | //make digits histo | |
374 | char ch[30]; | |
375 | sprintf(ch,"Track Segment_%d level %d ",GetID(),level ); | |
376 | if ( (fNrows<1)|| (fNcols<1)) { | |
377 | return 0; | |
378 | } | |
379 | AliH2F * his = new AliH2F("Track histo",ch,fNrows,0,fNrows,fNcols,0,fNcols); | |
380 | ExpandTrackBuffer(); | |
381 | //set histogram values | |
382 | for (Int_t i = 0; i<fNrows;i++) | |
383 | for (Int_t j = 0; j<fNcols;j++) | |
384 | his->Fill(i,j,GetTrackIDFast(i,j,level)); | |
385 | if (x1>=0) { | |
386 | AliH2F *h2fsub = his->GetSubrange2d(x1,x2,y1,y2); | |
387 | delete his; | |
388 | his=h2fsub; | |
389 | } | |
390 | if (his==0) return 0; | |
391 | if (option!=0) his->Draw(option); | |
392 | else his->Draw(); | |
393 | return his; | |
394 | } | |
395 | ||
396 | TClonesArray * AliSimDigits::GenerTPCClonesArray(TClonesArray * arr) | |
397 | { | |
398 | // | |
399 | //generate TClonnesArray of digits | |
400 | // | |
401 | TClonesArray * digits; | |
402 | if (arr==0) digits=new TClonesArray("AliTPCdigit",300); | |
403 | else digits = arr; | |
404 | Int_t index = digits->GetEntriesFast(); | |
405 | for (Int_t row =0; row<fNrows; row++) | |
406 | for (Int_t col =0; col<fNcols; col++){ | |
407 | Int_t amp = GetDigit(row,col); | |
408 | if (amp>GetThreshold()){ | |
409 | AliTPCdigit dig; | |
410 | dig.fPad = col; | |
411 | dig.fTime = row; | |
412 | dig.fSignal= amp; | |
413 | dig.fPadRow =fSegmentID; | |
414 | dig.fSector =fSegmentID; | |
116cbefd | 415 | dig.GetTracks()[0]= GetTrackID(row,col,0); |
416 | dig.GetTracks()[1]= GetTrackID(row,col,1); | |
417 | dig.GetTracks()[2]= GetTrackID(row,col,2); | |
cc80f89e | 418 | TClonesArray &ldigits = *digits; |
419 | new(ldigits[index++]) AliTPCdigit(dig); | |
420 | } | |
421 | } | |
422 | return digits; | |
423 | } | |
424 |