/************************************************************************** * Copyright(c) 1998-2003, ALICE Experiment at CERN, All rights reserved. * * * * Author: The ALICE Off-line Project. * * Contributors are mentioned in the code where appropriate. * * * * Permission to use, copy, modify and distribute this software and its * * documentation strictly for non-commercial purposes is hereby granted * * without fee, provided that the above copyright notice appears in all * * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims * * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Id$ */ //This class conteins all the methods to create raw data //as par a given DDL. //It produces DDL with both compressed and uncompressed format. //For compression we use the optimized table wich needs //to be provided. #include #include #include #include #include "AliTPCCompression.h" #include "AliTPCBuffer160.h" #include "AliTPCDDLRawData.h" ClassImp(AliTPCDDLRawData) //////////////////////////////////////////////////////////////////////////////////////// AliTPCDDLRawData::AliTPCDDLRawData(const AliTPCDDLRawData &source): TObject(source) { // Copy Constructor fVerbose=source.fVerbose; return; } AliTPCDDLRawData& AliTPCDDLRawData::operator=(const AliTPCDDLRawData &source){ //Assigment operator fVerbose=source.fVerbose; return *this; } //////////////////////////////////////////////////////////////////////////// void AliTPCDDLRawData::RawData(Int_t LDCsNumber,Int_t EventNumber){ //Raw data slides generation //Number of DDL=2*36+4*36=216 //2 DDL for each inner sector //4 DDL for each outer sector Int_t ddlPerFile=216/LDCsNumber; Int_t offset=1; if (216%LDCsNumber) ddlPerFile++; cout<<"Number of DDL per slide: "<WriteMiniHeader(0,pSecNumber,pSubSector,0,0);//Dummy; bunchLength=1; buffer->FillBuffer(data.Dig-offset); nwords++; }//end if else{ if ( (data.Time==(pTimeBin+1)) && (pPadNumber==data.Pad) && (pRowNumber==data.Row) && (pSecNumber==data.Sec)){ bunchLength++; }//end if else{ buffer->FillBuffer(pTimeBin); buffer->FillBuffer(bunchLength+2); nwords+=2; if ((pPadNumber!=data.Pad)||(pRowNumber!=data.Row)||(pSecNumber!=data.Sec)){ //Trailer is formatted and inserted!! buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber); numPackets++; nwords=0; if(pSubSector!=data.SubSec){ countDDL++; if(countDDL==ddlPerFile){ //size magic word sector number sub-sector number 0 for TPC 0 for uncompressed buffer->Flush(); buffer->WriteMiniHeader(1,pSecNumber,pSubSector,0,0); //cout<<"Mini header for DDL:"<WriteMiniHeader(0,data.Sec,data.SubSec,0,0);//Dummy; countDDL=0; }//end if else{ buffer->Flush(); buffer->WriteMiniHeader(1,pSecNumber,pSubSector,0,0); buffer->WriteMiniHeader(0,data.Sec,data.SubSec,0,0);//Dummy; } pSubSector=data.SubSec; }//end if }//end if bunchLength=1; pPadNumber=data.Pad; pRowNumber=data.Row; pSecNumber=data.Sec; }//end else pTimeBin=data.Time; buffer->FillBuffer(data.Dig-offset); nwords++; }//end else }//end while buffer->FillBuffer(pTimeBin); buffer->FillBuffer(bunchLength+2); nwords+=2; buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber); //write the M.H. buffer->Flush(); buffer->WriteMiniHeader(1,pSecNumber,pSubSector,0,0); //cout<<"Mini header for D D L:"<SetVerbose(0); if(!Comp){ util->CompressDataOptTables(kNumTables,temp,"TempCompDecomp"); } else util->DecompressDataOptTables(kNumTables,temp,"TempCompDecomp"); delete util; //the temp compressed file is open and copied to the final file fdest ifstream fi; #ifndef __DECCXX fi.open("TempCompDecomp",ios::binary); #else fi.open("TempCompDecomp"); #endif 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; UInt_t aux=0x0; flag<<=8; aux|=flag; miniHeader[2]=miniHeader[2]|aux; fdest.write((char*)(miniHeader),sizeof(UInt_t)*3); //The compressem temp file is copied into the output file fdest for(UInt_t j=0;jFillBuffer(data.Dig-offset); nwords++; }//end if else{ if ( (data.Time==(pTimeBin+1)) && (pPadNumber==data.Pad) && (pRowNumber==data.Row) && (pSecNumber==data.Sec)){ bunchLength++; }//end if else{ buffer->FillBuffer(pTimeBin); buffer->FillBuffer(bunchLength+2); nwords+=2; if ((pPadNumber!=data.Pad)||(pRowNumber!=data.Row)||(pSecNumber!=data.Sec)){ //Trailer is formatted and inserted!! buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber); numPackets++; nwords=0; }//end if bunchLength=1; pPadNumber=data.Pad; pRowNumber=data.Row; pSecNumber=data.Sec; }//end else pTimeBin=data.Time; buffer->FillBuffer(data.Dig-offset); nwords++; }//end else }//end while buffer->FillBuffer(pTimeBin); buffer->FillBuffer(bunchLength+2); nwords+=2; buffer->WriteTrailer(nwords,pPadNumber,pRowNumber,pSecNumber); delete buffer; cout<<"Number of digits: "<