From 9f992f70bb4aa8d1e60e1f9d285ea145dd806840 Mon Sep 17 00:00:00 2001 From: hristov Date: Thu, 22 May 2003 13:08:50 +0000 Subject: [PATCH] Updated version of raw data code (D.Favretto) --- ITS/AliITSDDLRawData.C | 134 ++++++++++++---------- ITS/AliITSDDLRawData.cxx | 203 ++++++++++++++++++---------------- ITS/AliITSDDLRawData.h | 13 ++- TPC/AliTPCBuffer.cxx | 30 ++++- TPC/AliTPCBuffer.h | 2 +- TPC/AliTPCBuffer160.cxx | 19 +++- TPC/AliTPCCompression.cxx | 166 ++++++++++++++++++++++++--- TPC/AliTPCCompression.h | 5 +- TPC/AliTPCDDL.C | 12 ++ TPC/AliTPCDDLRawData.C | 12 +- TPC/AliTPCDDLRawData.cxx | 16 ++- TPC/AliTPCDDLRawData.h | 4 +- TPC/AliTPCH5OptimizedTables.C | 57 ++++++++-- TPC/AliTPCHuffman.cxx | 21 +++- TPC/AliTPCHuffman.h | 1 + 15 files changed, 497 insertions(+), 198 deletions(-) diff --git a/ITS/AliITSDDLRawData.C b/ITS/AliITSDDLRawData.C index de88a043743..04d2d94b6d5 100644 --- a/ITS/AliITSDDLRawData.C +++ b/ITS/AliITSDDLRawData.C @@ -10,9 +10,10 @@ AddDigit in the class AliITSsimulationSDD //if( fResponse->Do10to8() ) signal = Convert8to10( signal ); In this way the amplitude value for signal coming from SDD takes only 8 bits and not 10. */ +//DigitsFile is the input file that contains digits -void AliITSDDLRawData(char* DigitsFile="galice.root"){ - #ifdef __NOCOMPILED__ +void AliITSDDLRawData(char* DigitsFile="galiceD.root"){ +#ifdef __NOCOMPILED__ if (gClassTable->GetID("AliRun") < 0) { gROOT->LoadMacro("loadlibs.C"); loadlibs(); @@ -26,67 +27,86 @@ void AliITSDDLRawData(char* DigitsFile="galice.root"){ #ifdef __NOCOMPILED__ } #endif - // Connect the Root input file containing Geometry, Kine and Hits - // galice.root file by default - char* filename="galice.root"; - // TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(filename); TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(DigitsFile); if (!file){ - // file = new TFile(filename); file = new TFile(DigitsFile); - cout<<"NEW FILE CREATED !!!"<ls(); - // Get AliRun object from file - if (!gAlice) { - gAlice = (AliRun*)file->Get("gAlice"); - if (gAlice)cout<<"AliRun object found on file "<SetTreeDFileName("digits.root"); - gAlice->SetTreeDFileName(DigitsFile); - Int_t nparticles = gAlice->GetEvent(0); - // - // ITS - AliITS *ITS = (AliITS*)gAlice->GetModule("ITS"); - Int_t nmodules; - ITS->InitModules(-1,nmodules); - cout<<"Number of ITS modules= "<FillModules(0,0,nmodules," "," "); - //cout<<"ITS modules .... DONE!"<TreeD(); - - AliITSDDLRawData *util=new AliITSDDLRawData(); - TStopwatch timer; + // Get AliRun object from file + if (!gAlice){ + gAlice = (AliRun*)file->Get("gAlice"); + if (gAlice)cout<<"AliRun object found on file "<SetTreeDFileName(DigitsFile); + // Long_t nparticles = gAlice->GetEvent(0); - //SILICON PIXEL DETECTOR - cout<<"Formatting data for SPD"<RawDataSPD(ITS,TD); - timer.Stop(); - timer.Print(); - //util->TestFormat(); + //Int_t nparticles = gAlice->GetEvent(0); + // + // ITS + AliITS *ITS = (AliITS*)gAlice->GetModule("ITS"); + Int_t nmodules; + ITS->InitModules(-1,nmodules); + cout<<"Number of ITS modules= "<FillModules(0,0,nmodules," "," "); + //cout<<"ITS modules .... DONE!"<RawDataSDD(ITS,TD); - timer.Stop(); - timer.Print(); - - //SILICON STRIP DETECTOR - cout<<"Formatting data for SSD"<RawDataSSD(ITS,TD); - timer.Stop(); - timer.Print(); - - delete util; - return; + + TTree* TD = (TTree*)file->Get("TreeD0"); + if (TD == 0x0){ + ::Error("DDLRawData","Can not find tree with ITS digits"); + return; + }//end if + ITS->SetTreeAddressD(TD); + + + //TTree *TD = gAlice->TreeD(); + + AliITSDDLRawData *util=new AliITSDDLRawData(); + //Verbose level + // 0: Silent + // 1: cout messages + // 2: txt files with digits + //BE CAREFUL, verbose level 2 MUST be used only for debugging and + //it is highly suggested to use this mode only for debugging digits files + //reasonably small, because otherwise the size of the txt files can reach + //quickly several MB wasting time and disk space. + util->SetVerbose(0); + TStopwatch timer; + + //SILICON PIXEL DETECTOR + cout<<"Formatting data for SPD"<RawDataSPD(ITS,TD); + // util->RawDataSPD(ITS,TD,20); + timer.Stop(); + timer.Print(); + //ONLY FOR DEBUGGING + util->TestFormat(); + + //SILICON DRIFT DETECTOR + cout<<"Formatting data for SDD"<RawDataSDD(ITS,TD,12); + util->RawDataSDD(ITS,TD); + timer.Stop(); + timer.Print(); + + //SILICON STRIP DETECTOR + cout<<"Formatting data for SSD"<RawDataSSD(ITS,TD,16); + util->RawDataSSD(ITS,TD); + timer.Stop(); + timer.Print(); + + delete util; + return; } diff --git a/ITS/AliITSDDLRawData.cxx b/ITS/AliITSDDLRawData.cxx index 1c2c5f09e09..154cfc66f22 100644 --- a/ITS/AliITSDDLRawData.cxx +++ b/ITS/AliITSDDLRawData.cxx @@ -12,8 +12,10 @@ * about the suitability of this software for any purpose. It is * * provided "as is" without express or implied warranty. * **************************************************************************/ + /* $Id$ */ + //This class contains all the necessary methods to create the Raw Data //files (slides) for the ITS data challenges for: //SPD @@ -37,6 +39,7 @@ AliITSDDLRawData::AliITSDDLRawData(){ //Default constructor fIndex=-1; fHalfStaveModule=-1; + fVerbose=0; } //////////////////////////////////////////////////////////////////////////////////////// @@ -45,6 +48,7 @@ AliITSDDLRawData::AliITSDDLRawData(const AliITSDDLRawData &source){ //Copy Constructor this->fIndex=source.fIndex; this->fHalfStaveModule=source.fHalfStaveModule; + this->fVerbose=source.fVerbose; return; } @@ -54,6 +58,7 @@ AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){ //Assigment operator this->fIndex=source.fIndex; this->fHalfStaveModule=source.fHalfStaveModule; + this->fVerbose=source.fVerbose; return *this; } @@ -61,7 +66,7 @@ AliITSDDLRawData& AliITSDDLRawData::operator=(const AliITSDDLRawData &source){ //STRIP // -void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod, ULong_t *buf){ +void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod,Int_t modR,Int_t ddl,ULong_t *buf){ //This method packs the SSD digits in a proper 32 bits structure Int_t ix; Int_t iz; @@ -70,13 +75,19 @@ void AliITSDDLRawData::GetDigitsSSD(TClonesArray *ITSdigits,Int_t mod, ULong_t * ULong_t baseWord; Int_t ndigits = ITSdigits->GetEntries(); AliITSdigit *digs; + ofstream ftxt; if(ndigits){ + if (fVerbose==2){ + ftxt.open("SSDdigits.txt",ios::app); + } for (Int_t digit=0;digitUncheckedAt(digit); iz=digs->fCoord1; // If iz==0, N side and if iz=1 P side ix=digs->fCoord2; // Strip Numbar is=digs->fSignal; // ADC Signal // cout<<" Module:"<GetEntries(); AliITSdigit *digs; + ofstream ftxt; if(ndigits){ //cout<<"Mudule "<UncheckedAt(digit); iz=digs->fCoord1; // Anode ix=digs->fCoord2; // Time is=digs->fSignal; // ADC Signal + if (fVerbose==2) + ftxt<<"DDL:"<255){cout<<"WARNING (!) bits words is needed)!!!\n";} baseWord=0; @@ -142,6 +160,8 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod, ULong_t * buf[fIndex]=baseWord; }//end for }//end if + if(fVerbose==2) + ftxt.close(); return; }//end GetDigitsSDD @@ -149,8 +169,11 @@ void AliITSDDLRawData::GetDigitsSDD(TClonesArray *ITSdigits,Int_t mod, ULong_t * //PIXEL // -void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod, ULong_t *buf){ - //This method packs the SPD digits in a proper 32 strucure +void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod,Int_t ddl, ULong_t *buf){ + //This method packs the SPD digits in a proper 32 structure + //Since data is zero suppressed,the coordinates for the chip having zero digits + //doesn't get listed in the galice.root file. However the SPD format requires + //the empty chip to be written with chip header and chip trailer. Int_t ix; Int_t iz; Int_t chipNo=0; @@ -163,24 +186,28 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod, ULong_t * AliITSdigit *digs; fHalfStaveModule++; //It's a private variable used to distinguish between the firs //and the second module of an Half Stave Module + ofstream ftxt; if(ndigits){ //loop over digits + if (fVerbose==2) + ftxt.open("SPDdigits.txt",ios::app); for (Int_t digit=0;digitUncheckedAt(digit); /*--------------------------------------------------------------------------- * Each module contains 5 read out chips of 256 rows and 32 columns. - * So, the cell number in Z direction varies from 1 to 160. Therefore, + * So, the cell number in Z direction varies from 0 to 159. Therefore, * to get the chip address (0 to 4), we need to divide column number by 32. * ---------------------------------------------------------------------*/ iz=digs->fCoord1; // Cell number in Z direction ix=digs->fCoord2; // Cell number in X direction chipNo=iz/32; + if(fVerbose==2) + ftxt<<"DDL:"<4)end+=5; WriteChipTrailer(buf,chipHitCount,baseWord); + chipHitCount=0; for(Int_t i=chipNo+1;i<=end;i++){ WriteChipHeader(i,(mod/2),baseWord); WriteChipTrailer(buf,0,baseWord); + chipHitCount=0; }//end for }//end if else{ @@ -231,8 +263,11 @@ void AliITSDDLRawData::GetDigitsSPD(TClonesArray *ITSdigits,Int_t mod, ULong_t * for(Int_t i=0;i<5;i++){ WriteChipHeader(chipNo+i,(mod/2),baseWord); WriteChipTrailer(buf,chipHitCount,baseWord); + chipHitCount=0; }//end for }//end else + if(fVerbose==2) + ftxt.close(); return; }//end GetDigitsSPD @@ -311,7 +346,8 @@ Int_t AliITSDDLRawData::RawDataSPD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){ {74,75,78,79,226,227,230,231,234,235,238,239}}; Int_t ddlsPerFile=kDDLsNumber/LDCsNumber; if(kDDLsNumber%LDCsNumber)ddlsPerFile++; - cout<<"Number of DDL per File: "<GetEvent(mapSPD[i][mod]); //For each Module, buf contains the array of data words in Binary format //fIndex gives the number of 32 bits words in the buffer for each module - GetDigitsSPD(digitsInITS,mapSPD[i][mod],buf); + GetDigitsSPD(digitsInITS,mapSPD[i][mod],i,buf); outfile.write((char *)buf,((fIndex+1)*sizeof(ULong_t))); for(Int_t i=0;i<(fIndex+1);i++){ buf[i]=0; @@ -578,8 +614,9 @@ Int_t AliITSDDLRawData::RawDataSSD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){ Int_t ddlsPerFile=kDDLsNumber/LDCsNumber; - if(20%LDCsNumber)ddlsPerFile++; - cout<<"Number of DDL per File: "<GetEvent(mapSSD[i][mod]); //For each Module, buf contains the array of data words in Binary format //fIndex gives the number of 32 bits words in the buffer for each module - GetDigitsSSD(digitsInITS,mod,buf); + GetDigitsSSD(digitsInITS,mod,mapSSD[i][mod],i,buf); outfile.write((char *)buf,((fIndex+1)*sizeof(ULong_t))); for(Int_t i=0;i<(fIndex+1);i++){ buf[i]=0; @@ -682,7 +719,8 @@ Int_t AliITSDDLRawData::RawDataSDD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber){ Int_t ddlsPerFile=kDDLsNumber/LDCsNumber; if(kDDLsNumber%LDCsNumber)ddlsPerFile++; - cout<<"Number of DDL per File: "<bits from 0 to 15 - //FirstHalf=1 ==>bits from 16 to 31 - if(!FirstHalf){ - switch (Code){ - case 0://trailer - UnpackWord(BaseWord,0,12,Decoded1); - break; - case 1://header - UnpackWord(BaseWord,4,10,Decoded1); - UnpackWord(BaseWord,0,3,Decoded2); - break; - case 2://hit - UnpackWord(BaseWord,5,12,Decoded1); - UnpackWord(BaseWord,0,4,Decoded2); - break;//fill word - case 3: - UnpackWord(BaseWord,0,13,Decoded1); - break; - }//end switch - } - else{ - switch (Code){ - case 0://trailer - UnpackWord(BaseWord,16,28,Decoded1); - break; - case 1://header - UnpackWord(BaseWord,20,26,Decoded1); - UnpackWord(BaseWord,16,19,Decoded2); - break; - case 2://hit - UnpackWord(BaseWord,21,28,Decoded1); - UnpackWord(BaseWord,16,20,Decoded2); - break; - case 3://fill word - UnpackWord(BaseWord,16,29,Decoded1); - break; - }//end switch - } - return; -} diff --git a/ITS/AliITSDDLRawData.h b/ITS/AliITSDDLRawData.h index b377c8d8ff1..cd5bab87cf7 100644 --- a/ITS/AliITSDDLRawData.h +++ b/ITS/AliITSDDLRawData.h @@ -24,13 +24,15 @@ class AliITSDDLRawData:public TObject{ Int_t RawDataSSD(AliITS *ITS,TTree *TD ,Int_t LDCsNumber=2); // This method generates the files with the Silicon pixel detector data void TestFormat(); - //A debugging method used to test the files generated for the SPD. + // A debugging method used to test the files generated for the SPD. + void SetVerbose(Int_t Verbose){fVerbose=Verbose;} + // To set the verbose level private: - void GetDigitsSPD(TClonesArray *ITSdigits, Int_t mod, ULong_t *buf); + void GetDigitsSPD(TClonesArray *ITSdigits, Int_t mod,Int_t ddl,ULong_t *buf); //This method formats and stores in buf all the digits of a SPD module - void GetDigitsSDD(TClonesArray *ITSdigits, Int_t mod, ULong_t *buf); + void GetDigitsSDD(TClonesArray *ITSdigits, Int_t mod,Int_t modR,Int_t ddl,ULong_t *buf); //This method formats and stores in buf all the digits of a SDD module - void GetDigitsSSD(TClonesArray *ITSdigits, Int_t mod, ULong_t *buf); + void GetDigitsSSD(TClonesArray *ITSdigits, Int_t mod,Int_t modR,Int_t ddl,ULong_t *buf); //This method formats and stores in buf all the digits of a SSD module void PackWord(ULong_t &BaseWord, ULong_t Word, Int_t StartBit, Int_t StopBit); //This method stores the value of the variable Word of StopBit-StartBit+1 bits @@ -45,9 +47,8 @@ class AliITSDDLRawData:public TObject{ //Silicon pixel detector data format void ReadChipHeader(Int_t &ChipAddr,Int_t &EventCnt,ULong_t BaseWord); void ReadChipTrailer(Int_t &ChipHitCount,ULong_t BaseWord); - void DecodeWord(ULong_t Code,ULong_t BaseWord,Int_t FirstHalf,ULong_t &Decoded1,ULong_t &Decoded2); //Methods used for reading and dubugging SPD data files - + Int_t fVerbose; //Verbose level (0:no msg, 1:msg, 2:digits in txt files) Long_t fIndex; //number of 32 words to be stored into the output file Int_t fHalfStaveModule; //first or second half of an Half Stave module ClassDef(AliITSDDLRawData,1) diff --git a/TPC/AliTPCBuffer.cxx b/TPC/AliTPCBuffer.cxx index 67f23c8bcf4..4487b31d2ea 100644 --- a/TPC/AliTPCBuffer.cxx +++ b/TPC/AliTPCBuffer.cxx @@ -41,6 +41,7 @@ AliTPCBuffer::AliTPCBuffer(const char* fileName){ // tree=new TTree("tree","Values"); fNumberOfDigits=0; fVerbose=0; + remove("TPCdigits.txt"); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -131,20 +132,39 @@ void AliTPCBuffer::WriteRowBinary(Int_t eth,AliSimDigits *digrow,Int_t minPad,In data.SubSec=SubSec; data.Row=row; digrow->First(); + Int_t padID=-1; + Int_t ddlNumber=0; + ofstream ftxt; + if (fVerbose==2){ + ftxt.open("TPCdigits.txt",ios::app); + if(sec<36) + ddlNumber=sec*2+SubSec; + else + ddlNumber=72+(sec-36)*4+SubSec; + }//end if do{ - data.Dig=digrow->CurrentDigit(); //adc - data.Time=digrow->CurrentRow(); //time - data.Pad =digrow->CurrentColumn(); // pad + data.Dig=digrow->CurrentDigit(); //adc + data.Time=digrow->CurrentRow(); //time + data.Pad =digrow->CurrentColumn(); // pad + if(fVerbose==2) + if (padID!=data.Pad){ + ftxt<<"S:"<eth){ switch (flag){ case 0:{ fNumberOfDigits++; f.write((char*)(&data),sizeof(data)); + if(fVerbose==2) + ftxt<<"A:"<=minPad)&&(data.Pad<=maxPad)){ f.write((char*)(&data),sizeof(data)); + if(fVerbose==2) + ftxt<<"A:"<maxPad)){ f.write((char*)(&data),sizeof(data)); + if(fVerbose==2) + ftxt<<"A:"<Next()); + if (fVerbose==2) + ftxt.close(); return; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/TPC/AliTPCBuffer.h b/TPC/AliTPCBuffer.h index 28d242f90c5..a275c87dbf0 100644 --- a/TPC/AliTPCBuffer.h +++ b/TPC/AliTPCBuffer.h @@ -30,7 +30,7 @@ public: ULong_t GetDigNumber()const{return fNumberOfDigits;} void SetVerbose(Int_t val){fVerbose=val;} private: - Int_t fVerbose; //Verbosity level: 0-silent, not 0-all printout + Int_t fVerbose; //Verbosity level: 0-silent, 1:cout msg, 2: txt files for checking fstream f; //The IO file name //TFile *fout; //TTree *tree; diff --git a/TPC/AliTPCBuffer160.cxx b/TPC/AliTPCBuffer160.cxx index 3092af271e8..43675580d43 100644 --- a/TPC/AliTPCBuffer160.cxx +++ b/TPC/AliTPCBuffer160.cxx @@ -56,7 +56,7 @@ AliTPCBuffer160::AliTPCBuffer160(const char* fileName,Int_t flag){ #else f.open(fileName,ios::in); #endif - if(!f){cout<<"File doesn't exist\n";exit(-1);} + if(!f){cout<<"File doesn't exist:"< "<<(Int_t)*tt<=3)//minimum bunch length + Table->SetValFrequency(x,A*FreqArray[x]*1000); + else + Table->SetValFrequency(x,0); + else //Time table + Table->SetValFrequency(x,A*FreqArray[x]); + } + Table->BuildHTable(); + ofstream fTable; + char filename[15]; + sprintf(filename,"Table%d.dat",Type); + fTable.open(filename,ios::binary); + Int_t dimTable=Table->Size(); + //Table dimension is written into a file + fTable.write((char*)(&dimTable),sizeof(Int_t)); + //One table is written into a file + for(Int_t i=0;iCodeLen()[i]; + Double_t Code=Table->Code()[i]; + fTable.write((char*)(&CodeLen),sizeof(UChar_t)); + fTable.write((char*)(&Code),sizeof(Double_t)); + } //end for + fTable.close(); + delete Table; + return 0; +} +//////////////////////////////////////////////////////////////////////////////////////// Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables){ //Tables manager /* @@ -269,7 +331,10 @@ Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables) Int_t n=10;// 10 bits per symbol AliTPCHTable ** table = new AliTPCHTable*[NumTables]; //The table is inizialized with the rigth number of rows - for(Int_t i=0;iSetVerbose(fVerbose); + } //The frequencies are calculated and the tables are filled if (fVerbose) cout<<"Filling tables...\n"; @@ -301,6 +366,14 @@ Int_t AliTPCCompression::CreateTables(const char* fSource,const Int_t NumTables) if (fVerbose) cout<<"Tables filled \n"; + + //Frequencies normalization + table[0]->NormalizeFrequencies(); + table[1]->NormalizeFrequencies(); + table[2]->NormalizeFrequencies(); + table[3]->NormalizeFrequencies(); + table[4]->NormalizeFrequencies(); + //Tables are saved in a sequence of text file and using the macro Histo.C is it possible to get //a series of histograms rappresenting the frequency distribution table[0]->StoreFrequencies("BunchLenFreq.txt"); @@ -366,6 +439,7 @@ Int_t AliTPCCompression::RetrieveTables(AliTPCHTable* table[],Int_t NumTable){ #else fTable.open(filename); #endif + if(!fTable){cout<<"File doesn't exist:"<>freq; + if (fTable.good()){ + if (freq<0){ + cout<<"Frequency cannot be negative !!!\n"; + exit(1); + } + table[k]->SetValFrequency(symbol,freq); + } + symbol++; + }//end while + fTable.clear(); + fTable.close(); + }//end for + fStat.open("Statistics",ios::app); + fStat<GetEntropy()<GetEntropy()<GetEntropy()<GetEntropy()<GetEntropy()<BuildHTable(); + }//end for + //The tables are saved ad binary files + StoreTables(table,NumTable); + //The tables stored in memory are deleted; + for(Int_t i=0;i No output messages are displayed @@ -42,7 +44,8 @@ class AliTPCCompression:public TObject{ void ReadAltroFormat(char* fileOut,char* fileIn)const; //This method is used to read an Altro file and generate a text file containing the same information //It's is useful for debugging - + Int_t CreateTablesFromTxtFiles(Int_t NumTable); + //This method creates a set of binary tables starting from a set of txt tables private: Int_t StoreTables(AliTPCHTable* table[],const Int_t NumTable); //This method is used to store an array of tables in a sequence of binary files diff --git a/TPC/AliTPCDDL.C b/TPC/AliTPCDDL.C index 520f203ecdf..39838bcd016 100644 --- a/TPC/AliTPCDDL.C +++ b/TPC/AliTPCDDL.C @@ -22,6 +22,18 @@ void AliTPCDDL(char* FileName,Int_t eth=0){ sprintf(cname,"TreeD_75x40_100x60_150x60_%d",eventn); digarr->ConnectTree(cname); AliTPCBuffer *b=new AliTPCBuffer("AliTPCDDL.dat"); + + //Verbose level + // 0: Silent + // 1: cout messages + // 2: txt files with digits + //BE CAREFUL, verbose level 2 MUST be used only for debugging and + //it is highly suggested to use this mode only for debugging digits files + //reasonably small, because otherwise the size of the txt files can reach + //quickly several MB wasting time and disk space. + b->SetVerbose(0); + + Int_t nrows=Int_t(digarr->GetTree()->GetEntries()); cout<<"Number of entries "<RawDataAltro(); - u->SetVerbose(1); + //u->SetVerbose(1); //The file "AltroFormatDDL.dat" is converted in a txt file "AltroFormatDDL.txt" //that is used for debugging + /* + cout<<"Creating a txt file from an Altro format file"<ReadAltroFormat("AltroFormatDDL.txt","AltroFormatDDL.dat"); + */ //Tables are created and stored in as sequence of binary files u->CreateTables("AltroFormatDDL.dat",NumTable); @@ -39,9 +42,10 @@ void AliTPCDDLRawData(Int_t LDCsNumber=12){ util->RawDataAltroDecode(LDCsNumber,0); ///The Altro file AltroDDLRecomposed.dat is converted in a txt file AltroDDLRecomposed.txt //This file must be equal to the ones created above. + cout<<"Creating a txt file from an Altro format file"<ReadAltroFormat("AltroDDLRecomposed.txt","AltroDDLRecomposed.dat"); */ - + //SLICE COMPRESSION cout<<"Slice Compression"<RawDataAltroDecode(LDCsNumber,1); //Convertion of the Altro file AltroDDLRecomposedDec.dat in a txt file AltroDDLRecomposedDec.txt //Useful for debugging + cout<<"Creating a txt file from an Altro format file"<ReadAltroFormat("AltroDDLRecomposedDec.txt","AltroDDLRecomposedDec.dat"); */ delete util; diff --git a/TPC/AliTPCDDLRawData.cxx b/TPC/AliTPCDDLRawData.cxx index 45c07ea7f3f..aa6adbe55e7 100644 --- a/TPC/AliTPCDDLRawData.cxx +++ b/TPC/AliTPCDDLRawData.cxx @@ -35,11 +35,13 @@ ClassImp(AliTPCDDLRawData) AliTPCDDLRawData::AliTPCDDLRawData(const AliTPCDDLRawData &source){ // Copy Constructor + fVerbose=source.fVerbose; return; } AliTPCDDLRawData& AliTPCDDLRawData::operator=(const AliTPCDDLRawData &source){ //Assigment operator + fVerbose=source.fVerbose; return *this; } @@ -193,7 +195,7 @@ Int_t AliTPCDDLRawData::RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp){ #else f.open(filename,ios::in); #endif - if(!f){cout<<"File doesn't exist \n";exit(1);} + if(!f){cout<<"BE CAREFUL!! There isn't enough data to generate "<SetVerbose(1); - if(!Comp) + util->SetVerbose(0); + if(!Comp){ util->CompressDataOptTables(kNumTables,temp,"TempCompDecomp"); + } else util->DecompressDataOptTables(kNumTables,temp,"TempCompDecomp"); delete util; @@ -273,7 +277,7 @@ Int_t AliTPCDDLRawData::RawDataCompDecompress(Int_t LDCsNumber,Int_t Comp){ ///////////////////////////////////////////////////////////////////////////////// void AliTPCDDLRawData::RawDataAltro()const{ //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 + //It is used to debug the code and creates the tables used in the compresseion phase Int_t offset=1; ifstream f; #ifndef __DECCXX @@ -386,14 +390,14 @@ void AliTPCDDLRawData::RawDataAltroDecode(Int_t LDCsNumber,Int_t Comp){ #else f.open(filename,ios::in); #endif - if(!f){cout<<"The file doesn't exist"< +#include #include #include "AliTPCCompression.h" #endif @@ -14,24 +14,65 @@ void AliTPCH5OptimizedTables(const char* fSource="AltroFormat.dat",const char* f AliTPCCompression *util = new AliTPCCompression(); TStopwatch timer; //verbose level can be: 0=silent 1=few messages 2=pedantic output - util->SetVerbose(2); - //Tables are created - util->CreateTables(fSource,NumTable); - //util->ReadAltroFormat("File1.txt","AltroFormat.dat"); - //The source file is compressed + util->SetVerbose(1); + Int_t choice; + do{ + cout<<"**** Chose the tables set **** "< Create tables from the input file "< Use external optimized tables (txt format)"< Time gap and Bunch length tables generated using formulas "<>choice; + cout<3)); + switch(choice){ + case 1:{ + //Tables are created + util->CreateTables(fSource,NumTable); + cout<<"Tables have been created"<CreateTablesFromTxtFiles(NumTable); + break; + } + case 3:{ + Double_t beta,gamma=0; + ULong_t mul=0; + cout<<"Multiplicity (suggested 20000) ==> "; + cin>>mul; + cout<<"Gamma (suggested 4.77) ==> "; + cin>>gamma; + cout<<"Beta (suggested 0.37) ==> "; + cin>>beta; + util->CreateTables(fSource,NumTable); + util->CreateTableFormula(gamma,mul,300,0); + util->CreateTableFormula(beta,mul,445,1); + break; + } + }; + + //BE CAREFUL, the following method must be used only for debugging and + //it is highly suggested to use it only for debugging files + //reasonably small, because otherwise the size of the txt files can reach + //quickly several MB wasting time and disk space. + + // util->ReadAltroFormat("File1.txt",fSource); + //The source file is compressed timer.Start(); util->CompressDataOptTables(NumTable,fSource,fDest); timer.Stop(); timer.Print(); - /* + + /* //The Compressed file is decompressed timer.Start(); util->DecompressDataOptTables(NumTable,fDest); timer.Stop(); timer.Print(); - //util->ReadAltroFormat("File2.txt","SourceDecompressed.dat"); + util->ReadAltroFormat("File2.txt","SourceDecompressed.dat"); */ delete util; } diff --git a/TPC/AliTPCHuffman.cxx b/TPC/AliTPCHuffman.cxx index 11670b399c9..dad7fc17a94 100644 --- a/TPC/AliTPCHuffman.cxx +++ b/TPC/AliTPCHuffman.cxx @@ -272,11 +272,30 @@ Int_t AliTPCHTable::SetFrequency(const Int_t Val){ ////////////////////////////////////////////////////////////////////////////// +Int_t AliTPCHTable::NormalizeFrequencies(){ + //This method normalized the frequencies + //Frequencies normalization + Double_t sum=0.; + for (Int_t i=0; i< fSize; i++) { + sum+=fCode[i]; + }//end for + if (fVerbose){ + cout<<"Frequency sum: "<