Moving to static AliL3Transform.
authorvestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 May 2002 08:05:06 +0000 (08:05 +0000)
committervestbo <vestbo@f7af4fe6-9843-0410-8265-dc069ae4e863>
Wed, 22 May 2002 08:05:06 +0000 (08:05 +0000)
Some changes has been made since last checkin;
some smaller bugfixes everywhere. The number of pads in a cluster is stored,
because there are some cluster containing only 1 pad which create problems
when restoring the data. In principle one has to remove these clusters
before writing them, but this has not been incorporated yet.

HLT/comp/AliL3Compress.cxx
HLT/comp/AliL3Compress.h
HLT/comp/AliL3ModelTrack.cxx
HLT/comp/AliL3ModelTrack.h
HLT/comp/AliL3Modeller.cxx
HLT/comp/AliL3Modeller.h
HLT/comp/AliL3Models.h
HLT/comp/bitio.c

index 53043b35ea3c2fe770325442bba77d691880d095..ae481ae55c513ca5c98db2f9753c80617491ee45 100644 (file)
@@ -82,7 +82,11 @@ void AliL3Compress::WriteFile(AliL3TrackArray *tracks)
     {
       AliL3ModelTrack *track = (AliL3ModelTrack*)tracks->GetCheckedTrack(i);
       if(!track) continue;
-            
+      
+      //Do not save useless tracks or clusters:
+      //if(track->CheckClustersQuality(2) == 0) 
+      //continue;
+      
       track->FillModel();
       model = track->GetModel();
       if(model->fNClusters==0) continue;
@@ -241,28 +245,37 @@ void AliL3Compress::CompressFile()
                  
          //Write shape information:
          temp = (Int_t)cluster.fDSigmaY2;
-         power = 1<<fNumShapeBits;
+         if(temp<0)
+           OutputBit(output,0);
+         else
+           OutputBit(output,1);
+         power = 1<<(fNumShapeBits-1);
          if(abs(temp) >= power)
            {
              shapeo++;
              temp = power - 1;
            }
-         OutputBits(output,abs(temp),fNumShapeBits);
+         OutputBits(output,abs(temp),(fNumShapeBits-1));
          
          temp = (Int_t)cluster.fDSigmaZ2;
+         if(temp<0)
+           OutputBit(output,0);
+         else
+           OutputBit(output,1);
+         power = 1<<(fNumShapeBits-1);
          if(abs(temp) >= power)
            {
              shapeo++;
              temp=power - 1;
            }
-         OutputBits(output,abs(temp),fNumShapeBits);
+         OutputBits(output,abs(temp),(fNumShapeBits-1));
        }
     }
   
   fclose(input);
   CloseOutputBitFile(output);
 
-  cout<<endl<<"There was following number of overflows: "<<endl
+  cout<<endl<<"Saturations: "<<endl
       <<"Pad "<<pado<<endl
       <<"Time "<<timeo<<endl
       <<"Charge "<<chargeo<<endl
@@ -293,7 +306,7 @@ void AliL3Compress::ExpandFile()
   AliL3ClusterModel *clusters=0;
   Int_t count=0;
   
-  clusters = new AliL3ClusterModel[(NumRows[fPatch])];
+  clusters = new AliL3ClusterModel[(AliL3Transform::GetNRows(fPatch))];
   while(!feof(input->file))
     {
       input->mask=0x80;//make sure we read a new byte from file.
@@ -302,7 +315,7 @@ void AliL3Compress::ExpandFile()
       if(fread(&trackmodel,sizeof(AliL3TrackModel),1,input->file)!=1) break;
       fwrite(&trackmodel,sizeof(AliL3TrackModel),1,output);
       
-      for(Int_t i=0; i<NumRows[fPatch]; i++)
+      for(Int_t i=0; i<AliL3Transform::GetNRows(fPatch); i++)
        {
          Int_t temp,sign;
          
@@ -337,10 +350,16 @@ void AliL3Compress::ExpandFile()
          clusters[i].fDCharge = temp;
          
          //Read shape information:
-         temp = InputBits(input,fNumShapeBits);
+         sign = InputBit(input);
+         temp = InputBits(input,(fNumShapeBits-1));
+         if(!sign)
+           temp*=-1;
          clusters[i].fDSigmaY2 = temp;
          
-         temp = InputBits(input,fNumShapeBits);
+         sign = InputBit(input);
+         temp = InputBits(input,(fNumShapeBits-1));
+         if(!sign)
+           temp*=-1;
          clusters[i].fDSigmaZ2 = temp;
        }
       
@@ -366,17 +385,20 @@ void AliL3Compress::CreateDigitArray(Int_t maxnumber)
   fDPt = new AliL3RandomDigitData*[maxnumber];
 }
 
-void AliL3Compress::RestoreData()
+void AliL3Compress::RestoreData(Char_t which='u')
 {
+  //Restore the data.
+  //which == u : restore compressed data
+  //which == m : restore uncompressed data
   
-  //Read the uncompressed file:
-  ReadFile('u');
+
+  ReadFile(which);
   
-  CreateDigitArray(100000);
+  CreateDigitArray(10000000);
   
   Float_t pad,time,sigmaY2,sigmaZ2;
   Int_t charge;
-  for(Int_t j=NRows[fPatch][0]; j<=NRows[fPatch][1]; j++)
+  for(Int_t j=AliL3Transform::GetFirstRow(fPatch); j<=AliL3Transform::GetLastRow(fPatch); j++)
     {
       cout<<"Building clusters on row "<<j<<endl;
       for(Int_t i=0; i<fTracks->GetNTracks(); i++)
@@ -397,18 +419,20 @@ void AliL3Compress::RestoreData()
   QSort(fDPt,0,fNDigits);
 }
 
-void AliL3Compress::PrintDigits()
+void AliL3Compress::PrintDigits(Int_t padrow=-1)
 {
   Int_t pad,time,charge,row;
   for(Int_t i=0; i<fNDigits; i++)
     {
       row = fDPt[i]->fRow;
+      if(padrow > 0)
+       if(row != padrow) continue;
       pad = fDPt[i]->fPad;
       time = fDPt[i]->fTime;
       charge = fDPt[i]->fCharge;
       if(i>0 && row != fDPt[i-1]->fRow)
        cout<<"---Padrow "<<row<<"---"<<endl;
-      cout<<"Pad "<<pad<<" time "<<time<<" charge "<<charge<<endl;
+      cout<<"Padrow "<<row<<" Pad "<<pad<<" time "<<time<<" charge "<<charge<<endl;
     }
 }
 
@@ -436,7 +460,7 @@ void AliL3Compress::WriteRestoredData()
       
   UInt_t digit_counter;
   Int_t row_counter=0;
-  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       tempRow->fRow = i;
       ndigits=0;
@@ -456,7 +480,7 @@ void AliL3Compress::WriteRestoredData()
              time = origDig[digit_counter].fTime;
              charge = origDig[digit_counter].fCharge;
              digit_counter++;
-             while((action=ComparePoints(i,pad,time)) == 1)
+             while( (action=ComparePoints(i,pad,time)) == 1)
                {
                  tempDig[ndigits].fPad = fDPt[fNUsed]->fPad;
                  tempDig[ndigits].fTime = fDPt[fNUsed]->fTime;
@@ -475,7 +499,10 @@ void AliL3Compress::WriteRestoredData()
            }
          
          if(fNUsed >= fNDigits) 
-           break;
+           {
+             //cerr<<"AliL3Compress::WriteRestoredData() : Array out of range : "<<fNUsed<<" "<<fNDigits<<endl;
+             break;
+           }
          if(fDPt[fNUsed]->fRow != i) //we are on a new row
            break;
          tempDig[ndigits].fPad = fDPt[fNUsed]->fPad;
@@ -485,10 +512,9 @@ void AliL3Compress::WriteRestoredData()
          fNUsed++;
        }
       //cout<<"Writing "<<ndigits<<" digits on row "<<i<<endl;
