//
// The L3 Binary File handler
//
-/**
- This class does all the memory I/O handling on raw binary files.
- For the moment the compressed binary files are run-length encoded, using
- 10 bit digits.
-
- Examples:
-
- 1) Reading a binary file:
-
- AliL3MemHandler file;
- file.SetBinaryInput(filename);
-
- UInt_t ndigits;
- AliL3DigitRowData *data = file.CompBinary2Memory(ndigits);
-
- for(int i=0; i<NumberOfRowsInPatch; i++)
- {
-
- AliL3DigitData *dataPt = (AliL3DigitData*)data->fDigitData;
- for(int j=0; j<data->fNDigit; j++)
- {
- pad = dataPt[j].fPad;
- time = dataPt[j].fTime;
- charge = dataPt[j].fCharge;
- }
-
- file.UpdateRowPointer(data);
-
- }
- file.CloseBinaryInput();
- ________________________
-
- 2) Writing a binary file:
-
- //First of all you need to store the data in memory,
- //and have a pointer to it of type AliL3DigitRowData.
- //E.g. if you just want to write the data you read in example 1)
- //into a new file, you can do the following:
-
- AliL3MemHandler newfile;
- newfile.SetBinaryOutput(newfilename);
- newfile.Memory2CompBinary((UInt_t)NumberOfRowsInPatch,(AliL3DigitRowData*)data);
- newfile.CloseBinaryOutput();
+//
+// This class does all the memory I/O handling on raw binary files.
+// For the moment the compressed binary files are run-length encoded, using
+// 10 bit digits.
+//
+// Examples:
+//
+// 1) Reading a binary file:
+//
+// AliL3MemHandler file;
+// file.SetBinaryInput(filename);
+//
+// UInt_t ndigits;
+// AliL3DigitRowData *data = file.CompBinary2Memory(ndigits);
+//
+// for(int i=0; i<NumberOfRowsInPatch; i++)
+// {
+//
+// AliL3DigitData *dataPt = (AliL3DigitData*)data->fDigitData;
+// for(int j=0; j<data->fNDigit; j++)
+// {
+// pad = dataPt[j].fPad;
+// time = dataPt[j].fTime;
+// charge = dataPt[j].fCharge;
+// }
+//
+// file.UpdateRowPointer(data);
+//
+// }
+// file.CloseBinaryInput();
+// ________________________
+//
+// 2) Writing a binary file:
+//
+// //First of all you need to store the data in memory,
+// //and have a pointer to it of type AliL3DigitRowData.
+// //E.g. if you just want to write the data you read in example 1)
+// //into a new file, you can do the following:
+//
+// AliL3MemHandler newfile;
+// newfile.SetBinaryOutput(newfilename);
+// newfile.Memory2CompBinary((UInt_t)NumberOfRowsInPatch,(AliL3DigitRowData*)data);
+// newfile.CloseBinaryOutput();
-*/
+
ClassImp(AliL3MemHandler)
AliL3MemHandler::AliL3MemHandler()
AliL3MemHandler::~AliL3MemHandler()
{
- ///Destructor
+ //Destructor
if(fPt) delete[] fPt;
if(fDigits) delete [] fDigits;
if(fDPt) delete [] fDPt;
void AliL3MemHandler::ResetROI()
{
- //*Resets the Look-up table for Region of Interest mode.
+ //Resets the Look-up table for Region of Interest mode.
for(Int_t i=fRowMin; i<=fRowMax; i++)
{
void AliL3MemHandler::SetROI(Float_t *eta,Int_t *slice)
{
- /**
- Init the Look-up table for the Region of Interest mode.
- Here you can specify a certain etaregion, - all data
- outside this region will be discarded:
- eta[0] = mimium eta
- eta[1] = maximum eta
- slice[0] = mimumum slice
- slice[1] = maximum slice
- */
+ // Init the Look-up table for the Region of Interest mode.
+ // Here you can specify a certain etaregion, - all data
+ // outside this region will be discarded:
+ // eta[0] = mimium eta
+ // eta[1] = maximum eta
+ // slice[0] = mimumum slice
+ // slice[1] = maximum slice
+
if(eta[1]==0)
{
LOG(AliL3Log::kWarning,"AliL3MemHandler::SetROI","Eta Values")
Bool_t AliL3MemHandler::SetBinaryInput(char *name)
{
- /**
- Set the input binary file.
- */
+ //Set the input binary file.
+
fInBinary = fopen(name,"r");
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryInput","File Open")
Bool_t AliL3MemHandler::SetBinaryInput(FILE *file)
{
- /**
- Set the input binary file.
- */
+ //Set the input binary file.
+
fInBinary = file;
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryInput","File Open")
void AliL3MemHandler::CloseBinaryInput()
{
- /**
- Close the input file.
- */
+ //Close the input file.
+
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::CloseBinaryInput","File Close")
<<"Nothing to Close"<<ENDLOG;
Bool_t AliL3MemHandler::SetBinaryOutput(char *name)
{
- /**
- Set the binary output file.
- */
+ //Set the binary output file.
fOutBinary = fopen(name,"w");
if(!fOutBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryOutput","File Open")
Bool_t AliL3MemHandler::SetBinaryOutput(FILE *file)
{
- /**
- Set the binary output file.
- */
+ //Set the binary output file.
+
fOutBinary = file;
if(!fOutBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::SetBinaryOutput","File Open")
UInt_t AliL3MemHandler::GetFileSize()
{
- /**
- Returns the file size in bytes of the input file.
- */
+ //Returns the file size in bytes of the input file.
+
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::GetFileSize","File")
<<"No Input File"<<ENDLOG;
Byte_t *AliL3MemHandler::Allocate(AliL3TrackArray *array)
{
- /**
- Allocate memory for tracks in memory. Used by TrackArray2Binary()
- */
+ //Allocate memory for tracks in memory. Used by TrackArray2Binary()
+
if(!array){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Allocate","Memory")
<<"Pointer to AliL3TrackArray = 0x0 "<<ENDLOG;
Byte_t *AliL3MemHandler::Allocate(UInt_t size)
{
- /**
- Allocate memory of size in bytes.
- */
+ //Allocate memory of size in bytes.
+
if(fPt){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Allocate","Memory")
<<"Delete Memory"<<ENDLOG;
void AliL3MemHandler::Free()
{
- /**
- Clear the memory, if allocated.
- */
+ //Clear the memory, if allocated.
+
if(!fPt){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Free","Memory")
<<"No Memory allocated - can't Free"<<ENDLOG;
///////////////////////////////////////// Random
void AliL3MemHandler::SetRandomSeed()
{
- /**
- If you are adding random data to the original data.
- */
+ //If you are adding random data to the original data.
time_t *tp=0;
SetRandomSeed(time(tp));
}
void AliL3MemHandler::SetRandomCluster(Int_t maxnumber)
{
- /**
- If you are adding random data to the original data.
- */
+ //If you are adding random data to the original data.
+
IsRandom = kTRUE;
fNRandom = maxnumber;
fNDigits = 0;
void AliL3MemHandler::QSort(AliL3RandomDigitData **a, Int_t first, Int_t last)
{
- //* Sort array of AliL3RandomDigitData pointers using a quicksort algorithm.
- //* Uses CompareDigits() to compare objects.
- //* Thanks to Root!
+ // Sort array of AliL3RandomDigitData pointers using a quicksort algorithm.
+ // Uses CompareDigits() to compare objects.
+ // Thanks to Root!
static AliL3RandomDigitData *tmp;
static int i; // "static" to save stack space
void AliL3MemHandler::Generate(Int_t row)
{
- /**
- Generate random data on row, if you didn't ask for this, nothing happens here.
- */
+ //Generate random data on row, if you didn't ask for this, nothing happens here.
+
if(!IsRandom) return;
ResetRandom();
fNDigits = 0;
void AliL3MemHandler::DigitizePoint(Int_t row, Int_t pad,
Int_t time,Int_t charge)
{
- /**
- Making one single random cluster.
- */
+ //Making one single random cluster.
for(Int_t j=-1;j<2;j++){
for(Int_t k=-1;k<2;k++){
Int_t dcharge = charge;
///////////////////////////////////////// Digit IO
Bool_t AliL3MemHandler::Memory2Binary(UInt_t nrow,AliL3DigitRowData *data)
{
- /**
- Write data to the outputfile as is. No run-length encoding is done.
+ //Write data to the outputfile as is. No run-length encoding is done.
- */
if(!fOutBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","File")
<<"No Output File"<<ENDLOG;
Bool_t AliL3MemHandler::Binary2Memory(UInt_t & nrow,AliL3DigitRowData *data)
{
- /**
- Read inputfile into memory as is, and store it in data. No run-length encoding
- is assumed.
- */
+ //Read inputfile into memory as is, and store it in data. No run-length encoding
+ // is assumed.
+
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2Memory","File")
<<"No Input File"<<ENDLOG;
Int_t AliL3MemHandler::Memory2CompMemory(UInt_t nrow,
AliL3DigitRowData *data,UInt_t *comp)
{
- /**
- Performs run-length encoding on data stored in memory pointed to by data.
- The compressed data is written to comp.
- */
+ //Performs run-length encoding on data stored in memory pointed to by data.
+ //The compressed data is written to comp.
if(!comp){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2CompMemory","Memory")
<<"Pointer to compressed data = 0x0 "<<ENDLOG;
Int_t AliL3MemHandler::CompMemory2Memory(UInt_t nrow,
AliL3DigitRowData *data,UInt_t *comp)
{
- /**
- Uncompress the run-length encoded data in memory pointed to by comp, and
- store it in data.
- */
+ //Uncompress the run-length encoded data in memory pointed to by comp, and
+ // store it in data.
+
if(!comp){
LOG(AliL3Log::kWarning,"AliL3MemHandler::CompMemory2Memory","Memory")
<<"Pointer to compressed data = 0x0 "<<ENDLOG;
UInt_t AliL3MemHandler::GetCompMemorySize(UInt_t nrow,AliL3DigitRowData *data)
{
- /**
- Return the size of RLE data, after compressing data.
- */
+ //Return the size of RLE data, after compressing data.
+
if(!data){
LOG(AliL3Log::kWarning,"AliL3MemHandler::GetCompMemorySize","Memory")
<<"Pointer to AliL3DigitRowData = 0x0 "<<ENDLOG;
Bool_t AliL3MemHandler::CompMemory2CompBinary(UInt_t nrow,UInt_t *comp,
UInt_t size)
{
- /**
- Write the RLE data in comp to the output file.
-
- */
+ //Write the RLE data in comp to the output file.
if(!fOutBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::CompMemory2CompBinary","File")
Bool_t AliL3MemHandler::CompBinary2CompMemory(UInt_t & nrow,UInt_t *comp)
{
- /**
- Read the RLE data from file, and store it in comp. No unpacking yet.
- */
+ //Read the RLE data from file, and store it in comp. No unpacking yet.
+
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::CompBinary2CompMemory","File")
<<"No Output File"<<ENDLOG;
AliL3DigitRowData *AliL3MemHandler::CompBinary2Memory(UInt_t & nrow)
{
- /**
- Read the RLE inputfile, unpack it and return the pointer to it.
-
- */
+ // Read the RLE inputfile, unpack it and return the pointer to it.
+
AliL3MemHandler * handler = new AliL3MemHandler();
handler->SetBinaryInput(fInBinary);
UInt_t *comp =(UInt_t *)handler->Allocate();
Bool_t AliL3MemHandler::Memory2CompBinary(UInt_t nrow,AliL3DigitRowData *data)
{
- /**
- Perform RLE on the data, and write it to the output file.
- */
+ //Perform RLE on the data, and write it to the output file.
Bool_t out = kTRUE;
AliL3MemHandler * handler = new AliL3MemHandler();
UInt_t size = GetCompMemorySize(nrow,data);
///////////////////////////////////////// Point IO
Bool_t AliL3MemHandler::Memory2Binary(UInt_t npoint,AliL3SpacePointData *data)
{
- /**
- Writing spacepoints stored in data to the outputfile.
- */
+ //Writing spacepoints stored in data to the outputfile.
if(!fOutBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","File")
<<"No Output File"<<ENDLOG;
Bool_t AliL3MemHandler::Transform(UInt_t npoint,AliL3SpacePointData *data,
Int_t slice, AliL3Transform* trans)
{
- /**
- Transform the space points in data, to global coordinates in slice.
-
- */
+ //Transform the space points in data, to global coordinates in slice.
if(!data){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Transform","Memory")
<<"Pointer to AliL3SpacePointData = 0x0 "<<ENDLOG;
Bool_t AliL3MemHandler::Binary2Memory(UInt_t & npoint,AliL3SpacePointData *data)
{
- /**
- Read the space points in inputfile, and store it in data.
- */
+ //Read the space points in inputfile, and store it in data.
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2Memory","File")
<<"No Input File"<<ENDLOG;
///////////////////////////////////////// Track IO
Bool_t AliL3MemHandler::Memory2Binary(UInt_t ntrack,AliL3TrackSegmentData *data)
{
- /**
- Write the tracks stored in data, to outputfile.
- */
+ //Write the tracks stored in data, to outputfile.
if(!fOutBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2Binary","File")
<<"No Output File"<<ENDLOG;
Bool_t AliL3MemHandler::Binary2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data)
{
- /**
- Read the tracks in inputfile, and store it in data.
- */
+ //Read the tracks in inputfile, and store it in data.
+
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2Memory","File")
<<"No Input File"<<ENDLOG;
Bool_t AliL3MemHandler::TrackArray2Binary(AliL3TrackArray *array)
{
- /**
- Write the trackarray to the outputfile.
- */
+ //Write the trackarray to the outputfile.
if(!fOutBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::TrackArray2Binary","File")
<<"No Output File"<<ENDLOG;
Bool_t AliL3MemHandler::Binary2TrackArray(AliL3TrackArray *array)
{
- /**
- Read the tracks in inputfile, and fill it in trackarray.
- array should already be constructed.
- */
+ //Read the tracks in inputfile, and fill it in trackarray.
+ //array should already be constructed.
if(!fInBinary){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Binary2TrackArray","File")
<<"No Input File"<<ENDLOG;
Bool_t AliL3MemHandler::TrackArray2Memory(UInt_t & ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array)
{
- /**
- Fill the trackarray into the AliTrackSegmentData structures before writing to outputfile.
- */
+ //Fill the trackarray into the AliTrackSegmentData structures before writing to outputfile.
if(!data){
LOG(AliL3Log::kWarning,"AliL3MemHandler::TrackArray2Memory","Memory")
<<"Pointer to AliL3TrackSegmentData = 0x0 "<<ENDLOG;
Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array)
{
- /**
- Fill the tracks in data into trackarray.
- */
+ //Fill the tracks in data into trackarray.
+
if(!data){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2TrackArray","Memory")
<<"Pointer to AliL3TrackSegmentData = 0x0 "<<ENDLOG;
Bool_t AliL3MemHandler::Memory2TrackArray(UInt_t ntrack,AliL3TrackSegmentData *data,AliL3TrackArray *array,Int_t slice,
AliL3Transform* trans)
{
- /**
- Fill the tracks in data into trackarray, and rotate the tracks to global coordinates.
- */
+ //Fill the tracks in data into trackarray, and rotate the tracks to global coordinates.
+
if(!data){
LOG(AliL3Log::kWarning,"AliL3MemHandler::Memory2TrackArray","Memory")
<<"Pointer to AliL3TrackSegmentData = 0x0 "<<ENDLOG;