#include "AliL3ModelTrack.h"
#include "AliL3Transform.h"
#include "AliL3MemHandler.h"
+#ifdef use_aliroot
#include "AliL3FileHandler.h"
+#endif
#include "bitio.h"
//_____________________________________________________________
if(output->mask != 0x80) //Write the current byte to file.
{
+ //cerr<<"\nAliL3Compress::CompressFile() : Writing overhead bits!!!"<<endl;
if(putc(output->rack,output->file )!=output->rack)
cerr<<"AliL3Compress::ComressFile : Error writing to bitfile"<<endl;
output->mask=0x80;
OutputBit(output,0);
else
OutputBit(output,1);
- power = 1<<fNumTimeBits;
+ power = 1<<(fNumTimeBits-1);
if(abs(temp)>=power)
{
timeo++;
temp=power - 1;
}
- OutputBits(output,abs(temp),fNumTimeBits);
+ OutputBits(output,abs(temp),(fNumTimeBits-1));
//Write pad information:
temp = (Int_t)cluster.fDPad;
OutputBit(output,0);
else
OutputBit(output,1);
- power = 1<<fNumPadBits;
+ power = 1<<(fNumPadBits-1);
if(abs(temp)>=power)
{
pado++;
temp=power - 1;
}
- OutputBits(output,abs(temp),fNumPadBits);
+ OutputBits(output,abs(temp),(fNumPadBits-1));
//Write charge information:
temp = (Int_t)cluster.fDCharge;
OutputBit(output,0);
else
OutputBit(output,1);
- power = 1<<fNumChargeBits;
+ power = 1<<(fNumChargeBits-1);
if(abs(temp)>=power)
{
chargeo++;
temp=power - 1;
}
- OutputBits(output,abs(temp),fNumChargeBits);
-
+ OutputBits(output,abs(temp),(fNumChargeBits-1));
+
//Write shape information:
temp = (Int_t)cluster.fDSigmaY2;
power = 1<<fNumShapeBits;
//Read time information:
sign=InputBit(input);
- temp = InputBits(input,fNumTimeBits);
+ temp = InputBits(input,(fNumTimeBits-1));
if(!sign)
temp*=-1;
clusters[i].fDTime = temp;
//Read pad information:
sign=InputBit(input);
- temp = InputBits(input,fNumPadBits);
+ temp = InputBits(input,(fNumPadBits-1));
if(!sign)
temp*=-1;
clusters[i].fDPad = temp;
//Read charge information:
sign = InputBit(input);
- temp=InputBits(input,fNumChargeBits);
+ temp=InputBits(input,(fNumChargeBits-1));
if(!sign)
temp*=-1;
clusters[i].fDCharge = temp;
Int_t charge;
for(Int_t j=NRows[fPatch][0]; j<=NRows[fPatch][1]; j++)
{
+ cout<<"Building clusters on row "<<j<<endl;
for(Int_t i=0; i<fTracks->GetNTracks(); i++)
{
AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i);
AliL3Transform *tr = new AliL3Transform();
TRandom *random = new TRandom();
- Int_t entries=10000;
+ Int_t entries=1000;
TH1F *hist1 = new TH1F("hist1","",tr->GetNPads(row),0,tr->GetNPads(row)-1);
TH1F *hist2 = new TH1F("hist2","",tr->GetNTimeBins(),0,tr->GetNTimeBins()-1);
TH2F *hist3 = new TH2F("hist3","",tr->GetNPads(row),0,tr->GetNPads(row)-1,tr->GetNTimeBins(),0,tr->GetNTimeBins()-1);
if(sigmaY2 <= 0 || sigmaZ2 <= 0)
{
- cerr<<"AliL3Compress::CreateDigits() : Wrong sigmas : "<<sigmaY2<<" "<<sigmaZ2<<endl;
+ cerr<<"AliL3Compress::CreateDigits() : Wrong sigmas : "<<sigmaY2<<" "<<sigmaZ2;
+ cerr<<" on row "<<row<<" pad "<<pad<<" time "<<time<<endl;
return;
}
delete tr;
}
+void AliL3Compress::PrintCompRatio()
+{
+ Char_t fname[100];
+ sprintf(fname,"%s/remains_%d_%d.raw",fPath,fSlice,fPatch);
+ AliL3MemHandler *mem = new AliL3MemHandler();
+ if(!mem->SetBinaryInput(fname))
+ {
+ cerr<<"AliL3Compress::PrintCompRatio(): Error opening file: "<<fname<<endl;
+ return;
+ }
+ UInt_t ndigits;
+ AliL3DigitRowData *rowPt = (AliL3DigitRowData*)mem->CompBinary2Memory(ndigits);
+ mem->CloseBinaryInput();
+
+ Int_t digit_counter=0;
+ for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+ {
+ digit_counter += rowPt->fNDigit;
+ mem->UpdateRowPointer(rowPt);
+ }
+ delete mem;
+
+ sprintf(fname,"%s/tracks_c_%d_%d.raw",fPath,fSlice,fPatch);
+ FILE *file1 = fopen(fname,"r");
+ if(!file1)
+ {
+ cerr<<"AliL3Compress::PrintCompRatio(): Error opening file: "<<fname<<endl;
+ return;
+ }
+ fseek(file1,0,SEEK_END);
+ UInt_t filesize1 = (UInt_t)ftell(file1);
+ fclose(file1);
+
+ sprintf(fname,"%s/digits_%d_%d.raw",fPath,fSlice,fPatch);
+ FILE *file2 = fopen(fname,"r");
+ if(!file2)
+ {
+ cerr<<"AliL3Compress::PrintCompRatio(): Error opening file: "<<fname<<endl;
+ return;
+ }
+ fseek(file2,0,SEEK_END);
+ UInt_t filesize2 = (UInt_t)ftell(file2);
+ fclose(file2);
+
+ cout<<"----------------------"<<endl;
+ cout<<"Original file size : "<<filesize2<<endl;
+ cout<<"Compressed file size : "<<filesize1<<endl;
+ cout<<"Remaining digits : "<<digit_counter<<endl;
+ cout<<"Compression ratio : "<<(Float_t)(filesize1 + (10*digit_counter)/8)/(Float_t)(filesize2)<<endl;
+
+}
+
void AliL3Compress::QSort(AliL3RandomDigitData **a, Int_t first, Int_t last)
{
void AliL3Compress::WriteRootFile(Char_t *digitsfile,Char_t *rootfile)
{
+#ifdef use_aliroot
Char_t fname[100];
AliL3MemHandler *mem = new AliL3MemHandler();
sprintf(fname,"%s/restored_%d_%d.raw",fPath,fSlice,fPatch);
delete mem;
delete file;
+#endif
+
+ return;
}
void WriteRestoredData();
void WriteRootFile(Char_t *digitsfile,Char_t *rootfile);
void PrintDigits();
-
+ void PrintCompRatio();
+
AliL3TrackArray *GetTracks() {return fTracks;}
ClassDef(AliL3Compress,1)
fTime=0;
fClusterCharge=0;
fTrackModel=0;
+ fTransform = 0;
}
delete [] fOverlap;
if(fTrackModel)
delete fTrackModel;
+ if(fTransform)
+ delete fTransform;
}
void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
for(Int_t i=0; i<nrows; i++)
fOverlap[i]=-1;
+ fTransform = new AliL3Transform();
fClusterCharge = 260;
- AliL3Transform transform;
- fXYResidualQ = 0.1/transform.GetPadPitchWidth(patch);
- fZResidualQ = 0.1/transform.GetPadPitchWidth(patch);
-
+ fXYResidualQ = 0.1/fTransform->GetPadPitchWidth(patch);
+ fZResidualQ = 0.1/fTransform->GetPadPitchWidth(patch);
+
fXYWidthQ = 0.01;
fZWidthQ = 0.01;
}
CalculateHelix();
- AliL3Transform transform;
Float_t hit[3];
Int_t sector,row;
for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
AliL3ClusterModel *cl = GetClusterModel(i);
if(!cl) continue;
GetCrossingPoint(i,hit);
- transform.Slice2Sector(fSlice,i,sector,row);
- transform.Local2Raw(hit,sector,row);
+ fTransform->Slice2Sector(fSlice,i,sector,row);
+ fTransform->Local2Raw(hit,sector,row);
SetPadHit(i,hit[1]);
SetTimeHit(i,hit[2]);
}
//----------Code below taken from AliTPCTracker.cxx-----------------------
//Functions that give the expected cluster errors based on track parameters.
-Double_t AliL3ModelTrack::GetParSigmaY2(Double_t r)//, Double_t tgl, Double_t pt)
+Double_t AliL3ModelTrack::GetParSigmaY2(Int_t row)//Double_t r)//, Double_t tgl, Double_t pt)
{
//
//
// Sigma rphi
+ Float_t pad,time;
+ if(!GetTime(row,time) || !GetPad(row,pad))
+ return -1;
+
+ Float_t xyz[3];
+ Int_t sector,padrow;
+ fTransform->Slice2Sector(fSlice,row,sector,padrow);
+ fTransform->Raw2Local(xyz,sector,padrow,pad,time);
+ Double_t r = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+
Double_t tgl = GetTgl();
Double_t pt = GetPt();
return s;
}
-Double_t AliL3ModelTrack::GetParSigmaZ2(Double_t r)//, Double_t tgl)
+Double_t AliL3ModelTrack::GetParSigmaZ2(Int_t row)//Double_t r)//, Double_t tgl)
{
//
// Parametrised error of the cluster reconstruction (drift direction)
//
// Sigma z
+ Float_t pad,time;
+ if(!GetTime(row,time) || !GetPad(row,pad))
+ return -1;
+
+ Float_t xyz[3];
+ Int_t sector,padrow;
+ fTransform->Slice2Sector(fSlice,row,sector,padrow);
+ fTransform->Raw2Local(xyz,sector,padrow,pad,time);
+ Double_t r = sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
+
Double_t tgl = GetTgl();
const Float_t kAz=0.39614e-2;
#include "AliL3Models.h"
#include "AliL3Defs.h"
+class AliL3Transform;
+
class AliL3ModelTrack : public AliL3Track {
private:
Short_t fClusterCharge; //Average cluster charge
AliL3ClusterModel *fClusters; //!
AliL3TrackModel *fTrackModel; //!
+ AliL3Transform *fTransform; //!
Short_t fNClusters;
Int_t *fOverlap; //!
Float_t fXYResidualQ; //Quantization steps.
Bool_t GetTimeResidual(Int_t row,Float_t &res);
Int_t GetNClusters() {return fNClusters;}
- Double_t GetParSigmaY2(Double_t r);
- Double_t GetParSigmaZ2(Double_t r);
+ Double_t GetParSigmaY2(Int_t row);
+ Double_t GetParSigmaZ2(Int_t row);
ClassDef(AliL3ModelTrack,1)
}
-void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *path)
+void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path)
{
fSlice = slice;
fPatch = patch;
- fPadOverlap=4;
- fTimeOverlap=4;
+ fPadOverlap=6;
+ fTimeOverlap=8;
fTrackThreshold=10;
sprintf(fPath,"%s",path);
fTransform = new AliL3Transform();
fTracks = new AliL3TrackArray("AliL3ModelTrack");
-
+
+ Char_t fname[100];
AliL3MemHandler *file = new AliL3MemHandler();
- if(!file->SetBinaryInput("tracks.raw"))
+ sprintf(fname,"%s/tracks.raw",trackdata);
+ if(!file->SetBinaryInput(fname))
{
- cerr<<"AliL3Modeller::Init : Error opening trackfile"<<endl;
+ cerr<<"AliL3Modeller::Init : Error opening trackfile: "<<fname<<endl;
return;
}
file->Binary2TrackArray(fTracks);
CheckForOverlaps();
fMemHandler = new AliL3MemHandler();
- Char_t fname[100];
sprintf(fname,"%sdigits_%d_%d.raw",fPath,fSlice,fPatch);
if(!fMemHandler->SetBinaryInput(fname))
{
{
if(pad < 0 || pad >= fTransform->GetNPads(i))
{
- //cout<<"Pad<0 on row "<<i<<endl;
+ //cout<<"Pad = "<<pad<<" on row "<<i<<endl;
FillCluster(track,&cluster,i);
break;
}
continue;
}
else
- break;
+ {
+ //cerr<<"Breaking off at pad "<<pad<<" and time "<<time<<endl;
+ break;
+ }
}
//cout<<"Doing pad "<<pad<<" time "<<time<<" charge "<<charge<<endl;
{
if(padsign==-1)
{
- if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2)
+ if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2 && pad > 0)
{
pad--; //In this case, we haven't found anything yet,
} //so we will try to expand our search within the natural boundaries.
else if(padsign==1)
{
- if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2)
+ if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2 && pad < fTransform->GetNPads(i)-2)
{
pad++; //In this case, we haven't found anything yet,
continue; //so we will try to expand our search within the natural boundaries.
for(UInt_t j=0; j<rowPt->fNDigit; j++)
{
if(digPt[j].fCharge==0) continue;
+
digitcount++;
ndigits[(i-NRows[fPatch][0])]++;
}
AliL3Modeller();
virtual ~AliL3Modeller();
- void Init(Int_t slice,Int_t patch,Char_t *path="./");
+ void Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path);
void FindClusters();
void CheckForOverlaps();
void CalculateCrossingPoints();