-      if(ndigits < 4)
+      if(ndigits > 4)
        {
          row_counter++;
-         cout<<"Few digits on row "<<i<<endl;
        }
       tempRow->fNDigit = ndigits;
       Int_t size = sizeof(AliL3DigitData)*tempRow->fNDigit + sizeof(AliL3DigitRowData);
@@ -498,13 +524,13 @@ void AliL3Compress::WriteRestoredData()
       mem->UpdateRowPointer(origRow);
     }
   
-  if(row_counter != NumRows[fPatch])
-    cerr<<"AliL3Compress::WriteRestoredData() : Written rows: "<<row_counter<<" total rows "<<NumRows[fPatch]<<endl;
+  if(row_counter != AliL3Transform::GetNRows(fPatch))
+    cerr<<"AliL3Compress::WriteRestoredData() : Written rows: "<<row_counter<<" total rows "<<AliL3Transform::GetNRows(fPatch)<<endl;
   
   mem->Free();  
   sprintf(fname,"%s/restored_%d_%d.raw",fPath,fSlice,fPatch);
   mem->SetBinaryOutput(fname);
-  mem->Memory2CompBinary((UInt_t)NumRows[fPatch],(AliL3DigitRowData*)data);
+  mem->Memory2CompBinary((UInt_t)AliL3Transform::GetNRows(fPatch),(AliL3DigitRowData*)data);
   mem->CloseBinaryOutput();
   
   delete [] data;
@@ -516,33 +542,36 @@ void AliL3Compress::CreateDigits(Int_t row,Float_t pad,Float_t time,Int_t charge
 {
   //Create raw data out of the cluster.
   
-  AliL3Transform *tr = new AliL3Transform();
-  TRandom *random = new TRandom();
-  
-  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);
-  
-  //Convert back the sigmas:
-  Float_t padw,timew;
-  if(fPatch < 3)
-    padw = tr->GetPadPitchWidthLow();
-  else
-    padw = tr->GetPadPitchWidthUp();
-  timew = tr->GetZWidth();
 
-  if(fPatch < 3)
+    
+  //Convert back the sigmas:
+  /*
+    Float_t padw,timew;
+    if(fPatch < 2)
+    padw = AliL3Transform::GetPadPitchWidthLow();
+    else
+    padw = AliL3Transform::GetPadPitchWidthUp();
+    timew = AliL3Transform::GetZWidth();
+  */
+  
+  /*
+    if(fPatch < 3)
     sigmaY2 = sigmaY2/2.07;
-  sigmaY2 = sigmaY2/0.108;
-  sigmaY2 = sigmaY2/(padw*padw);
-  sigmaY2 = sigmaY2 - 1./12;
+    sigmaY2 = sigmaY2/0.108;
+  */
+  
+  //sigmaY2 = sigmaY2/(padw*padw);
+  
+  //sigmaY2 = sigmaY2;// - 1./12;
   
-  if(fPatch < 3)
+  /*
+    if(fPatch < 3)
     sigmaZ2 = sigmaZ2/1.77;
-  sigmaZ2 = sigmaZ2/0.169;
-  sigmaZ2 = sigmaZ2/(timew*timew);
-  sigmaZ2 = sigmaZ2 - 1./12;
+    sigmaZ2 = sigmaZ2/0.169;
+  */
+  
+  //sigmaZ2 = sigmaZ2/(timew*timew);
+  //sigmaZ2 = sigmaZ2;// - 1./12;
   
   if(sigmaY2 <= 0 || sigmaZ2 <= 0)
     {
@@ -551,6 +580,15 @@ void AliL3Compress::CreateDigits(Int_t row,Float_t pad,Float_t time,Int_t charge
       return;
     }
   
+  TRandom *random = new TRandom();
+  
+  Int_t entries=1000;
+  TH1F *hist1 = new TH1F("hist1","",AliL3Transform::GetNPads(row),0,AliL3Transform::GetNPads(row)-1);
+  TH1F *hist2 = new TH1F("hist2","",AliL3Transform::GetNTimeBins(),0,AliL3Transform::GetNTimeBins()-1);
+  TH2F *hist3 = new TH2F("hist3","",AliL3Transform::GetNPads(row),0,AliL3Transform::GetNPads(row)-1,AliL3Transform::GetNTimeBins(),0,AliL3Transform::GetNTimeBins()-1);
+
+  
+  
   //Create the distributions in pad and time:
   for(Int_t i=0; i<entries; i++)
     {
@@ -579,6 +617,7 @@ void AliL3Compress::CreateDigits(Int_t row,Float_t pad,Float_t time,Int_t charge
        }
     }
   
+  Int_t local_dig=0;
   //Fill it into the digit array:
   for(Int_t i=0; i<hist3->GetNbinsX(); i++)
     {
@@ -600,14 +639,16 @@ void AliL3Compress::CreateDigits(Int_t row,Float_t pad,Float_t time,Int_t charge
          fDigits[fNDigits].fTime = (Int_t)hist3->GetYaxis()->GetBinCenter(j);
          fDPt[fNDigits] = &fDigits[fNDigits];
          fNDigits++;
+         local_dig++;
        }
     }
+  //if(local_dig < 5)
+  //  cout<<"Small cluster "<<local_dig<<" pad "<<(Int_t)fDigits[fNDigits-1].fPad<<" time "<<(Int_t)fDigits[fNDigits-1].fTime<<endl;
   
   delete random;
   delete hist1;
   delete hist2;
   delete hist3;
-  delete tr;
 }
 
 void AliL3Compress::PrintCompRatio()
@@ -625,7 +666,7 @@ void AliL3Compress::PrintCompRatio()
   mem->CloseBinaryInput();
 
   Int_t digit_counter=0;
-  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       digit_counter += rowPt->fNDigit;
       mem->UpdateRowPointer(rowPt);
@@ -705,7 +746,7 @@ void AliL3Compress::QSort(AliL3RandomDigitData **a, Int_t first, Int_t last)
   }
 }
 
-void AliL3Compress::WriteRootFile(Char_t *digitsfile,Char_t *rootfile)
+void AliL3Compress::WriteRootFile(Char_t *newrootfile)
 {
 #ifdef use_aliroot
   Char_t fname[100];
@@ -715,15 +756,18 @@ void AliL3Compress::WriteRootFile(Char_t *digitsfile,Char_t *rootfile)
   UInt_t ndigits;
   AliL3DigitRowData *rowPt = (AliL3DigitRowData*)mem->CompBinary2Memory(ndigits);
   mem->CloseBinaryInput();
-
+  
+  sprintf(fname,"%s/digitfile",fPath);
+  
   AliL3FileHandler *file = new AliL3FileHandler();
-  if(!file->SetAliInput(digitsfile))
+  if(!file->SetAliInput(fname))
     {
-      cerr<<"AliL3Compress::WriteRootFile() : Error opening file: "<<digitsfile<<endl;
+      cerr<<"AliL3Compress::WriteRootFile() : Error opening file: "<<fname<<endl;
       return;
     }
-  file->Init(fSlice,fPatch,NRows[fPatch]);
-  file->AliDigits2RootFile(rowPt,rootfile);
+  const Int_t rows[2] = {AliL3Transform::GetFirstRow(fPatch),AliL3Transform::GetLastRow(fPatch)};
+  file->Init(fSlice,fPatch,rows);
+  file->AliDigits2RootFile(rowPt,newrootfile);
   file->CloseAliInput();
 
   delete mem;
index 9015c00f4fef91989ff99242b1aee8f1134a6cbe..740e70ba27bdd79a3ea45aeddc50cd1048e0ea0c 100644 (file)
@@ -41,10 +41,10 @@ class AliL3Compress {
   void ReadFile(Char_t which);
   void CompressFile();
   void ExpandFile();
-  void RestoreData();
+  void RestoreData(Char_t which='u');
   void WriteRestoredData();
-  void WriteRootFile(Char_t *digitsfile,Char_t *rootfile);
-  void PrintDigits();
+  void WriteRootFile(Char_t *newrootfile);
+  void PrintDigits(Int_t padrow=-1);
   void PrintCompRatio();
   
   AliL3TrackArray *GetTracks() {return fTracks;}
@@ -59,9 +59,12 @@ inline Int_t  AliL3Compress::ComparePoints(Int_t row,UShort_t pad,UShort_t time)
   
   if(fDPt[fNUsed]->fRow != row) return 0;
   
+  
   if(fDPt[fNUsed]->fPad < pad) return 1;
   if(fDPt[fNUsed]->fPad == pad && fDPt[fNUsed]->fTime < time) return 1;
   
+  //if(fDPt[fNUsed]->fPad == pad && fDPt[fNUsed]->fTime == time) return 2;
+  
   return 0;
 
 }
index 7b5895cd51ac7325bb9ec71adb164fe96e3aba09..b8945dfd45e1404d46aee578169bcb6b9e476351 100644 (file)
 #include "AliL3ModelTrack.h"
 #include "AliL3Transform.h"
 
+//_____________________________________________________________
+// AliL3ModelTrack
+//
+// 
+
 ClassImp(AliL3ModelTrack)
 
 AliL3ModelTrack::AliL3ModelTrack()
@@ -21,7 +26,6 @@ AliL3ModelTrack::AliL3ModelTrack()
   fTime=0;
   fClusterCharge=0;
   fTrackModel=0;
-  fTransform = 0;
 }
 
 
