-//$Id$
+// @(#) $Id$
// Author: Anders Vestbo <mailto:vestbo@fi.uib.no>
-//*-- Copyright © ASV
+//*-- Copyright © ALICE HLT Group
#include "AliL3StandardIncludes.h"
-#include "AliL3DataHandler.h"
+#include "AliL3RootTypes.h"
+#include "AliL3Logging.h"
+#include "AliL3MemHandler.h"
#include "AliL3Logging.h"
-#include "AliTransBit.h"
+#include "AliL3TransBit.h"
+#include "AliL3Transform.h"
+#include "AliL3DataHandler.h"
+#include "AliL3DigitData.h"
-#if GCCVERSION == 3
+#if __GNUC__ >= 3
using namespace std;
#endif
+/** \class AliL3DataHandler
+<pre>
//_____________________________________________________________
// AliL3DataHandler
//
// --------------------
//
// The data is RLE encoded, using _8_bit representation of the ADC-values.
-// Conversion is done in the class AliTransBit.
+// Conversion is done in the class AliL3TransBit.
//
// In the beginning of every row, the row number if written and the number of pads
// containing data on that row. For every pad with data the pad number is written,
// 255 (8 bit), another 8 bit word is written for the remaining. At the end of one
// pad, 2 zeros are written. Example:
//
-// ROW PAD 0 NZEROS ADC ADC ADC ADC 0 NZEROS ADC ADC 0 0
+// ROW NPADSWITHDATA PAD 0 NZEROS ADC ADC ADC ADC 0 NZEROS ADC ADC 0 0
//
// Everything is written using 8 bit;
// (ROW < 176, PAD < 200, ADC < 255, if(NZEROS > 255) write 2 words;)
+</pre>
+*/
ClassImp(AliL3DataHandler)
-
AliL3DataHandler::AliL3DataHandler()
{
+ // default constructor
fBitTransformer = 0;
LOG(AliL3Log::kInformational,"AliL3DataHandler::AliL3DataHandler","Data format")
<<"8 bit data handler initialized"<<ENDLOG;
AliL3DataHandler::~AliL3DataHandler()
{
+ // destructor
if(fBitTransformer)
delete fBitTransformer;
-
}
void AliL3DataHandler::Convert10to8Bit()
if(!fInBinary)
{
LOG(AliL3Log::kError,"AliL3DataHandler::Convert10to8Bit","File")
- <<AliL3Log::kHex<<"Pointer to input file : "<<(Int_t)fInBinary<<ENDLOG;
+ <<AliL3Log::kHex<<"Pointer to input file : "<<(void*)fInBinary<<ENDLOG;
return;
}
if(!fOutBinary)
{
LOG(AliL3Log::kError,"AliL3DataHandler::Convert10to8Bit","File")
- <<AliL3Log::kHex<<"Pointer to output file : "<<(Int_t)fOutBinary<<ENDLOG;
+ <<AliL3Log::kHex<<"Pointer to output file : "<<(void*)fOutBinary<<ENDLOG;
return;
}
//Initialize the bit transformation class:
- fBitTransformer = new AliTransBit_v1();
+ fBitTransformer = new AliL3TransBitV1();
Int_t b0=10; // original number of bits
Int_t b1=8; // compressed
fBitTransformer->SetBits(b0,b1);
<<"Error reading from file "<<ENDLOG;
return 0;
}
+
UInt_t size = GetMemorySize(nrow,comp);
AliL3DigitRowData *data = (AliL3DigitRowData*)Allocate(size);
CompMemory2Memory(nrow,data,comp);
if(!data)
{
LOG(AliL3Log::kError,"AliL3DataHandler::Memory2CompMemory","Data")
- <<AliL3Log::kHex<<" Pointer to data = "<<(Int_t)data<<ENDLOG;
+ <<AliL3Log::kHex<<" Pointer to data = "<<(void*)data<<ENDLOG;
return 0;
}
if(!comp)
{
LOG(AliL3Log::kError,"AliL3DataHandler::Memory2CompMemory","Data")
- <<AliL3Log::kHex<<" Pointer to compressed data = "<<(Int_t)comp<<ENDLOG;
+ <<AliL3Log::kHex<<" Pointer to compressed data = "<<(void*)comp<<ENDLOG;
return 0;
}
UShort_t value = rowPt->fRow;
Write(comp,index,value);
- UShort_t number_of_pads=0;
- UShort_t max_pad = 0;
+ UShort_t numberOfPads=0;
+ UShort_t maxPad = 0;
for(Int_t j=0; j<200; j++)
npads[j]=0;
{
if(npads[j])
{
- number_of_pads++;
- max_pad = j;
+ numberOfPads++;
+ maxPad = j;
}
}
//Write the number of pads on this row:
- Write(comp,index,number_of_pads);
+ Write(comp,index,numberOfPads);
UInt_t digit=0;
- for(UShort_t pad=0; pad <= max_pad; pad++)
+ for(UShort_t pad=0; pad <= maxPad; pad++)
{
if(digit >= rowPt->fNDigit || rowPt->fDigitData[digit].fPad != pad)
Write(comp,index,0);
//Check if we have to use more than 1 byte to write the zeros:
- Int_t number_of_zero_intervals=0;
- if(rowPt->fDigitData[digit].fTime > 255)
+ Int_t numberOfZeroIntervals=0;
+ if(rowPt->fDigitData[digit].fTime >= 255)
{
- number_of_zero_intervals++;
+ numberOfZeroIntervals++;
Write(comp,index,255);
- if(rowPt->fDigitData[digit].fTime > 2*255)
+ if(rowPt->fDigitData[digit].fTime >= 2*255)
{
+ cerr<<"AliL3DataHandler::Memory2CompMemory : Should not happen "<<(Int_t)rowPt->fDigitData[digit].fTime<<endl;
Write(comp,index,255);
- number_of_zero_intervals++;
+ numberOfZeroIntervals++;
}
}
- Write(comp,index,(rowPt->fDigitData[digit].fTime - number_of_zero_intervals*255));
+ Write(comp,index,(rowPt->fDigitData[digit].fTime - numberOfZeroIntervals*255));
}
}
UShort_t nzero = rowPt->fDigitData[digit+1].fTime - (rowPt->fDigitData[digit].fTime + 1);
//Check if we have to use more than one byte to write the zeros:
- Int_t number_of_zero_intervals=0;
- if(nzero > 255)
+ Int_t numberOfZeroIntervals=0;
+ if(nzero >= 255)
{
- number_of_zero_intervals++;
+ numberOfZeroIntervals++;
Write(comp,index,255);
- if(nzero > 2*255)
+ if(nzero >= 2*255)
{
+ cerr<<"AliL3DataHandler::Memory2CompMemory : Should not happen "<<(Int_t)rowPt->fDigitData[digit].fTime<<endl;
Write(comp,index,255);
- number_of_zero_intervals++;
+ numberOfZeroIntervals++;
}
}
- Write(comp,index,(nzero - number_of_zero_intervals*255));
+ Write(comp,index,(nzero - numberOfZeroIntervals*255));
}
}
digit++;
if(!data)
{
LOG(AliL3Log::kError,"AliL3DataHandler::GetCompMemorySize","Data")
- <<AliL3Log::kHex<<" Data pointer = "<<(Int_t)data<<ENDLOG;
+ <<AliL3Log::kHex<<" Data pointer = "<<(void*)data<<ENDLOG;
return 0;
}
//Write the row number:
index++;
- UShort_t max_pad=0;
- UShort_t number_of_pads = 0;
+ UShort_t maxPad=0;
+ UShort_t numberOfPads = 0;
for(Int_t j=0; j<200; j++)
npads[j]=0;
{
if(npads[j])
{
- number_of_pads++;
- max_pad = j;
+ numberOfPads++;
+ maxPad = j;
}
}
index++;
UInt_t digit=0;
- for(UShort_t pad=0; pad <= max_pad; pad++)
+ for(UShort_t pad=0; pad <= maxPad; pad++)
{
if(digit>=rowPt->fNDigit || rowPt->fDigitData[digit].fPad != pad)
continue;
index++;
//Check if we have to use more than 1 byte to write the zeros:
- if(rowPt->fDigitData[digit].fTime > 255)
+ if(rowPt->fDigitData[digit].fTime >= 255)
index++;
- if(rowPt->fDigitData[digit].fTime > 2*255)
+ if(rowPt->fDigitData[digit].fTime >= 2*255)
index++;
}
}
//Check if we have to use more than 1 byte to write the zeros:
UInt_t nzeros = rowPt->fDigitData[digit+1].fTime - rowPt->fDigitData[digit].fTime + 1;
- if(nzeros > 255)
+ if(nzeros >= 255)
index++;
- if(nzeros > 2*255)
+ if(nzeros >= 2*255)
index++;
}
}
if(!data)
{
LOG(AliL3Log::kError,"AliL3DataHandler::CompMemory2Memory","Array")
- <<AliL3Log::kHex<<"Pointer to data: "<<(Int_t)data<<ENDLOG;
+ <<AliL3Log::kHex<<"Pointer to data: "<<(void*)data<<ENDLOG;
return 0;
}
if(!comp)
{
LOG(AliL3Log::kError,"AliL3DataHandler::CompMemory2Memory","Array")
- <<AliL3Log::kHex<<"Pointer to compressed data: "<<(Int_t)data<<ENDLOG;
+ <<AliL3Log::kHex<<"Pointer to compressed data: "<<(void*)comp<<ENDLOG;
return 0;
}
{
//Read the first zero
Read(comp,index);
+
+
if(Test(comp,index) == 0)//end of pad.
{
time = Read(comp,index);
if( (time += Read(comp,index)) == 2*255)
time += Read(comp,index);
}
+
while(1)
{
while( (charge = Read(comp,index)) != 0)
{
+ if(time >= AliL3Transform::GetNTimeBins())
+ cerr<<"AliL3DataHandler::CompMemory2Memory : Time out of range "<<time<<endl;
rowPt->fDigitData[ndigit].fPad = pad;
rowPt->fDigitData[ndigit].fTime = time;
rowPt->fDigitData[ndigit].fCharge = charge;
- time++;
ndigit++;
+ if(Test(comp,index) != 0)
+ time++;
}
if(Test(comp,index) == 0)
{
Read(comp,index); //end of pad
break;
}
- UShort_t time_shift;
- if( (time_shift = Read(comp,index)) == 255)
- if( (time_shift += Read(comp,index)) == 2*255)
- time_shift += Read(comp,index);
- time += time_shift;
+ UShort_t timeShift;
+ if( (timeShift = Read(comp,index)) == 255)
+ if( (timeShift += Read(comp,index)) == 2*255)
+ timeShift += Read(comp,index);
+ time += timeShift;
+
}
}
rowPt->fNDigit = ndigit;