-Int_t AliTPCDDLRawData::RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp){
- static const Int_t NumTable=5;
- char filename[20];
- char dest[20];
- fstream f;
- ULong_t Size=0;
- //Int_t MagicWord,DDLNumber,SecNumber,SubSector,Detector;
- Int_t Flag=0;
- for(Int_t i=1;i<=LDCsNumber;i++){
- if(!Comp){
- sprintf(filename,"TPCslice%d",i);
- sprintf(dest,"TPCslice%d.comp",i);
- }
- else{
- sprintf(filename,"TPCslice%d.comp",i);
- sprintf(dest,"TPCslice%d.decomp",i);
- }
- f.open(filename,ios::binary|ios::in);
- if(!f){cout<<"File doesn't exist \n";exit(1);}
- cout<<filename<<" "<<dest<<endl;
- ofstream fdest;
- fdest.open(dest,ios::binary);
- //loop over the DDL block
- //Each block contains a Mini Header followed by raw data (ALTRO FORMAT)
- //The number of block is ceil(216/LDCsNumber)
- ULong_t MiniHeader[3];
- //here the Mini Header is read
- while( (f.read((char*)(MiniHeader),sizeof(ULong_t)*3)) ){
- Size=MiniHeader[0];
- //Int_t dim=sizeof(ULong_t)+sizeof(Int_t)*5;
- //cout<<" Sec "<<SecNumber<<" SubSector "<<SubSector<<" Size "<<Size<<endl;
- //open the temporay File
- ofstream fo;
- char temp[15]="TempFile";
- fo.open(temp,ios::binary);
- Int_t car=0;
- for(ULong_t j=0;j<Size;j++){
- f.read((char*)(&car),1);
- fo.write((char*)(&car),1);
- }//end for
- fo.close();
- //The temp file is compressed or decompressed
- AliTPCCompression *util = new AliTPCCompression();
- if(!Comp)
- util->CompressDataOptTables(NumTable,temp,"TempCompDecomp");
- else
- util->DecompressDataOptTables(NumTable,temp,"TempCompDecomp");
- delete util;
- //the temp compressed file is open and copied to the final file fdest
- ifstream fi;
- fi.open("TempCompDecomp",ios::binary);
- fi.seekg(0,ios::end);
- Size=fi.tellg();
- fi.seekg(0);
- //The Mini Header is updated (Size and Compressed flag)
- //and written into the output file
- MiniHeader[0]=Size;
- if(!Comp)
- Flag=1;
- else
- Flag=0;
- ULong_t aux=0xFFFF;
- aux<<=16;
- aux|=Flag;
- aux|=0xFF;
- MiniHeader[2]=MiniHeader[2]&aux;
- fdest.write((char*)(MiniHeader),sizeof(ULong_t)*3);
- //The compressem temp file is copied into the output file fdest
- for(ULong_t j=0;j<Size;j++){
- fi.read((char*)(&car),1);
- fdest.write((char*)(&car),1);
- }//end for
- fi.close();
- }//end while
- f.clear();
- f.close();
- fdest.close();
- remove("TempFile");
- remove("TempCompDecomp");
- }//end for
- return 0;
-}
-
-/////////////////////////////////////////////////////////////////////////////////
-//This method is used to build the Altro format from AliTPCDDL.dat
-//It is used to debug the code and create the tables used in the compresseion phase
-void AliTPCDDLRawData::RawDataAltro(){
- Int_t offset=1;
- ifstream f;
- f.open("AliTPCDDL.dat",ios::binary);
- if(!f){cout<<"File doesn't exist !!"<<endl;return;}
- struct DataPad{
- Int_t Sec;
- Int_t SubSec;
- Int_t Row;
- Int_t Pad;
- Int_t Dig;
- Int_t Time;
- };
- DataPad data;
-
- //AliTPCBuffer160 is used in write mode to generate AltroFormat.dat file
- char filename[30]="AltroFormatDDL.dat";
- cout<<" Creating "<<filename<<endl;
- AliTPCBuffer160 *Buffer=new AliTPCBuffer160(filename,1);