@@ -37,8 +41,6 @@ AliL3ModelTrack::~AliL3ModelTrack()
     delete [] fOverlap;
   if(fTrackModel)
     delete fTrackModel;
-  if(fTransform)
-    delete fTransform;
 }
 
 void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
@@ -46,7 +48,7 @@ void AliL3ModelTrack::Init(Int_t slice,Int_t patch)
   fNClusters = 0;
   fSlice=slice;
   fPatch=patch;
-  Int_t nrows = NumRows[patch];
+  Int_t nrows = AliL3Transform::GetNRows(fPatch);
   fClusters = new AliL3ClusterModel[nrows];
   fPad = new Float_t[nrows];
   fTime = new Float_t[nrows];
@@ -60,25 +62,24 @@ 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;
-  
+  fClusterCharge = 100;
   
-  fXYResidualQ = 0.1/fTransform->GetPadPitchWidth(patch);
-  fZResidualQ = 0.1/fTransform->GetPadPitchWidth(patch);
+  // 100 micrometers:
+  fXYResidualQ = 0.01/AliL3Transform::GetPadPitchWidth(patch);
+  fZResidualQ = 0.01/AliL3Transform::GetPadPitchWidth(patch);
   
-  fXYWidthQ = 0.01;
-  fZWidthQ = 0.01;
+  fXYWidthQ = 0.005/AliL3Transform::GetPadPitchWidth(patch);
+  fZWidthQ = 0.005/AliL3Transform::GetPadPitchWidth(patch);
 }
 
 
-void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t charge,Float_t sigmaY2,Float_t sigmaZ2)
+void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t charge,Float_t sigmaY2,Float_t sigmaZ2,Int_t npads)
 {
-  Int_t index = row - NRows[fPatch][0];
+  Int_t index = row - AliL3Transform::GetFirstRow(fPatch);
   if(index != fNClusters)
     cout<<"AliL3ModelTrack::SetCluster() : Mismatch ; index: "<<index<<" nclusters "<<fNClusters<<endl;
   
-  if(index < 0 || index > NumRows[fPatch])
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::SetCluster() : Wrong index: "<<index<<" row "<<row<<endl;
       return;
@@ -92,13 +93,34 @@ void AliL3ModelTrack::SetCluster(Int_t row,Float_t fpad,Float_t ftime,Float_t ch
       cl->fDTime = (ftime - GetTimeHit(row))/fXYResidualQ;
       cl->fDPad = (fpad - GetPadHit(row))/fZResidualQ;
       cl->fDCharge = charge - fClusterCharge;
-      cl->fDSigmaY2 = sigmaY2/fXYWidthQ;
-      cl->fDSigmaZ2 = sigmaZ2/fZWidthQ;
+      cl->fDSigmaY2 = (sigmaY2 - GetParSigmaY2(row))/fXYWidthQ;
+      cl->fDSigmaZ2 = (sigmaZ2 - GetParSigmaZ2(row))/fZWidthQ;
+      cl->fNPads = npads;
     }
   
   fNClusters++;
 }
 
+Int_t AliL3ModelTrack::CheckClustersQuality(UInt_t npads=3)
+{
+
+  //Check the quality of clusters,- remove clusters with less than
+  //npads. 
+  //Returns the number of good clusters left.
+
+  Int_t count=0;
+
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
+    {
+      AliL3ClusterModel *cl = GetClusterModel(i);
+      if(cl->fNPads < npads)
+       cl->fPresent = kFALSE;
+      if(cl->fPresent)
+       count++;
+    }
+  
+  return count;
+}
 
 void AliL3ModelTrack::FillModel()
 {
@@ -138,19 +160,19 @@ void AliL3ModelTrack::FillTrack()
   SetLength(fTrackModel->fLength);
   fClusterCharge=fTrackModel->fClusterCharge;
   fNClusters = fTrackModel->fNClusters;
-  SetPt((BFACT*BField)/fabs(GetKappa()));
+  SetPt((BFACT*AliL3Transform::GetBField())/fabs(GetKappa()));
   
   CalculateHelix();
   
   Float_t hit[3];
   Int_t sector,row;
-  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       AliL3ClusterModel *cl = GetClusterModel(i);
       if(!cl) continue;
       GetCrossingPoint(i,hit);
-      fTransform->Slice2Sector(fSlice,i,sector,row);
-      fTransform->Local2Raw(hit,sector,row);
+      AliL3Transform::Slice2Sector(fSlice,i,sector,row);
+      AliL3Transform::Local2Raw(hit,sector,row);
       SetPadHit(i,hit[1]);
       SetTimeHit(i,hit[2]);
     }
