]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/comp/AliL3Compress.cxx
Compiler Warning removed
[u/mrichter/AliRoot.git] / HLT / comp / AliL3Compress.cxx
CommitLineData
3e87ef69 1// @(#) $Id$
5bf93292 2
3// Author: Anders Vestbo <mailto:vestbo$fi.uib.no>
3e87ef69 4//*-- Copyright &copy ALICE HLT Group
5bf93292 5
4994a25d 6#include "AliL3StandardIncludes.h"
5bf93292 7
3e87ef69 8#include "bitio.h"
9#include "AliL3RootTypes.h"
10#include "AliL3Models.h"
11#include "AliL3DigitData.h"
4994a25d 12#include "AliL3Logging.h"
5bf93292 13#include "AliL3TrackArray.h"
14#include "AliL3ModelTrack.h"
029912b7 15#include "AliL3Transform.h"
16#include "AliL3MemHandler.h"
3e87ef69 17#include "AliL3DataCompressor.h"
6f388e0d 18#include "AliL3SpacePointData.h"
3e87ef69 19
20#if 0
21#ifdef use_root
22#include <TH1.h>
23#include <TH2.h>
24#include <TRandom.h>
25#endif
92a876e2 26#ifdef use_aliroot
be6ddb10 27#include "AliL3FileHandler.h"
92a876e2 28#endif
3e87ef69 29#endif
30
31#include "AliL3Compress.h"
32
33#if GCCVERSION == 3
34using namespace std;
35#endif
5bf93292 36
029912b7 37//_____________________________________________________________
38//
39// AliL3Compress
40//
41// Class for compressing and uncompressing data.
42
5bf93292 43ClassImp(AliL3Compress)
44
45AliL3Compress::AliL3Compress()
46{
95a00d93 47 fTracks=0;
029912b7 48 fSlice =0;
49 fPatch=0;
2357bb38 50 fWriteShape=kFALSE;
3e87ef69 51 fEvent=-1;
029912b7 52}
53
3e87ef69 54AliL3Compress::AliL3Compress(Int_t slice,Int_t patch,Char_t *path,Bool_t writeshape,Int_t event)
029912b7 55{
3e87ef69 56 fEvent=event;
029912b7 57 fSlice=slice;
58 fPatch=patch;
029912b7 59 fTracks=0;
be6ddb10 60 sprintf(fPath,"%s",path);
2357bb38 61 fWriteShape=writeshape;
5bf93292 62}
63
64AliL3Compress::~AliL3Compress()
65{
95a00d93 66 if(fTracks)
67 delete fTracks;
029912b7 68}
69
3e87ef69 70Bool_t AliL3Compress::WriteFile(AliL3TrackArray *tracks,Char_t *filename)
029912b7 71{
3e87ef69 72 Char_t fname[1024];
73 if(filename)
74 sprintf(fname,"%s/comp/%s",fPath,filename);
75 else if(fEvent<0)
76 sprintf(fname,"%s/comp/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
77 else
78 sprintf(fname,"%s/comp/tracks_m_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
5bf93292 79
be6ddb10 80 FILE *file = fopen(fname,"w");
2357bb38 81 if(!file)
82 {
83 cerr<<"AliL3Compress::WriteFile : Error opening file "<<fname<<endl;
3e87ef69 84 return kFALSE;
2357bb38 85 }
5bf93292 86 Short_t ntracks = tracks->GetNTracks();
95a00d93 87
88 Int_t count=0;
89 AliL3ClusterModel *clusters=0;
90 AliL3TrackModel *model=0;
5bf93292 91 for(Int_t i=0; i<ntracks; i++)
92 {
93 AliL3ModelTrack *track = (AliL3ModelTrack*)tracks->GetCheckedTrack(i);
94 if(!track) continue;
3e87ef69 95
4a838220 96 //Do not save useless tracks or clusters:
3e87ef69 97 //if(track->GetNPresentClusters() == 0)
98 //continue;
4a838220 99
029912b7 100 track->FillModel();
95a00d93 101 model = track->GetModel();
0a86fbb7 102 //if(model->fNClusters==0) continue;
95a00d93 103 clusters = track->GetClusters();
5bf93292 104 if(fwrite(model,sizeof(AliL3TrackModel),1,file)!=1) break;
0a86fbb7 105 //if(fwrite(clusters,model->fNClusters*sizeof(AliL3ClusterModel),1,file)!=1) break;
106 if(fwrite(clusters,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel),1,file)!=1) break;
95a00d93 107 count++;
029912b7 108
5bf93292 109 }
110 fclose(file);
3e87ef69 111 return kTRUE;
5bf93292 112}
113
3e87ef69 114Bool_t AliL3Compress::ReadFile(Char_t which,Char_t *filename)
5bf93292 115{
be6ddb10 116 //Read the trackfile.
117
3e87ef69 118 Char_t fname[1024];
119 if(filename)
120 sprintf(fname,"%s/comp/%s",fPath,filename);
be6ddb10 121 else
122 {
3e87ef69 123 if(which == 'm')
124 {
125 if(fEvent<0)
126 sprintf(fname,"%s/comp/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
127 else
128 sprintf(fname,"%s/comp/tracks_m_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
129 }
130 else if(which == 'u')
131 {
132 if(fEvent<0)
133 sprintf(fname,"%s/comp/tracks_u_%d_%d.raw",fPath,fSlice,fPatch);
134 else
135 sprintf(fname,"%s/comp/tracks_u_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
136 }
137 else
138 {
139 cerr<<"AliL3Compress::ReadFile() : Wrong option"<<endl;
140 return kFALSE;
141 }
be6ddb10 142 }
143
144 FILE *file = fopen(fname,"r");
029912b7 145 if(!file)
146 {
2357bb38 147 cerr<<"AliL3Compress::ReadFile : Cannot open file "<<fname<<endl;
3e87ef69 148 return kFALSE;
029912b7 149 }
150
95a00d93 151 if(fTracks)
152 delete fTracks;
153 fTracks = new AliL3TrackArray("AliL3ModelTrack");
5bf93292 154
155 while(!feof(file))
156 {
95a00d93 157 AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->NextTrack();
029912b7 158 track->Init(fSlice,fPatch);
5bf93292 159 AliL3TrackModel *model = track->GetModel();
160 AliL3ClusterModel *clusters = track->GetClusters();
161 if(fread(model,sizeof(AliL3TrackModel),1,file)!=1) break;
0a86fbb7 162 //if(fread(clusters,model->fNClusters*sizeof(AliL3ClusterModel),1,file)!=1) break;
163 if(fread(clusters,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel),1,file)!=1) break;
029912b7 164 track->FillTrack();
5bf93292 165 }
029912b7 166
167 fTracks->RemoveLast();
5bf93292 168 fclose(file);
3e87ef69 169 return kTRUE;
5bf93292 170}
171
3e87ef69 172Bool_t AliL3Compress::CompressFile()
5bf93292 173{
be6ddb10 174 Char_t fname[100];
3e87ef69 175 if(fEvent<0)
176 sprintf(fname,"%s/comp/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
177 else
178 sprintf(fname,"%s/comp/tracks_c_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
be6ddb10 179 BIT_FILE *output = OpenOutputBitFile(fname);
180
3e87ef69 181 if(fEvent<0)
182 sprintf(fname,"%s/comp/tracks_m_%d_%d.raw",fPath,fSlice,fPatch);
183 else
184 sprintf(fname,"%s/comp/tracks_m_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
185
be6ddb10 186 FILE *input = fopen(fname,"r");
187 if(!input)
188 {
189 cerr<<"AliL3Compress::CompressFile() : Error opening file: "<<fname<<endl;
3e87ef69 190 return kFALSE;
be6ddb10 191 }
5bf93292 192
193 AliL3TrackModel track;
194 AliL3ClusterModel cluster;
195 Int_t temp;
2357bb38 196 Int_t power;
029912b7 197
6f388e0d 198 Int_t timeo,pado,chargeo,padshapeo,timeshapeo;
199 timeo=pado=chargeo=padshapeo=timeshapeo=0;
5bf93292 200 while(!feof(input))
201 {
202 if(fread(&track,sizeof(AliL3TrackModel),1,input)!=1) break;
95a00d93 203
204 if(output->mask != 0x80) //Write the current byte to file.
205 {
92a876e2 206 //cerr<<"\nAliL3Compress::CompressFile() : Writing overhead bits!!!"<<endl;
95a00d93 207 if(putc(output->rack,output->file )!=output->rack)
208 cerr<<"AliL3Compress::ComressFile : Error writing to bitfile"<<endl;
209 output->mask=0x80;
029912b7 210 output->rack=0;
95a00d93 211 }
029912b7 212
213 //Write track parameters:
5bf93292 214 fwrite(&track,sizeof(AliL3TrackModel),1,output->file);
3e87ef69 215
216 Int_t origslice=-1,slice,clustercount=0;
0a86fbb7 217 for(Int_t i=0; i<AliL3Transform::GetNRows(fPatch); i++)
5bf93292 218 {
219 if(fread(&cluster,sizeof(AliL3ClusterModel),1,input)!=1) break;
029912b7 220
221 //Write empty flag:
222 temp = (Int_t)cluster.fPresent;
223 OutputBit(output,temp);
224 if(!temp) continue;
225
3e87ef69 226 if(cluster.fSlice<0 || cluster.fSlice>35)
227 {
228 cerr<<"AliL3DataCompress::CompressFile : Fucked up slice number :"<<cluster.fSlice<<endl;
229 exit(5);
230 }
231
232 //Write slice number of first point
233 if(clustercount==0)
234 {
235 origslice = cluster.fSlice;
236 OutputBits(output,origslice,6); //Need 6 bits to encode slice number
237 }
238 else
239 {
240 slice = cluster.fSlice;
241 if(slice == origslice)
6f388e0d 242 OutputBit(output,0); //No change of slice
3e87ef69 243 else
244 {
245 OutputBit(output,1);
246 OutputBits(output,slice,6);
247 origslice=slice;
248 }
249 }
250
029912b7 251 //Write time information:
3e87ef69 252 temp = (Int_t)rint(cluster.fDTime);
5bf93292 253 if(temp<0)
254 OutputBit(output,0);
255 else
256 OutputBit(output,1);
3e87ef69 257 power = 1<<(AliL3DataCompressor::GetNTimeBits()-1);
029912b7 258 if(abs(temp)>=power)
259 {
260 timeo++;
261 temp=power - 1;
262 }
3e87ef69 263 OutputBits(output,abs(temp),(AliL3DataCompressor::GetNTimeBits()-1));
029912b7 264
265 //Write pad information:
3e87ef69 266 temp = (Int_t)rint(cluster.fDPad);
5bf93292 267 if(temp<0)
268 OutputBit(output,0);
269 else
270 OutputBit(output,1);
3e87ef69 271 power = 1<<(AliL3DataCompressor::GetNPadBits()-1);
029912b7 272 if(abs(temp)>=power)
273 {
274 pado++;
275 temp=power - 1;
276 }
3e87ef69 277 OutputBits(output,abs(temp),(AliL3DataCompressor::GetNPadBits()-1));
029912b7 278
279 //Write charge information:
5bf93292 280 temp = (Int_t)cluster.fDCharge;
3e87ef69 281 power = 1<<(AliL3DataCompressor::GetNChargeBits());
029912b7 282 if(abs(temp)>=power)
283 {
284 chargeo++;
285 temp=power - 1;
286 }
3e87ef69 287 OutputBits(output,abs(temp),(AliL3DataCompressor::GetNChargeBits()));
029912b7 288
2357bb38 289 if(fWriteShape)
029912b7 290 {
2357bb38 291 //Write shape information:
292 temp = (Int_t)cluster.fDSigmaY2;
293 if(temp<0)
294 OutputBit(output,0);
295 else
296 OutputBit(output,1);
6f388e0d 297 power = 1<<(AliL3DataCompressor::GetNPadShapeBits()-1);
2357bb38 298 if(abs(temp) >= power)
299 {
6f388e0d 300 padshapeo++;
2357bb38 301 temp = power - 1;
302 }
6f388e0d 303 OutputBits(output,abs(temp),(AliL3DataCompressor::GetNPadShapeBits()-1));
2357bb38 304
305 temp = (Int_t)cluster.fDSigmaZ2;
306 if(temp<0)
307 OutputBit(output,0);
308 else
309 OutputBit(output,1);
6f388e0d 310 power = 1<<(AliL3DataCompressor::GetNTimeShapeBits()-1);
2357bb38 311 if(abs(temp) >= power)
312 {
6f388e0d 313 timeshapeo++;
2357bb38 314 temp=power - 1;
315 }
6f388e0d 316 OutputBits(output,abs(temp),(AliL3DataCompressor::GetNTimeShapeBits()-1));
029912b7 317 }
3e87ef69 318
319 clustercount++;
5bf93292 320 }
5bf93292 321 }
95a00d93 322
5bf93292 323 fclose(input);
324 CloseOutputBitFile(output);
6f388e0d 325 if(pado || timeo || chargeo || padshapeo || timeshapeo)
f64c4364 326 {
327 cout<<endl<<"Saturations: "<<endl
328 <<"Pad "<<pado<<endl
329 <<"Time "<<timeo<<endl
330 <<"Charge "<<chargeo<<endl
6f388e0d 331 <<"Padshape "<<padshapeo<<endl
332 <<"Timeshape "<<timeshapeo<<endl<<endl;
f64c4364 333 }
3e87ef69 334 return kTRUE;
5bf93292 335}
336
3e87ef69 337Bool_t AliL3Compress::ExpandFile()
5bf93292 338{
be6ddb10 339 Char_t fname[100];
3e87ef69 340 if(fEvent<0)
341 sprintf(fname,"%s/comp/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
342 else
343 sprintf(fname,"%s/comp/tracks_c_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
be6ddb10 344 BIT_FILE *input = OpenInputBitFile(fname);
345
3e87ef69 346 if(fEvent<0)
347 sprintf(fname,"%s/comp/tracks_u_%d_%d.raw",fPath,fSlice,fPatch);
348 else
349 sprintf(fname,"%s/comp/tracks_u_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
be6ddb10 350 FILE *output = fopen(fname,"w");
351 if(!output)
352 {
353 cerr<<"AliL3Compress::ExpandFile() : Error opening file: "<<fname<<endl;
3e87ef69 354 return kFALSE;
be6ddb10 355 }
95a00d93 356
357 AliL3TrackModel trackmodel;
358 AliL3ClusterModel *clusters=0;
029912b7 359 Int_t count=0;
5bf93292 360
4a838220 361 clusters = new AliL3ClusterModel[(AliL3Transform::GetNRows(fPatch))];
95a00d93 362 while(!feof(input->file))
5bf93292 363 {
029912b7 364 input->mask=0x80;//make sure we read a new byte from file.
95a00d93 365
029912b7 366 //Read and write track:
95a00d93 367 if(fread(&trackmodel,sizeof(AliL3TrackModel),1,input->file)!=1) break;
368 fwrite(&trackmodel,sizeof(AliL3TrackModel),1,output);
2357bb38 369
370 memset(clusters,0,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel));
3e87ef69 371 Int_t origslice=-1,clustercount=0;
0a86fbb7 372 for(Int_t i=0; i<AliL3Transform::GetNRows(fPatch); i++)
95a00d93 373 {
374 Int_t temp,sign;
029912b7 375
376 //Read empty flag:
95a00d93 377 temp = InputBit(input);
378 if(!temp)
379 {
380 clusters[i].fPresent=kFALSE;
381 continue;
382 }
383 clusters[i].fPresent=kTRUE;
029912b7 384
3e87ef69 385 //Read slice information
386 if(clustercount==0)
387 {
388 temp = InputBits(input,6);
389 clusters[i].fSlice = temp;
390 origslice = temp;
391 }
392 else
393 {
394 temp = InputBit(input);
395 if(!temp)//no change
396 clusters[i].fSlice = origslice;
397 else
398 {
399 temp = InputBits(input,6);//read new slice
400 clusters[i].fSlice = temp;
401 origslice = temp;//store new slice
402 }
403 }
404
029912b7 405 //Read time information:
95a00d93 406 sign=InputBit(input);
3e87ef69 407 temp = InputBits(input,(AliL3DataCompressor::GetNTimeBits()-1));
95a00d93 408 if(!sign)
409 temp*=-1;
410 clusters[i].fDTime = temp;
029912b7 411
412 //Read pad information:
95a00d93 413 sign=InputBit(input);
3e87ef69 414 temp = InputBits(input,(AliL3DataCompressor::GetNPadBits()-1));
95a00d93 415 if(!sign)
416 temp*=-1;
417 clusters[i].fDPad = temp;
029912b7 418
419 //Read charge information:
3e87ef69 420 temp=InputBits(input,(AliL3DataCompressor::GetNChargeBits()));
95a00d93 421 clusters[i].fDCharge = temp;
029912b7 422
2357bb38 423 if(fWriteShape)
424 {
425 //Read shape information:
426 sign = InputBit(input);
6f388e0d 427 temp = InputBits(input,(AliL3DataCompressor::GetNPadShapeBits()-1));
2357bb38 428 if(!sign)
429 temp*=-1;
430 clusters[i].fDSigmaY2 = temp;
431
432 sign = InputBit(input);
6f388e0d 433 temp = InputBits(input,(AliL3DataCompressor::GetNTimeShapeBits()-1));
2357bb38 434 if(!sign)
435 temp*=-1;
436 clusters[i].fDSigmaZ2 = temp;
437 }
3e87ef69 438 clustercount++;
95a00d93 439 }
029912b7 440 count++;
0a86fbb7 441 //fwrite(clusters,(trackmodel.fNClusters)*sizeof(AliL3ClusterModel),1,output);
442 fwrite(clusters,AliL3Transform::GetNRows(fPatch)*sizeof(AliL3ClusterModel),1,output);
5bf93292 443 }
029912b7 444
445 delete [] clusters;
95a00d93 446 fclose(output);
5bf93292 447 CloseInputBitFile(input);
3e87ef69 448 return kTRUE;
5bf93292 449}
029912b7 450
6f388e0d 451void AliL3Compress::CompressRemaining(AliL3SpacePointData *clusters[36][6],UInt_t nclusters[36][6])
452{
453 //Write the remaining clusters in a compressed format.
454
455 Char_t filename[1024];
456 Int_t nrows = AliL3Transform::GetNRows();
457 Int_t *npoints = new Int_t[nrows];
458 for(Int_t slice=0; slice<=35; slice++)
459 {
460 for(Int_t patch=0; patch < 1; patch++)
461 {
462 sprintf(filename,"%s/comp/remains_%d_%d_%d.raw",fPath,fEvent,slice,-1);
463 BIT_FILE *output = OpenOutputBitFile(filename);
464 if(!output)
465 {
466 cerr<<"AliL3Compress::CompressRemaining : Cannot open file "<<filename<<endl;
467 exit(5);
468 }
469 AliL3SpacePointData *cl = clusters[slice][patch];
470 memset(npoints,0,nrows*sizeof(Int_t));
471
472 UInt_t i;
473 for(i=0; i<nclusters[slice][patch]; i++)
474 {
475 if(cl[i].fCharge == 0) continue; //has been used
476 npoints[cl[i].fPadRow]++;
477 }
478 Int_t rowspresent=0;
479 for(Int_t j=0; j<nrows; j++)
480 {
481 if(!npoints[j]) continue;
482 rowspresent++;
483 }
484
485 //Write number of padrows with clusters
486 OutputBits(output,rowspresent,8);
487
488 Int_t last_padrow=-1;
489 for(i=0; i<nclusters[slice][patch]; i++)
490 {
491 if(cl[i].fCharge == 0) continue; //has been used
492 Int_t padrow = cl[i].fPadRow;
493 if(padrow != last_padrow)
494 {
495 OutputBits(output,padrow,8);//Write padrow #
496 if(npoints[padrow] >= 1<<10)
497 {
498 cerr<<"AliL3Compress::CompressRemaining : Too many remaining clusters "<<npoints[padrow]<<endl;
499 exit(5);
500 }
501 OutputBits(output,npoints[padrow],10);//Write number of clusters on this padrow
502 last_padrow = padrow;
503 }
504
505 Float_t xyz[3] = {cl[i].fX,cl[i].fY,cl[i].fZ};
506 Int_t sector,row,buff;
507 AliL3Transform::Slice2Sector(slice,padrow,sector,row);
508 AliL3Transform::Global2Raw(xyz,sector,row);
509
510 Float_t padw = cl[i].fSigmaY2 / AliL3Transform::GetPadPitchWidth(AliL3Transform::GetPatch(padrow));
511 Float_t timew = cl[i].fSigmaZ2 / AliL3Transform::GetZWidth();
512
513 //Write pad
514 buff = (Int_t)rint(xyz[1]*10);
515 if(buff<0)
516 {
517 cerr<<"AliL3Compress:CompressRemaining : Wrong pad value "<<buff<<endl;
518 exit(5);
519 }
520 OutputBits(output,buff,11);
521
522 //Write time
523 buff = (Int_t)rint(xyz[2]*10);
524 if(buff<0)
525 {
526 cerr<<"AliL3Compress:CompressRemaining : Wrong time value "<<buff<<endl;
527 exit(5);
528 }
529 OutputBits(output,buff,13);
530
531 //Write widths
532 buff = (Int_t)rint(padw*100);
533 OutputBits(output,buff,8);
534 buff = (Int_t)rint(timew*100);
535 OutputBits(output,buff,8);
536
537 //Write charge
538 buff = cl[i].fCharge;
539 if(buff >= 1<<14)
540 buff = (1<<14)-1;
541 OutputBits(output,buff,14);
542 }
543
544 CloseOutputBitFile(output);
545 }
546
547 }
548 delete [] npoints;
549}
550
551void AliL3Compress::ExpandRemaining(TempCluster **clusters,Int_t *ncl,const Int_t maxpoints)
552{
553 //Expand the remaining clusters stored using function CompressRemaining
554
555 Char_t filename[1024];
556 Int_t buff;
557 for(Int_t slice=0; slice<=35; slice++)
558 {
559 for(Int_t p=0; p<1; p++)
560 {
561 sprintf(filename,"%s/comp/remains_%d_%d_%d.raw",fPath,fEvent,slice,-1);
562 BIT_FILE *input = OpenInputBitFile(filename);
563
564 //Read number of padrows
565 buff = InputBits(input,8);
566 Int_t nrows = buff;
567
568 for(Int_t i=0; i<nrows; i++)
569 {
570 //Read padrow
571 buff = InputBits(input,8);
572 Int_t padrow = buff;
573
574 //Read nclusters;
575 buff = InputBits(input,10);
576 Int_t npoints = buff;
577
578 for(Int_t i=0; i<npoints; i++)
579 {
580 clusters[slice][ncl[slice]].padrow = padrow;
581
582 //Read pad
583 buff = InputBits(input,11);
584 clusters[slice][ncl[slice]].pad = (Float_t)buff/10.;
585
586 //Read time
587 buff = InputBits(input,13);
588 clusters[slice][ncl[slice]].time = (Float_t)buff/10.;
589
590 //Read widths
591 buff = InputBits(input,8);
592 clusters[slice][ncl[slice]].sigmaY2 = (Float_t)buff/100.;
593 buff = InputBits(input,8);
594 clusters[slice][ncl[slice]].sigmaZ2 = (Float_t)buff/100.;
595
596 //Read charge
597 buff = InputBits(input,14);
598 clusters[slice][ncl[slice]].charge = buff;
599 //cout<<"padrow "<<padrow<<" pad "<<clusters[slice][ncl[slice]].pad<<" time "<<clusters[slice][ncl[slice]].time<<" charge "<<clusters[slice][ncl[slice]].charge<<" widths "<<clusters[slice][ncl[slice]].sigmaY2<<" "<<clusters[slice][ncl[slice]].sigmaZ2<<endl;
600 ncl[slice]++;
601 }
602
603 }
604 CloseInputBitFile(input);
605 }
606 }
607}
608
3e87ef69 609void AliL3Compress::PrintCompRatio(ofstream *outfile)
029912b7 610{
029912b7 611 AliL3MemHandler *mem = new AliL3MemHandler();
3e87ef69 612 Char_t fname[1024];
613 UInt_t remain_size=0,digit_size=0;
614 for(Int_t i=0; i<36; i++)
029912b7 615 {
3e87ef69 616 if(fEvent<0)
617 sprintf(fname,"%s/comp/remains_%d_%d.raw",fPath,i,-1);
618 else
619 sprintf(fname,"%s/comp/remains_%d_%d_%d.raw",fPath,fEvent,i,-1);
620 mem->SetBinaryInput(fname);
621 remain_size += mem->GetFileSize();
622 mem->CloseBinaryInput();
623
624 sprintf(fname,"%s/binaries/digits_c8_%d_%d_%d.raw",fPath,fEvent,i,-1);
625 mem->SetBinaryInput(fname);
626 digit_size += mem->GetFileSize();
627 mem->CloseBinaryInput();
029912b7 628 }
629
4a838220 630
3e87ef69 631 if(fEvent<0)
632 sprintf(fname,"%s/comp/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
633 else
634 sprintf(fname,"%s/comp/tracks_c_%d_%d_%d.raw",fPath,fEvent,fSlice,fPatch);
029912b7 635
3e87ef69 636 mem->SetBinaryInput(fname);
637 UInt_t compress_size = mem->GetFileSize();
92a876e2 638 mem->CloseBinaryInput();
92a876e2 639
3e87ef69 640 if(digit_size==0)
92a876e2 641 {
0a86fbb7 642 cerr<<"AliL3Compress::PrintCompRatio : Zero digit size, not able to obtain comp. ratios!"<<endl;
643 return;
92a876e2 644 }
92a876e2 645
3e87ef69 646 Float_t compratio = (Float_t)(compress_size + remain_size)/(Float_t)digit_size;
f64c4364 647 if(outfile)
f64c4364 648 {
3e87ef69 649 ofstream &out = *outfile;
650 out<<compress_size<<' '<<remain_size<<' '<<digit_size<<endl;
f64c4364 651 }
92a876e2 652
3e87ef69 653 cout<<"=========================================="<<endl;
654 cout<<"Original digits size : "<<digit_size/1000<<" kByte ( 100 % )"<<endl;
655 cout<<"Compressed file size : "<<compress_size/1000<<" kByte ( "<<(Float_t)compress_size*100/(Float_t)digit_size<<" % )"<<endl;
656 cout<<"Remainig file size : "<<remain_size/1000<<" kByte ( "<<(Float_t)remain_size*100/(Float_t)digit_size<<" % )"<<endl;
657 cout<<"---------------------- "<<endl;
658 cout<<"Compression ratio : "<<compratio*100<<" %"<<endl;
659 cout<<"=========================================="<<endl;
be6ddb10 660}