A bugfix in AliL3Modeller::FindClusters. Changed parameter list in AliL3ModelTrack...
authorvestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Mar 2002 11:50:20 +0000 (11:50 +0000)
committervestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 22 Mar 2002 11:50:20 +0000 (11:50 +0000)
HLT/comp/AliL3Compress.cxx
HLT/comp/AliL3Compress.h
HLT/comp/AliL3ModelTrack.cxx
HLT/comp/AliL3ModelTrack.h
HLT/comp/AliL3Modeller.cxx
HLT/comp/AliL3Modeller.h

index 7e4d1cc..53043b3 100644 (file)
@@ -15,7 +15,9 @@
 #include "AliL3ModelTrack.h"
 #include "AliL3Transform.h"
 #include "AliL3MemHandler.h"
+#ifdef use_aliroot
 #include "AliL3FileHandler.h"
+#endif
 #include "bitio.h"
 
 //_____________________________________________________________
@@ -177,6 +179,7 @@ void AliL3Compress::CompressFile()
       
       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;
@@ -200,13 +203,13 @@ void AliL3Compress::CompressFile()
            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;
@@ -214,13 +217,13 @@ void AliL3Compress::CompressFile()
            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;
@@ -228,14 +231,14 @@ void AliL3Compress::CompressFile()
            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;
@@ -314,21 +317,21 @@ void AliL3Compress::ExpandFile()
          
          //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;
@@ -375,6 +378,7 @@ void AliL3Compress::RestoreData()
   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);
@@ -515,7 +519,7 @@ void AliL3Compress::CreateDigits(Int_t row,Float_t pad,Float_t time,Int_t charge
   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);
@@ -542,7 +546,8 @@ void AliL3Compress::CreateDigits(Int_t row,Float_t pad,Float_t time,Int_t charge
   
   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;
     }
   
@@ -605,6 +610,58 @@ void AliL3Compress::CreateDigits(Int_t row,Float_t pad,Float_t time,Int_t charge
   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)
 {
   
@@ -650,6 +707,7 @@ 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);
@@ -670,4 +728,7 @@ void AliL3Compress::WriteRootFile(Char_t *digitsfile,Char_t *rootfile)
 
   delete mem;
   delete file;
+#endif
+
+  return;
 }
index e57f562..9015c00 100644 (file)
@@ -45,7 +45,8 @@ class AliL3Compress {
   void WriteRestoredData();
   void WriteRootFile(Char_t *digitsfile,Char_t *rootfile);
   void PrintDigits();
-
+  void PrintCompRatio();
+  
   AliL3TrackArray *GetTracks() {return fTracks;}
   
   ClassDef(AliL3Compress,1) 
index 19a4ff1..7b5895c 100644 (file)
@@ -21,6 +21,7 @@ AliL3ModelTrack::AliL3ModelTrack()
   fTime=0;
   fClusterCharge=0;
   fTrackModel=0;
+  fTransform = 0;
 }
 
 
@@ -36,6 +37,8 @@ AliL3ModelTrack::~AliL3ModelTrack()
     delete [] fOverlap;
   if(fTrackModel)
     delete fTrackModel;
+  if(fTransform)
+    delete fTransform;
 }
 
 void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
@@ -57,13 +60,13 @@ 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;
 }
@@ -139,7 +142,6 @@ void AliL3ModelTrack::FillTrack()
   
   CalculateHelix();
   
-  AliL3Transform transform;
   Float_t hit[3];
   Int_t sector,row;
   for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
@@ -147,8 +149,8 @@ void AliL3ModelTrack::FillTrack()
       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]);
     }
@@ -317,7 +319,7 @@ void AliL3ModelTrack::Print()
 
 //----------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)
 {
   
   //
@@ -325,6 +327,16 @@ Double_t AliL3ModelTrack::GetParSigmaY2(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();
   
@@ -343,13 +355,23 @@ Double_t AliL3ModelTrack::GetParSigmaY2(Double_t r)//, Double_t tgl, Double_t pt
   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;
index 4ee05d8..2eba6ef 100644 (file)
@@ -5,6 +5,8 @@
 #include "AliL3Models.h"
 #include "AliL3Defs.h"
 
+class AliL3Transform;
+
 class AliL3ModelTrack : public AliL3Track {
 
  private:
@@ -12,6 +14,7 @@ class AliL3ModelTrack : public AliL3Track {
   Short_t fClusterCharge; //Average cluster charge
   AliL3ClusterModel *fClusters; //!
   AliL3TrackModel *fTrackModel; //!
+  AliL3Transform *fTransform; //!
   Short_t fNClusters;
   Int_t *fOverlap; //!
   Float_t fXYResidualQ; //Quantization steps.
@@ -58,8 +61,8 @@ class AliL3ModelTrack : public AliL3Track {
   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)
 
index 1a8d0d8..0639c58 100644 (file)
@@ -37,22 +37,24 @@ AliL3Modeller::~AliL3Modeller()
 
 }
 
-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);
@@ -73,7 +75,6 @@ void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *path)
   CheckForOverlaps();
 
   fMemHandler = new AliL3MemHandler();
-  Char_t fname[100];
   sprintf(fname,"%sdigits_%d_%d.raw",fPath,fSlice,fPatch);
   if(!fMemHandler->SetBinaryInput(fname))
     {
@@ -153,7 +154,7 @@ void AliL3Modeller::FindClusters()
            {
              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;
                }
@@ -193,7 +194,10 @@ void AliL3Modeller::FindClusters()
                          continue;
                        }
                      else
-                       break;
+                       {
+                         //cerr<<"Breaking off at pad "<<pad<<" and time "<<time<<endl;
+                         break;
+                       }
                    }
                  
                  //cout<<"Doing pad "<<pad<<" time "<<time<<" charge "<<charge<<endl;
@@ -216,7 +220,7 @@ void AliL3Modeller::FindClusters()
                {
                  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.
@@ -230,7 +234,7 @@ void AliL3Modeller::FindClusters()
                  
                  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.
@@ -317,6 +321,7 @@ void AliL3Modeller::WriteRemaining()
       for(UInt_t j=0; j<rowPt->fNDigit; j++)
        {
          if(digPt[j].fCharge==0) continue;
+         
          digitcount++;
          ndigits[(i-NRows[fPatch][0])]++;
        }
index 59f1136..5de02bf 100644 (file)
@@ -52,7 +52,7 @@ class AliL3Modeller {
   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();