@@ -158,8 +180,8 @@ void AliL3ModelTrack::FillTrack()
 
 void AliL3ModelTrack::SetPadHit(Int_t row,Float_t pad)
 {
-  Int_t index = row-NRows[fPatch][0];
-  if(index < 0 || index > NumRows[fPatch])
+  Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::SetPadHit() : Wrong index: "<<index<<endl;
       return;
@@ -170,8 +192,8 @@ void AliL3ModelTrack::SetPadHit(Int_t row,Float_t pad)
 
 void AliL3ModelTrack::SetTimeHit(Int_t row,Float_t time)
 {
-  Int_t index = row-NRows[fPatch][0];
-  if(index < 0 || index > NumRows[fPatch])
+  Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::SetTimeHit() : Wrong index: "<<index<<endl;
       return;
@@ -181,8 +203,8 @@ void AliL3ModelTrack::SetTimeHit(Int_t row,Float_t time)
 
 void AliL3ModelTrack::SetOverlap(Int_t row,Int_t id)
 {
-  Int_t index = row-NRows[fPatch][0];
-  if(index < 0 || index > NumRows[fPatch])
+  Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::SetOverlap() : Wrong index: "<<index<<endl;
       return;
@@ -190,6 +212,12 @@ void AliL3ModelTrack::SetOverlap(Int_t row,Int_t id)
   fOverlap[index]=id;
 }
 
+Int_t AliL3ModelTrack::GetNPads(Int_t row)
+{
+  AliL3ClusterModel *cl = GetClusterModel(row);
+  return cl->fNPads;
+}
+
 Bool_t AliL3ModelTrack::GetPad(Int_t row,Float_t &pad)
 {
   //(ftime - GetTimeHit(fNClusters))/fXYResidualQ;
@@ -220,7 +248,7 @@ Bool_t AliL3ModelTrack::GetClusterCharge(Int_t row,Int_t &charge)
 Bool_t AliL3ModelTrack::GetXYWidth(Int_t row,Float_t &width)
 {
   AliL3ClusterModel *cl = GetClusterModel(row);
-  width = cl->fDSigmaY2*fXYWidthQ;
+  width = cl->fDSigmaY2*fXYWidthQ + GetParSigmaY2(row);
   
   return (Bool_t)cl->fPresent;
 }
@@ -228,27 +256,43 @@ Bool_t AliL3ModelTrack::GetXYWidth(Int_t row,Float_t &width)
 Bool_t AliL3ModelTrack::GetZWidth(Int_t row,Float_t &width)
 {
   AliL3ClusterModel *cl = GetClusterModel(row);
-  width = cl->fDSigmaZ2*fZWidthQ;
+  width = cl->fDSigmaZ2*fZWidthQ + GetParSigmaZ2(row);
   
   return (Bool_t)cl->fPresent;
 }
 
 Bool_t AliL3ModelTrack::GetPadResidual(Int_t row,Float_t &res)
 {
-  res = fClusters[row].fDPad;
-  return fClusters[row].fPresent;
+  AliL3ClusterModel *cl = GetClusterModel(row);
+  res = cl->fDPad;
+  return cl->fPresent;
 }
 
 Bool_t AliL3ModelTrack::GetTimeResidual(Int_t row,Float_t &res)
 {
-  res = fClusters[row].fDTime;
-  return fClusters[row].fPresent;
+  AliL3ClusterModel *cl = GetClusterModel(row);
+  res = cl->fDTime;
+  return cl->fPresent;
+}
+
+Bool_t AliL3ModelTrack::GetXYWidthResidual(Int_t row,Float_t &res)
+{
+  AliL3ClusterModel *cl = GetClusterModel(row);
+  res = cl->fDSigmaY2;
+  return cl->fPresent;
+}
+
+Bool_t AliL3ModelTrack::GetZWidthResidual(Int_t row,Float_t &res)
+{
+  AliL3ClusterModel *cl = GetClusterModel(row);
+  res = cl->fDSigmaZ2;
+  return cl->fPresent;
 }
 
 Float_t AliL3ModelTrack::GetPadHit(Int_t row)
 {
-  Int_t index = row-NRows[fPatch][0];
-  if(index < 0 || index > NumRows[fPatch])
+  Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::GetPadHit() : Wrong index: "<<index<<" row "<<row<<endl;
       return 0;
@@ -258,8 +302,8 @@ Float_t AliL3ModelTrack::GetPadHit(Int_t row)
 
 Float_t AliL3ModelTrack::GetTimeHit(Int_t row)
 {
-  Int_t index = row-NRows[fPatch][0];
-  if(index < 0 || index > NumRows[fPatch])
+  Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::GetTimeHit() : Wrong index: "<<index<<" row "<<row<<endl;
       return 0;
@@ -269,8 +313,8 @@ Float_t AliL3ModelTrack::GetTimeHit(Int_t row)
 
 Int_t AliL3ModelTrack::GetOverlap(Int_t row)
 {
-  Int_t index = row-NRows[fPatch][0];
-  if(index < 0 || index > NumRows[fPatch])
+  Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::GetOverlap() : Wrong index: "<<index<<endl;
       return 0;
@@ -281,8 +325,8 @@ Int_t AliL3ModelTrack::GetOverlap(Int_t row)
 AliL3ClusterModel *AliL3ModelTrack::GetClusterModel(Int_t row)
 {
   if(!fClusters) return 0; 
-  Int_t index = row-NRows[fPatch][0];
-  if(index < 0 || index > NumRows[fPatch])
+  Int_t index = row-AliL3Transform::GetFirstRow(fPatch);
+  if(index < 0 || index > AliL3Transform::GetNRows(fPatch))
     {
       cerr<<"AliL3ModelTrack::GetClusterModel() : Wrong index: "<<index<<endl;
       return 0;
@@ -294,7 +338,7 @@ void AliL3ModelTrack::Print()
 {
   //Print info
 
-  cout<<"---------------------"<<endl;
+  cout<<"----Slice "<<fSlice<<" Patch "<<fPatch<<"----"<<endl;
   cout<<"First point "<<GetFirstPointX()<<" "<<GetFirstPointY()<<" "<<GetFirstPointZ()<<endl;
   cout<<"Last point "<<GetLastPointX()<<" "<<GetLastPointY()<<" "<<GetLastPointZ()<<endl;
   cout<<"Pt "<<GetPt()<<" kappa "<<GetKappa()<<" tgl "<<GetTgl()<<" psi "<<GetPsi()<<" charge "<<GetCharge()<<endl;
@@ -302,7 +346,7 @@ void AliL3ModelTrack::Print()
   cout<<"NHits "<<GetNClusters()<<endl;
   cout<<"Clusters:"<<endl;
 
-  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       AliL3ClusterModel *cl = GetClusterModel(i);
       
@@ -311,56 +355,50 @@ void AliL3ModelTrack::Print()
       else
        {
          cout<<i<<" Dpad "<<cl->fDPad<<" Dtime "<<cl->fDTime<<" Dcharge "<<cl->fDCharge;
+         cout<<" DsigmaY2 "<<cl->fDSigmaY2<<" DsigmaZ2 "<<cl->fDSigmaZ2;
          cout<<" Padcrossing "<<GetPadHit(i)<<" Timecrossing "<<GetTimeHit(i)<<" ";
+         cout<<"Number of pads "<<GetNPads(i)<<endl;
        }
       cout<<"Overlapping index "<<GetOverlap(i)<<endl;
     }
 }
 
-//----------Code below taken from AliTPCTracker.cxx-----------------------
-//Functions that give the expected cluster errors based on track parameters.
-Double_t AliL3ModelTrack::GetParSigmaY2(Int_t row)//Double_t r)//, Double_t tgl, Double_t pt)
+Double_t AliL3ModelTrack::GetParSigmaY2(Int_t row)
 {
-  
-  //
-  // Parametrised error of the cluster reconstruction (pad direction)   
-  //
-  // Sigma rphi
-  
+  //Calculate the expected cluster width, based on the track parameters and drift distance.
+
   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]);
+  AliL3Transform::Slice2Sector(fSlice,row,sector,padrow);
+  AliL3Transform::Raw2Local(xyz,sector,padrow,pad,time);
   
-  Double_t tgl = GetTgl();
-  Double_t pt = GetPt();
+  //Calculate the drift length:
+  Double_t drift;
+  if(xyz[2] > 0)
+    drift = AliL3Transform::GetZLength() - xyz[2];
+  else
+    drift = AliL3Transform::GetZLength() + xyz[2];
+  
+  Double_t prf = AliL3Transform::GetPRFSigma(fPatch);
+  Double_t diffT = AliL3Transform::GetDiffT();
+  Double_t padlength = AliL3Transform::GetPadLength(fPatch);
+  Double_t anode = AliL3Transform::GetAnodeWireSpacing();
+  Double_t beta = GetCrossingAngle(row);
   
-  const Float_t kArphi=0.41818e-2;
-  const Float_t kBrphi=0.17460e-4;
-  const Float_t kCrphi=0.30993e-2;
-  const Float_t kDrphi=0.41061e-3;
+  Double_t sigmaY2 = prf*prf + diffT*diffT*drift + padlength*padlength*tan(beta)*tan(beta)/12 + anode*anode*pow( tan(beta)-0.15, 2)/12;
   
-  pt=fabs(pt)*1000.;
-  Double_t x=r/pt;
-  tgl=fabs(tgl);
-  Double_t s=kArphi - kBrphi*r*tgl + kCrphi*x*x + kDrphi*x;
-  if (s<0.4e-3) s=0.4e-3;
-  s*=1.3; //Iouri Belikov
-
-  return s;
+  //Convert back to raw coordinates.
+  sigmaY2 = sigmaY2/pow(AliL3Transform::GetPadPitchWidth(fPatch),2);
+  return sigmaY2;
 }
 
-Double_t AliL3ModelTrack::GetParSigmaZ2(Int_t row)//Double_t r)//, Double_t tgl) 
+Double_t AliL3ModelTrack::GetParSigmaZ2(Int_t row)
 {
-  //
-  // Parametrised error of the cluster reconstruction (drift direction)
-  //
-  // Sigma z
+  //Calculate the expected cluster width, based on the track parameters and drift distance.
   
   Float_t pad,time;
   if(!GetTime(row,time) || !GetPad(row,pad))
@@ -368,21 +406,25 @@ Double_t AliL3ModelTrack::GetParSigmaZ2(Int_t row)//Double_t r)//, Double_t tgl)
   
   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]);
+  AliL3Transform::Slice2Sector(fSlice,row,sector,padrow);
+  AliL3Transform::Raw2Local(xyz,sector,padrow,pad,time);
   
-  Double_t tgl = GetTgl();
-
-  const Float_t kAz=0.39614e-2;
-  const Float_t kBz=0.22443e-4;
-  const Float_t kCz=0.51504e-1;
+  //Calculate the drift length:
+  Double_t drift;
+  if(xyz[2] > 0)
+    drift = AliL3Transform::GetZLength() - xyz[2];
+  else
+    drift = AliL3Transform::GetZLength() + xyz[2];
+  
+  Double_t sigma0 = AliL3Transform::GetTimeSigma();
+  Double_t diffL = AliL3Transform::GetDiffL();
+  Double_t padlength = AliL3Transform::GetPadLength(fPatch);
+  Double_t tanl = GetTgl();
+  
+  Double_t sigmaZ2 = sigma0*sigma0 + diffL*diffL*drift + padlength*padlength * tanl*tanl/12;
+  
+  //Convert back to raw coodinates:
+  sigmaZ2 = sigmaZ2/pow(AliL3Transform::GetZWidth(),2);
+  return sigmaZ2;
   
-
-  tgl=fabs(tgl);
-  Double_t s=kAz - kBz*r*tgl + kCz*tgl*tgl;
-  if (s<0.4e-3) s=0.4e-3;
-  s*=1.3; //Iouri Belikov
-
-  return s;
 }
index 2eba6ef89fbc3d572f81850be03e1ec2577479d7..b889adc6a79cc2232ddac6bca89c4c3adf7dfc08 100644 (file)
@@ -3,9 +3,6 @@
 
 #include "AliL3Track.h"
 #include "AliL3Models.h"
-#include "AliL3Defs.h"
-
-class AliL3Transform;
 
 class AliL3ModelTrack : public AliL3Track {
 
@@ -14,7 +11,6 @@ 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.
@@ -35,7 +31,7 @@ class AliL3ModelTrack : public AliL3Track {
   virtual ~AliL3ModelTrack();
   
   void Init(Int_t slice,Int_t patch);
-  void SetCluster(Int_t row,Float_t dpad,Float_t dtime,Float_t charge,Float_t sigmaY2,Float_t sigmaZ2);
+  void SetCluster(Int_t row,Float_t dpad,Float_t dtime,Float_t charge,Float_t sigmaY2,Float_t sigmaZ2,Int_t npads);
   void FillModel();
   void FillTrack();
   void Print();
@@ -45,11 +41,13 @@ class AliL3ModelTrack : public AliL3Track {
   void SetOverlap(Int_t row,Int_t id);
   void SetXYResolution(Float_t f) {fXYResolution=f;}
   void SetZResolution(Float_t f) {fZResolution=f;}
+  Int_t CheckClustersQuality(UInt_t npads=3);
   
   AliL3ClusterModel *GetClusters() {return fClusters;}
   AliL3TrackModel *GetModel() {return fTrackModel;}
   AliL3ClusterModel *GetClusterModel(Int_t row);
   Int_t GetOverlap(Int_t row);
+  Int_t GetNPads(Int_t row);
   Float_t GetPadHit(Int_t row);
   Float_t GetTimeHit(Int_t row);
   Bool_t GetPad(Int_t row,Float_t &pad);
@@ -59,6 +57,8 @@ class AliL3ModelTrack : public AliL3Track {
   Bool_t GetZWidth(Int_t row,Float_t &width);
   Bool_t GetPadResidual(Int_t row,Float_t &res);
   Bool_t GetTimeResidual(Int_t row,Float_t &res);
+  Bool_t GetXYWidthResidual(Int_t row,Float_t &res);
+  Bool_t GetZWidthResidual(Int_t row,Float_t &res);
   Int_t GetNClusters() {return fNClusters;}
   
   Double_t GetParSigmaY2(Int_t row);
index 0639c582fbf483623cc1a7f6106a5189fcd528fb..cf79b1d2741c67520f8ac6fb8e9562372bbe0e1d 100644 (file)
 #include "AliL3DigitData.h"
 #include "AliL3Transform.h"
 
-#include "AliL3Defs.h"
+//_____________________________________________________________
+// AliL3Modeller
+//
+// Class for modeling TPC data.
+// 
+// This performs the cluster finding, based on track parameters.
+// Basically it propagates the tracks to all padrows, and looks 
+// for a corresponding cluster. For the moment only cog is calculated,
+// and no deconvolution is done. 
 
 ClassImp(AliL3Modeller)
 
@@ -22,7 +30,10 @@ AliL3Modeller::AliL3Modeller()
 {
   fMemHandler=0;
   fTracks=0;
-  fTransform=0;
+  fTrackThreshold=0;
+  fPadOverlap=0;
+  fTimeOverlap=0;
+  fRowData=0;
 }
 
 
@@ -32,26 +43,24 @@ AliL3Modeller::~AliL3Modeller()
     delete fMemHandler;
   if(fTracks)
     delete fTracks;
-  if(fTransform)
-    delete fTransform;
-
 }
 
-void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path)
+void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path,Bool_t houghtracks)
 {
   fSlice = slice;
   fPatch = patch;
   fPadOverlap=6;
   fTimeOverlap=8;
-  fTrackThreshold=10;
+  
   sprintf(fPath,"%s",path);
   
-  fTransform = new AliL3Transform();
+  AliL3Transform::Init(fPath);
+  
   fTracks = new AliL3TrackArray("AliL3ModelTrack");
   
   Char_t fname[100];
   AliL3MemHandler *file = new AliL3MemHandler();
-  sprintf(fname,"%s/tracks.raw",trackdata);
+  sprintf(fname,"%s/tracks_tr_%d_0.raw",trackdata,fSlice); //output tracks from the tracker (no merging)
   if(!file->SetBinaryInput(fname))
     {
       cerr<<"AliL3Modeller::Init : Error opening trackfile: "<<fname<<endl;
@@ -61,18 +70,31 @@ void AliL3Modeller::Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path)
   file->CloseBinaryInput();
   delete file;
   
-  fTracks->QSort();
+  if(houghtracks)
+    cout<<"AliL3Modeller is assuming local hough tracksegments!"<<endl;
+  else
+    cout<<"AliL3Modeller is assuming global tracks!"<<endl;
+
+  if(!houghtracks)
+    fTracks->QSort();
+  
   for(Int_t i=0; i<fTracks->GetNTracks(); i++)
     {
       AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i);
       if(!track) continue;
       track->Init(fSlice,fPatch);
-      track->Rotate(fSlice,kTRUE);
+
+      //Only if the tracks has been merged across sector boundaries:
+      //if(!houghtracks)
+      //track->Rotate(fSlice,kTRUE); //!!!!!!!!!!!!!!!!!!!
+      
       track->CalculateHelix();
     }    
   
   CalculateCrossingPoints();
-  CheckForOverlaps();
+  
+  if(!houghtracks)
+    CheckForOverlaps();
 
   fMemHandler = new AliL3MemHandler();
   sprintf(fname,"%sdigits_%d_%d.raw",fPath,fSlice,fPatch);
@@ -104,8 +126,8 @@ void AliL3Modeller::FindClusters()
   AliL3DigitRowData *rowPt = fRowData;
   AliL3DigitData *digPt=0;
 
-  Int_t ntimes = fTransform->GetNTimeBins()+1;
-  Int_t npads = fTransform->GetNPads(NRows[fPatch][1])+1;//Max num of pads.
+  Int_t ntimes = AliL3Transform::GetNTimeBins()+1;
+  Int_t npads = AliL3Transform::GetNPads(AliL3Transform::GetLastRow(fPatch))+1;//Max num of pads.
   Int_t bounds = ntimes*npads;
   Digit *row = new Digit[bounds];
   
@@ -114,7 +136,7 @@ void AliL3Modeller::FindClusters()
   Short_t charge;
   Cluster cluster;
 
-  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       memset((void*)row,0,ntimes*npads*sizeof(Digit));
       digPt = (AliL3DigitData*)rowPt->fDigitData;
@@ -136,7 +158,7 @@ void AliL3Modeller::FindClusters()
          
          if(track->GetPadHit(i)<0 || track->GetTimeHit(i)<0 || track->GetOverlap(i)>=0)
            {
-             track->SetCluster(i,0,0,0,0,0); //The track has left the patch.
+             track->SetCluster(i,0,0,0,0,0,0); //The track has left the patch.
              continue;
            }
          
@@ -150,17 +172,19 @@ void AliL3Modeller::FindClusters()
          
          memset(&cluster,0,sizeof(Cluster));
          
+         Int_t npads=0;
          while(1)//Process this padrow
            {
-             if(pad < 0 || pad >= fTransform->GetNPads(i)) 
+             if(pad < 0 || pad >= AliL3Transform::GetNPads(i)) 
                {
                  //cout<<"Pad = "<<pad<<" on row "<<i<<endl;
-                 FillCluster(track,&cluster,i);
+                 FillCluster(track,&cluster,i,npads);
                  break;
                }
              seq_charge=0;
              timesign=-1;
              time = hittime;
+             
              while(1) //Process sequence on this pad:
                {
                  if(time < 0) break;
@@ -171,6 +195,14 @@ void AliL3Modeller::FindClusters()
                        <<" on row "<<i<<" pad "<<pad<<" time "<<time<<endl;
                      break;
                    }
+                 
+                 /*
+                 if(row[index].fUsed == kTRUE)//Only use the digits once....
+                   charge = 0;
+                 else
+                   charge = row[index].fCharge;
+                 */
+                 
                  charge = row[index].fCharge;
                  if(charge==0 && timesign==-1)
                    {
@@ -213,9 +245,13 @@ void AliL3Modeller::FindClusters()
                  row[ntimes*pad+time].fUsed = kTRUE;
                  time += timesign;
                }
-             //cout<<"Finished on pad "<<pad<<" and time "<<time<<endl;
-             if(seq_charge)
-               pad += padsign;
+             
+             
+             if(seq_charge)//There was something on this pad.
+               {
+                 pad += padsign;
+                 npads++;
+               }
              else //Nothing more on this pad, goto next pad
                {
                  if(padsign==-1) 
@@ -234,7 +270,7 @@ void AliL3Modeller::FindClusters()
                  
                  else if(padsign==1)
                    {
-                     if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2 && pad < fTransform->GetNPads(i)-2)
+                     if(cluster.fCharge==0 && abs(pad-hitpad) <= fPadOverlap/2 && pad < AliL3Transform::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.
@@ -242,14 +278,14 @@ void AliL3Modeller::FindClusters()
                      else //We are out of range, or cluster if finished.
                        {
                          //cout<<"Outof range; charge "<<cluster.fCharge<<" paddiff "<<abs(pad-hitpad)<<endl;
-                         FillCluster(track,&cluster,i);
+                         FillCluster(track,&cluster,i,npads);
                          break;
                        }
                    }
                  else //Nothing more in this cluster
                    {
                      //cout<<"Filling final cluster"<<endl;
-                     FillCluster(track,&cluster,i);
+                     FillCluster(track,&cluster,i,npads);
                      break;
                    } 
                }
@@ -269,17 +305,17 @@ void AliL3Modeller::FindClusters()
     {
       AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i);
       if(!track) continue;
-      if(track->GetNClusters() != NumRows[fPatch])
-       cerr<<endl<<"Mismatching hitcounts; nclusters: "<<track->GetNClusters()<<" nrows "<<NumRows[fPatch]<<endl<<endl;
+      if(track->GetNClusters() != AliL3Transform::GetNRows(fPatch))
+       cerr<<endl<<"Mismatching hitcounts; nclusters: "<<track->GetNClusters()<<" nrows "<<AliL3Transform::GetNRows(fPatch)<<endl<<endl;
     }
   
 }
 
-void AliL3Modeller::FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t row)
+void AliL3Modeller::FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t row,Int_t npads)
 {
   if(cluster->fCharge==0)
     {
-      track->SetCluster(row,0,0,0,0,0);
+      track->SetCluster(row,0,0,0,0,0,0);
       return;
     }
   Float_t fcharge = (Float_t)cluster->fCharge;
@@ -287,7 +323,7 @@ void AliL3Modeller::FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t ro
   Float_t ftime = ((Float_t)cluster->fTime/fcharge);
   Float_t sigmaY2,sigmaZ2;
   CalcClusterWidth(cluster,sigmaY2,sigmaZ2);
-  track->SetCluster(row,fpad,ftime,fcharge,sigmaY2,sigmaZ2);
+  track->SetCluster(row,fpad,ftime,fcharge,sigmaY2,sigmaZ2,npads);
   
 }
 
@@ -295,7 +331,7 @@ void AliL3Modeller::FillZeros(AliL3DigitRowData *rowPt,Digit *row)
 {
   //Fill zero where data has been used.
   
-  Int_t ntimes = fTransform->GetNTimeBins()+1;
+  Int_t ntimes = AliL3Transform::GetNTimeBins()+1;
   AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
   for(UInt_t j=0; j<rowPt->fNDigit; j++)
     {
@@ -313,38 +349,37 @@ void AliL3Modeller::WriteRemaining()
   AliL3DigitRowData *rowPt;
   rowPt = (AliL3DigitRowData*)fRowData;
   Int_t digitcount=0;
-  Int_t ndigits[(NumRows[fPatch])];
-  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+  Int_t ndigits[(AliL3Transform::GetNRows(fPatch))];
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
-      ndigits[(i-NRows[fPatch][0])]=0;
+      ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]=0;
       for(UInt_t j=0; j<rowPt->fNDigit; j++)
        {
          if(digPt[j].fCharge==0) continue;
-         
          digitcount++;
-         ndigits[(i-NRows[fPatch][0])]++;
+         ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]++;
        }
-      //cout<<"Difference "<<(int)ndigits[(i-NRows[fPatch][0])]<<" "<<(int)rowPt->fNDigit<<endl;
+      //cout<<"Difference "<<(int)ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]<<" "<<(int)rowPt->fNDigit<<endl;
       fMemHandler->UpdateRowPointer(rowPt);
     }
   
-  Int_t size = digitcount*sizeof(AliL3DigitData) + NumRows[fPatch]*sizeof(AliL3DigitRowData);
+  Int_t size = digitcount*sizeof(AliL3DigitData) + AliL3Transform::GetNRows(fPatch)*sizeof(AliL3DigitRowData);
   Byte_t *data = new Byte_t[size];
   memset(data,0,size);
   AliL3DigitRowData *tempPt = (AliL3DigitRowData*)data;
   rowPt = (AliL3DigitRowData*)fRowData;
   
-  for(Int_t i=NRows[fPatch][0]; i<=NRows[fPatch][1]; i++)
+  for(Int_t i=AliL3Transform::GetFirstRow(fPatch); i<=AliL3Transform::GetLastRow(fPatch); i++)
     {
       Int_t localcount=0;
       tempPt->fRow = i;
-      tempPt->fNDigit = ndigits[(i-NRows[fPatch][0])];
+      tempPt->fNDigit = ndigits[(i-AliL3Transform::GetFirstRow(fPatch))];
       AliL3DigitData *digPt = (AliL3DigitData*)rowPt->fDigitData;
       for(UInt_t j=0; j<rowPt->fNDigit; j++)
        {
          if(digPt[j].fCharge==0) continue;
-         if(localcount >= ndigits[(i-NRows[fPatch][0])])
+         if(localcount >= ndigits[(i-AliL3Transform::GetFirstRow(fPatch))])
            {
              cerr<<"AliL3Modeller::WriteRemaining : Digitarray out of range!!"<<endl;
              return;
@@ -352,16 +387,17 @@ void AliL3Modeller::WriteRemaining()
          tempPt->fDigitData[localcount].fCharge = digPt[j].fCharge;
          tempPt->fDigitData[localcount].fPad = digPt[j].fPad;
          tempPt->fDigitData[localcount].fTime = digPt[j].fTime;
+
          localcount++;
        }
-      if(ndigits[(i-NRows[fPatch][0])] != localcount)
+      if(ndigits[(i-AliL3Transform::GetFirstRow(fPatch))] != localcount)
        {
          cerr<<"AliL3Modeller::WriteRemaining : Mismatch in digitcount"<<endl;
          return;
        }
       fMemHandler->UpdateRowPointer(rowPt);
       Byte_t *tmp = (Byte_t*)tempPt;
-      Int_t size = sizeof(AliL3DigitRowData) + ndigits[(i-NRows[fPatch][0])]*sizeof(AliL3DigitData);
+      Int_t size = sizeof(AliL3DigitRowData) + ndigits[(i-AliL3Transform::GetFirstRow(fPatch))]*sizeof(AliL3DigitData);
       tmp += size;
       tempPt = (AliL3DigitRowData*)tmp;
     }
@@ -370,7 +406,7 @@ void AliL3Modeller::WriteRemaining()
   AliL3MemHandler *mem = new AliL3MemHandler();
   sprintf(fname,"%s/remains_%d_%d.raw",fPath,fSlice,fPatch);
   mem->SetBinaryOutput(fname);
-  mem->Memory2CompBinary((UInt_t)NumRows[fPatch],(AliL3DigitRowData*)data);
+  mem->Memory2CompBinary((UInt_t)AliL3Transform::GetNRows(fPatch),(AliL3DigitRowData*)data);
   mem->CloseBinaryOutput();
   delete mem;
   delete [] data;
@@ -393,24 +429,23 @@ void AliL3Modeller::CalculateCrossingPoints()
     {
       AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(i);
       if(!track) continue;
-      if(track->GetFirstPointX() > fTransform->Row2X(NRows[fPatch][1]) || track->GetPt()<0.1)
+      if(track->GetFirstPointX() > AliL3Transform::Row2X(AliL3Transform::GetLastRow(fPatch)) || track->GetPt()<0.1)
        fTracks->Remove(i);
+      if(track->GetNHits() < fTrackThreshold)
+       {
+         fTracks->Remove(i);
+         continue;
+       }
     }
   
   Int_t sector,row;
-  for(Int_t i=NRows[fPatch][1]; i>=NRows[fPatch][0]; i--)
+  for(Int_t i=AliL3Transform::GetLastRow(fPatch); i>=AliL3Transform::GetFirstRow(fPatch); i--)
     {
       for(Int_t j=0; j<fTracks->GetNTracks(); j++)
        {
          AliL3ModelTrack *track = (AliL3ModelTrack*)fTracks->GetCheckedTrack(j);
          if(!track) continue;
-                 
-         if(track->GetNHits() < fTrackThreshold)
-           {
-             fTracks->Remove(j);
-             continue;
-           }
-         
+
          if(!track->GetCrossingPoint(i,hit)) 
            {
              cerr<<"AliL3Modeller::CalculateCrossingPoints : Track "<<j<<" does not intersect row "<<i<<" :"<<endl<<
@@ -423,16 +458,17 @@ void AliL3Modeller::CalculateCrossingPoints()
            }
          //cout<<" x "<<track->GetPointX()<<" y "<<track->GetPointY()<<" z "<<track->GetPointZ()<<endl;
          
-         fTransform->Slice2Sector(fSlice,i,sector,row);
-         fTransform->Local2Raw(hit,sector,row);
-         if(hit[1]<0 || hit[1]>fTransform->GetNPads(i) ||
-            hit[2]<0 || hit[2]>fTransform->GetNTimeBins())
+         AliL3Transform::Slice2Sector(fSlice,i,sector,row);
+         AliL3Transform::Local2Raw(hit,sector,row);
+         if(hit[1]<0 || hit[1]>AliL3Transform::GetNPads(i) ||
+            hit[2]<0 || hit[2]>AliL3Transform::GetNTimeBins())
            {//Track is leaving the patch, so flag the track hits (<0)
              track->SetPadHit(i,-1);
              track->SetTimeHit(i,-1);
              continue;
            }
-           
+         
+         
          track->SetPadHit(i,hit[1]);
          track->SetTimeHit(i,hit[2]);
          
@@ -460,7 +496,7 @@ void AliL3Modeller::CheckForOverlaps()
        {
          AliL3ModelTrack *track2 = (AliL3ModelTrack*)fTracks->GetCheckedTrack(j);
          if(!track2) continue;
-         for(Int_t k=NRows[fPatch][0]; k<=NRows[fPatch][1]; k++)
+         for(Int_t k=AliL3Transform::GetFirstRow(fPatch); k<=AliL3Transform::GetLastRow(fPatch); k++)
            {
              if(track1->GetPadHit(k)<0 || track1->GetTimeHit(k)<0 ||
                 track2->GetPadHit(k)<0 || track2->GetTimeHit(k)<0)
@@ -482,31 +518,39 @@ void AliL3Modeller::CalcClusterWidth(Cluster *cl,Float_t &sigmaY2,Float_t &sigma
 {
   
   Float_t padw,timew;
-  if(fPatch < 3)
-    padw = fTransform->GetPadPitchWidthLow();
-  else
-    padw = fTransform->GetPadPitchWidthUp();
+  
+  padw = AliL3Transform::GetPadPitchWidth(fPatch);
+  
   Float_t charge = (Float_t)cl->fCharge;
   Float_t pad = (Float_t)cl->fPad/charge;
   Float_t time = (Float_t)cl->fTime/charge;
   Float_t s2 = (Float_t)cl->fSigmaY2/charge - pad*pad;
-  sigmaY2 = (s2 + 1./12)*padw*padw;
-
-  if(s2 != 0)
+  
+  //Save the sigmas in pad and time:
+  
+  sigmaY2 = (s2);// + 1./12);//*padw*padw;
+  
+  /*Constants added by offline
+    if(s2 != 0)
     {
-      sigmaY2 = sigmaY2*0.108;
-      if(fPatch<3)
-       sigmaY2 = sigmaY2*2.07;
+    sigmaY2 = sigmaY2*0.108;
+    if(fPatch<3)
+    sigmaY2 = sigmaY2*2.07;
     }
-  
+  */
+
   s2 = (Float_t)cl->fSigmaZ2/charge - time*time;
-  timew = fTransform->GetZWidth();
-  sigmaZ2 = (s2 +1./12)*timew*timew;
-  if(s2 != 0)
+  timew = AliL3Transform::GetZWidth();
+  sigmaZ2 = (s2);// +1./12);//*timew*timew;
+  
+
+  
+  /*Constants added by offline
+    if(s2 != 0)
     {
-      sigmaZ2 = sigmaZ2*0.169;
-      if(fPatch < 3)
-       sigmaZ2 = sigmaZ2*1.77;
+    sigmaZ2 = sigmaZ2*0.169;
+    if(fPatch < 3)
+    sigmaZ2 = sigmaZ2*1.77;
     }
-  
+  */
 }
index 5de02bf0d79ae744fc4213550046eb38955f4872..59fd30fbf6b03ac89142493ad1fdb4a82f5ce965 100644 (file)
@@ -7,7 +7,6 @@
 class AliL3TrackArray;
 class AliL3MemHandler;
 class AliL3DigitRowData;
-class AliL3Transform;
 class AliL3ModelTrack;
 
 struct Cluster {
@@ -31,7 +30,6 @@ class AliL3Modeller {
   AliL3MemHandler *fMemHandler; //!
   AliL3DigitRowData *fRowData;//!
   
-  AliL3Transform *fTransform; //!
   Int_t fNClusters;
   Int_t fMaxClusters;
   
@@ -42,8 +40,8 @@ class AliL3Modeller {
   Int_t fSlice;
   Int_t fPatch;
   Char_t fPath[100];
-  
-  void FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t row);
+
+  void FillCluster(AliL3ModelTrack *track,Cluster *cluster,Int_t row,Int_t npads);
   void CalcClusterWidth(Cluster *cl,Float_t &sigmaY2,Float_t &sigmaZ2);
   void FillZeros(AliL3DigitRowData *digPt,Digit *row);
 
@@ -52,14 +50,15 @@ class AliL3Modeller {
   AliL3Modeller();
   virtual ~AliL3Modeller();
   
-  void Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path);
+  void Init(Int_t slice,Int_t patch,Char_t *trackdata,Char_t *path,Bool_t houghtracks=kFALSE);
   void FindClusters();
   void CheckForOverlaps();
   void CalculateCrossingPoints();
   void WriteRemaining();
   
   void SetInputData(AliL3DigitRowData *digits) {fRowData = digits;}
-  
+  void SetTrackThreshold(Int_t i) {fTrackThreshold=i;}
+
   AliL3TrackArray *GetTracks() {return fTracks;}
     
   ClassDef(AliL3Modeller,1) //Modeller class
index fcfeb54a22e5655114f97a80bdf0a541efc778c4..529b10a8bca79577f0e859492e60ecd8f064f408 100644 (file)
@@ -12,6 +12,7 @@ struct AliL3ClusterModel {
   Float_t fDCharge;
   Float_t fDSigmaY2;
   Float_t fDSigmaZ2;
+  UInt_t fNPads;
 };
 typedef struct AliL3ClusterModel AliL3ClusterModel;
 
index c46cb85a49aa75238b84947e6a8206ef3684a087..7fbe3989a7f67b3b4821ba2f6e8df643f6d193a2 100644 (file)
@@ -57,57 +57,57 @@ void CloseInputBitFile(BIT_FILE *bit_file )
 
 void OutputBit( BIT_FILE *bit_file, int bit )
 {
-    if ( bit )
-        bit_file->rack |= bit_file->mask;
-    bit_file->mask >>= 1;
-    if ( bit_file->mask == 0 ) {
-       if ( putc( bit_file->rack, bit_file->file ) != bit_file->rack )
-           fatal_error( "Fatal error in OutputBit!\n" );
-       else
-        if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
-               putc( '.', stdout );
-       bit_file->rack = 0;
-       bit_file->mask = 0x80;
-    }
+  if ( bit )
+    bit_file->rack |= bit_file->mask;
+  bit_file->mask >>= 1;
+  if ( bit_file->mask == 0 ) {
+    if ( putc( bit_file->rack, bit_file->file ) != bit_file->rack )
+      fatal_error( "Fatal error in OutputBit!\n" );
+    /*else
+      if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
+      putc( '.', stdout );*/
+    bit_file->rack = 0;
+    bit_file->mask = 0x80;
+  }
 }
 
 void OutputBits(BIT_FILE *bit_file,unsigned long code, int count )
 {
     unsigned long mask;
-
+    
     mask = 1L << ( count - 1 );
     while ( mask != 0) {
-        if ( mask & code )
-            bit_file->rack |= bit_file->mask;
-        bit_file->mask >>= 1;
-        if ( bit_file->mask == 0 ) {
-           if ( putc( bit_file->rack, bit_file->file ) != bit_file->rack )
-               fatal_error( "Fatal error in OutputBit!\n" );
-        else if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
-               putc( '.', stdout );
-           bit_file->rack = 0;
-            bit_file->mask = 0x80;
-        }
-        mask >>= 1;
+      if ( mask & code )
+       bit_file->rack |= bit_file->mask;
+      bit_file->mask >>= 1;
+      if ( bit_file->mask == 0 ) {
+       if ( putc( bit_file->rack, bit_file->file ) != bit_file->rack )
+         fatal_error( "Fatal error in OutputBit!\n" );
+        /*else if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
+         putc( '.', stdout );*/
+       bit_file->rack = 0;
+       bit_file->mask = 0x80;
+      }
+      mask >>= 1;
     }
 }
 
 int InputBit( BIT_FILE *bit_file )
 {
-    int value;
-
-    if ( bit_file->mask == 0x80 ) {
-        bit_file->rack = getc( bit_file->file );
-        if ( bit_file->rack == EOF )
-            fatal_error( "Fatal error in InputBit!\n" );
-    if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
-           putc( '.', stdout );
-    }
-    value = bit_file->rack & bit_file->mask;
-    bit_file->mask >>= 1;
-    if ( bit_file->mask == 0 )
-       bit_file->mask = 0x80;
-    return( value ? 1 : 0 );
+  int value;
+  
+  if ( bit_file->mask == 0x80 ) {
+    bit_file->rack = getc( bit_file->file );
+    if ( bit_file->rack == EOF )
+      fatal_error( "Fatal error in InputBit!\n" );
+    /*if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
+      putc( '.', stdout );*/
+  }
+  value = bit_file->rack & bit_file->mask;
+  bit_file->mask >>= 1;
+  if ( bit_file->mask == 0 )
+    bit_file->mask = 0x80;
+  return( value ? 1 : 0 );
 }
 
 unsigned long InputBits( BIT_FILE *bit_file, int bit_count )
@@ -118,19 +118,19 @@ unsigned long InputBits( BIT_FILE *bit_file, int bit_count )
     mask = 1L << ( bit_count - 1 );
     return_value = 0;
     while ( mask != 0) {
-       if ( bit_file->mask == 0x80 ) {
-           bit_file->rack = getc( bit_file->file );
-           if ( bit_file->rack == EOF )
-               fatal_error( "Fatal error in InputBit!\n" );
-        if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
-               putc( '.', stdout );
-       }
-       if ( bit_file->rack & bit_file->mask )
-            return_value |= mask;
-        mask >>= 1;
-        bit_file->mask >>= 1;
-        if ( bit_file->mask == 0 )
-            bit_file->mask = 0x80;
+      if ( bit_file->mask == 0x80 ) {
+       bit_file->rack = getc( bit_file->file );
+       if ( bit_file->rack == EOF )
+         fatal_error( "Fatal error in InputBit!\n" );
+        /*if ( ( bit_file->pacifier_counter++ & PACIFIER_COUNT ) == 0 )
+         putc( '.', stdout );*/
+      }
+      if ( bit_file->rack & bit_file->mask )
+       return_value |= mask;
+      mask >>= 1;
+      bit_file->mask >>= 1;
+      if ( bit_file->mask == 0 )
+       bit_file->mask = 0x80;
     }
     return( return_value );
 }